@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @since 1.5 |
21 | 21 | */ |
22 | 22 | function give_register_batch_recount_export_classes() { |
23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
24 | 24 | } |
25 | 25 | |
26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return void |
37 | 37 | */ |
38 | -function give_include_batch_export_class( $class ) { |
|
39 | - switch ( $class ) { |
|
38 | +function give_include_batch_export_class($class) { |
|
39 | + switch ($class) { |
|
40 | 40 | |
41 | 41 | case 'Give_Tools_Delete_Donors': |
42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
43 | 43 | break; |
44 | 44 | |
45 | 45 | case 'Give_Tools_Delete_Test_Transactions': |
46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
47 | 47 | break; |
48 | 48 | |
49 | 49 | case 'Give_Tools_Recount_Donor_Stats': |
50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
51 | 51 | break; |
52 | 52 | |
53 | 53 | case 'Give_Tools_Reset_Stats': |
54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
55 | 55 | break; |
56 | 56 | |
57 | 57 | case 'Give_Tools_Recount_All_Stats': |
58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
59 | 59 | break; |
60 | 60 | |
61 | 61 | case 'Give_Tools_Recount_Form_Stats': |
62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
63 | 63 | break; |
64 | 64 | |
65 | 65 | case 'Give_Tools_Recount_Income': |
66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
67 | 67 | break; |
68 | 68 | } |
69 | 69 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -59,58 +59,58 @@ discard block |
||
59 | 59 | * @return bool |
60 | 60 | */ |
61 | 61 | public function get_data() { |
62 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
62 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_form_stats'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
68 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
69 | 69 | |
70 | - if ( false === $totals ) { |
|
70 | + if (false === $totals) { |
|
71 | 71 | $totals = array( |
72 | 72 | 'earnings' => (float) 0, |
73 | 73 | 'sales' => 0, |
74 | 74 | ); |
75 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
75 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
76 | 76 | } |
77 | 77 | |
78 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
78 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
79 | 79 | 'give_forms' => $this->form_id, |
80 | 80 | 'number' => $this->per_step, |
81 | 81 | 'status' => $accepted_statuses, |
82 | 82 | 'paged' => $this->step, |
83 | 83 | 'fields' => 'ids', |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | |
86 | - $payments = new Give_Payments_Query( $args ); |
|
86 | + $payments = new Give_Payments_Query($args); |
|
87 | 87 | $payments = $payments->get_payments(); |
88 | 88 | |
89 | - if ( $payments ) { |
|
90 | - foreach ( $payments as $payment ) { |
|
89 | + if ($payments) { |
|
90 | + foreach ($payments as $payment) { |
|
91 | 91 | //Ensure acceptible status only |
92 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
92 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
96 | 96 | //Ensure only payments for this form are counted |
97 | - if ( $payment->form_id != $this->form_id ) { |
|
97 | + if ($payment->form_id != $this->form_id) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
101 | - $totals['sales'] ++; |
|
101 | + $totals['sales']++; |
|
102 | 102 | $totals['earnings'] += $payment->total; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
106 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
107 | 107 | |
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
113 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
112 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
113 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
114 | 114 | |
115 | 115 | return false; |
116 | 116 | } |
@@ -122,35 +122,35 @@ discard block |
||
122 | 122 | * @return int |
123 | 123 | */ |
124 | 124 | public function get_percentage_complete() { |
125 | - if ( $this->step == 1 ) { |
|
126 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
125 | + if ($this->step == 1) { |
|
126 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
127 | 127 | } |
128 | 128 | |
129 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
130 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
129 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
130 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
131 | 131 | |
132 | - if ( false === $total ) { |
|
132 | + if (false === $total) { |
|
133 | 133 | $total = 0; |
134 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
134 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
135 | 135 | 'give_forms' => $this->form_id, |
136 | - 'number' => - 1, |
|
136 | + 'number' => -1, |
|
137 | 137 | 'status' => $accepted_statuses, |
138 | 138 | 'fields' => 'ids', |
139 | - ) ); |
|
139 | + )); |
|
140 | 140 | |
141 | - $payments = new Give_Payments_Query( $args ); |
|
142 | - $total = count( $payments->get_payments() ); |
|
143 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
141 | + $payments = new Give_Payments_Query($args); |
|
142 | + $total = count($payments->get_payments()); |
|
143 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
147 | 147 | $percentage = 100; |
148 | 148 | |
149 | - if ( $total > 0 ) { |
|
150 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
149 | + if ($total > 0) { |
|
150 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( $percentage > 100 ) { |
|
153 | + if ($percentage > 100) { |
|
154 | 154 | $percentage = 100; |
155 | 155 | } |
156 | 156 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param array $request The Form Data passed into the batch processing |
166 | 166 | */ |
167 | - public function set_properties( $request ) { |
|
168 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
167 | + public function set_properties($request) { |
|
168 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -176,31 +176,31 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function process_step() { |
178 | 178 | |
179 | - if ( ! $this->can_export() ) { |
|
180 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
179 | + if ( ! $this->can_export()) { |
|
180 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $had_data = $this->get_data(); |
184 | 184 | |
185 | - if ( $had_data ) { |
|
185 | + if ($had_data) { |
|
186 | 186 | $this->done = false; |
187 | 187 | |
188 | 188 | return true; |
189 | 189 | } else { |
190 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
191 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
190 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
191 | + $this->delete_data('give_temp_recount_form_stats'); |
|
192 | 192 | $this->done = true; |
193 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
193 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
194 | 194 | |
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | public function headers() { |
200 | - ignore_user_abort( true ); |
|
200 | + ignore_user_abort(true); |
|
201 | 201 | |
202 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
203 | - set_time_limit( 0 ); |
|
202 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
203 | + set_time_limit(0); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return mixed Returns the data from the database |
230 | 230 | */ |
231 | - private function get_stored_data( $key ) { |
|
231 | + private function get_stored_data($key) { |
|
232 | 232 | global $wpdb; |
233 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
233 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
234 | 234 | |
235 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
235 | + return empty($value) ? false : maybe_unserialize($value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - private function store_data( $key, $value ) { |
|
248 | + private function store_data($key, $value) { |
|
249 | 249 | global $wpdb; |
250 | 250 | |
251 | - $value = maybe_serialize( $value ); |
|
251 | + $value = maybe_serialize($value); |
|
252 | 252 | |
253 | 253 | $data = array( |
254 | 254 | 'option_name' => $key, |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | '%s', |
263 | 263 | ); |
264 | 264 | |
265 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
265 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - private function delete_data( $key ) { |
|
277 | + private function delete_data($key) { |
|
278 | 278 | global $wpdb; |
279 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
279 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if (! defined('ABSPATH') ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -80,104 +80,102 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_data() { |
82 | 82 | |
83 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
84 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
85 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
86 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
83 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
84 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
85 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
86 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
87 | 87 | |
88 | - if ( false === $totals ) { |
|
88 | + if (false === $totals) { |
|
89 | 89 | $totals = array(); |
90 | 90 | } |
91 | 91 | |
92 | - if ( false === $payment_items ) { |
|
92 | + if (false === $payment_items) { |
|
93 | 93 | $payment_items = array(); |
94 | 94 | } |
95 | 95 | |
96 | - if ( false === $processed_payments ) { |
|
96 | + if (false === $processed_payments) { |
|
97 | 97 | $processed_payments = array(); |
98 | 98 | } |
99 | 99 | |
100 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
100 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
101 | 101 | |
102 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
102 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
103 | 103 | |
104 | - if( false === $payments ) { |
|
105 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
104 | + if (false === $payments) { |
|
105 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
106 | 106 | 'post_parent__in' => $all_forms, |
107 | 107 | 'number' => $this->per_step, |
108 | 108 | 'status' => 'publish', |
109 | 109 | 'paged' => $this->step, |
110 | 110 | 'output' => 'payments', |
111 | - ) ); |
|
111 | + )); |
|
112 | 112 | |
113 | - $payments_query = new Give_Payments_Query( $args ); |
|
113 | + $payments_query = new Give_Payments_Query($args); |
|
114 | 114 | $payments = $payments_query->get_payments(); |
115 | 115 | } |
116 | 116 | |
117 | - if ( $payments ) { |
|
117 | + if ($payments) { |
|
118 | 118 | |
119 | 119 | //Loop through payments |
120 | - foreach ( $payments as $payment ) { |
|
120 | + foreach ($payments as $payment) { |
|
121 | 121 | |
122 | 122 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
123 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
123 | + if (in_array($payment->ID, $processed_payments)) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Verify accepted status |
128 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
128 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
129 | 129 | $processed_payments[] = $payment->ID; |
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
133 | - $payment_item = $payment_items[ $payment->ID ]; |
|
133 | + $payment_item = $payment_items[$payment->ID]; |
|
134 | 134 | |
135 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
135 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
136 | 136 | |
137 | 137 | //Must have a form ID |
138 | - if ( empty( $form_id ) ) { |
|
138 | + if (empty($form_id)) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | |
142 | 142 | //Form ID must be within $all_forms array to be validated |
143 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
143 | + if ( ! in_array($form_id, $all_forms)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Set Sales count |
148 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
149 | - ++ $totals[ $form_id ]['sales'] : |
|
150 | - 1; |
|
148 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
149 | + ++$totals[$form_id]['sales'] : 1; |
|
151 | 150 | |
152 | 151 | // Set Total Earnings |
153 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
154 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
155 | - $payment_item['price']; |
|
152 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
153 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
156 | 154 | |
157 | 155 | $processed_payments[] = $payment->ID; |
158 | 156 | } |
159 | 157 | |
160 | 158 | // Get the list of form ids which does not contain any payment record. |
161 | - $remaining_form_ids = array_diff( $all_forms, array_keys($totals) ); |
|
162 | - foreach( $remaining_form_ids as $form_id) { |
|
159 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
160 | + foreach ($remaining_form_ids as $form_id) { |
|
163 | 161 | //If array key doesn't exist, create it |
164 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
165 | - $totals[ $form_id ] = array( |
|
162 | + if ( ! array_key_exists($form_id, $totals)) { |
|
163 | + $totals[$form_id] = array( |
|
166 | 164 | 'sales' => (int) 0, |
167 | 165 | 'earnings' => (float) 0, |
168 | 166 | ); |
169 | 167 | } |
170 | 168 | } |
171 | 169 | |
172 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
173 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
170 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
171 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
174 | 172 | |
175 | 173 | return true; |
176 | 174 | } |
177 | 175 | |
178 | - foreach ( $totals as $key => $stats ) { |
|
179 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
180 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
176 | + foreach ($totals as $key => $stats) { |
|
177 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
178 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
181 | 179 | } |
182 | 180 | |
183 | 181 | return false; |
@@ -192,20 +190,20 @@ discard block |
||
192 | 190 | */ |
193 | 191 | public function get_percentage_complete() { |
194 | 192 | |
195 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
193 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
196 | 194 | |
197 | - if ( false === $total ) { |
|
195 | + if (false === $total) { |
|
198 | 196 | $this->pre_fetch(); |
199 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
197 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
200 | 198 | } |
201 | 199 | |
202 | 200 | $percentage = 100; |
203 | 201 | |
204 | - if ( $total > 0 ) { |
|
205 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
202 | + if ($total > 0) { |
|
203 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
206 | 204 | } |
207 | 205 | |
208 | - if ( $percentage > 100 ) { |
|
206 | + if ($percentage > 100) { |
|
209 | 207 | $percentage = 100; |
210 | 208 | } |
211 | 209 | |
@@ -219,8 +217,8 @@ discard block |
||
219 | 217 | * |
220 | 218 | * @param array $request The Form Data passed into the batch processing |
221 | 219 | */ |
222 | - public function set_properties( $request ) { |
|
223 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
220 | + public function set_properties($request) { |
|
221 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
224 | 222 | } |
225 | 223 | |
226 | 224 | /** |
@@ -231,35 +229,35 @@ discard block |
||
231 | 229 | */ |
232 | 230 | public function process_step() { |
233 | 231 | |
234 | - if ( ! $this->can_export() ) { |
|
235 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
232 | + if ( ! $this->can_export()) { |
|
233 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
236 | 234 | } |
237 | 235 | |
238 | 236 | $had_data = $this->get_data(); |
239 | 237 | |
240 | - if ( $had_data ) { |
|
238 | + if ($had_data) { |
|
241 | 239 | $this->done = false; |
242 | 240 | |
243 | 241 | return true; |
244 | 242 | } else { |
245 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
246 | - $this->delete_data( 'give_recount_all_total' ); |
|
247 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
248 | - $this->delete_data( 'give_temp_payment_items' ); |
|
249 | - $this->delete_data( 'give_temp_form_ids' ); |
|
250 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
243 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
244 | + $this->delete_data('give_recount_all_total'); |
|
245 | + $this->delete_data('give_temp_recount_all_stats'); |
|
246 | + $this->delete_data('give_temp_payment_items'); |
|
247 | + $this->delete_data('give_temp_form_ids'); |
|
248 | + $this->delete_data('give_temp_processed_payments'); |
|
251 | 249 | $this->done = true; |
252 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
250 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
253 | 251 | |
254 | 252 | return false; |
255 | 253 | } |
256 | 254 | } |
257 | 255 | |
258 | 256 | public function headers() { |
259 | - ignore_user_abort( true ); |
|
257 | + ignore_user_abort(true); |
|
260 | 258 | |
261 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
262 | - set_time_limit( 0 ); |
|
259 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
260 | + set_time_limit(0); |
|
263 | 261 | } |
264 | 262 | } |
265 | 263 | |
@@ -286,69 +284,69 @@ discard block |
||
286 | 284 | */ |
287 | 285 | public function pre_fetch() { |
288 | 286 | |
289 | - if ( $this->step == 1 ) { |
|
290 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
291 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
292 | - $this->delete_data( 'give_temp_payment_items' ); |
|
293 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
294 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
287 | + if ($this->step == 1) { |
|
288 | + $this->delete_data('give_temp_recount_all_total'); |
|
289 | + $this->delete_data('give_temp_recount_all_stats'); |
|
290 | + $this->delete_data('give_temp_payment_items'); |
|
291 | + $this->delete_data('give_temp_processed_payments'); |
|
292 | + $this->delete_data('give_temp_all_payments_data'); |
|
295 | 293 | } |
296 | 294 | |
297 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
298 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
295 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
296 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
299 | 297 | |
300 | - if ( false === $total ) { |
|
298 | + if (false === $total) { |
|
301 | 299 | $total = 0; |
302 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
300 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
303 | 301 | |
304 | - if ( false === $payment_items ) { |
|
302 | + if (false === $payment_items) { |
|
305 | 303 | $payment_items = array(); |
306 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
304 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
307 | 305 | } |
308 | 306 | |
309 | 307 | $args = array( |
310 | 308 | 'post_status' => 'publish', |
311 | 309 | 'post_type' => 'give_forms', |
312 | - 'posts_per_page' => - 1, |
|
310 | + 'posts_per_page' => -1, |
|
313 | 311 | 'fields' => 'ids', |
314 | 312 | ); |
315 | 313 | |
316 | - $all_forms = get_posts( $args ); |
|
317 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
314 | + $all_forms = get_posts($args); |
|
315 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
318 | 316 | |
319 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
317 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
320 | 318 | 'post_parent__in' => $all_forms, |
321 | 319 | 'number' => $this->per_step, |
322 | 320 | 'status' => 'publish', |
323 | 321 | 'page' => $this->step, |
324 | 322 | 'output' => 'payments', |
325 | - ) ); |
|
323 | + )); |
|
326 | 324 | |
327 | - $payments_query = new Give_Payments_Query( $args ); |
|
325 | + $payments_query = new Give_Payments_Query($args); |
|
328 | 326 | $payments = $payments_query->get_payments(); |
329 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
327 | + $total = wp_count_posts('give_payment')->publish; |
|
330 | 328 | |
331 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
329 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
332 | 330 | |
333 | - if ( $payments ) { |
|
331 | + if ($payments) { |
|
334 | 332 | |
335 | - foreach ( $payments as $payment ) { |
|
333 | + foreach ($payments as $payment) { |
|
336 | 334 | |
337 | - $payment = new Give_Payment( $payment->ID ); |
|
335 | + $payment = new Give_Payment($payment->ID); |
|
338 | 336 | $form_id = $payment->form_id; |
339 | 337 | |
340 | 338 | //If for some reason somehow the form_ID isn't set check payment meta |
341 | - if ( empty( $payment->form_id ) ) { |
|
339 | + if (empty($payment->form_id)) { |
|
342 | 340 | $payment_meta = $payment->get_meta(); |
343 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
341 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
344 | 342 | } |
345 | 343 | |
346 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
344 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
347 | 345 | continue; |
348 | 346 | } |
349 | 347 | |
350 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
351 | - $payment_items[ $payment->ID ] = array( |
|
348 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
349 | + $payment_items[$payment->ID] = array( |
|
352 | 350 | 'id' => $form_id, |
353 | 351 | 'payment_id' => $payment->ID, |
354 | 352 | 'price' => $payment->total |
@@ -359,8 +357,8 @@ discard block |
||
359 | 357 | |
360 | 358 | } |
361 | 359 | |
362 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
363 | - $this->store_data( 'give_recount_all_total', $total ); |
|
360 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
361 | + $this->store_data('give_recount_all_total', $total); |
|
364 | 362 | } |
365 | 363 | |
366 | 364 | } |
@@ -374,11 +372,11 @@ discard block |
||
374 | 372 | * |
375 | 373 | * @return mixed Returns the data from the database |
376 | 374 | */ |
377 | - private function get_stored_data( $key ) { |
|
375 | + private function get_stored_data($key) { |
|
378 | 376 | global $wpdb; |
379 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
377 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
380 | 378 | |
381 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
379 | + return empty($value) ? false : maybe_unserialize($value); |
|
382 | 380 | } |
383 | 381 | |
384 | 382 | /** |
@@ -391,10 +389,10 @@ discard block |
||
391 | 389 | * |
392 | 390 | * @return void |
393 | 391 | */ |
394 | - private function store_data( $key, $value ) { |
|
392 | + private function store_data($key, $value) { |
|
395 | 393 | global $wpdb; |
396 | 394 | |
397 | - $value = maybe_serialize( $value ); |
|
395 | + $value = maybe_serialize($value); |
|
398 | 396 | |
399 | 397 | $data = array( |
400 | 398 | 'option_name' => $key, |
@@ -408,7 +406,7 @@ discard block |
||
408 | 406 | '%s', |
409 | 407 | ); |
410 | 408 | |
411 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
409 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
412 | 410 | } |
413 | 411 | |
414 | 412 | /** |
@@ -420,9 +418,9 @@ discard block |
||
420 | 418 | * |
421 | 419 | * @return void |
422 | 420 | */ |
423 | - private function delete_data( $key ) { |
|
421 | + private function delete_data($key) { |
|
424 | 422 | global $wpdb; |
425 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
423 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
426 | 424 | } |
427 | 425 | |
428 | 426 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,40 +53,40 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 | |
56 | - $donor = new Give_Donor( $this->customer_id ); |
|
57 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
56 | + $donor = new Give_Donor($this->customer_id); |
|
57 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
58 | 58 | |
59 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
60 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
59 | + $offset = ($this->step - 1) * $this->per_step; |
|
60 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
61 | 61 | |
62 | - if ( count( $step_items ) > 0 ) { |
|
63 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
62 | + if (count($step_items) > 0) { |
|
63 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
64 | 64 | $step_total = 0; |
65 | 65 | |
66 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
66 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
67 | 67 | |
68 | - foreach ( $step_items as $payment ) { |
|
69 | - $payment = get_post( $payment->ID ); |
|
68 | + foreach ($step_items as $payment) { |
|
69 | + $payment = get_post($payment->ID); |
|
70 | 70 | |
71 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
71 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
72 | 72 | |
73 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
73 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
74 | 74 | $missing_payments[] = $payment->ID; |
75 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
75 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
76 | 76 | |
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
81 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
81 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
82 | 82 | |
83 | - if ( true === $should_process_payment ) { |
|
83 | + if (true === $should_process_payment) { |
|
84 | 84 | |
85 | 85 | $found_payment_ids[] = $payment->ID; |
86 | 86 | |
87 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
88 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
89 | - $step_total += $payment_amount; |
|
87 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
88 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
89 | + $step_total += $payment_amount; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | $updated_total = $pending_total + $step_total; |
97 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
98 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
97 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
98 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
99 | 99 | |
100 | 100 | return true; |
101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function get_percentage_complete() { |
114 | 114 | |
115 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
116 | - $total = count( $payments ); |
|
115 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
116 | + $total = count($payments); |
|
117 | 117 | |
118 | 118 | $percentage = 100; |
119 | 119 | |
120 | - if ( $total > 0 ) { |
|
121 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
120 | + if ($total > 0) { |
|
121 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
122 | 122 | } |
123 | 123 | |
124 | - if ( $percentage > 100 ) { |
|
124 | + if ($percentage > 100) { |
|
125 | 125 | $percentage = 100; |
126 | 126 | } |
127 | 127 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $request The Form Data passed into the batch processing |
137 | 137 | */ |
138 | - public function set_properties( $request ) { |
|
139 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
138 | + public function set_properties($request) { |
|
139 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,63 +147,63 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function process_step() { |
149 | 149 | |
150 | - if ( ! $this->can_export() ) { |
|
151 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
150 | + if ( ! $this->can_export()) { |
|
151 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $had_data = $this->get_data(); |
155 | 155 | |
156 | - if ( $had_data ) { |
|
156 | + if ($had_data) { |
|
157 | 157 | $this->done = false; |
158 | 158 | |
159 | 159 | return true; |
160 | 160 | } else { |
161 | - $donor = new Give_Donor( $this->customer_id ); |
|
162 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
163 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
161 | + $donor = new Give_Donor($this->customer_id); |
|
162 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
163 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
164 | 164 | |
165 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
165 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
166 | 166 | |
167 | 167 | // Find non-existing payments (deleted) and total up the donation count |
168 | 168 | $purchase_count = 0; |
169 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
170 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
171 | - unset( $payment_ids[ $key ] ); |
|
169 | + foreach ($payment_ids as $key => $payment_id) { |
|
170 | + if (in_array($payment_id, $removed_payments)) { |
|
171 | + unset($payment_ids[$key]); |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | - $payment = get_post( $payment_id ); |
|
176 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
177 | - $purchase_count ++; |
|
175 | + $payment = get_post($payment_id); |
|
176 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
177 | + $purchase_count++; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
181 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
182 | 182 | |
183 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
184 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
185 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
186 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
183 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
184 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
185 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
186 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
187 | 187 | |
188 | - $payment_ids = implode( ',', $payment_ids ); |
|
189 | - $donor->update( array( |
|
188 | + $payment_ids = implode(',', $payment_ids); |
|
189 | + $donor->update(array( |
|
190 | 190 | 'payment_ids' => $payment_ids, |
191 | 191 | 'purchase_count' => $purchase_count, |
192 | 192 | 'purchase_value' => $pending_total, |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | 195 | $this->done = true; |
196 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
196 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
197 | 197 | |
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | public function headers() { |
203 | - ignore_user_abort( true ); |
|
203 | + ignore_user_abort(true); |
|
204 | 204 | |
205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
206 | - set_time_limit( 0 ); |
|
205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
206 | + set_time_limit(0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
230 | 230 | * @return void |
231 | 231 | */ |
232 | 232 | public function pre_fetch() { |
233 | - if ( $this->step === 1 ) { |
|
234 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
233 | + if ($this->step === 1) { |
|
234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
235 | 235 | |
236 | 236 | // Before we start, let's zero out the customer's data |
237 | - $donor = new Give_Donor( $this->customer_id ); |
|
238 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
237 | + $donor = new Give_Donor($this->customer_id); |
|
238 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
239 | 239 | |
240 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
240 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
241 | 241 | |
242 | 242 | $attached_args = array( |
243 | 243 | 'post__in' => $attached_payment_ids, |
244 | - 'number' => - 1, |
|
244 | + 'number' => -1, |
|
245 | 245 | 'status' => $allowed_payment_status, |
246 | 246 | ); |
247 | 247 | |
248 | - $attached_payments = give_get_payments( $attached_args ); |
|
248 | + $attached_payments = give_get_payments($attached_args); |
|
249 | 249 | |
250 | 250 | $unattached_args = array( |
251 | 251 | 'post__not_in' => $attached_payment_ids, |
252 | - 'number' => - 1, |
|
252 | + 'number' => -1, |
|
253 | 253 | 'status' => $allowed_payment_status, |
254 | 254 | 'meta_query' => array( |
255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | ), |
260 | 260 | ); |
261 | 261 | |
262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
262 | + $unattached_payments = give_get_payments($unattached_args); |
|
263 | 263 | |
264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
265 | 265 | |
266 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
266 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return mixed Returns the data from the database |
278 | 278 | */ |
279 | - private function get_stored_data( $key ) { |
|
279 | + private function get_stored_data($key) { |
|
280 | 280 | global $wpdb; |
281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
282 | 282 | |
283 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
283 | + return empty($value) ? false : maybe_unserialize($value); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return void |
295 | 295 | */ |
296 | - private function store_data( $key, $value ) { |
|
296 | + private function store_data($key, $value) { |
|
297 | 297 | global $wpdb; |
298 | 298 | |
299 | - $value = maybe_serialize( $value ); |
|
299 | + $value = maybe_serialize($value); |
|
300 | 300 | |
301 | 301 | $data = array( |
302 | 302 | 'option_name' => $key, |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | '%s', |
311 | 311 | ); |
312 | 312 | |
313 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
313 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return void |
324 | 324 | */ |
325 | - private function delete_data( $key ) { |
|
325 | + private function delete_data($key) { |
|
326 | 326 | global $wpdb; |
327 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
327 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | } |
@@ -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 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | public function headers() { |
41 | - ignore_user_abort( true ); |
|
41 | + ignore_user_abort(true); |
|
42 | 42 | |
43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
44 | - set_time_limit( 0 ); |
|
43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
44 | + set_time_limit(0); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | nocache_headers(); |
48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
50 | - header( "Expires: 0" ); |
|
48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
50 | + header("Expires: 0"); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | public function csv_cols() { |
62 | 62 | |
63 | 63 | $cols = array( |
64 | - 'date' => __( 'Date', 'give' ), |
|
65 | - 'donations' => __( 'Donations', 'give' ), |
|
64 | + 'date' => __('Date', 'give'), |
|
65 | + 'donations' => __('Donations', 'give'), |
|
66 | 66 | /* translators: %s: currency */ |
67 | - 'earnings' => sprintf( __( 'Income (%s)', 'give' ), give_currency_symbol('', true) ) |
|
67 | + 'earnings' => sprintf(__('Income (%s)', 'give'), give_currency_symbol('', true)) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function get_data() { |
81 | 81 | |
82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
86 | 86 | |
87 | 87 | $data = array(); |
88 | 88 | $year = $start_year; |
89 | 89 | $stats = new Give_Payment_Stats; |
90 | 90 | |
91 | - while ( $year <= $end_year ) { |
|
91 | + while ($year <= $end_year) { |
|
92 | 92 | |
93 | - if ( $year == $start_year && $year == $end_year ) { |
|
93 | + if ($year == $start_year && $year == $end_year) { |
|
94 | 94 | |
95 | 95 | $m1 = $start_month; |
96 | 96 | $m2 = $end_month; |
97 | 97 | |
98 | - } elseif ( $year == $start_year ) { |
|
98 | + } elseif ($year == $start_year) { |
|
99 | 99 | |
100 | 100 | $m1 = $start_month; |
101 | 101 | $m2 = 12; |
102 | 102 | |
103 | - } elseif ( $year == $end_year ) { |
|
103 | + } elseif ($year == $end_year) { |
|
104 | 104 | |
105 | 105 | $m1 = 1; |
106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - while ( $m1 <= $m2 ) { |
|
115 | + while ($m1 <= $m2) { |
|
116 | 116 | |
117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
119 | 119 | |
120 | 120 | $data[] = array( |
121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ), array( 'sanitize' => false ) ), |
|
121 | + 'date' => date_i18n('F Y', $date1), |
|
122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2), array('sanitize' => false)), |
|
124 | 124 | ); |
125 | 125 | |
126 | - $m1 ++; |
|
126 | + $m1++; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $year ++; |
|
131 | + $year++; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
136 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
135 | + $data = apply_filters('give_export_get_data', $data); |
|
136 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
137 | 137 | |
138 | 138 | return $data; |
139 | 139 | } |
@@ -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 | |
@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function csv_cols() { |
41 | 41 | $cols = array( |
42 | - 'id' => __( 'ID', 'give' ), // unaltered payment ID (use for querying). |
|
43 | - 'seq_id' => __( 'Payment Number', 'give' ), // sequential payment ID. |
|
44 | - 'email' => __( 'Email', 'give' ), |
|
45 | - 'first' => __( 'First Name', 'give' ), |
|
46 | - 'last' => __( 'Last Name', 'give' ), |
|
47 | - 'address1' => __( 'Address 1', 'give' ), |
|
48 | - 'address2' => __( 'Address 2', 'give' ), |
|
49 | - 'city' => __( 'City', 'give' ), |
|
50 | - 'state' => __( 'State', 'give' ), |
|
51 | - 'country' => __( 'Country', 'give' ), |
|
52 | - 'zip' => __( 'Zip / Postal Code', 'give' ), |
|
53 | - 'form_id' => __( 'Form ID', 'give' ), |
|
54 | - 'form_name' => __( 'Form Name', 'give' ), |
|
55 | - 'amount' => __( 'Amount', 'give' ) . ' (' . give_currency_symbol( '', true ) . ')', |
|
56 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
57 | - 'trans_id' => __( 'Transaction ID', 'give' ), |
|
58 | - 'key' => __( 'Key', 'give' ), |
|
59 | - 'date' => __( 'Date', 'give' ), |
|
60 | - 'user' => __( 'User', 'give' ), |
|
61 | - 'status' => __( 'Status', 'give' ) |
|
42 | + 'id' => __('ID', 'give'), // unaltered payment ID (use for querying). |
|
43 | + 'seq_id' => __('Payment Number', 'give'), // sequential payment ID. |
|
44 | + 'email' => __('Email', 'give'), |
|
45 | + 'first' => __('First Name', 'give'), |
|
46 | + 'last' => __('Last Name', 'give'), |
|
47 | + 'address1' => __('Address 1', 'give'), |
|
48 | + 'address2' => __('Address 2', 'give'), |
|
49 | + 'city' => __('City', 'give'), |
|
50 | + 'state' => __('State', 'give'), |
|
51 | + 'country' => __('Country', 'give'), |
|
52 | + 'zip' => __('Zip / Postal Code', 'give'), |
|
53 | + 'form_id' => __('Form ID', 'give'), |
|
54 | + 'form_name' => __('Form Name', 'give'), |
|
55 | + 'amount' => __('Amount', 'give').' ('.give_currency_symbol('', true).')', |
|
56 | + 'gateway' => __('Payment Method', 'give'), |
|
57 | + 'trans_id' => __('Transaction ID', 'give'), |
|
58 | + 'key' => __('Key', 'give'), |
|
59 | + 'date' => __('Date', 'give'), |
|
60 | + 'user' => __('User', 'give'), |
|
61 | + 'status' => __('Status', 'give') |
|
62 | 62 | ); |
63 | 63 | |
64 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
65 | - unset( $cols['seq_id'] ); |
|
64 | + if ( ! give_get_option('enable_sequential')) { |
|
65 | + unset($cols['seq_id']); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return $cols; |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | 'status' => $this->status |
87 | 87 | ); |
88 | 88 | |
89 | - if ( ! empty( $this->start ) || ! empty( $this->end ) ) { |
|
89 | + if ( ! empty($this->start) || ! empty($this->end)) { |
|
90 | 90 | |
91 | 91 | $args['date_query'] = array( |
92 | 92 | array( |
93 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ), |
|
94 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ), |
|
93 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->start)), |
|
94 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), |
|
95 | 95 | 'inclusive' => true |
96 | 96 | ) |
97 | 97 | ); |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Add category or tag to payment query if any. |
102 | - if ( ! empty( $this->categories ) || ! empty( $this->tags ) ) { |
|
102 | + if ( ! empty($this->categories) || ! empty($this->tags)) { |
|
103 | 103 | $form_args = array( |
104 | 104 | 'post_type' => 'give_forms', |
105 | 105 | 'post_status' => 'publish', |
106 | - 'posts_per_page' => - 1, |
|
106 | + 'posts_per_page' => -1, |
|
107 | 107 | 'fields' => 'ids', |
108 | 108 | 'tax_query' => array( |
109 | 109 | 'relation' => 'AND', |
@@ -111,72 +111,72 @@ discard block |
||
111 | 111 | ); |
112 | 112 | |
113 | 113 | |
114 | - if ( ! empty( $this->categories ) ) { |
|
114 | + if ( ! empty($this->categories)) { |
|
115 | 115 | $form_args['tax_query'][] = array( |
116 | 116 | 'taxonomy' => 'give_forms_category', |
117 | 117 | 'terms' => $this->categories, |
118 | 118 | ); |
119 | 119 | } |
120 | 120 | |
121 | - if ( ! empty( $this->tags ) ) { |
|
121 | + if ( ! empty($this->tags)) { |
|
122 | 122 | $form_args['tax_query'][] = array( |
123 | 123 | 'taxonomy' => 'give_forms_tag', |
124 | 124 | 'terms' => $this->tags, |
125 | 125 | ); |
126 | 126 | } |
127 | 127 | |
128 | - $forms = new WP_Query( $form_args ); |
|
128 | + $forms = new WP_Query($form_args); |
|
129 | 129 | |
130 | - if ( empty( $forms->posts ) ) { |
|
130 | + if (empty($forms->posts)) { |
|
131 | 131 | return array(); |
132 | 132 | } |
133 | 133 | |
134 | 134 | $args['give_forms'] = $forms->posts; |
135 | 135 | } |
136 | 136 | |
137 | - $payments = give_get_payments( $args ); |
|
137 | + $payments = give_get_payments($args); |
|
138 | 138 | |
139 | - if ( $payments ) { |
|
139 | + if ($payments) { |
|
140 | 140 | |
141 | - foreach ( $payments as $payment ) { |
|
142 | - $payment_meta = give_get_payment_meta( $payment->ID ); |
|
143 | - $user_info = give_get_payment_meta_user_info( $payment->ID ); |
|
144 | - $total = give_get_payment_amount( $payment->ID ); |
|
145 | - $user_id = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
141 | + foreach ($payments as $payment) { |
|
142 | + $payment_meta = give_get_payment_meta($payment->ID); |
|
143 | + $user_info = give_get_payment_meta_user_info($payment->ID); |
|
144 | + $total = give_get_payment_amount($payment->ID); |
|
145 | + $user_id = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email']; |
|
146 | 146 | |
147 | - if ( is_numeric( $user_id ) ) { |
|
148 | - $user = get_userdata( $user_id ); |
|
147 | + if (is_numeric($user_id)) { |
|
148 | + $user = get_userdata($user_id); |
|
149 | 149 | } else { |
150 | 150 | $user = false; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $data[] = array( |
154 | 154 | 'id' => $payment->ID, |
155 | - 'seq_id' => give_get_payment_number( $payment->ID ), |
|
155 | + 'seq_id' => give_get_payment_number($payment->ID), |
|
156 | 156 | 'email' => $payment_meta['email'], |
157 | 157 | 'first' => $user_info['first_name'], |
158 | 158 | 'last' => $user_info['last_name'], |
159 | - 'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '', |
|
160 | - 'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '', |
|
161 | - 'city' => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '', |
|
162 | - 'state' => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '', |
|
163 | - 'country' => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '', |
|
164 | - 'zip' => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '', |
|
165 | - 'form_id' => isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : '', |
|
166 | - 'form_name' => isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '', |
|
167 | - 'amount' => html_entity_decode( give_format_amount( $total, array( 'sanitize' => false ) ) ), |
|
168 | - 'gateway' => give_get_gateway_admin_label( give_get_meta( $payment->ID, '_give_payment_gateway', true ) ), |
|
169 | - 'trans_id' => give_get_payment_transaction_id( $payment->ID ), |
|
159 | + 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', |
|
160 | + 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', |
|
161 | + 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', |
|
162 | + 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', |
|
163 | + 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', |
|
164 | + 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', |
|
165 | + 'form_id' => isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '', |
|
166 | + 'form_name' => isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '', |
|
167 | + 'amount' => html_entity_decode(give_format_amount($total, array('sanitize' => false))), |
|
168 | + 'gateway' => give_get_gateway_admin_label(give_get_meta($payment->ID, '_give_payment_gateway', true)), |
|
169 | + 'trans_id' => give_get_payment_transaction_id($payment->ID), |
|
170 | 170 | 'key' => $payment_meta['key'], |
171 | 171 | 'date' => $payment->post_date, |
172 | - 'user' => $user ? $user->display_name : __( 'guest', 'give' ), |
|
173 | - 'status' => give_get_payment_status( $payment, true ) |
|
172 | + 'user' => $user ? $user->display_name : __('guest', 'give'), |
|
173 | + 'status' => give_get_payment_status($payment, true) |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | } |
177 | 177 | |
178 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
179 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
178 | + $data = apply_filters('give_export_get_data', $data); |
|
179 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
180 | 180 | |
181 | 181 | return $data; |
182 | 182 | |
@@ -196,27 +196,27 @@ discard block |
||
196 | 196 | |
197 | 197 | $status = $this->status; |
198 | 198 | $args = array( |
199 | - 'start-date' => date( 'n/d/Y', strtotime( $this->start ) ), |
|
200 | - 'end-date' => date( 'n/d/Y', strtotime( $this->end ) ), |
|
199 | + 'start-date' => date('n/d/Y', strtotime($this->start)), |
|
200 | + 'end-date' => date('n/d/Y', strtotime($this->end)), |
|
201 | 201 | ); |
202 | 202 | |
203 | - if ( 'any' == $status ) { |
|
203 | + if ('any' == $status) { |
|
204 | 204 | |
205 | - $total = array_sum( (array) give_count_payments( $args ) ); |
|
205 | + $total = array_sum((array) give_count_payments($args)); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | |
209 | - $total = give_count_payments( $args )->$status; |
|
209 | + $total = give_count_payments($args)->$status; |
|
210 | 210 | |
211 | 211 | } |
212 | 212 | |
213 | 213 | $percentage = 100; |
214 | 214 | |
215 | - if ( $total > 0 ) { |
|
216 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
215 | + if ($total > 0) { |
|
216 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( $percentage > 100 ) { |
|
219 | + if ($percentage > 100) { |
|
220 | 220 | $percentage = 100; |
221 | 221 | } |
222 | 222 | |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param array $request The Form Data passed into the batch processing. |
232 | 232 | */ |
233 | - public function set_properties( $request ) { |
|
234 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
235 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
236 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete'; |
|
237 | - $this->categories = isset( $request['give_forms_categories'] ) ? give_clean( $request['give_forms_categories'] ) : array(); |
|
238 | - $this->tags = isset( $request['give_forms_tags'] ) ? give_clean( $request['give_forms_tags'] ) : array(); |
|
233 | + public function set_properties($request) { |
|
234 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
235 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
236 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete'; |
|
237 | + $this->categories = isset($request['give_forms_categories']) ? give_clean($request['give_forms_categories']) : array(); |
|
238 | + $this->tags = isset($request['give_forms_tags']) ? give_clean($request['give_forms_tags']) : array(); |
|
239 | 239 | } |
240 | 240 | } |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | * Admin View: Exports |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
10 | +if ( ! current_user_can('manage_give_settings')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -16,28 +16,28 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @since 1.5 |
18 | 18 | */ |
19 | -do_action( 'give_tools_recount_stats_before' ); |
|
19 | +do_action('give_tools_recount_stats_before'); |
|
20 | 20 | ?> |
21 | 21 | <div id="poststuff"> |
22 | 22 | <div class="postbox"> |
23 | 23 | |
24 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
24 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
25 | 25 | |
26 | 26 | <div class="inside recount-stats-controls"> |
27 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
27 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
28 | 28 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
29 | 29 | |
30 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
30 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
31 | 31 | |
32 | 32 | <select name="give-export-class" id="recount-stats-type"> |
33 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
34 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
35 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
36 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
37 | - <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
38 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
39 | - <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e( 'Delete Test Donor', 'give' ); ?></option> |
|
40 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
33 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
34 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
35 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
36 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
37 | + <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
38 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
39 | + <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e('Delete Test Donor', 'give'); ?></option> |
|
40 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
41 | 41 | <?php |
42 | 42 | /** |
43 | 43 | * Fires in the recount stats selectbox. |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @since 1.5 |
48 | 48 | */ |
49 | - do_action( 'give_recount_tool_options' ); |
|
49 | + do_action('give_recount_tool_options'); |
|
50 | 50 | ?> |
51 | 51 | </select> |
52 | 52 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | <?php |
55 | 55 | $args = array( |
56 | 56 | 'name' => 'form_id', |
57 | - 'number' => - 1, |
|
57 | + 'number' => -1, |
|
58 | 58 | 'chosen' => true, |
59 | 59 | ); |
60 | - echo Give()->html->forms_dropdown( $args ); |
|
60 | + echo Give()->html->forms_dropdown($args); |
|
61 | 61 | ?> |
62 | 62 | </span> |
63 | 63 | |
64 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
64 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
65 | 65 | |
66 | 66 | <br/> |
67 | 67 | |
68 | 68 | <span class="give-recount-stats-descriptions"> |
69 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
70 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
71 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
72 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
69 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
70 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
71 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
72 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
73 | 73 | <?php |
74 | 74 | /** |
75 | 75 | * Fires in the recount stats description area. |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.5 |
80 | 80 | */ |
81 | - do_action( 'give_recount_tool_descriptions' ); |
|
81 | + do_action('give_recount_tool_descriptions'); |
|
82 | 82 | ?> |
83 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
84 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
83 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
84 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
85 | 85 | </span> |
86 | 86 | |
87 | 87 | <span class="spinner"></span> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @since 1.5 |
97 | 97 | */ |
98 | - do_action( 'give_tools_recount_forms' ); |
|
98 | + do_action('give_tools_recount_forms'); |
|
99 | 99 | ?> |
100 | 100 | </div><!-- .inside --> |
101 | 101 | </div><!-- .postbox --> |
@@ -106,4 +106,4 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @since 1.5 |
108 | 108 | */ |
109 | -do_action( 'give_tools_recount_stats_after' ); |
|
109 | +do_action('give_tools_recount_stats_after'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,52 +25,52 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | 65 | } |
66 | 66 | |
67 | - if ( $did_upgrade ) { |
|
68 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
67 | + if ($did_upgrade) { |
|
68 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
73 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
72 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
73 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Display Upgrade Notices |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return void |
84 | 84 | */ |
85 | -function give_show_upgrade_notices( $give_updates ) { |
|
85 | +function give_show_upgrade_notices($give_updates) { |
|
86 | 86 | // v1.3.2 Upgrades |
87 | 87 | $give_updates->register( |
88 | 88 | array( |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ); |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
142 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Triggers all upgrade functions |
@@ -151,29 +151,29 @@ discard block |
||
151 | 151 | */ |
152 | 152 | function give_trigger_upgrades() { |
153 | 153 | |
154 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
155 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
154 | + if ( ! current_user_can('manage_give_settings')) { |
|
155 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
156 | 156 | 'response' => 403, |
157 | - ) ); |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | - $give_version = get_option( 'give_version' ); |
|
160 | + $give_version = get_option('give_version'); |
|
161 | 161 | |
162 | - if ( ! $give_version ) { |
|
162 | + if ( ! $give_version) { |
|
163 | 163 | // 1.0 is the first version to use this option so we must add it. |
164 | 164 | $give_version = '1.0'; |
165 | - add_option( 'give_version', $give_version ); |
|
165 | + add_option('give_version', $give_version); |
|
166 | 166 | } |
167 | 167 | |
168 | - update_option( 'give_version', GIVE_VERSION ); |
|
169 | - delete_option( 'give_doing_upgrade' ); |
|
168 | + update_option('give_version', GIVE_VERSION); |
|
169 | + delete_option('give_doing_upgrade'); |
|
170 | 170 | |
171 | - if ( DOING_AJAX ) { |
|
172 | - die( 'complete' ); |
|
171 | + if (DOING_AJAX) { |
|
172 | + die('complete'); |
|
173 | 173 | } // End if(). |
174 | 174 | } |
175 | 175 | |
176 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
176 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
177 | 177 | |
178 | 178 | |
179 | 179 | /** |
@@ -189,24 +189,24 @@ discard block |
||
189 | 189 | /* @var Give_Updates $give_updates */ |
190 | 190 | $give_updates = Give_Updates::get_instance(); |
191 | 191 | |
192 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
193 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
192 | + if ( ! current_user_can('manage_give_settings')) { |
|
193 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
194 | 194 | 'response' => 403, |
195 | - ) ); |
|
195 | + )); |
|
196 | 196 | } |
197 | 197 | |
198 | - ignore_user_abort( true ); |
|
198 | + ignore_user_abort(true); |
|
199 | 199 | |
200 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
201 | - @set_time_limit( 0 ); |
|
200 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
201 | + @set_time_limit(0); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | // UPDATE DB METAKEYS. |
205 | 205 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
206 | - $query = $wpdb->query( $sql ); |
|
206 | + $query = $wpdb->query($sql); |
|
207 | 207 | |
208 | 208 | $give_updates->percentage = 100; |
209 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
209 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -230,24 +230,24 @@ discard block |
||
230 | 230 | $where .= "AND ( p.post_status = 'abandoned' )"; |
231 | 231 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
232 | 232 | |
233 | - $sql = $select . $join . $where; |
|
234 | - $found_payments = $wpdb->get_col( $sql ); |
|
233 | + $sql = $select.$join.$where; |
|
234 | + $found_payments = $wpdb->get_col($sql); |
|
235 | 235 | |
236 | - foreach ( $found_payments as $payment ) { |
|
236 | + foreach ($found_payments as $payment) { |
|
237 | 237 | |
238 | 238 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
239 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
239 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
240 | 240 | |
241 | 241 | // 1450124863 = 12/10/2015 20:42:25. |
242 | - if ( $modified_time >= 1450124863 ) { |
|
242 | + if ($modified_time >= 1450124863) { |
|
243 | 243 | |
244 | - give_update_payment_status( $payment, 'pending' ); |
|
244 | + give_update_payment_status($payment, 'pending'); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | $give_updates->percentage = 100; |
250 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
250 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function give_v152_cleanup_users() { |
262 | 262 | |
263 | - $give_version = get_option( 'give_version' ); |
|
263 | + $give_version = get_option('give_version'); |
|
264 | 264 | |
265 | - if ( ! $give_version ) { |
|
265 | + if ( ! $give_version) { |
|
266 | 266 | // 1.0 is the first version to use this option so we must add it. |
267 | 267 | $give_version = '1.0'; |
268 | 268 | } |
269 | 269 | |
270 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
270 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
271 | 271 | |
272 | 272 | // v1.5.2 Upgrades |
273 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
273 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
274 | 274 | |
275 | 275 | // Delete all caps with "ss". |
276 | 276 | // Also delete all unused "campaign" roles. |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | ); |
318 | 318 | |
319 | 319 | global $wp_roles; |
320 | - foreach ( $delete_caps as $cap ) { |
|
321 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
322 | - $wp_roles->remove_cap( $role, $cap ); |
|
320 | + foreach ($delete_caps as $cap) { |
|
321 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
322 | + $wp_roles->remove_cap($role, $cap); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | $roles->add_caps(); |
330 | 330 | |
331 | 331 | // The Update Ran. |
332 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
333 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
334 | - delete_option( 'give_doing_upgrade' ); |
|
332 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
333 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
334 | + delete_option('give_doing_upgrade'); |
|
335 | 335 | |
336 | 336 | }// End if(). |
337 | 337 | |
338 | 338 | } |
339 | 339 | |
340 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
340 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -380,53 +380,53 @@ discard block |
||
380 | 380 | |
381 | 381 | // Get addons license key. |
382 | 382 | $addons = array(); |
383 | - foreach ( $give_options as $key => $value ) { |
|
384 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
385 | - $addons[ $key ] = $value; |
|
383 | + foreach ($give_options as $key => $value) { |
|
384 | + if (false !== strpos($key, '_license_key')) { |
|
385 | + $addons[$key] = $value; |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Bailout: We do not have any addon license data to upgrade. |
390 | - if ( empty( $addons ) ) { |
|
390 | + if (empty($addons)) { |
|
391 | 391 | return false; |
392 | 392 | } |
393 | 393 | |
394 | - foreach ( $addons as $key => $addon_license ) { |
|
394 | + foreach ($addons as $key => $addon_license) { |
|
395 | 395 | |
396 | 396 | // Get addon shortname. |
397 | - $shortname = str_replace( '_license_key', '', $key ); |
|
397 | + $shortname = str_replace('_license_key', '', $key); |
|
398 | 398 | |
399 | 399 | // Addon license option name. |
400 | - $addon_license_option_name = $shortname . '_license_active'; |
|
400 | + $addon_license_option_name = $shortname.'_license_active'; |
|
401 | 401 | |
402 | 402 | // bailout if license is empty. |
403 | - if ( empty( $addon_license ) ) { |
|
404 | - delete_option( $addon_license_option_name ); |
|
403 | + if (empty($addon_license)) { |
|
404 | + delete_option($addon_license_option_name); |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
408 | 408 | // Get addon name. |
409 | 409 | $addon_name = array(); |
410 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
411 | - foreach ( $addon_name_parts as $name_part ) { |
|
410 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
411 | + foreach ($addon_name_parts as $name_part) { |
|
412 | 412 | |
413 | 413 | // Fix addon name |
414 | - switch ( $name_part ) { |
|
414 | + switch ($name_part) { |
|
415 | 415 | case 'authorizenet' : |
416 | 416 | $name_part = 'authorize.net'; |
417 | 417 | break; |
418 | 418 | } |
419 | 419 | |
420 | - $addon_name[] = ucfirst( $name_part ); |
|
420 | + $addon_name[] = ucfirst($name_part); |
|
421 | 421 | } |
422 | 422 | |
423 | - $addon_name = implode( ' ', $addon_name ); |
|
423 | + $addon_name = implode(' ', $addon_name); |
|
424 | 424 | |
425 | 425 | // Data to send to the API |
426 | 426 | $api_params = array( |
427 | 427 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
428 | 428 | 'license' => $addon_license, |
429 | - 'item_name' => urlencode( $addon_name ), |
|
429 | + 'item_name' => urlencode($addon_name), |
|
430 | 430 | 'url' => home_url(), |
431 | 431 | ); |
432 | 432 | |
@@ -441,17 +441,17 @@ discard block |
||
441 | 441 | ); |
442 | 442 | |
443 | 443 | // Make sure there are no errors. |
444 | - if ( is_wp_error( $response ) ) { |
|
445 | - delete_option( $addon_license_option_name ); |
|
444 | + if (is_wp_error($response)) { |
|
445 | + delete_option($addon_license_option_name); |
|
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | |
449 | 449 | // Tell WordPress to look for updates. |
450 | - set_site_transient( 'update_plugins', null ); |
|
450 | + set_site_transient('update_plugins', null); |
|
451 | 451 | |
452 | 452 | // Decode license data. |
453 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
454 | - update_option( $addon_license_option_name, $license_data ); |
|
453 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
454 | + update_option($addon_license_option_name, $license_data); |
|
455 | 455 | }// End foreach(). |
456 | 456 | } |
457 | 457 | |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | ); |
482 | 482 | |
483 | 483 | global $wp_roles; |
484 | - foreach ( $delete_caps as $cap ) { |
|
485 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
486 | - $wp_roles->remove_cap( $role, $cap ); |
|
484 | + foreach ($delete_caps as $cap) { |
|
485 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
486 | + $wp_roles->remove_cap($role, $cap); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | function give_v18_upgrades_core_setting() { |
518 | 518 | // Core settings which changes from checkbox to radio. |
519 | 519 | $core_setting_names = array_merge( |
520 | - array_keys( give_v18_renamed_core_settings() ), |
|
520 | + array_keys(give_v18_renamed_core_settings()), |
|
521 | 521 | array( |
522 | 522 | 'uninstall_on_delete', |
523 | 523 | 'scripts_footer', |
@@ -529,48 +529,48 @@ discard block |
||
529 | 529 | ); |
530 | 530 | |
531 | 531 | // Bailout: If not any setting define. |
532 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
532 | + if ($give_settings = get_option('give_settings')) { |
|
533 | 533 | |
534 | 534 | $setting_changed = false; |
535 | 535 | |
536 | 536 | // Loop: check each setting field. |
537 | - foreach ( $core_setting_names as $setting_name ) { |
|
537 | + foreach ($core_setting_names as $setting_name) { |
|
538 | 538 | // New setting name. |
539 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
539 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
540 | 540 | |
541 | 541 | // Continue: If setting already set. |
542 | 542 | if ( |
543 | - array_key_exists( $new_setting_name, $give_settings ) |
|
544 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
543 | + array_key_exists($new_setting_name, $give_settings) |
|
544 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
545 | 545 | ) { |
546 | 546 | continue; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Set checkbox value to radio value. |
550 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
550 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
551 | 551 | |
552 | 552 | // @see https://github.com/WordImpress/Give/issues/1063 |
553 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
553 | + if (false !== strpos($setting_name, 'disable_')) { |
|
554 | 554 | |
555 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
556 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
555 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
556 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
557 | 557 | |
558 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
558 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | // Tell bot to update core setting to db. |
562 | - if ( ! $setting_changed ) { |
|
562 | + if ( ! $setting_changed) { |
|
563 | 563 | $setting_changed = true; |
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | 567 | // Update setting only if they changed. |
568 | - if ( $setting_changed ) { |
|
569 | - update_option( 'give_settings', $give_settings ); |
|
568 | + if ($setting_changed) { |
|
569 | + update_option('give_settings', $give_settings); |
|
570 | 570 | } |
571 | 571 | }// End if(). |
572 | 572 | |
573 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
573 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | $give_updates = Give_Updates::get_instance(); |
585 | 585 | |
586 | 586 | // form query |
587 | - $forms = new WP_Query( array( |
|
587 | + $forms = new WP_Query(array( |
|
588 | 588 | 'paged' => $give_updates->step, |
589 | 589 | 'status' => 'any', |
590 | 590 | 'order' => 'ASC', |
@@ -593,41 +593,41 @@ discard block |
||
593 | 593 | ) |
594 | 594 | ); |
595 | 595 | |
596 | - if ( $forms->have_posts() ) { |
|
597 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
596 | + if ($forms->have_posts()) { |
|
597 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
598 | 598 | |
599 | - while ( $forms->have_posts() ) { |
|
599 | + while ($forms->have_posts()) { |
|
600 | 600 | $forms->the_post(); |
601 | 601 | |
602 | 602 | // Form content. |
603 | 603 | // Note in version 1.8 display content setting split into display content and content placement setting. |
604 | 604 | // You can delete _give_content_option in future |
605 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
606 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
607 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
608 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
605 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
606 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
607 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
608 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
609 | 609 | |
610 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
611 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
610 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
611 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | // "Disable" Guest Donation. Checkbox |
615 | 615 | // See: https://github.com/WordImpress/Give/issues/1470 |
616 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
617 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
618 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
616 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
617 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
618 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
619 | 619 | |
620 | 620 | // Offline Donations |
621 | 621 | // See: https://github.com/WordImpress/Give/issues/1579 |
622 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
623 | - if ( 'no' === $offline_donation ) { |
|
622 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
623 | + if ('no' === $offline_donation) { |
|
624 | 624 | $offline_donation_newval = 'global'; |
625 | - } elseif ( 'yes' === $offline_donation ) { |
|
625 | + } elseif ('yes' === $offline_donation) { |
|
626 | 626 | $offline_donation_newval = 'enabled'; |
627 | 627 | } else { |
628 | 628 | $offline_donation_newval = 'disabled'; |
629 | 629 | } |
630 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
630 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
631 | 631 | |
632 | 632 | // Convert yes/no setting field to enabled/disabled. |
633 | 633 | $form_radio_settings = array( |
@@ -647,15 +647,15 @@ discard block |
||
647 | 647 | '_give_offline_donation_enable_billing_fields_single', |
648 | 648 | ); |
649 | 649 | |
650 | - foreach ( $form_radio_settings as $meta_key ) { |
|
650 | + foreach ($form_radio_settings as $meta_key) { |
|
651 | 651 | // Get value. |
652 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
652 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
653 | 653 | |
654 | 654 | // Convert meta value only if it is in yes/no/none. |
655 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
655 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
656 | 656 | |
657 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
658 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
657 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
658 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | }// End while(). |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | |
665 | 665 | } else { |
666 | 666 | // No more forms found, finish up. |
667 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
667 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | '_transient_give_stats_', |
714 | 714 | 'give_cache', |
715 | 715 | '_transient_give_add_ons_feed', |
716 | - '_transient__give_ajax_works' . |
|
716 | + '_transient__give_ajax_works'. |
|
717 | 717 | '_transient_give_total_api_keys', |
718 | 718 | '_transient_give_i18n_give_promo_hide', |
719 | 719 | '_transient_give_contributors', |
@@ -740,24 +740,24 @@ discard block |
||
740 | 740 | ARRAY_A |
741 | 741 | ); |
742 | 742 | |
743 | - if ( ! empty( $user_apikey_options ) ) { |
|
744 | - foreach ( $user_apikey_options as $user ) { |
|
745 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
746 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
747 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
743 | + if ( ! empty($user_apikey_options)) { |
|
744 | + foreach ($user_apikey_options as $user) { |
|
745 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
746 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
747 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | |
751 | - if ( ! empty( $cached_options ) ) { |
|
752 | - foreach ( $cached_options as $option ) { |
|
753 | - switch ( true ) { |
|
754 | - case ( false !== strpos( $option, 'transient' ) ): |
|
755 | - $option = str_replace( '_transient_', '', $option ); |
|
756 | - delete_transient( $option ); |
|
751 | + if ( ! empty($cached_options)) { |
|
752 | + foreach ($cached_options as $option) { |
|
753 | + switch (true) { |
|
754 | + case (false !== strpos($option, 'transient')): |
|
755 | + $option = str_replace('_transient_', '', $option); |
|
756 | + delete_transient($option); |
|
757 | 757 | break; |
758 | 758 | |
759 | 759 | default: |
760 | - delete_option( $option ); |
|
760 | + delete_option($option); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | global $wp_roles; |
776 | 776 | |
777 | 777 | // Get the role object. |
778 | - $give_worker = get_role( 'give_worker' ); |
|
778 | + $give_worker = get_role('give_worker'); |
|
779 | 779 | |
780 | 780 | // A list of capabilities to add for give workers. |
781 | 781 | $caps_to_add = array( |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | 'edit_pages', |
784 | 784 | ); |
785 | 785 | |
786 | - foreach ( $caps_to_add as $cap ) { |
|
786 | + foreach ($caps_to_add as $cap) { |
|
787 | 787 | // Add the capability. |
788 | - $give_worker->add_cap( $cap ); |
|
788 | + $give_worker->add_cap($cap); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | } |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | $give_updates = Give_Updates::get_instance(); |
803 | 803 | |
804 | 804 | // form query |
805 | - $donation_forms = new WP_Query( array( |
|
805 | + $donation_forms = new WP_Query(array( |
|
806 | 806 | 'paged' => $give_updates->step, |
807 | 807 | 'status' => 'any', |
808 | 808 | 'order' => 'ASC', |
@@ -811,10 +811,10 @@ discard block |
||
811 | 811 | ) |
812 | 812 | ); |
813 | 813 | |
814 | - if ( $donation_forms->have_posts() ) { |
|
815 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
814 | + if ($donation_forms->have_posts()) { |
|
815 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
816 | 816 | |
817 | - while ( $donation_forms->have_posts() ) { |
|
817 | + while ($donation_forms->have_posts()) { |
|
818 | 818 | $donation_forms->the_post(); |
819 | 819 | $form_id = get_the_ID(); |
820 | 820 | |
@@ -822,41 +822,41 @@ discard block |
||
822 | 822 | update_post_meta( |
823 | 823 | $form_id, |
824 | 824 | '_give_set_price', |
825 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
825 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
826 | 826 | ); |
827 | 827 | |
828 | 828 | // Remove formatting from _give_custom_amount_minimum |
829 | 829 | update_post_meta( |
830 | 830 | $form_id, |
831 | 831 | '_give_custom_amount_minimum', |
832 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
832 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
833 | 833 | ); |
834 | 834 | |
835 | 835 | // Bailout. |
836 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
836 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
837 | 837 | continue; |
838 | 838 | } |
839 | 839 | |
840 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
840 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
841 | 841 | |
842 | - if ( ! empty( $donation_levels ) ) { |
|
842 | + if ( ! empty($donation_levels)) { |
|
843 | 843 | |
844 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
845 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
846 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
844 | + foreach ($donation_levels as $index => $donation_level) { |
|
845 | + if (isset($donation_level['_give_amount'])) { |
|
846 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
850 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
851 | 851 | |
852 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
852 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
853 | 853 | |
854 | - $min_amount = min( $donation_levels_amounts ); |
|
855 | - $max_amount = max( $donation_levels_amounts ); |
|
854 | + $min_amount = min($donation_levels_amounts); |
|
855 | + $max_amount = max($donation_levels_amounts); |
|
856 | 856 | |
857 | 857 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
858 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
859 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
858 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
859 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | wp_reset_postdata(); |
866 | 866 | } else { |
867 | 867 | // The Update Ran. |
868 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
868 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | } |
@@ -921,22 +921,22 @@ discard block |
||
921 | 921 | $give_settings = give_get_settings(); |
922 | 922 | $give_setting_updated = false; |
923 | 923 | |
924 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
924 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
925 | 925 | $give_settings['number_decimals'] = 0; |
926 | 926 | $give_settings['decimal_separator'] = ''; |
927 | 927 | $give_setting_updated = true; |
928 | 928 | |
929 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
929 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
930 | 930 | $give_settings['number_decimals'] = 0; |
931 | 931 | $give_setting_updated = true; |
932 | 932 | |
933 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
933 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
934 | 934 | $give_settings['number_decimals'] = 5; |
935 | 935 | $give_setting_updated = true; |
936 | 936 | } |
937 | 937 | |
938 | - if ( $give_setting_updated ) { |
|
939 | - update_option( 'give_settings', $give_settings ); |
|
938 | + if ($give_setting_updated) { |
|
939 | + update_option('give_settings', $give_settings); |
|
940 | 940 | } |
941 | 941 | } |
942 | 942 | |
@@ -955,70 +955,70 @@ discard block |
||
955 | 955 | $give_updates = Give_Updates::get_instance(); |
956 | 956 | |
957 | 957 | // form query |
958 | - $donation_forms = new WP_Query( array( |
|
958 | + $donation_forms = new WP_Query(array( |
|
959 | 959 | 'paged' => $give_updates->step, |
960 | 960 | 'status' => 'any', |
961 | 961 | 'order' => 'ASC', |
962 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
962 | + 'post_type' => array('give_forms', 'give_payment'), |
|
963 | 963 | 'posts_per_page' => 20, |
964 | 964 | ) |
965 | 965 | ); |
966 | 966 | |
967 | - if ( $donation_forms->have_posts() ) { |
|
968 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
967 | + if ($donation_forms->have_posts()) { |
|
968 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
969 | 969 | |
970 | - while ( $donation_forms->have_posts() ) { |
|
970 | + while ($donation_forms->have_posts()) { |
|
971 | 971 | $donation_forms->the_post(); |
972 | 972 | global $post; |
973 | 973 | |
974 | - $meta = get_post_meta( $post->ID ); |
|
974 | + $meta = get_post_meta($post->ID); |
|
975 | 975 | |
976 | - switch ( $post->post_type ) { |
|
976 | + switch ($post->post_type) { |
|
977 | 977 | case 'give_forms': |
978 | 978 | // _give_set_price |
979 | - if( ! empty( $meta['_give_set_price'][0] ) ) { |
|
980 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
979 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
980 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // _give_custom_amount_minimum |
984 | - if( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
985 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
984 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
985 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | // _give_levels_minimum_amount |
989 | - if( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
990 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
989 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
990 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | // _give_levels_maximum_amount |
994 | - if( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
995 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
994 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
995 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | // _give_set_goal |
999 | - if( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1000 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
999 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1000 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // _give_form_earnings |
1004 | - if( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1005 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1004 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1005 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // _give_custom_amount_minimum |
1009 | - if( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1010 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1009 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1010 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1011 | 1011 | |
1012 | - foreach( $donation_levels as $index => $level ) { |
|
1013 | - if( empty( $level['_give_amount'] ) ) { |
|
1012 | + foreach ($donation_levels as $index => $level) { |
|
1013 | + if (empty($level['_give_amount'])) { |
|
1014 | 1014 | continue; |
1015 | 1015 | } |
1016 | 1016 | |
1017 | - $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1017 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | $meta['_give_donation_levels'] = $donation_levels; |
1021 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1021 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | |
1027 | 1027 | case 'give_payment': |
1028 | 1028 | // _give_payment_total |
1029 | - if( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1030 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1029 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1030 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | break; |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | wp_reset_postdata(); |
1039 | 1039 | } else { |
1040 | 1040 | // The Update Ran. |
1041 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1041 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
@@ -1058,21 +1058,21 @@ discard block |
||
1058 | 1058 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1059 | 1059 | |
1060 | 1060 | // form query |
1061 | - $donors = Give()->donors->get_donors( array( |
|
1061 | + $donors = Give()->donors->get_donors(array( |
|
1062 | 1062 | 'number' => 20, |
1063 | 1063 | 'offset' => $offset, |
1064 | 1064 | ) |
1065 | 1065 | ); |
1066 | 1066 | |
1067 | - if ( ! empty( $donors ) ) { |
|
1068 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1067 | + if ( ! empty($donors)) { |
|
1068 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1069 | 1069 | |
1070 | 1070 | /* @var Object $donor */ |
1071 | - foreach ( $donors as $donor ) { |
|
1072 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1071 | + foreach ($donors as $donor) { |
|
1072 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1073 | 1073 | } |
1074 | 1074 | } else { |
1075 | 1075 | // The Update Ran. |
1076 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1076 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1077 | 1077 | } |
1078 | 1078 | } |
@@ -10,15 +10,15 @@ |
||
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 | ?> |
17 | 17 | <div class="wrap" id="poststuff"> |
18 | 18 | <div id="give-updates"> |
19 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates Complete', 'give' ); ?></h1> |
|
19 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates Complete', 'give'); ?></h1> |
|
20 | 20 | <div class="give-update-panel-content"> |
21 | - <p><?php esc_html_e( 'Congratulations! You are running the latest versions of Give and it\'s add-ons.', 'give' ); ?></p> |
|
21 | + <p><?php esc_html_e('Congratulations! You are running the latest versions of Give and it\'s add-ons.', 'give'); ?></p> |
|
22 | 22 | </div> |
23 | 23 | |
24 | 24 | </div> |