@@ -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,8 +53,8 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Constructor. |
55 | 55 | */ |
56 | - public function __construct( $_step = 1 ) { |
|
57 | - parent::__construct( $_step ); |
|
56 | + public function __construct($_step = 1) { |
|
57 | + parent::__construct($_step); |
|
58 | 58 | |
59 | 59 | $this->is_writable = true; |
60 | 60 | } |
@@ -69,59 +69,59 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_data() { |
71 | 71 | |
72 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
72 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
73 | 73 | |
74 | - if ( $this->step == 1 ) { |
|
75 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
74 | + if ($this->step == 1) { |
|
75 | + $this->delete_data('give_temp_recount_form_stats'); |
|
76 | 76 | } |
77 | 77 | |
78 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
78 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
79 | 79 | |
80 | - if ( false === $totals ) { |
|
80 | + if (false === $totals) { |
|
81 | 81 | $totals = array( |
82 | 82 | 'earnings' => (float) 0, |
83 | 83 | 'sales' => 0, |
84 | 84 | ); |
85 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
85 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
86 | 86 | } |
87 | 87 | |
88 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
88 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
89 | 89 | 'give_forms' => $this->form_id, |
90 | 90 | 'number' => $this->per_step, |
91 | 91 | 'status' => $accepted_statuses, |
92 | 92 | 'paged' => $this->step, |
93 | 93 | 'fields' => 'ids', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $payments = new Give_Payments_Query( $args ); |
|
96 | + $payments = new Give_Payments_Query($args); |
|
97 | 97 | $payments = $payments->get_payments(); |
98 | 98 | |
99 | - if ( $payments ) { |
|
100 | - foreach ( $payments as $payment ) { |
|
99 | + if ($payments) { |
|
100 | + foreach ($payments as $payment) { |
|
101 | 101 | |
102 | 102 | // Ensure acceptable status only. |
103 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
103 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Ensure only payments for this form are counted. |
108 | - if ( $payment->form_id != $this->form_id ) { |
|
108 | + if ($payment->form_id != $this->form_id) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $totals['sales'] ++; |
|
112 | + $totals['sales']++; |
|
113 | 113 | $totals['earnings'] += $payment->total; |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
117 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
118 | 118 | |
119 | 119 | return true; |
120 | 120 | } |
121 | 121 | |
122 | 122 | |
123 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
124 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
123 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
124 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
125 | 125 | |
126 | 126 | return false; |
127 | 127 | } |
@@ -133,35 +133,35 @@ discard block |
||
133 | 133 | * @return int |
134 | 134 | */ |
135 | 135 | public function get_percentage_complete() { |
136 | - if ( $this->step == 1 ) { |
|
137 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
136 | + if ($this->step == 1) { |
|
137 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
138 | 138 | } |
139 | 139 | |
140 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
141 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
140 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
141 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
142 | 142 | |
143 | - if ( false === $total ) { |
|
143 | + if (false === $total) { |
|
144 | 144 | $total = 0; |
145 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
145 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
146 | 146 | 'give_forms' => $this->form_id, |
147 | - 'number' => - 1, |
|
147 | + 'number' => -1, |
|
148 | 148 | 'status' => $accepted_statuses, |
149 | 149 | 'fields' => 'ids', |
150 | - ) ); |
|
150 | + )); |
|
151 | 151 | |
152 | - $payments = new Give_Payments_Query( $args ); |
|
153 | - $total = count( $payments->get_payments() ); |
|
154 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
152 | + $payments = new Give_Payments_Query($args); |
|
153 | + $total = count($payments->get_payments()); |
|
154 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | $percentage = 100; |
159 | 159 | |
160 | - if ( $total > 0 ) { |
|
161 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
160 | + if ($total > 0) { |
|
161 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
162 | 162 | } |
163 | 163 | |
164 | - if ( $percentage > 100 ) { |
|
164 | + if ($percentage > 100) { |
|
165 | 165 | $percentage = 100; |
166 | 166 | } |
167 | 167 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param array $request The Form Data passed into the batch processing |
177 | 177 | */ |
178 | - public function set_properties( $request ) { |
|
179 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
178 | + public function set_properties($request) { |
|
179 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -187,21 +187,21 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function process_step() { |
189 | 189 | |
190 | - if ( ! $this->can_export() ) { |
|
191 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
190 | + if ( ! $this->can_export()) { |
|
191 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $had_data = $this->get_data(); |
195 | 195 | |
196 | - if ( $had_data ) { |
|
196 | + if ($had_data) { |
|
197 | 197 | $this->done = false; |
198 | 198 | |
199 | 199 | return true; |
200 | 200 | } else { |
201 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
202 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
201 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
202 | + $this->delete_data('give_temp_recount_form_stats'); |
|
203 | 203 | $this->done = true; |
204 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
204 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
205 | 205 | |
206 | 206 | return false; |
207 | 207 | } |
@@ -235,17 +235,17 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return mixed Returns the data from the database |
237 | 237 | */ |
238 | - private function get_stored_data( $key ) { |
|
238 | + private function get_stored_data($key) { |
|
239 | 239 | global $wpdb; |
240 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
240 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
241 | 241 | |
242 | - if ( empty( $value ) ) { |
|
242 | + if (empty($value)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - $maybe_json = json_decode( $value ); |
|
247 | - if ( ! is_null( $maybe_json ) ) { |
|
248 | - $value = json_decode( $value, true ); |
|
246 | + $maybe_json = json_decode($value); |
|
247 | + if ( ! is_null($maybe_json)) { |
|
248 | + $value = json_decode($value, true); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | return $value; |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return void |
263 | 263 | */ |
264 | - private function store_data( $key, $value ) { |
|
264 | + private function store_data($key, $value) { |
|
265 | 265 | global $wpdb; |
266 | 266 | |
267 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
267 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
268 | 268 | |
269 | 269 | $data = array( |
270 | 270 | 'option_name' => $key, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | '%s', |
279 | 279 | ); |
280 | 280 | |
281 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
281 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - private function delete_data( $key ) { |
|
293 | + private function delete_data($key) { |
|
294 | 294 | global $wpdb; |
295 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
295 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | } |
299 | 299 | \ 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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -61,49 +61,49 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function get_data() { |
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_earnings'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
68 | + $total = get_option('give_temp_recount_earnings', false); |
|
69 | 69 | |
70 | - if ( false === $total ) { |
|
70 | + if (false === $total) { |
|
71 | 71 | $total = (float) 0; |
72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
73 | 73 | } |
74 | 74 | |
75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
76 | 76 | |
77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
78 | 78 | 'number' => $this->per_step, |
79 | 79 | 'page' => $this->step, |
80 | 80 | 'status' => $accepted_statuses, |
81 | 81 | 'fields' => 'ids' |
82 | - ) ); |
|
82 | + )); |
|
83 | 83 | |
84 | - $payments = give_get_payments( $args ); |
|
84 | + $payments = give_get_payments($args); |
|
85 | 85 | |
86 | - if ( ! empty( $payments ) ) { |
|
86 | + if ( ! empty($payments)) { |
|
87 | 87 | |
88 | - foreach ( $payments as $payment ) { |
|
88 | + foreach ($payments as $payment) { |
|
89 | 89 | |
90 | - $total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) ); |
|
90 | + $total += (float) give_donation_amount($payment, array('type' => 'stats')); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - if ( $total < 0 ) { |
|
94 | + if ($total < 0) { |
|
95 | 95 | $totals = 0; |
96 | 96 | } |
97 | 97 | |
98 | - $total = round( $total, give_get_price_decimals() ); |
|
98 | + $total = round($total, give_get_price_decimals()); |
|
99 | 99 | |
100 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
100 | + $this->store_data('give_temp_recount_earnings', $total); |
|
101 | 101 | |
102 | 102 | return true; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - update_option( 'give_earnings_total', $total ); |
|
106 | + update_option('give_earnings_total', $total); |
|
107 | 107 | |
108 | 108 | return false; |
109 | 109 | |
@@ -117,25 +117,25 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function get_percentage_complete() { |
119 | 119 | |
120 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
120 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
121 | 121 | |
122 | - if ( false === $total ) { |
|
123 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
122 | + if (false === $total) { |
|
123 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
124 | 124 | |
125 | - $counts = give_count_payments( $args ); |
|
126 | - $total = absint( $counts->publish ); |
|
127 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
125 | + $counts = give_count_payments($args); |
|
126 | + $total = absint($counts->publish); |
|
127 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
128 | 128 | |
129 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
129 | + $this->store_data('give_recount_earnings_total', $total); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $percentage = 100; |
133 | 133 | |
134 | - if ( $total > 0 ) { |
|
135 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
134 | + if ($total > 0) { |
|
135 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( $percentage > 100 ) { |
|
138 | + if ($percentage > 100) { |
|
139 | 139 | $percentage = 100; |
140 | 140 | } |
141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param array $request The Form Data passed into the batch processing |
151 | 151 | */ |
152 | - public function set_properties( $request ) { |
|
152 | + public function set_properties($request) { |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,21 +160,21 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function process_step() { |
162 | 162 | |
163 | - if ( ! $this->can_export() ) { |
|
164 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
163 | + if ( ! $this->can_export()) { |
|
164 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | $had_data = $this->get_data(); |
168 | 168 | |
169 | - if ( $had_data ) { |
|
169 | + if ($had_data) { |
|
170 | 170 | $this->done = false; |
171 | 171 | |
172 | 172 | return true; |
173 | 173 | } else { |
174 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
175 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
174 | + $this->delete_data('give_recount_earnings_total'); |
|
175 | + $this->delete_data('give_temp_recount_earnings'); |
|
176 | 176 | $this->done = true; |
177 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
177 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
178 | 178 | |
179 | 179 | return false; |
180 | 180 | } |
@@ -211,17 +211,17 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return mixed Returns the data from the database |
213 | 213 | */ |
214 | - private function get_stored_data( $key ) { |
|
214 | + private function get_stored_data($key) { |
|
215 | 215 | global $wpdb; |
216 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
216 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
217 | 217 | |
218 | - if ( empty( $value ) ) { |
|
218 | + if (empty($value)) { |
|
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
222 | - $maybe_json = json_decode( $value ); |
|
223 | - if ( ! is_null( $maybe_json ) ) { |
|
224 | - $value = json_decode( $value, true ); |
|
222 | + $maybe_json = json_decode($value); |
|
223 | + if ( ! is_null($maybe_json)) { |
|
224 | + $value = json_decode($value, true); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $value; |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - private function store_data( $key, $value ) { |
|
240 | + private function store_data($key, $value) { |
|
241 | 241 | global $wpdb; |
242 | 242 | |
243 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
243 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
244 | 244 | |
245 | 245 | $data = array( |
246 | 246 | 'option_name' => $key, |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | '%s', |
255 | 255 | ); |
256 | 256 | |
257 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
257 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - private function delete_data( $key ) { |
|
269 | + private function delete_data($key) { |
|
270 | 270 | global $wpdb; |
271 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
271 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | } |
@@ -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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | * @return array|bool $data The data for the CSV file |
63 | 63 | */ |
64 | 64 | public function get_data() { |
65 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
65 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
66 | 66 | |
67 | - if ( ! is_array( $items ) ) { |
|
67 | + if ( ! is_array($items)) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
71 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
72 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
73 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
71 | + $offset = ($this->step - 1) * $this->per_step; |
|
72 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
73 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
74 | 74 | |
75 | - if ( $step_items ) { |
|
76 | - foreach ( $step_items as $item ) { |
|
75 | + if ($step_items) { |
|
76 | + foreach ($step_items as $item) { |
|
77 | 77 | // Delete the main payment. |
78 | - give_delete_donation( absint( $item['id'] ) ); |
|
78 | + give_delete_donation(absint($item['id'])); |
|
79 | 79 | } |
80 | 80 | return true; |
81 | 81 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_percentage_complete() { |
93 | 93 | |
94 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
95 | - $total = count( $items ); |
|
94 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
95 | + $total = count($items); |
|
96 | 96 | |
97 | 97 | $percentage = 100; |
98 | 98 | |
99 | - if ( $total > 0 ) { |
|
100 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
99 | + if ($total > 0) { |
|
100 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $percentage > 100 ) { |
|
103 | + if ($percentage > 100) { |
|
104 | 104 | $percentage = 100; |
105 | 105 | } |
106 | 106 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param array $request The Form Data passed into the batch processing |
116 | 116 | */ |
117 | - public function set_properties( $request ) { |
|
117 | + public function set_properties($request) { |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,29 +125,29 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function process_step() { |
127 | 127 | |
128 | - if ( ! $this->can_export() ) { |
|
129 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
128 | + if ( ! $this->can_export()) { |
|
129 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $had_data = $this->get_data(); |
133 | 133 | |
134 | - if ( $had_data ) { |
|
134 | + if ($had_data) { |
|
135 | 135 | $this->done = false; |
136 | 136 | |
137 | 137 | return true; |
138 | 138 | } else { |
139 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
140 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
139 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
140 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
141 | 141 | |
142 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
142 | + $this->delete_data('give_temp_delete_test_ids'); |
|
143 | 143 | |
144 | 144 | // Reset the sequential order numbers |
145 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
146 | - delete_option( 'give_last_payment_number' ); |
|
145 | + if (give_get_option('enable_sequential')) { |
|
146 | + delete_option('give_last_payment_number'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $this->done = true; |
150 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
150 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
151 | 151 | |
152 | 152 | return false; |
153 | 153 | } |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function pre_fetch() { |
182 | 182 | |
183 | - if ( $this->step == 1 ) { |
|
184 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
183 | + if ($this->step == 1) { |
|
184 | + $this->delete_data('give_temp_delete_test_ids'); |
|
185 | 185 | } |
186 | 186 | |
187 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
187 | + $items = get_option('give_temp_delete_test_ids', false); |
|
188 | 188 | |
189 | - if ( false === $items ) { |
|
189 | + if (false === $items) { |
|
190 | 190 | $items = array(); |
191 | 191 | |
192 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
192 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
193 | 193 | 'post_status' => 'any', |
194 | - 'number' => - 1, |
|
194 | + 'number' => -1, |
|
195 | 195 | 'meta_key' => '_give_payment_mode', |
196 | 196 | 'meta_value' => 'test' |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | |
199 | - $posts = new Give_Payments_Query( $args ); |
|
199 | + $posts = new Give_Payments_Query($args); |
|
200 | 200 | $payments = $posts->get_payments(); |
201 | 201 | |
202 | 202 | /* @var Give_Payment $payment */ |
203 | - foreach ( $payments as $payment ) { |
|
203 | + foreach ($payments as $payment) { |
|
204 | 204 | $items[] = array( |
205 | 205 | 'id' => (int) $payment->ID, |
206 | 206 | 'type' => 'give_payment', |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | |
210 | 210 | // Allow filtering of items to remove with an unassociative array for each item. |
211 | 211 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
212 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
212 | + $items = apply_filters('give_delete_test_items', $items); |
|
213 | 213 | |
214 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
214 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed Returns the data from the database |
227 | 227 | */ |
228 | - private function get_stored_data( $key ) { |
|
228 | + private function get_stored_data($key) { |
|
229 | 229 | global $wpdb; |
230 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
230 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
231 | 231 | |
232 | - if ( empty( $value ) ) { |
|
232 | + if (empty($value)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - $maybe_json = json_decode( $value ); |
|
237 | - if ( ! is_null( $maybe_json ) ) { |
|
238 | - $value = json_decode( $value, true ); |
|
236 | + $maybe_json = json_decode($value); |
|
237 | + if ( ! is_null($maybe_json)) { |
|
238 | + $value = json_decode($value, true); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $value; |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | - private function store_data( $key, $value ) { |
|
254 | + private function store_data($key, $value) { |
|
255 | 255 | global $wpdb; |
256 | 256 | |
257 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
257 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
258 | 258 | |
259 | 259 | $data = array( |
260 | 260 | 'option_name' => $key, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | '%s', |
269 | 269 | ); |
270 | 270 | |
271 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
271 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - private function delete_data( $key ) { |
|
283 | + private function delete_data($key) { |
|
284 | 284 | global $wpdb; |
285 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
285 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | } |
@@ -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 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Constructor. |
75 | 75 | */ |
76 | - public function __construct( $_step = 1 ) { |
|
77 | - parent::__construct( $_step ); |
|
76 | + public function __construct($_step = 1) { |
|
77 | + parent::__construct($_step); |
|
78 | 78 | |
79 | 79 | $this->is_writable = true; |
80 | 80 | } |
@@ -89,108 +89,106 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function get_data() { |
91 | 91 | |
92 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
93 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
94 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
95 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
92 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
93 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
94 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
95 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
96 | 96 | |
97 | - if ( false === $totals ) { |
|
97 | + if (false === $totals) { |
|
98 | 98 | $totals = array(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( false === $payment_items ) { |
|
101 | + if (false === $payment_items) { |
|
102 | 102 | $payment_items = array(); |
103 | 103 | } |
104 | 104 | |
105 | - if ( false === $processed_payments ) { |
|
105 | + if (false === $processed_payments) { |
|
106 | 106 | $processed_payments = array(); |
107 | 107 | } |
108 | 108 | |
109 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
109 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
110 | 110 | |
111 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
111 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
112 | 112 | |
113 | - if ( empty( $payments ) ) { |
|
114 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
113 | + if (empty($payments)) { |
|
114 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
115 | 115 | 'give_forms' => $all_forms, |
116 | 116 | 'number' => $this->per_step, |
117 | 117 | 'status' => $accepted_statuses, |
118 | 118 | 'paged' => $this->step, |
119 | 119 | 'output' => 'give_payments', |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - $payments_query = new Give_Payments_Query( $args ); |
|
122 | + $payments_query = new Give_Payments_Query($args); |
|
123 | 123 | $payments = $payments_query->get_payments(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! empty( $payments ) ) { |
|
126 | + if ( ! empty($payments)) { |
|
127 | 127 | |
128 | 128 | //Loop through payments |
129 | - foreach ( $payments as $payment ) { |
|
129 | + foreach ($payments as $payment) { |
|
130 | 130 | |
131 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
132 | - $payment = new Give_Payment( $payment_id ); |
|
131 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
132 | + $payment = new Give_Payment($payment_id); |
|
133 | 133 | |
134 | 134 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
135 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
135 | + if (in_array($payment->ID, $processed_payments)) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Verify accepted status. |
140 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
140 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
141 | 141 | $processed_payments[] = $payment->ID; |
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
145 | - $payment_item = $payment_items[ $payment->ID ]; |
|
145 | + $payment_item = $payment_items[$payment->ID]; |
|
146 | 146 | |
147 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
147 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
148 | 148 | |
149 | 149 | // Must have a form ID. |
150 | - if ( empty( $form_id ) ) { |
|
150 | + if (empty($form_id)) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Form ID must be within $all_forms array to be validated. |
155 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
155 | + if ( ! in_array($form_id, $all_forms)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Set Sales count |
160 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
161 | - ++ $totals[ $form_id ]['sales'] : |
|
162 | - 1; |
|
160 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
161 | + ++$totals[$form_id]['sales'] : 1; |
|
163 | 162 | |
164 | 163 | // Set Total Earnings |
165 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
166 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
167 | - $payment_item['price']; |
|
164 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
165 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
168 | 166 | |
169 | 167 | $processed_payments[] = $payment->ID; |
170 | 168 | } |
171 | 169 | |
172 | 170 | // Get the list of form ids which does not contain any payment record. |
173 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
174 | - foreach ( $remaining_form_ids as $form_id ) { |
|
171 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
172 | + foreach ($remaining_form_ids as $form_id) { |
|
175 | 173 | //If array key doesn't exist, create it |
176 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
177 | - $totals[ $form_id ] = array( |
|
174 | + if ( ! array_key_exists($form_id, $totals)) { |
|
175 | + $totals[$form_id] = array( |
|
178 | 176 | 'sales' => (int) 0, |
179 | 177 | 'earnings' => (float) 0, |
180 | 178 | ); |
181 | 179 | } |
182 | 180 | } |
183 | 181 | |
184 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
185 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
182 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
183 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
186 | 184 | |
187 | 185 | return true; |
188 | 186 | } |
189 | 187 | |
190 | 188 | |
191 | - foreach ( $totals as $key => $stats ) { |
|
192 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
193 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
189 | + foreach ($totals as $key => $stats) { |
|
190 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
191 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
194 | 192 | } |
195 | 193 | |
196 | 194 | return false; |
@@ -205,20 +203,20 @@ discard block |
||
205 | 203 | */ |
206 | 204 | public function get_percentage_complete() { |
207 | 205 | |
208 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
206 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
209 | 207 | |
210 | - if ( false === $total ) { |
|
208 | + if (false === $total) { |
|
211 | 209 | $this->pre_fetch(); |
212 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
210 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
213 | 211 | } |
214 | 212 | |
215 | 213 | $percentage = 100; |
216 | 214 | |
217 | - if ( $total > 0 ) { |
|
218 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
215 | + if ($total > 0) { |
|
216 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
219 | 217 | } |
220 | 218 | |
221 | - if ( $percentage > 100 ) { |
|
219 | + if ($percentage > 100) { |
|
222 | 220 | $percentage = 100; |
223 | 221 | } |
224 | 222 | |
@@ -232,8 +230,8 @@ discard block |
||
232 | 230 | * |
233 | 231 | * @param array $request The Form Data passed into the batch processing |
234 | 232 | */ |
235 | - public function set_properties( $request ) { |
|
236 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
233 | + public function set_properties($request) { |
|
234 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
237 | 235 | } |
238 | 236 | |
239 | 237 | /** |
@@ -244,25 +242,25 @@ discard block |
||
244 | 242 | */ |
245 | 243 | public function process_step() { |
246 | 244 | |
247 | - if ( ! $this->can_export() ) { |
|
248 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
245 | + if ( ! $this->can_export()) { |
|
246 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
249 | 247 | } |
250 | 248 | |
251 | 249 | $had_data = $this->get_data(); |
252 | 250 | |
253 | - if ( $had_data ) { |
|
251 | + if ($had_data) { |
|
254 | 252 | $this->done = false; |
255 | 253 | |
256 | 254 | return true; |
257 | 255 | } else { |
258 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
259 | - $this->delete_data( 'give_recount_all_total' ); |
|
260 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
261 | - $this->delete_data( 'give_temp_payment_items' ); |
|
262 | - $this->delete_data( 'give_temp_form_ids' ); |
|
263 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
256 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
257 | + $this->delete_data('give_recount_all_total'); |
|
258 | + $this->delete_data('give_temp_recount_all_stats'); |
|
259 | + $this->delete_data('give_temp_payment_items'); |
|
260 | + $this->delete_data('give_temp_form_ids'); |
|
261 | + $this->delete_data('give_temp_processed_payments'); |
|
264 | 262 | $this->done = true; |
265 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
263 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
266 | 264 | |
267 | 265 | return false; |
268 | 266 | } |
@@ -298,70 +296,70 @@ discard block |
||
298 | 296 | */ |
299 | 297 | public function pre_fetch() { |
300 | 298 | |
301 | - if ( 1 == $this->step ) { |
|
302 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
303 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
304 | - $this->delete_data( 'give_temp_payment_items' ); |
|
305 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
306 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
299 | + if (1 == $this->step) { |
|
300 | + $this->delete_data('give_temp_recount_all_total'); |
|
301 | + $this->delete_data('give_temp_recount_all_stats'); |
|
302 | + $this->delete_data('give_temp_payment_items'); |
|
303 | + $this->delete_data('give_temp_processed_payments'); |
|
304 | + $this->delete_data('give_temp_all_payments_data'); |
|
307 | 305 | } |
308 | 306 | |
309 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
310 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
307 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
308 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
311 | 309 | |
312 | - if ( false === $total ) { |
|
310 | + if (false === $total) { |
|
313 | 311 | |
314 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
312 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
315 | 313 | |
316 | - if ( false === $payment_items ) { |
|
314 | + if (false === $payment_items) { |
|
317 | 315 | $payment_items = array(); |
318 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
316 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
319 | 317 | } |
320 | 318 | |
321 | 319 | $args = array( |
322 | 320 | 'post_status' => 'publish', |
323 | 321 | 'post_type' => 'give_forms', |
324 | - 'posts_per_page' => - 1, |
|
322 | + 'posts_per_page' => -1, |
|
325 | 323 | 'fields' => 'ids', |
326 | 324 | ); |
327 | 325 | |
328 | - $all_forms = get_posts( $args ); |
|
326 | + $all_forms = get_posts($args); |
|
329 | 327 | |
330 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
328 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
331 | 329 | |
332 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
330 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
333 | 331 | 'give_forms' => $all_forms, |
334 | 332 | 'number' => $this->per_step, |
335 | 333 | 'status' => $accepted_statuses, |
336 | 334 | 'page' => $this->step, |
337 | 335 | 'output' => 'payments', |
338 | - ) ); |
|
336 | + )); |
|
339 | 337 | |
340 | - $payments_query = new Give_Payments_Query( $args ); |
|
338 | + $payments_query = new Give_Payments_Query($args); |
|
341 | 339 | $payments = $payments_query->get_payments(); |
342 | 340 | |
343 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
341 | + $total = wp_count_posts('give_payment')->publish; |
|
344 | 342 | |
345 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
343 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
346 | 344 | |
347 | - if ( $payments ) { |
|
345 | + if ($payments) { |
|
348 | 346 | |
349 | - foreach ( $payments as $payment ) { |
|
347 | + foreach ($payments as $payment) { |
|
350 | 348 | |
351 | 349 | $form_id = $payment->form_id; |
352 | 350 | |
353 | 351 | //If for some reason somehow the form_ID isn't set check payment meta |
354 | - if ( empty( $payment->form_id ) ) { |
|
352 | + if (empty($payment->form_id)) { |
|
355 | 353 | $payment_meta = $payment->get_meta(); |
356 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
354 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
357 | 355 | } |
358 | 356 | |
359 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
357 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
360 | 358 | continue; |
361 | 359 | } |
362 | 360 | |
363 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
364 | - $payment_items[ $payment->ID ] = array( |
|
361 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
362 | + $payment_items[$payment->ID] = array( |
|
365 | 363 | 'id' => $form_id, |
366 | 364 | 'payment_id' => $payment->ID, |
367 | 365 | 'price' => $payment->total, |
@@ -369,8 +367,8 @@ discard block |
||
369 | 367 | } |
370 | 368 | } |
371 | 369 | } |
372 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
373 | - $this->store_data( 'give_recount_all_total', $total ); |
|
370 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
371 | + $this->store_data('give_recount_all_total', $total); |
|
374 | 372 | } |
375 | 373 | |
376 | 374 | } |
@@ -384,17 +382,17 @@ discard block |
||
384 | 382 | * |
385 | 383 | * @return mixed Returns the data from the database |
386 | 384 | */ |
387 | - private function get_stored_data( $key ) { |
|
385 | + private function get_stored_data($key) { |
|
388 | 386 | global $wpdb; |
389 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
390 | - if ( empty( $value ) ) { |
|
387 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
388 | + if (empty($value)) { |
|
391 | 389 | return false; |
392 | 390 | } |
393 | 391 | |
394 | - $maybe_json = json_decode( $value ); |
|
392 | + $maybe_json = json_decode($value); |
|
395 | 393 | |
396 | - if ( ! is_null( $maybe_json ) ) { |
|
397 | - $value = json_decode( $value, true ); |
|
394 | + if ( ! is_null($maybe_json)) { |
|
395 | + $value = json_decode($value, true); |
|
398 | 396 | } |
399 | 397 | |
400 | 398 | return $value; |
@@ -410,10 +408,10 @@ discard block |
||
410 | 408 | * |
411 | 409 | * @return void |
412 | 410 | */ |
413 | - private function store_data( $key, $value ) { |
|
411 | + private function store_data($key, $value) { |
|
414 | 412 | global $wpdb; |
415 | 413 | |
416 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
414 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
417 | 415 | |
418 | 416 | $data = array( |
419 | 417 | 'option_name' => $key, |
@@ -427,7 +425,7 @@ discard block |
||
427 | 425 | '%s', |
428 | 426 | ); |
429 | 427 | |
430 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
428 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
431 | 429 | } |
432 | 430 | |
433 | 431 | /** |
@@ -439,9 +437,9 @@ discard block |
||
439 | 437 | * |
440 | 438 | * @return void |
441 | 439 | */ |
442 | - private function delete_data( $key ) { |
|
440 | + private function delete_data($key) { |
|
443 | 441 | global $wpdb; |
444 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
442 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
445 | 443 | } |
446 | 444 | |
447 | 445 | } |
@@ -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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -62,40 +62,40 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get_data() { |
64 | 64 | |
65 | - $donor = new Give_Donor( $this->customer_id ); |
|
66 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
65 | + $donor = new Give_Donor($this->customer_id); |
|
66 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
67 | 67 | |
68 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
69 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
68 | + $offset = ($this->step - 1) * $this->per_step; |
|
69 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
70 | 70 | |
71 | - if ( count( $step_items ) > 0 ) { |
|
72 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
71 | + if (count($step_items) > 0) { |
|
72 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
73 | 73 | $step_total = 0; |
74 | 74 | |
75 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
75 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
76 | 76 | |
77 | - foreach ( $step_items as $payment ) { |
|
78 | - $payment = get_post( $payment->ID ); |
|
77 | + foreach ($step_items as $payment) { |
|
78 | + $payment = get_post($payment->ID); |
|
79 | 79 | |
80 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
80 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
81 | 81 | |
82 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
82 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
83 | 83 | $missing_payments[] = $payment->ID; |
84 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
84 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
85 | 85 | |
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | |
89 | 89 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
90 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
90 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
91 | 91 | |
92 | - if ( true === $should_process_payment ) { |
|
92 | + if (true === $should_process_payment) { |
|
93 | 93 | |
94 | 94 | $found_payment_ids[] = $payment->ID; |
95 | 95 | |
96 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
97 | - $payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
98 | - $step_total += $payment_amount; |
|
96 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
97 | + $payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
98 | + $step_total += $payment_amount; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | $updated_total = $pending_total + $step_total; |
106 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
107 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
106 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
107 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
108 | 108 | |
109 | 109 | return true; |
110 | 110 | } |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function get_percentage_complete() { |
123 | 123 | |
124 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
125 | - $total = count( $payments ); |
|
124 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
125 | + $total = count($payments); |
|
126 | 126 | |
127 | 127 | $percentage = 100; |
128 | 128 | |
129 | - if ( $total > 0 ) { |
|
130 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
129 | + if ($total > 0) { |
|
130 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( $percentage > 100 ) { |
|
133 | + if ($percentage > 100) { |
|
134 | 134 | $percentage = 100; |
135 | 135 | } |
136 | 136 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param array $request The Form Data passed into the batch processing |
146 | 146 | */ |
147 | - public function set_properties( $request ) { |
|
148 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
147 | + public function set_properties($request) { |
|
148 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -156,53 +156,53 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function process_step() { |
158 | 158 | |
159 | - if ( ! $this->can_export() ) { |
|
160 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
159 | + if ( ! $this->can_export()) { |
|
160 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | $had_data = $this->get_data(); |
164 | 164 | |
165 | - if ( $had_data ) { |
|
165 | + if ($had_data) { |
|
166 | 166 | $this->done = false; |
167 | 167 | |
168 | 168 | return true; |
169 | 169 | } else { |
170 | - $donor = new Give_Donor( $this->customer_id ); |
|
171 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
172 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
170 | + $donor = new Give_Donor($this->customer_id); |
|
171 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
172 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
173 | 173 | |
174 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
174 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
175 | 175 | |
176 | 176 | // Find non-existing payments (deleted) and total up the donation count |
177 | 177 | $purchase_count = 0; |
178 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
179 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
180 | - unset( $payment_ids[ $key ] ); |
|
178 | + foreach ($payment_ids as $key => $payment_id) { |
|
179 | + if (in_array($payment_id, $removed_payments)) { |
|
180 | + unset($payment_ids[$key]); |
|
181 | 181 | continue; |
182 | 182 | } |
183 | 183 | |
184 | - $payment = get_post( $payment_id ); |
|
185 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
186 | - $purchase_count ++; |
|
184 | + $payment = get_post($payment_id); |
|
185 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
186 | + $purchase_count++; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
190 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
191 | 191 | |
192 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
193 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
194 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
195 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
192 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
193 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
194 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
195 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
196 | 196 | |
197 | - $payment_ids = implode( ',', $payment_ids ); |
|
198 | - $donor->update( array( |
|
197 | + $payment_ids = implode(',', $payment_ids); |
|
198 | + $donor->update(array( |
|
199 | 199 | 'payment_ids' => $payment_ids, |
200 | 200 | 'purchase_count' => $purchase_count, |
201 | 201 | 'purchase_value' => $pending_total, |
202 | - ) ); |
|
202 | + )); |
|
203 | 203 | |
204 | 204 | $this->done = true; |
205 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
205 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
206 | 206 | |
207 | 207 | return false; |
208 | 208 | } |
@@ -235,26 +235,26 @@ discard block |
||
235 | 235 | * @return void |
236 | 236 | */ |
237 | 237 | public function pre_fetch() { |
238 | - if ( $this->step === 1 ) { |
|
239 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
238 | + if ($this->step === 1) { |
|
239 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
240 | 240 | |
241 | 241 | // Before we start, let's zero out the customer's data |
242 | - $donor = new Give_Donor( $this->customer_id ); |
|
243 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
242 | + $donor = new Give_Donor($this->customer_id); |
|
243 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
244 | 244 | |
245 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
245 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
246 | 246 | |
247 | 247 | $attached_args = array( |
248 | 248 | 'post__in' => $attached_payment_ids, |
249 | - 'number' => - 1, |
|
249 | + 'number' => -1, |
|
250 | 250 | 'status' => $allowed_payment_status, |
251 | 251 | ); |
252 | 252 | |
253 | - $attached_payments = give_get_payments( $attached_args ); |
|
253 | + $attached_payments = give_get_payments($attached_args); |
|
254 | 254 | |
255 | 255 | $unattached_args = array( |
256 | 256 | 'post__not_in' => $attached_payment_ids, |
257 | - 'number' => - 1, |
|
257 | + 'number' => -1, |
|
258 | 258 | 'status' => $allowed_payment_status, |
259 | 259 | 'meta_query' => array( |
260 | 260 | array( |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | ), |
265 | 265 | ); |
266 | 266 | |
267 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
267 | + $unattached_payments = give_get_payments($unattached_args); |
|
268 | 268 | |
269 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
269 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
270 | 270 | |
271 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
271 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -281,17 +281,17 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return mixed Returns the data from the database |
283 | 283 | */ |
284 | - private function get_stored_data( $key ) { |
|
284 | + private function get_stored_data($key) { |
|
285 | 285 | global $wpdb; |
286 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
286 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
287 | 287 | |
288 | - if ( empty( $value ) ) { |
|
288 | + if (empty($value)) { |
|
289 | 289 | return false; |
290 | 290 | } |
291 | 291 | |
292 | - $maybe_json = json_decode( $value ); |
|
293 | - if ( ! is_null( $maybe_json ) ) { |
|
294 | - $value = json_decode( $value, true ); |
|
292 | + $maybe_json = json_decode($value); |
|
293 | + if ( ! is_null($maybe_json)) { |
|
294 | + $value = json_decode($value, true); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | return $value; |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return void |
309 | 309 | */ |
310 | - private function store_data( $key, $value ) { |
|
310 | + private function store_data($key, $value) { |
|
311 | 311 | global $wpdb; |
312 | 312 | |
313 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
313 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
314 | 314 | |
315 | 315 | $data = array( |
316 | 316 | 'option_name' => $key, |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | '%s', |
325 | 325 | ); |
326 | 326 | |
327 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
327 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return void |
338 | 338 | */ |
339 | - private function delete_data( $key ) { |
|
339 | + private function delete_data($key) { |
|
340 | 340 | global $wpdb; |
341 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
341 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | } |
@@ -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 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Constructor. |
100 | 100 | */ |
101 | - public function __construct( $_step = 1 ) { |
|
102 | - parent::__construct( $_step ); |
|
101 | + public function __construct($_step = 1) { |
|
102 | + parent::__construct($_step); |
|
103 | 103 | |
104 | 104 | $this->is_writable = true; |
105 | 105 | } |
@@ -118,32 +118,32 @@ discard block |
||
118 | 118 | $donor_ids = array(); |
119 | 119 | |
120 | 120 | // Check if the ajax request if running for the first time. |
121 | - if ( 1 === (int) $this->step ) { |
|
121 | + if (1 === (int) $this->step) { |
|
122 | 122 | // Delete all the donation ids. |
123 | - $this->delete_option( $this->donation_key ); |
|
123 | + $this->delete_option($this->donation_key); |
|
124 | 124 | // Delete all the donor ids. |
125 | - $this->delete_option( $this->donor_key ); |
|
125 | + $this->delete_option($this->donor_key); |
|
126 | 126 | |
127 | 127 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
128 | - $this->update_option( $this->step_key, 'count' ); |
|
128 | + $this->update_option($this->step_key, 'count'); |
|
129 | 129 | |
130 | 130 | // Delete tha page count of the step. |
131 | - $this->update_option( $this->step_on_key, '0' ); |
|
131 | + $this->update_option($this->step_on_key, '0'); |
|
132 | 132 | } else { |
133 | 133 | // Get the old donors list. |
134 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
134 | + $donor_ids = $this->get_option($this->donor_key); |
|
135 | 135 | |
136 | 136 | // Get the old donation list. |
137 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
137 | + $donation_ids = $this->get_option($this->donation_key); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
141 | 141 | $step = (int) $this->get_step(); |
142 | - if ( 1 === $step ) { |
|
142 | + if (1 === $step) { |
|
143 | 143 | /** |
144 | 144 | * Will add or update the donation and donor data by running wp query. |
145 | 145 | */ |
146 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
146 | + $this->count($step, $donation_ids, $donor_ids); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
155 | 155 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
156 | 156 | */ |
157 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
157 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
158 | 158 | |
159 | 159 | // Get the Page count by default it's zero. |
160 | 160 | $paged = (int) $this->get_step_page(); |
161 | 161 | // Incresed the page count by one. |
162 | - ++ $paged; |
|
162 | + ++$paged; |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Filter add to alter the argument before the wp quest run |
166 | 166 | */ |
167 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
167 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
168 | 168 | 'post_type' => 'give_payment', |
169 | 169 | 'post_status' => 'any', |
170 | 170 | 'posts_per_page' => $this->per_step, |
@@ -172,16 +172,16 @@ discard block |
||
172 | 172 | // ONLY TEST MODE TRANSACTIONS!!! |
173 | 173 | 'meta_key' => '_give_payment_mode', |
174 | 174 | 'meta_value' => 'test', |
175 | - ) ); |
|
175 | + )); |
|
176 | 176 | |
177 | 177 | // Reset the post data. |
178 | 178 | wp_reset_postdata(); |
179 | 179 | // Getting the new donation. |
180 | - $donation_posts = new WP_Query( $args ); |
|
180 | + $donation_posts = new WP_Query($args); |
|
181 | 181 | |
182 | 182 | // The Loop. |
183 | - if ( $donation_posts->have_posts() ) { |
|
184 | - while ( $donation_posts->have_posts() ) { |
|
183 | + if ($donation_posts->have_posts()) { |
|
184 | + while ($donation_posts->have_posts()) { |
|
185 | 185 | $donation_posts->the_post(); |
186 | 186 | global $post; |
187 | 187 | // Add the donation id in side the array. |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | $max_num_pages = (int) $donation_posts->max_num_pages; |
201 | 201 | |
202 | 202 | // Check current page is less then max number of page or not |
203 | - if ( $paged < $max_num_pages ) { |
|
203 | + if ($paged < $max_num_pages) { |
|
204 | 204 | // Update the curretn page virable for the next step |
205 | - $this->update_option( $this->step_on_key, $paged ); |
|
205 | + $this->update_option($this->step_on_key, $paged); |
|
206 | 206 | |
207 | 207 | // Calculating percentage. |
208 | 208 | $page_remain = $max_num_pages - $paged; |
209 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
209 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
210 | 210 | $this->step_completed = $paged; |
211 | 211 | } else { |
212 | - $donation_ids_count = count( $donor_ids ); |
|
213 | - $this->update_option( $this->step_key, 'donation' ); |
|
214 | - $this->update_option( $this->step_on_key, '0' ); |
|
212 | + $donation_ids_count = count($donor_ids); |
|
213 | + $this->update_option($this->step_key, 'donation'); |
|
214 | + $this->update_option($this->step_on_key, '0'); |
|
215 | 215 | } |
216 | 216 | |
217 | - $donor_ids = array_unique( $donor_ids ); |
|
218 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
219 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
217 | + $donor_ids = array_unique($donor_ids); |
|
218 | + $this->update_option($this->donor_key, $donor_ids); |
|
219 | + $this->update_option($this->donation_key, $donation_ids); |
|
220 | 220 | |
221 | 221 | wp_reset_postdata(); |
222 | 222 | } |
@@ -228,34 +228,34 @@ discard block |
||
228 | 228 | * @return int |
229 | 229 | */ |
230 | 230 | public function get_percentage_complete() { |
231 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
231 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | public function process_step() { |
235 | 235 | |
236 | - if ( ! $this->can_export() ) { |
|
237 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
236 | + if ( ! $this->can_export()) { |
|
237 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $had_data = $this->get_data(); |
241 | 241 | |
242 | - if ( $had_data ) { |
|
242 | + if ($had_data) { |
|
243 | 243 | $this->done = false; |
244 | 244 | |
245 | 245 | return true; |
246 | 246 | } else { |
247 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
248 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
247 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
248 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
249 | 249 | |
250 | - $this->delete_option( $this->donation_key ); |
|
250 | + $this->delete_option($this->donation_key); |
|
251 | 251 | |
252 | 252 | // Reset the sequential order numbers |
253 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
254 | - delete_option( 'give_last_payment_number' ); |
|
253 | + if (give_get_option('enable_sequential')) { |
|
254 | + delete_option('give_last_payment_number'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $this->done = true; |
258 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
258 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
259 | 259 | |
260 | 260 | return false; |
261 | 261 | } |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | public function get_data() { |
274 | 274 | |
275 | 275 | // Get the donation id's. |
276 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
276 | + $donation_ids = $this->get_option($this->donation_key); |
|
277 | 277 | |
278 | 278 | /** |
279 | 279 | * Return false id not test donation is found. |
280 | 280 | */ |
281 | - if ( empty( $donation_ids ) ) { |
|
281 | + if (empty($donation_ids)) { |
|
282 | 282 | $this->is_empty = true; |
283 | 283 | $this->total_step = 1; |
284 | 284 | |
@@ -289,70 +289,70 @@ discard block |
||
289 | 289 | $step = (int) $this->get_step(); |
290 | 290 | |
291 | 291 | // get teh donor ids. |
292 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
292 | + $donor_ids = $this->get_option($this->donor_key); |
|
293 | 293 | |
294 | 294 | // In step to we delete all the donation in loop. |
295 | - if ( 2 === $step ) { |
|
295 | + if (2 === $step) { |
|
296 | 296 | $pass_to_donor = false; |
297 | 297 | $page = (int) $this->get_step_page(); |
298 | - $page ++; |
|
299 | - $count = count( $donation_ids ); |
|
298 | + $page++; |
|
299 | + $count = count($donation_ids); |
|
300 | 300 | |
301 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
301 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
302 | 302 | $this->step_completed = $page; |
303 | 303 | |
304 | 304 | |
305 | - if ( $count > $this->per_step ) { |
|
305 | + if ($count > $this->per_step) { |
|
306 | 306 | |
307 | - $this->update_option( $this->step_on_key, $page ); |
|
308 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
309 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
307 | + $this->update_option($this->step_on_key, $page); |
|
308 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
309 | + $current_page = (int) ceil($count / $this->per_step); |
|
310 | 310 | |
311 | - if ( $page === $current_page ) { |
|
311 | + if ($page === $current_page) { |
|
312 | 312 | $pass_to_donor = true; |
313 | 313 | } |
314 | 314 | } else { |
315 | 315 | $pass_to_donor = true; |
316 | 316 | } |
317 | 317 | |
318 | - if ( true === $pass_to_donor ) { |
|
319 | - $this->update_option( $this->step_key, 'donor' ); |
|
320 | - $this->update_option( $this->step_on_key, '0' ); |
|
318 | + if (true === $pass_to_donor) { |
|
319 | + $this->update_option($this->step_key, 'donor'); |
|
320 | + $this->update_option($this->step_on_key, '0'); |
|
321 | 321 | } |
322 | 322 | |
323 | - foreach ( $donation_ids as $item ) { |
|
323 | + foreach ($donation_ids as $item) { |
|
324 | 324 | // Delete the main payment. |
325 | - give_delete_donation( absint( $item ) ); |
|
325 | + give_delete_donation(absint($item)); |
|
326 | 326 | } |
327 | - do_action( 'give_delete_log_cache' ); |
|
327 | + do_action('give_delete_log_cache'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
331 | 331 | // Here we delete all the donor |
332 | - if ( 3 === $step ) { |
|
332 | + if (3 === $step) { |
|
333 | 333 | $page = (int) $this->get_step_page(); |
334 | - $count = count( $donor_ids ); |
|
334 | + $count = count($donor_ids); |
|
335 | 335 | |
336 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
337 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
336 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
337 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
338 | 338 | |
339 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
339 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
340 | 340 | 'post_type' => 'give_payment', |
341 | 341 | 'post_status' => 'any', |
342 | 342 | 'posts_per_page' => 1, |
343 | 343 | 'meta_key' => '_give_payment_mode', |
344 | 344 | 'meta_value' => 'live', |
345 | - 'author' => $donor_ids[ $page ], |
|
346 | - ) ); |
|
345 | + 'author' => $donor_ids[$page], |
|
346 | + )); |
|
347 | 347 | |
348 | - $donation_posts = get_posts( $args ); |
|
349 | - if ( empty( $donation_posts ) ) { |
|
350 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
348 | + $donation_posts = get_posts($args); |
|
349 | + if (empty($donation_posts)) { |
|
350 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
351 | 351 | } |
352 | 352 | |
353 | - $page ++; |
|
354 | - $this->update_option( $this->step_on_key, $page ); |
|
355 | - if ( $count === $page ) { |
|
353 | + $page++; |
|
354 | + $this->update_option($this->step_on_key, $page); |
|
355 | + if ($count === $page) { |
|
356 | 356 | $this->is_empty = false; |
357 | 357 | |
358 | 358 | return false; |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | return true; |
365 | 365 | } |
366 | 366 | |
367 | - public function get_delete_ids( $donation_ids, $page ) { |
|
368 | - $index = $page --; |
|
369 | - $count = count( $donation_ids ); |
|
367 | + public function get_delete_ids($donation_ids, $page) { |
|
368 | + $index = $page--; |
|
369 | + $count = count($donation_ids); |
|
370 | 370 | $temp = 0; |
371 | 371 | $current_page = 0; |
372 | 372 | $post_delete = $this->per_step; |
373 | 373 | $page_donation_id = array(); |
374 | 374 | |
375 | - foreach ( $donation_ids as $item ) { |
|
376 | - $temp ++; |
|
377 | - $page_donation_id[ $current_page ][] = $item; |
|
378 | - if ( $temp === $post_delete ) { |
|
379 | - $current_page ++; |
|
375 | + foreach ($donation_ids as $item) { |
|
376 | + $temp++; |
|
377 | + $page_donation_id[$current_page][] = $item; |
|
378 | + if ($temp === $post_delete) { |
|
379 | + $current_page++; |
|
380 | 380 | $temp = 0; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return $page_donation_id[ $page ]; |
|
384 | + return $page_donation_id[$page]; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return mixed Returns the data from the database |
395 | 395 | */ |
396 | - public function get_option( $key, $defalut_value = false ) { |
|
397 | - return get_option( $key, $defalut_value ); |
|
396 | + public function get_option($key, $defalut_value = false) { |
|
397 | + return get_option($key, $defalut_value); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return void |
409 | 409 | */ |
410 | - public function update_option( $key, $value ) { |
|
411 | - update_option( $key, $value, false ); |
|
410 | + public function update_option($key, $value) { |
|
411 | + update_option($key, $value, false); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @return void |
422 | 422 | */ |
423 | - public function delete_option( $key ) { |
|
424 | - delete_option( $key ); |
|
423 | + public function delete_option($key) { |
|
424 | + delete_option($key); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | * @return int|string |
433 | 433 | */ |
434 | 434 | private function get_step() { |
435 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
436 | - if ( 'count' === $step_key ) { |
|
435 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
436 | + if ('count' === $step_key) { |
|
437 | 437 | return 1; |
438 | - } elseif ( 'donation' === $step_key ) { |
|
438 | + } elseif ('donation' === $step_key) { |
|
439 | 439 | return 2; |
440 | - } elseif ( 'donor' === $step_key ) { |
|
440 | + } elseif ('donor' === $step_key) { |
|
441 | 441 | return 3; |
442 | 442 | } else { |
443 | 443 | return $step_key; |
@@ -448,6 +448,6 @@ discard block |
||
448 | 448 | * Get the current $page value in the ajax. |
449 | 449 | */ |
450 | 450 | private function get_step_page() { |
451 | - return $this->get_option( $this->step_on_key, false ); |
|
451 | + return $this->get_option($this->step_on_key, false); |
|
452 | 452 | } |
453 | 453 | } |
@@ -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 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Constructor. |
51 | 51 | */ |
52 | - public function __construct( $_step = 1 ) { |
|
53 | - parent::__construct( $_step ); |
|
52 | + public function __construct($_step = 1) { |
|
53 | + parent::__construct($_step); |
|
54 | 54 | |
55 | 55 | $this->is_writable = true; |
56 | 56 | } |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | public function get_data() { |
68 | 68 | global $wpdb; |
69 | 69 | |
70 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
70 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
71 | 71 | |
72 | - if ( ! is_array( $items ) ) { |
|
72 | + if ( ! is_array($items)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
77 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
76 | + $offset = ($this->step - 1) * $this->per_step; |
|
77 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
78 | 78 | |
79 | - if ( $step_items ) { |
|
79 | + if ($step_items) { |
|
80 | 80 | |
81 | 81 | $step_ids = array( |
82 | 82 | 'customers' => array(), |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | 'other' => array(), |
85 | 85 | ); |
86 | 86 | |
87 | - foreach ( $step_items as $item ) { |
|
87 | + foreach ($step_items as $item) { |
|
88 | 88 | |
89 | - switch ( $item['type'] ) { |
|
89 | + switch ($item['type']) { |
|
90 | 90 | case 'customer': |
91 | 91 | $step_ids['customers'][] = $item['id']; |
92 | 92 | break; |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | $step_ids['give_forms'][] = $item['id']; |
95 | 95 | break; |
96 | 96 | default: |
97 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
98 | - $step_ids[ $item_type ][] = $item['id']; |
|
97 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
98 | + $step_ids[$item_type][] = $item['id']; |
|
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | $sql = array(); |
104 | - $meta_table = __give_v20_bc_table_details('form' ); |
|
104 | + $meta_table = __give_v20_bc_table_details('form'); |
|
105 | 105 | |
106 | - foreach ( $step_ids as $type => $ids ) { |
|
106 | + foreach ($step_ids as $type => $ids) { |
|
107 | 107 | |
108 | - if ( empty( $ids ) ) { |
|
108 | + if (empty($ids)) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $ids = implode( ',', $ids ); |
|
112 | + $ids = implode(',', $ids); |
|
113 | 113 | |
114 | - switch ( $type ) { |
|
114 | + switch ($type) { |
|
115 | 115 | case 'customers': |
116 | 116 | $sql[] = "DELETE FROM $wpdb->donors WHERE id IN ($ids)"; |
117 | 117 | $table_name = $wpdb->donors; |
@@ -131,16 +131,16 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
134 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
135 | 135 | // Allows other types of custom post types to filter on their own post_type |
136 | 136 | // and add items to the query list, for the IDs found in their post type. |
137 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
137 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - if ( ! empty( $sql ) ) { |
|
142 | - foreach ( $sql as $query ) { |
|
143 | - $wpdb->query( $query ); |
|
141 | + if ( ! empty($sql)) { |
|
142 | + foreach ($sql as $query) { |
|
143 | + $wpdb->query($query); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_percentage_complete() { |
162 | 162 | |
163 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
164 | - $total = count( $items ); |
|
163 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
164 | + $total = count($items); |
|
165 | 165 | |
166 | 166 | $percentage = 100; |
167 | 167 | |
168 | - if ( $total > 0 ) { |
|
169 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
168 | + if ($total > 0) { |
|
169 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( $percentage > 100 ) { |
|
172 | + if ($percentage > 100) { |
|
173 | 173 | $percentage = 100; |
174 | 174 | } |
175 | 175 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param array $request The Form Data passed into the batch processing. |
185 | 185 | */ |
186 | - public function set_properties( $request ) { |
|
186 | + public function set_properties($request) { |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function process_step() { |
196 | 196 | |
197 | - if ( ! $this->can_export() ) { |
|
198 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
197 | + if ( ! $this->can_export()) { |
|
198 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
199 | 199 | 'response' => 403, |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $had_data = $this->get_data(); |
204 | 204 | |
205 | - if ( $had_data ) { |
|
205 | + if ($had_data) { |
|
206 | 206 | $this->done = false; |
207 | 207 | |
208 | 208 | return true; |
209 | 209 | } else { |
210 | - update_option( 'give_earnings_total', 0 ); |
|
211 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
210 | + update_option('give_earnings_total', 0); |
|
211 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
212 | 212 | |
213 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
213 | + $this->delete_data('give_temp_reset_ids'); |
|
214 | 214 | |
215 | 215 | // Reset the sequential order numbers |
216 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
217 | - delete_option( 'give_last_payment_number' ); |
|
216 | + if (give_get_option('enable_sequential')) { |
|
217 | + delete_option('give_last_payment_number'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | $this->done = true; |
221 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
221 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
222 | 222 | |
223 | 223 | return false; |
224 | 224 | } |
@@ -251,26 +251,26 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function pre_fetch() { |
253 | 253 | |
254 | - if ( $this->step == 1 ) { |
|
255 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
254 | + if ($this->step == 1) { |
|
255 | + $this->delete_data('give_temp_reset_ids'); |
|
256 | 256 | } |
257 | 257 | |
258 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
258 | + $items = get_option('give_temp_reset_ids', false); |
|
259 | 259 | |
260 | - if ( false === $items ) { |
|
260 | + if (false === $items) { |
|
261 | 261 | $items = array(); |
262 | 262 | |
263 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
264 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
263 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
264 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
265 | 265 | |
266 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
266 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
267 | 267 | 'post_type' => $give_types_for_reset, |
268 | 268 | 'post_status' => 'any', |
269 | - 'posts_per_page' => - 1, |
|
270 | - ) ); |
|
269 | + 'posts_per_page' => -1, |
|
270 | + )); |
|
271 | 271 | |
272 | - $posts = get_posts( $args ); |
|
273 | - foreach ( $posts as $post ) { |
|
272 | + $posts = get_posts($args); |
|
273 | + foreach ($posts as $post) { |
|
274 | 274 | $items[] = array( |
275 | 275 | 'id' => (int) $post->ID, |
276 | 276 | 'type' => $post->post_type, |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | $donor_args = array( |
281 | - 'number' => - 1, |
|
281 | + 'number' => -1, |
|
282 | 282 | ); |
283 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
284 | - foreach ( $donors as $donor ) { |
|
283 | + $donors = Give()->donors->get_donors($donor_args); |
|
284 | + foreach ($donors as $donor) { |
|
285 | 285 | $items[] = array( |
286 | 286 | 'id' => (int) $donor->id, |
287 | 287 | 'type' => 'customer', |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | |
291 | 291 | // Allow filtering of items to remove with an unassociative array for each item |
292 | 292 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
293 | - $items = apply_filters( 'give_reset_items', $items ); |
|
293 | + $items = apply_filters('give_reset_items', $items); |
|
294 | 294 | |
295 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
295 | + $this->store_data('give_temp_reset_ids', $items); |
|
296 | 296 | }// End if(). |
297 | 297 | |
298 | 298 | } |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return mixed Returns the data from the database. |
308 | 308 | */ |
309 | - private function get_stored_data( $key ) { |
|
309 | + private function get_stored_data($key) { |
|
310 | 310 | global $wpdb; |
311 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
311 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
312 | 312 | |
313 | - if ( empty( $value ) ) { |
|
313 | + if (empty($value)) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | 316 | |
317 | - $maybe_json = json_decode( $value ); |
|
318 | - if ( ! is_null( $maybe_json ) ) { |
|
319 | - $value = json_decode( $value, true ); |
|
317 | + $maybe_json = json_decode($value); |
|
318 | + if ( ! is_null($maybe_json)) { |
|
319 | + $value = json_decode($value, true); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $value; |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | - private function store_data( $key, $value ) { |
|
335 | + private function store_data($key, $value) { |
|
336 | 336 | global $wpdb; |
337 | 337 | |
338 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
338 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
339 | 339 | |
340 | 340 | $data = array( |
341 | 341 | 'option_name' => $key, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | '%s', |
350 | 350 | ); |
351 | 351 | |
352 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
352 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - private function delete_data( $key ) { |
|
364 | + private function delete_data($key) { |
|
365 | 365 | global $wpdb; |
366 | - $wpdb->delete( $wpdb->options, array( |
|
366 | + $wpdb->delete($wpdb->options, array( |
|
367 | 367 | 'option_name' => $key, |
368 | - ) ); |
|
368 | + )); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
372 | 372 | \ 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 | |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.0 |
64 | 64 | */ |
65 | - public function __construct( $shortcode ) { |
|
65 | + public function __construct($shortcode) { |
|
66 | 66 | |
67 | 67 | $this->shortcode_tag = $shortcode; |
68 | 68 | |
69 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
69 | + add_action('admin_init', array($this, 'init')); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function init() { |
79 | 79 | |
80 | - if ( $this->shortcode_tag ) { |
|
80 | + if ($this->shortcode_tag) { |
|
81 | 81 | |
82 | - $this->self = get_class( $this ); |
|
82 | + $this->self = get_class($this); |
|
83 | 83 | |
84 | 84 | $this->errors = array(); |
85 | 85 | $this->required = array(); |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | $fields = $this->get_fields(); |
89 | 89 | |
90 | 90 | $defaults = array( |
91 | - 'btn_close' => esc_html__( 'Close', 'give' ), |
|
92 | - 'btn_okay' => esc_html__( 'Insert Shortcode', 'give' ), |
|
91 | + 'btn_close' => esc_html__('Close', 'give'), |
|
92 | + 'btn_okay' => esc_html__('Insert Shortcode', 'give'), |
|
93 | 93 | 'errors' => $this->errors, |
94 | 94 | 'fields' => $fields, |
95 | - 'label' => '[' . $this->shortcode_tag . ']', |
|
95 | + 'label' => '['.$this->shortcode_tag.']', |
|
96 | 96 | 'required' => $this->required, |
97 | - 'title' => esc_html__( 'Insert Shortcode', 'give' ), |
|
97 | + 'title' => esc_html__('Insert Shortcode', 'give'), |
|
98 | 98 | ); |
99 | 99 | |
100 | - if ( user_can_richedit() ) { |
|
100 | + if (user_can_richedit()) { |
|
101 | 101 | |
102 | - Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults ); |
|
102 | + Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | } |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | - protected function generate_fields( $defined_fields ) { |
|
131 | + protected function generate_fields($defined_fields) { |
|
132 | 132 | |
133 | 133 | $fields = array(); |
134 | 134 | |
135 | - if ( is_array( $defined_fields ) ) { |
|
135 | + if (is_array($defined_fields)) { |
|
136 | 136 | |
137 | - foreach ( $defined_fields as $field ) { |
|
137 | + foreach ($defined_fields as $field) { |
|
138 | 138 | |
139 | 139 | $defaults = array( |
140 | 140 | 'label' => false, |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | 'type' => '', |
146 | 146 | ); |
147 | 147 | |
148 | - $field = wp_parse_args( (array) $field, $defaults ); |
|
149 | - $method = 'generate_' . strtolower( $field['type'] ); |
|
148 | + $field = wp_parse_args((array) $field, $defaults); |
|
149 | + $method = 'generate_'.strtolower($field['type']); |
|
150 | 150 | |
151 | - if ( method_exists( $this, $method ) ) { |
|
151 | + if (method_exists($this, $method)) { |
|
152 | 152 | |
153 | - $field = call_user_func( array( $this, $method ), $field ); |
|
153 | + $field = call_user_func(array($this, $method), $field); |
|
154 | 154 | |
155 | - if ( $field ) { |
|
155 | + if ($field) { |
|
156 | 156 | $fields[] = $field; |
157 | 157 | } |
158 | 158 | } |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | protected function get_fields() { |
173 | 173 | |
174 | 174 | $defined_fields = $this->define_fields(); |
175 | - $generated_fields = $this->generate_fields( $defined_fields ); |
|
175 | + $generated_fields = $this->generate_fields($defined_fields); |
|
176 | 176 | |
177 | 177 | $errors = array(); |
178 | 178 | |
179 | - if ( ! empty( $this->errors ) ) { |
|
180 | - foreach ( $this->required as $name => $alert ) { |
|
179 | + if ( ! empty($this->errors)) { |
|
180 | + foreach ($this->required as $name => $alert) { |
|
181 | 181 | // Using WordPress function in place of array_column wp_list_pluck as it support older version as well. |
182 | - if ( false === array_search( $name, give_list_pluck( $generated_fields, 'name' ) ) ) { |
|
182 | + if (false === array_search($name, give_list_pluck($generated_fields, 'name'))) { |
|
183 | 183 | |
184 | - $errors[] = $this->errors[ $name ]; |
|
184 | + $errors[] = $this->errors[$name]; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | $this->errors = $errors; |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $errors ) ) { |
|
191 | + if ( ! empty($errors)) { |
|
192 | 192 | |
193 | 193 | return $errors; |
194 | 194 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - protected function generate_container( $field ) { |
|
208 | + protected function generate_container($field) { |
|
209 | 209 | |
210 | - if ( array_key_exists( 'html', $field ) ) { |
|
210 | + if (array_key_exists('html', $field)) { |
|
211 | 211 | |
212 | 212 | return array( |
213 | 213 | 'type' => $field['type'], |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | */ |
230 | - protected function generate_listbox( $field ) { |
|
230 | + protected function generate_listbox($field) { |
|
231 | 231 | |
232 | - $listbox = shortcode_atts( array( |
|
232 | + $listbox = shortcode_atts(array( |
|
233 | 233 | 'label' => '', |
234 | 234 | 'minWidth' => '', |
235 | 235 | 'name' => false, |
@@ -237,27 +237,27 @@ discard block |
||
237 | 237 | 'type' => '', |
238 | 238 | 'value' => '', |
239 | 239 | 'classes' => '' |
240 | - ), $field ); |
|
240 | + ), $field); |
|
241 | 241 | |
242 | - if ( $this->validate( $field ) ) { |
|
242 | + if ($this->validate($field)) { |
|
243 | 243 | |
244 | 244 | $new_listbox = array(); |
245 | 245 | |
246 | - foreach ( $listbox as $key => $value ) { |
|
246 | + foreach ($listbox as $key => $value) { |
|
247 | 247 | |
248 | - if ( $key == 'value' && empty( $value ) ) { |
|
249 | - $new_listbox[ $key ] = $listbox['name']; |
|
250 | - } else if ( $value ) { |
|
251 | - $new_listbox[ $key ] = $value; |
|
248 | + if ($key == 'value' && empty($value)) { |
|
249 | + $new_listbox[$key] = $listbox['name']; |
|
250 | + } else if ($value) { |
|
251 | + $new_listbox[$key] = $value; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // do not reindex array! |
256 | 256 | $field['options'] = array( |
257 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
257 | + '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')), |
|
258 | 258 | ) + $field['options']; |
259 | 259 | |
260 | - foreach ( $field['options'] as $value => $text ) { |
|
260 | + foreach ($field['options'] as $value => $text) { |
|
261 | 261 | $new_listbox['values'][] = array( |
262 | 262 | 'text' => $text, |
263 | 263 | 'value' => $value, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @since 1.0 |
281 | 281 | */ |
282 | - protected function generate_post( $field ) { |
|
282 | + protected function generate_post($field) { |
|
283 | 283 | |
284 | 284 | $args = array( |
285 | 285 | 'post_type' => 'post', |
@@ -288,26 +288,26 @@ discard block |
||
288 | 288 | 'posts_per_page' => 30, |
289 | 289 | ); |
290 | 290 | |
291 | - $args = wp_parse_args( (array) $field['query_args'], $args ); |
|
292 | - $posts = new WP_Query( $args ); |
|
291 | + $args = wp_parse_args((array) $field['query_args'], $args); |
|
292 | + $posts = new WP_Query($args); |
|
293 | 293 | $options = array(); |
294 | 294 | |
295 | - if ( $posts->have_posts() ) { |
|
296 | - while ( $posts->have_posts() ) { |
|
295 | + if ($posts->have_posts()) { |
|
296 | + while ($posts->have_posts()) { |
|
297 | 297 | $posts->the_post(); |
298 | 298 | $post_title = get_the_title(); |
299 | 299 | $post_id = get_the_ID(); |
300 | - $options[ absint( $post_id ) ] = ( empty( $post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post_id ) : $post_title ); |
|
300 | + $options[absint($post_id)] = (empty($post_title) ? sprintf(__('Untitled (#%s)', 'give'), $post_id) : $post_title); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | $field['type'] = 'listbox'; |
304 | 304 | $field['options'] = $options; |
305 | 305 | |
306 | - return $this->generate_listbox( $field ); |
|
306 | + return $this->generate_listbox($field); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | // perform validation here before returning false |
310 | - $this->validate( $field ); |
|
310 | + $this->validate($field); |
|
311 | 311 | |
312 | 312 | return false; |
313 | 313 | } |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @since 1.0 |
323 | 323 | */ |
324 | - protected function generate_textbox( $field ) { |
|
324 | + protected function generate_textbox($field) { |
|
325 | 325 | |
326 | - $textbox = shortcode_atts( array( |
|
326 | + $textbox = shortcode_atts(array( |
|
327 | 327 | 'label' => '', |
328 | 328 | 'maxLength' => '', |
329 | 329 | 'minHeight' => '', |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | 'type' => '', |
335 | 335 | 'value' => '', |
336 | 336 | 'classes' => '' |
337 | - ), $field ); |
|
337 | + ), $field); |
|
338 | 338 | |
339 | - if ( $this->validate( $field ) ) { |
|
340 | - return array_filter( $textbox, array( $this, 'return_textbox_value' ) ); |
|
339 | + if ($this->validate($field)) { |
|
340 | + return array_filter($textbox, array($this, 'return_textbox_value')); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return false; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return bool |
352 | 352 | */ |
353 | - function return_textbox_value( $value ) { |
|
353 | + function return_textbox_value($value) { |
|
354 | 354 | return $value !== ''; |
355 | 355 | } |
356 | 356 | |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @since 1.0 |
368 | 368 | */ |
369 | - protected function validate( $field ) { |
|
369 | + protected function validate($field) { |
|
370 | 370 | |
371 | - extract( shortcode_atts( |
|
371 | + extract(shortcode_atts( |
|
372 | 372 | array( |
373 | 373 | 'name' => false, |
374 | 374 | 'required' => false, |
@@ -376,36 +376,36 @@ discard block |
||
376 | 376 | ), $field ) |
377 | 377 | ); |
378 | 378 | |
379 | - if ( $name ) { |
|
379 | + if ($name) { |
|
380 | 380 | |
381 | - if ( isset( $required['error'] ) ) { |
|
381 | + if (isset($required['error'])) { |
|
382 | 382 | |
383 | 383 | $error = array( |
384 | 384 | 'type' => 'container', |
385 | 385 | 'html' => $required['error'], |
386 | 386 | ); |
387 | 387 | |
388 | - $this->errors[ $name ] = $this->generate_container( $error ); |
|
388 | + $this->errors[$name] = $this->generate_container($error); |
|
389 | 389 | } |
390 | 390 | |
391 | - if ( ! ! $required || is_array( $required ) ) { |
|
391 | + if ( ! ! $required || is_array($required)) { |
|
392 | 392 | |
393 | - $alert = esc_html__( 'Some of the shortcode options are required.', 'give' ); |
|
393 | + $alert = esc_html__('Some of the shortcode options are required.', 'give'); |
|
394 | 394 | |
395 | - if ( isset( $required['alert'] ) ) { |
|
395 | + if (isset($required['alert'])) { |
|
396 | 396 | |
397 | 397 | $alert = $required['alert']; |
398 | 398 | |
399 | - } else if ( ! empty( $label ) ) { |
|
399 | + } else if ( ! empty($label)) { |
|
400 | 400 | |
401 | 401 | $alert = sprintf( |
402 | 402 | /* translators: %s: option label */ |
403 | - esc_html__( 'The "%s" option is required.', 'give' ), |
|
404 | - str_replace( ':', '', $label ) |
|
403 | + esc_html__('The "%s" option is required.', 'give'), |
|
404 | + str_replace(':', '', $label) |
|
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
408 | - $this->required[ $name ] = $alert; |
|
408 | + $this->required[$name] = $alert; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return true; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,31 +98,31 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades' |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades )] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $did_upgrade ) { |
|
120 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
119 | + if ($did_upgrade) { |
|
120 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
125 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
124 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
125 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Display Upgrade Notices. |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return void |
138 | 138 | */ |
139 | -function give_show_upgrade_notices( $give_updates ) { |
|
139 | +function give_show_upgrade_notices($give_updates) { |
|
140 | 140 | // v1.3.2 Upgrades |
141 | 141 | $give_updates->register( |
142 | 142 | array( |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | ); |
203 | 203 | |
204 | 204 | // v1.8.17 Upgrades for donations. |
205 | - $give_updates->register( array( |
|
205 | + $give_updates->register(array( |
|
206 | 206 | 'id' => 'v1817_update_donation_iranian_currency_code', |
207 | 207 | 'version' => '1.8.17', |
208 | 208 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
209 | - ) ); |
|
209 | + )); |
|
210 | 210 | |
211 | 211 | // v1.8.17 Upgrades for cleanup of user roles. |
212 | - $give_updates->register( array( |
|
212 | + $give_updates->register(array( |
|
213 | 213 | 'id' => 'v1817_cleanup_user_roles', |
214 | 214 | 'version' => '1.8.17', |
215 | 215 | 'callback' => 'give_v1817_cleanup_user_roles', |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | |
218 | 218 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
219 | - $give_updates->register( array( |
|
219 | + $give_updates->register(array( |
|
220 | 220 | 'id' => 'v1818_assign_custom_amount_set_donation', |
221 | 221 | 'version' => '1.8.18', |
222 | 222 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | |
225 | 225 | // v1.8.18 Cleanup the Give Worker Role Caps. |
226 | - $give_updates->register( array( |
|
226 | + $give_updates->register(array( |
|
227 | 227 | 'id' => 'v1818_give_worker_role_cleanup', |
228 | 228 | 'version' => '1.8.18', |
229 | 229 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
230 | - ) ); |
|
230 | + )); |
|
231 | 231 | |
232 | 232 | // v2.0.0 Upgrades |
233 | 233 | $give_updates->register( |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | 'id' => 'v20_move_metadata_into_new_table', |
282 | 282 | 'version' => '2.0.0', |
283 | 283 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
284 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
284 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
285 | 285 | ) |
286 | 286 | ); |
287 | 287 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | 'id' => 'v201_move_metadata_into_new_table', |
328 | 328 | 'version' => '2.0.1', |
329 | 329 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
330 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
330 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
331 | 331 | ) |
332 | 332 | ); |
333 | 333 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | ); |
343 | 343 | } |
344 | 344 | |
345 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
345 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Triggers all upgrade functions |
@@ -354,29 +354,29 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function give_trigger_upgrades() { |
356 | 356 | |
357 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
358 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
357 | + if ( ! current_user_can('manage_give_settings')) { |
|
358 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
359 | 359 | 'response' => 403, |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | - $give_version = get_option( 'give_version' ); |
|
363 | + $give_version = get_option('give_version'); |
|
364 | 364 | |
365 | - if ( ! $give_version ) { |
|
365 | + if ( ! $give_version) { |
|
366 | 366 | // 1.0 is the first version to use this option so we must add it. |
367 | 367 | $give_version = '1.0'; |
368 | - add_option( 'give_version', $give_version ); |
|
368 | + add_option('give_version', $give_version); |
|
369 | 369 | } |
370 | 370 | |
371 | - update_option( 'give_version', GIVE_VERSION ); |
|
372 | - delete_option( 'give_doing_upgrade' ); |
|
371 | + update_option('give_version', GIVE_VERSION); |
|
372 | + delete_option('give_doing_upgrade'); |
|
373 | 373 | |
374 | - if ( DOING_AJAX ) { |
|
375 | - die( 'complete' ); |
|
374 | + if (DOING_AJAX) { |
|
375 | + die('complete'); |
|
376 | 376 | } // End if(). |
377 | 377 | } |
378 | 378 | |
379 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
379 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
380 | 380 | |
381 | 381 | |
382 | 382 | /** |
@@ -392,20 +392,20 @@ discard block |
||
392 | 392 | /* @var Give_Updates $give_updates */ |
393 | 393 | $give_updates = Give_Updates::get_instance(); |
394 | 394 | |
395 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
396 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
395 | + if ( ! current_user_can('manage_give_settings')) { |
|
396 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
397 | 397 | 'response' => 403, |
398 | - ) ); |
|
398 | + )); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | give_ignore_user_abort(); |
402 | 402 | |
403 | 403 | // UPDATE DB METAKEYS. |
404 | 404 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
405 | - $query = $wpdb->query( $sql ); |
|
405 | + $query = $wpdb->query($sql); |
|
406 | 406 | |
407 | 407 | $give_updates->percentage = 100; |
408 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
408 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -429,24 +429,24 @@ discard block |
||
429 | 429 | $where .= "AND ( p.post_status = 'abandoned' )"; |
430 | 430 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
431 | 431 | |
432 | - $sql = $select . $join . $where; |
|
433 | - $found_payments = $wpdb->get_col( $sql ); |
|
432 | + $sql = $select.$join.$where; |
|
433 | + $found_payments = $wpdb->get_col($sql); |
|
434 | 434 | |
435 | - foreach ( $found_payments as $payment ) { |
|
435 | + foreach ($found_payments as $payment) { |
|
436 | 436 | |
437 | 437 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
438 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
438 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
439 | 439 | |
440 | 440 | // 1450124863 = 12/10/2015 20:42:25. |
441 | - if ( $modified_time >= 1450124863 ) { |
|
441 | + if ($modified_time >= 1450124863) { |
|
442 | 442 | |
443 | - give_update_payment_status( $payment, 'pending' ); |
|
443 | + give_update_payment_status($payment, 'pending'); |
|
444 | 444 | |
445 | 445 | } |
446 | 446 | } |
447 | 447 | |
448 | 448 | $give_updates->percentage = 100; |
449 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
449 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | |
@@ -459,17 +459,17 @@ discard block |
||
459 | 459 | */ |
460 | 460 | function give_v152_cleanup_users() { |
461 | 461 | |
462 | - $give_version = get_option( 'give_version' ); |
|
462 | + $give_version = get_option('give_version'); |
|
463 | 463 | |
464 | - if ( ! $give_version ) { |
|
464 | + if ( ! $give_version) { |
|
465 | 465 | // 1.0 is the first version to use this option so we must add it. |
466 | 466 | $give_version = '1.0'; |
467 | 467 | } |
468 | 468 | |
469 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
469 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
470 | 470 | |
471 | 471 | // v1.5.2 Upgrades |
472 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
472 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
473 | 473 | |
474 | 474 | // Delete all caps with "ss". |
475 | 475 | // Also delete all unused "campaign" roles. |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | ); |
517 | 517 | |
518 | 518 | global $wp_roles; |
519 | - foreach ( $delete_caps as $cap ) { |
|
520 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
521 | - $wp_roles->remove_cap( $role, $cap ); |
|
519 | + foreach ($delete_caps as $cap) { |
|
520 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
521 | + $wp_roles->remove_cap($role, $cap); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -528,15 +528,15 @@ discard block |
||
528 | 528 | $roles->add_caps(); |
529 | 529 | |
530 | 530 | // The Update Ran. |
531 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
532 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
533 | - delete_option( 'give_doing_upgrade' ); |
|
531 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
532 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
533 | + delete_option('give_doing_upgrade'); |
|
534 | 534 | |
535 | 535 | }// End if(). |
536 | 536 | |
537 | 537 | } |
538 | 538 | |
539 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
539 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
540 | 540 | |
541 | 541 | /** |
542 | 542 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -579,53 +579,53 @@ discard block |
||
579 | 579 | |
580 | 580 | // Get addons license key. |
581 | 581 | $addons = array(); |
582 | - foreach ( $give_options as $key => $value ) { |
|
583 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
584 | - $addons[ $key ] = $value; |
|
582 | + foreach ($give_options as $key => $value) { |
|
583 | + if (false !== strpos($key, '_license_key')) { |
|
584 | + $addons[$key] = $value; |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Bailout: We do not have any addon license data to upgrade. |
589 | - if ( empty( $addons ) ) { |
|
589 | + if (empty($addons)) { |
|
590 | 590 | return false; |
591 | 591 | } |
592 | 592 | |
593 | - foreach ( $addons as $key => $addon_license ) { |
|
593 | + foreach ($addons as $key => $addon_license) { |
|
594 | 594 | |
595 | 595 | // Get addon shortname. |
596 | - $shortname = str_replace( '_license_key', '', $key ); |
|
596 | + $shortname = str_replace('_license_key', '', $key); |
|
597 | 597 | |
598 | 598 | // Addon license option name. |
599 | - $addon_license_option_name = $shortname . '_license_active'; |
|
599 | + $addon_license_option_name = $shortname.'_license_active'; |
|
600 | 600 | |
601 | 601 | // bailout if license is empty. |
602 | - if ( empty( $addon_license ) ) { |
|
603 | - delete_option( $addon_license_option_name ); |
|
602 | + if (empty($addon_license)) { |
|
603 | + delete_option($addon_license_option_name); |
|
604 | 604 | continue; |
605 | 605 | } |
606 | 606 | |
607 | 607 | // Get addon name. |
608 | 608 | $addon_name = array(); |
609 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
610 | - foreach ( $addon_name_parts as $name_part ) { |
|
609 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
610 | + foreach ($addon_name_parts as $name_part) { |
|
611 | 611 | |
612 | 612 | // Fix addon name |
613 | - switch ( $name_part ) { |
|
613 | + switch ($name_part) { |
|
614 | 614 | case 'authorizenet' : |
615 | 615 | $name_part = 'authorize.net'; |
616 | 616 | break; |
617 | 617 | } |
618 | 618 | |
619 | - $addon_name[] = ucfirst( $name_part ); |
|
619 | + $addon_name[] = ucfirst($name_part); |
|
620 | 620 | } |
621 | 621 | |
622 | - $addon_name = implode( ' ', $addon_name ); |
|
622 | + $addon_name = implode(' ', $addon_name); |
|
623 | 623 | |
624 | 624 | // Data to send to the API. |
625 | 625 | $api_params = array( |
626 | 626 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
627 | 627 | 'license' => $addon_license, |
628 | - 'item_name' => urlencode( $addon_name ), |
|
628 | + 'item_name' => urlencode($addon_name), |
|
629 | 629 | 'url' => home_url(), |
630 | 630 | ); |
631 | 631 | |
@@ -640,17 +640,17 @@ discard block |
||
640 | 640 | ); |
641 | 641 | |
642 | 642 | // Make sure there are no errors. |
643 | - if ( is_wp_error( $response ) ) { |
|
644 | - delete_option( $addon_license_option_name ); |
|
643 | + if (is_wp_error($response)) { |
|
644 | + delete_option($addon_license_option_name); |
|
645 | 645 | continue; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // Tell WordPress to look for updates. |
649 | - set_site_transient( 'update_plugins', null ); |
|
649 | + set_site_transient('update_plugins', null); |
|
650 | 650 | |
651 | 651 | // Decode license data. |
652 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
653 | - update_option( $addon_license_option_name, $license_data ); |
|
652 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
653 | + update_option($addon_license_option_name, $license_data); |
|
654 | 654 | }// End foreach(). |
655 | 655 | } |
656 | 656 | |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | ); |
681 | 681 | |
682 | 682 | global $wp_roles; |
683 | - foreach ( $delete_caps as $cap ) { |
|
684 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
685 | - $wp_roles->remove_cap( $role, $cap ); |
|
683 | + foreach ($delete_caps as $cap) { |
|
684 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
685 | + $wp_roles->remove_cap($role, $cap); |
|
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | function give_v18_upgrades_core_setting() { |
717 | 717 | // Core settings which changes from checkbox to radio. |
718 | 718 | $core_setting_names = array_merge( |
719 | - array_keys( give_v18_renamed_core_settings() ), |
|
719 | + array_keys(give_v18_renamed_core_settings()), |
|
720 | 720 | array( |
721 | 721 | 'uninstall_on_delete', |
722 | 722 | 'scripts_footer', |
@@ -728,48 +728,48 @@ discard block |
||
728 | 728 | ); |
729 | 729 | |
730 | 730 | // Bailout: If not any setting define. |
731 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
731 | + if ($give_settings = get_option('give_settings')) { |
|
732 | 732 | |
733 | 733 | $setting_changed = false; |
734 | 734 | |
735 | 735 | // Loop: check each setting field. |
736 | - foreach ( $core_setting_names as $setting_name ) { |
|
736 | + foreach ($core_setting_names as $setting_name) { |
|
737 | 737 | // New setting name. |
738 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
738 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
739 | 739 | |
740 | 740 | // Continue: If setting already set. |
741 | 741 | if ( |
742 | - array_key_exists( $new_setting_name, $give_settings ) |
|
743 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
742 | + array_key_exists($new_setting_name, $give_settings) |
|
743 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
744 | 744 | ) { |
745 | 745 | continue; |
746 | 746 | } |
747 | 747 | |
748 | 748 | // Set checkbox value to radio value. |
749 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
749 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
750 | 750 | |
751 | 751 | // @see https://github.com/WordImpress/Give/issues/1063. |
752 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
752 | + if (false !== strpos($setting_name, 'disable_')) { |
|
753 | 753 | |
754 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
755 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
754 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
755 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
756 | 756 | |
757 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
757 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | // Tell bot to update core setting to db. |
761 | - if ( ! $setting_changed ) { |
|
761 | + if ( ! $setting_changed) { |
|
762 | 762 | $setting_changed = true; |
763 | 763 | } |
764 | 764 | } |
765 | 765 | |
766 | 766 | // Update setting only if they changed. |
767 | - if ( $setting_changed ) { |
|
768 | - update_option( 'give_settings', $give_settings ); |
|
767 | + if ($setting_changed) { |
|
768 | + update_option('give_settings', $give_settings); |
|
769 | 769 | } |
770 | 770 | }// End if(). |
771 | 771 | |
772 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
772 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | $give_updates = Give_Updates::get_instance(); |
784 | 784 | |
785 | 785 | // form query |
786 | - $forms = new WP_Query( array( |
|
786 | + $forms = new WP_Query(array( |
|
787 | 787 | 'paged' => $give_updates->step, |
788 | 788 | 'status' => 'any', |
789 | 789 | 'order' => 'ASC', |
@@ -792,41 +792,41 @@ discard block |
||
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | |
795 | - if ( $forms->have_posts() ) { |
|
796 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
795 | + if ($forms->have_posts()) { |
|
796 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
797 | 797 | |
798 | - while ( $forms->have_posts() ) { |
|
798 | + while ($forms->have_posts()) { |
|
799 | 799 | $forms->the_post(); |
800 | 800 | |
801 | 801 | // Form content. |
802 | 802 | // Note in version 1.8 display content setting split into display content and content placement setting. |
803 | 803 | // You can delete _give_content_option in future. |
804 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
805 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
806 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
807 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
804 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
805 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
806 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
807 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
808 | 808 | |
809 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
810 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
809 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
810 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | // "Disable" Guest Donation. Checkbox. |
814 | 814 | // See: https://github.com/WordImpress/Give/issues/1470. |
815 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
816 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
817 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
815 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
816 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
817 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
818 | 818 | |
819 | 819 | // Offline Donations. |
820 | 820 | // See: https://github.com/WordImpress/Give/issues/1579. |
821 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
822 | - if ( 'no' === $offline_donation ) { |
|
821 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
822 | + if ('no' === $offline_donation) { |
|
823 | 823 | $offline_donation_newval = 'global'; |
824 | - } elseif ( 'yes' === $offline_donation ) { |
|
824 | + } elseif ('yes' === $offline_donation) { |
|
825 | 825 | $offline_donation_newval = 'enabled'; |
826 | 826 | } else { |
827 | 827 | $offline_donation_newval = 'disabled'; |
828 | 828 | } |
829 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
829 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
830 | 830 | |
831 | 831 | // Convert yes/no setting field to enabled/disabled. |
832 | 832 | $form_radio_settings = array( |
@@ -846,15 +846,15 @@ discard block |
||
846 | 846 | '_give_offline_donation_enable_billing_fields_single', |
847 | 847 | ); |
848 | 848 | |
849 | - foreach ( $form_radio_settings as $meta_key ) { |
|
849 | + foreach ($form_radio_settings as $meta_key) { |
|
850 | 850 | // Get value. |
851 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
851 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
852 | 852 | |
853 | 853 | // Convert meta value only if it is in yes/no/none. |
854 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
854 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
855 | 855 | |
856 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
857 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
856 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
857 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | }// End while(). |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | |
864 | 864 | } else { |
865 | 865 | // No more forms found, finish up. |
866 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
866 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | '%_transient_give_stats_%', |
931 | 931 | 'give_cache%', |
932 | 932 | '%_transient_give_add_ons_feed%', |
933 | - '%_transient__give_ajax_works' . |
|
933 | + '%_transient__give_ajax_works'. |
|
934 | 934 | '%_transient_give_total_api_keys%', |
935 | 935 | '%_transient_give_i18n_give_promo_hide%', |
936 | 936 | '%_transient_give_contributors%', |
@@ -957,24 +957,24 @@ discard block |
||
957 | 957 | ARRAY_A |
958 | 958 | ); |
959 | 959 | |
960 | - if ( ! empty( $user_apikey_options ) ) { |
|
961 | - foreach ( $user_apikey_options as $user ) { |
|
962 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
963 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
964 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
960 | + if ( ! empty($user_apikey_options)) { |
|
961 | + foreach ($user_apikey_options as $user) { |
|
962 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
963 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
964 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
968 | - if ( ! empty( $cached_options ) ) { |
|
969 | - foreach ( $cached_options as $option ) { |
|
970 | - switch ( true ) { |
|
971 | - case ( false !== strpos( $option, 'transient' ) ): |
|
972 | - $option = str_replace( '_transient_', '', $option ); |
|
973 | - delete_transient( $option ); |
|
968 | + if ( ! empty($cached_options)) { |
|
969 | + foreach ($cached_options as $option) { |
|
970 | + switch (true) { |
|
971 | + case (false !== strpos($option, 'transient')): |
|
972 | + $option = str_replace('_transient_', '', $option); |
|
973 | + delete_transient($option); |
|
974 | 974 | break; |
975 | 975 | |
976 | 976 | default: |
977 | - delete_option( $option ); |
|
977 | + delete_option($option); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | } |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | global $wp_roles; |
993 | 993 | |
994 | 994 | // Get the role object. |
995 | - $give_worker = get_role( 'give_worker' ); |
|
995 | + $give_worker = get_role('give_worker'); |
|
996 | 996 | |
997 | 997 | // A list of capabilities to add for give workers. |
998 | 998 | $caps_to_add = array( |
@@ -1000,9 +1000,9 @@ discard block |
||
1000 | 1000 | 'edit_pages', |
1001 | 1001 | ); |
1002 | 1002 | |
1003 | - foreach ( $caps_to_add as $cap ) { |
|
1003 | + foreach ($caps_to_add as $cap) { |
|
1004 | 1004 | // Add the capability. |
1005 | - $give_worker->add_cap( $cap ); |
|
1005 | + $give_worker->add_cap($cap); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | } |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | $give_updates = Give_Updates::get_instance(); |
1020 | 1020 | |
1021 | 1021 | // form query. |
1022 | - $donation_forms = new WP_Query( array( |
|
1022 | + $donation_forms = new WP_Query(array( |
|
1023 | 1023 | 'paged' => $give_updates->step, |
1024 | 1024 | 'status' => 'any', |
1025 | 1025 | 'order' => 'ASC', |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | ) |
1029 | 1029 | ); |
1030 | 1030 | |
1031 | - if ( $donation_forms->have_posts() ) { |
|
1032 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1031 | + if ($donation_forms->have_posts()) { |
|
1032 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1033 | 1033 | |
1034 | - while ( $donation_forms->have_posts() ) { |
|
1034 | + while ($donation_forms->have_posts()) { |
|
1035 | 1035 | $donation_forms->the_post(); |
1036 | 1036 | $form_id = get_the_ID(); |
1037 | 1037 | |
@@ -1039,41 +1039,41 @@ discard block |
||
1039 | 1039 | update_post_meta( |
1040 | 1040 | $form_id, |
1041 | 1041 | '_give_set_price', |
1042 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1042 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1043 | 1043 | ); |
1044 | 1044 | |
1045 | 1045 | // Remove formatting from _give_custom_amount_minimum. |
1046 | 1046 | update_post_meta( |
1047 | 1047 | $form_id, |
1048 | 1048 | '_give_custom_amount_minimum', |
1049 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1049 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1050 | 1050 | ); |
1051 | 1051 | |
1052 | 1052 | // Bailout. |
1053 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1053 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1054 | 1054 | continue; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1057 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1058 | 1058 | |
1059 | - if ( ! empty( $donation_levels ) ) { |
|
1059 | + if ( ! empty($donation_levels)) { |
|
1060 | 1060 | |
1061 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1062 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1063 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1061 | + foreach ($donation_levels as $index => $donation_level) { |
|
1062 | + if (isset($donation_level['_give_amount'])) { |
|
1063 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | |
1067 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1067 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1068 | 1068 | |
1069 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1069 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1070 | 1070 | |
1071 | - $min_amount = min( $donation_levels_amounts ); |
|
1072 | - $max_amount = max( $donation_levels_amounts ); |
|
1071 | + $min_amount = min($donation_levels_amounts); |
|
1072 | + $max_amount = max($donation_levels_amounts); |
|
1073 | 1073 | |
1074 | 1074 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1075 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1076 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1075 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1076 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | wp_reset_postdata(); |
1083 | 1083 | } else { |
1084 | 1084 | // The Update Ran. |
1085 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1085 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | */ |
1133 | 1133 | function give_v20_upgrades() { |
1134 | 1134 | // Update cache setting. |
1135 | - give_update_option( 'cache', 'enabled' ); |
|
1135 | + give_update_option('cache', 'enabled'); |
|
1136 | 1136 | |
1137 | 1137 | // Upgrade email settings. |
1138 | 1138 | give_v20_upgrades_email_setting(); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $all_setting = give_get_settings(); |
1152 | 1152 | |
1153 | 1153 | // Bailout on fresh install. |
1154 | - if ( empty( $all_setting ) ) { |
|
1154 | + if (empty($all_setting)) { |
|
1155 | 1155 | return; |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1170,19 +1170,19 @@ discard block |
||
1170 | 1170 | 'admin_notices' => 'new-donation_notification', |
1171 | 1171 | ); |
1172 | 1172 | |
1173 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1173 | + foreach ($settings as $old_setting => $new_setting) { |
|
1174 | 1174 | // Do not update already modified |
1175 | - if ( ! is_array( $new_setting ) ) { |
|
1176 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1175 | + if ( ! is_array($new_setting)) { |
|
1176 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1177 | 1177 | continue; |
1178 | 1178 | } |
1179 | 1179 | } |
1180 | 1180 | |
1181 | - switch ( $old_setting ) { |
|
1181 | + switch ($old_setting) { |
|
1182 | 1182 | case 'admin_notices': |
1183 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1183 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1184 | 1184 | |
1185 | - give_update_option( $new_setting, $notification_status ); |
|
1185 | + give_update_option($new_setting, $notification_status); |
|
1186 | 1186 | |
1187 | 1187 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1188 | 1188 | // give_delete_option( $old_setting ); |
@@ -1193,19 +1193,19 @@ discard block |
||
1193 | 1193 | case 'admin_notice_emails': |
1194 | 1194 | $recipients = give_get_admin_notice_emails(); |
1195 | 1195 | |
1196 | - foreach ( $new_setting as $setting ) { |
|
1196 | + foreach ($new_setting as $setting) { |
|
1197 | 1197 | // bailout if setting already exist. |
1198 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1198 | + if (array_key_exists($setting, $all_setting)) { |
|
1199 | 1199 | continue; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - give_update_option( $setting, $recipients ); |
|
1202 | + give_update_option($setting, $recipients); |
|
1203 | 1203 | } |
1204 | 1204 | break; |
1205 | 1205 | |
1206 | 1206 | default: |
1207 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1208 | - give_delete_option( $old_setting ); |
|
1207 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1208 | + give_delete_option($old_setting); |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | } |
@@ -1222,22 +1222,22 @@ discard block |
||
1222 | 1222 | $give_settings = give_get_settings(); |
1223 | 1223 | $give_setting_updated = false; |
1224 | 1224 | |
1225 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1225 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1226 | 1226 | $give_settings['number_decimals'] = 0; |
1227 | 1227 | $give_settings['decimal_separator'] = ''; |
1228 | 1228 | $give_setting_updated = true; |
1229 | 1229 | |
1230 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1230 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1231 | 1231 | $give_settings['number_decimals'] = 0; |
1232 | 1232 | $give_setting_updated = true; |
1233 | 1233 | |
1234 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1234 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1235 | 1235 | $give_settings['number_decimals'] = 5; |
1236 | 1236 | $give_setting_updated = true; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - if ( $give_setting_updated ) { |
|
1240 | - update_option( 'give_settings', $give_settings ); |
|
1239 | + if ($give_setting_updated) { |
|
1240 | + update_option('give_settings', $give_settings); |
|
1241 | 1241 | } |
1242 | 1242 | } |
1243 | 1243 | |
@@ -1256,69 +1256,69 @@ discard block |
||
1256 | 1256 | $give_updates = Give_Updates::get_instance(); |
1257 | 1257 | |
1258 | 1258 | // form query. |
1259 | - $donation_forms = new WP_Query( array( |
|
1259 | + $donation_forms = new WP_Query(array( |
|
1260 | 1260 | 'paged' => $give_updates->step, |
1261 | 1261 | 'status' => 'any', |
1262 | 1262 | 'order' => 'ASC', |
1263 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1263 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1264 | 1264 | 'posts_per_page' => 20, |
1265 | 1265 | ) |
1266 | 1266 | ); |
1267 | - if ( $donation_forms->have_posts() ) { |
|
1268 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1267 | + if ($donation_forms->have_posts()) { |
|
1268 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1269 | 1269 | |
1270 | - while ( $donation_forms->have_posts() ) { |
|
1270 | + while ($donation_forms->have_posts()) { |
|
1271 | 1271 | $donation_forms->the_post(); |
1272 | 1272 | global $post; |
1273 | 1273 | |
1274 | - $meta = get_post_meta( $post->ID ); |
|
1274 | + $meta = get_post_meta($post->ID); |
|
1275 | 1275 | |
1276 | - switch ( $post->post_type ) { |
|
1276 | + switch ($post->post_type) { |
|
1277 | 1277 | case 'give_forms': |
1278 | 1278 | // _give_set_price. |
1279 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1280 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1279 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1280 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | // _give_custom_amount_minimum. |
1284 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1285 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1284 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1285 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | // _give_levels_minimum_amount. |
1289 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1290 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1289 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1290 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | // _give_levels_maximum_amount. |
1294 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1295 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1294 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1295 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | // _give_set_goal. |
1299 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1300 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1299 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1300 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | // _give_form_earnings. |
1304 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1305 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1304 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1305 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | // _give_custom_amount_minimum. |
1309 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1310 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1309 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1310 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1311 | 1311 | |
1312 | - foreach ( $donation_levels as $index => $level ) { |
|
1313 | - if ( empty( $level['_give_amount'] ) ) { |
|
1312 | + foreach ($donation_levels as $index => $level) { |
|
1313 | + if (empty($level['_give_amount'])) { |
|
1314 | 1314 | continue; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1317 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | $meta['_give_donation_levels'] = $donation_levels; |
1321 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1321 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | |
@@ -1326,8 +1326,8 @@ discard block |
||
1326 | 1326 | |
1327 | 1327 | case 'give_payment': |
1328 | 1328 | // _give_payment_total. |
1329 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1330 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1329 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1330 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | break; |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | wp_reset_postdata(); |
1339 | 1339 | } else { |
1340 | 1340 | // The Update Ran. |
1341 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1341 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1342 | 1342 | } |
1343 | 1343 | } |
1344 | 1344 | |
@@ -1358,22 +1358,22 @@ discard block |
||
1358 | 1358 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1359 | 1359 | |
1360 | 1360 | // form query. |
1361 | - $donors = Give()->donors->get_donors( array( |
|
1361 | + $donors = Give()->donors->get_donors(array( |
|
1362 | 1362 | 'number' => 20, |
1363 | 1363 | 'offset' => $offset, |
1364 | 1364 | ) |
1365 | 1365 | ); |
1366 | 1366 | |
1367 | - if ( ! empty( $donors ) ) { |
|
1368 | - $give_updates->set_percentage( Give()->donors->count(), $offset ); |
|
1367 | + if ( ! empty($donors)) { |
|
1368 | + $give_updates->set_percentage(Give()->donors->count(), $offset); |
|
1369 | 1369 | |
1370 | 1370 | /* @var Object $donor */ |
1371 | - foreach ( $donors as $donor ) { |
|
1372 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1371 | + foreach ($donors as $donor) { |
|
1372 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1373 | 1373 | } |
1374 | 1374 | } else { |
1375 | 1375 | // The Update Ran. |
1376 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1376 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
@@ -1388,25 +1388,25 @@ discard block |
||
1388 | 1388 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1389 | 1389 | |
1390 | 1390 | // Fetch all the existing donors. |
1391 | - $donors = Give()->donors->get_donors( array( |
|
1391 | + $donors = Give()->donors->get_donors(array( |
|
1392 | 1392 | 'number' => 20, |
1393 | 1393 | 'offset' => $offset, |
1394 | 1394 | ) |
1395 | 1395 | ); |
1396 | 1396 | |
1397 | - if ( ! empty( $donors ) ) { |
|
1398 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1397 | + if ( ! empty($donors)) { |
|
1398 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1399 | 1399 | |
1400 | 1400 | /* @var Object $donor */ |
1401 | - foreach ( $donors as $donor ) { |
|
1401 | + foreach ($donors as $donor) { |
|
1402 | 1402 | $user_id = $donor->user_id; |
1403 | 1403 | |
1404 | 1404 | // Proceed, if donor is attached with user. |
1405 | - if ( $user_id ) { |
|
1406 | - $user = get_userdata( $user_id ); |
|
1405 | + if ($user_id) { |
|
1406 | + $user = get_userdata($user_id); |
|
1407 | 1407 | |
1408 | 1408 | // Update user role, if user has subscriber role. |
1409 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1409 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1410 | 1410 | wp_update_user( |
1411 | 1411 | array( |
1412 | 1412 | 'ID' => $user_id, |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | } |
1419 | 1419 | } else { |
1420 | 1420 | // The Update Ran. |
1421 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1421 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1422 | 1422 | } |
1423 | 1423 | } |
1424 | 1424 | |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | */ |
1431 | 1431 | function give_v1813_upgrades() { |
1432 | 1432 | // Update admin setting. |
1433 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1433 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1434 | 1434 | |
1435 | 1435 | // Update Give roles. |
1436 | 1436 | $roles = new Give_Roles(); |
@@ -1448,33 +1448,33 @@ discard block |
||
1448 | 1448 | $give_updates = Give_Updates::get_instance(); |
1449 | 1449 | |
1450 | 1450 | // form query. |
1451 | - $payments = new WP_Query( array( |
|
1451 | + $payments = new WP_Query(array( |
|
1452 | 1452 | 'paged' => $give_updates->step, |
1453 | 1453 | 'status' => 'any', |
1454 | 1454 | 'order' => 'ASC', |
1455 | - 'post_type' => array( 'give_payment' ), |
|
1455 | + 'post_type' => array('give_payment'), |
|
1456 | 1456 | 'posts_per_page' => 100, |
1457 | 1457 | ) |
1458 | 1458 | ); |
1459 | 1459 | |
1460 | - if ( $payments->have_posts() ) { |
|
1461 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1460 | + if ($payments->have_posts()) { |
|
1461 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1462 | 1462 | |
1463 | - while ( $payments->have_posts() ) { |
|
1463 | + while ($payments->have_posts()) { |
|
1464 | 1464 | $payments->the_post(); |
1465 | 1465 | |
1466 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1466 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1467 | 1467 | |
1468 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1468 | + if ('RIAL' === $payment_meta['currency']) { |
|
1469 | 1469 | $payment_meta['currency'] = 'IRR'; |
1470 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1470 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | } else { |
1476 | 1476 | // The Update Ran. |
1477 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1477 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1478 | 1478 | } |
1479 | 1479 | } |
1480 | 1480 | |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | function give_v1817_upgrades() { |
1488 | 1488 | $give_settings = give_get_settings(); |
1489 | 1489 | |
1490 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1490 | + if ('RIAL' === $give_settings['currency']) { |
|
1491 | 1491 | $give_settings['currency'] = 'IRR'; |
1492 | - update_option( 'give_settings', $give_settings ); |
|
1492 | + update_option('give_settings', $give_settings); |
|
1493 | 1493 | } |
1494 | 1494 | } |
1495 | 1495 | |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | |
1503 | 1503 | global $wp_roles; |
1504 | 1504 | |
1505 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1505 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1506 | 1506 | return; |
1507 | 1507 | } |
1508 | 1508 | |
@@ -1526,15 +1526,15 @@ discard block |
||
1526 | 1526 | ), |
1527 | 1527 | ); |
1528 | 1528 | |
1529 | - foreach ( $add_caps as $role => $caps ) { |
|
1530 | - foreach ( $caps as $cap ) { |
|
1531 | - $wp_roles->add_cap( $role, $cap ); |
|
1529 | + foreach ($add_caps as $role => $caps) { |
|
1530 | + foreach ($caps as $cap) { |
|
1531 | + $wp_roles->add_cap($role, $cap); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | |
1535 | - foreach ( $remove_caps as $role => $caps ) { |
|
1536 | - foreach ( $caps as $cap ) { |
|
1537 | - $wp_roles->remove_cap( $role, $cap ); |
|
1535 | + foreach ($remove_caps as $role => $caps) { |
|
1536 | + foreach ($caps as $cap) { |
|
1537 | + $wp_roles->remove_cap($role, $cap); |
|
1538 | 1538 | } |
1539 | 1539 | } |
1540 | 1540 | |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | $roles->add_roles(); |
1559 | 1559 | $roles->add_caps(); |
1560 | 1560 | |
1561 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1561 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1562 | 1562 | } |
1563 | 1563 | |
1564 | 1564 | /** |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | function give_v1818_upgrades() { |
1570 | 1570 | |
1571 | 1571 | // Remove email_access_installed from give_settings. |
1572 | - give_delete_option( 'email_access_installed' ); |
|
1572 | + give_delete_option('email_access_installed'); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | /** |
@@ -1580,25 +1580,25 @@ discard block |
||
1580 | 1580 | function give_v1818_assign_custom_amount_set_donation() { |
1581 | 1581 | |
1582 | 1582 | /* @var Give_Updates $give_updates */ |
1583 | - $give_updates = Give_Updates::get_instance(); |
|
1583 | + $give_updates = Give_Updates::get_instance(); |
|
1584 | 1584 | |
1585 | - $donations = new WP_Query( array( |
|
1585 | + $donations = new WP_Query(array( |
|
1586 | 1586 | 'paged' => $give_updates->step, |
1587 | 1587 | 'status' => 'any', |
1588 | 1588 | 'order' => 'ASC', |
1589 | - 'post_type' => array( 'give_payment' ), |
|
1589 | + 'post_type' => array('give_payment'), |
|
1590 | 1590 | 'posts_per_page' => 100, |
1591 | 1591 | ) |
1592 | 1592 | ); |
1593 | 1593 | |
1594 | - if ( $donations->have_posts() ) { |
|
1595 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1594 | + if ($donations->have_posts()) { |
|
1595 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1596 | 1596 | |
1597 | - while ( $donations->have_posts() ) { |
|
1597 | + while ($donations->have_posts()) { |
|
1598 | 1598 | $donations->the_post(); |
1599 | 1599 | |
1600 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1601 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1600 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1601 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1602 | 1602 | |
1603 | 1603 | // Update Donation meta with price_id set as custom, only if it is: |
1604 | 1604 | // 1. Donation Type = Set Donation. |
@@ -1607,19 +1607,19 @@ discard block |
||
1607 | 1607 | if ( |
1608 | 1608 | $form->ID && |
1609 | 1609 | $form->is_set_type_donation_form() && |
1610 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1611 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1610 | + ('custom' !== $donation_meta['price_id']) && |
|
1611 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1612 | 1612 | ) { |
1613 | 1613 | $donation_meta['price_id'] = 'custom'; |
1614 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1615 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1614 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1615 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1616 | 1616 | } |
1617 | 1617 | } |
1618 | 1618 | |
1619 | 1619 | wp_reset_postdata(); |
1620 | 1620 | } else { |
1621 | 1621 | // Update Ran Successfully. |
1622 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1622 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1623 | 1623 | } |
1624 | 1624 | } |
1625 | 1625 | |
@@ -1630,14 +1630,14 @@ discard block |
||
1630 | 1630 | * |
1631 | 1631 | * @since 1.8.18 |
1632 | 1632 | */ |
1633 | -function give_v1818_give_worker_role_cleanup(){ |
|
1633 | +function give_v1818_give_worker_role_cleanup() { |
|
1634 | 1634 | |
1635 | 1635 | /* @var Give_Updates $give_updates */ |
1636 | 1636 | $give_updates = Give_Updates::get_instance(); |
1637 | 1637 | |
1638 | 1638 | global $wp_roles; |
1639 | 1639 | |
1640 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1640 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1641 | 1641 | return; |
1642 | 1642 | } |
1643 | 1643 | |
@@ -1655,9 +1655,9 @@ discard block |
||
1655 | 1655 | ), |
1656 | 1656 | ); |
1657 | 1657 | |
1658 | - foreach ( $remove_caps as $role => $caps ) { |
|
1659 | - foreach( $caps as $cap ) { |
|
1660 | - $wp_roles->remove_cap( $role, $cap ); |
|
1658 | + foreach ($remove_caps as $role => $caps) { |
|
1659 | + foreach ($caps as $cap) { |
|
1660 | + $wp_roles->remove_cap($role, $cap); |
|
1661 | 1661 | } |
1662 | 1662 | } |
1663 | 1663 | |
@@ -1668,7 +1668,7 @@ discard block |
||
1668 | 1668 | $roles->add_roles(); |
1669 | 1669 | $roles->add_caps(); |
1670 | 1670 | |
1671 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1671 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | /** |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | $give_updates = Give_Updates::get_instance(); |
1683 | 1683 | |
1684 | 1684 | // form query |
1685 | - $forms = new WP_Query( array( |
|
1685 | + $forms = new WP_Query(array( |
|
1686 | 1686 | 'paged' => $give_updates->step, |
1687 | 1687 | 'status' => 'any', |
1688 | 1688 | 'order' => 'ASC', |
@@ -1691,22 +1691,22 @@ discard block |
||
1691 | 1691 | ) |
1692 | 1692 | ); |
1693 | 1693 | |
1694 | - if ( $forms->have_posts() ) { |
|
1695 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1694 | + if ($forms->have_posts()) { |
|
1695 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1696 | 1696 | |
1697 | - while ( $forms->have_posts() ) { |
|
1697 | + while ($forms->have_posts()) { |
|
1698 | 1698 | $forms->the_post(); |
1699 | 1699 | global $post; |
1700 | 1700 | |
1701 | 1701 | // Update offline instruction email notification status. |
1702 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1703 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1702 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1703 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1704 | 1704 | 'enabled', |
1705 | 1705 | 'global', |
1706 | - ) ) |
|
1706 | + )) |
|
1707 | 1707 | ? $offline_instruction_notification_status |
1708 | 1708 | : 'global'; |
1709 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1709 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1710 | 1710 | |
1711 | 1711 | // Update offline instruction email message. |
1712 | 1712 | update_post_meta( |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | wp_reset_postdata(); |
1739 | 1739 | } else { |
1740 | 1740 | // No more forms found, finish up. |
1741 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1741 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1742 | 1742 | } |
1743 | 1743 | } |
1744 | 1744 | |
@@ -1755,7 +1755,7 @@ discard block |
||
1755 | 1755 | $give_updates = Give_Updates::get_instance(); |
1756 | 1756 | |
1757 | 1757 | // form query |
1758 | - $forms = new WP_Query( array( |
|
1758 | + $forms = new WP_Query(array( |
|
1759 | 1759 | 'paged' => $give_updates->step, |
1760 | 1760 | 'status' => 'any', |
1761 | 1761 | 'order' => 'ASC', |
@@ -1764,19 +1764,19 @@ discard block |
||
1764 | 1764 | ) |
1765 | 1765 | ); |
1766 | 1766 | |
1767 | - if ( $forms->have_posts() ) { |
|
1768 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1767 | + if ($forms->have_posts()) { |
|
1768 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1769 | 1769 | |
1770 | - while ( $forms->have_posts() ) { |
|
1770 | + while ($forms->have_posts()) { |
|
1771 | 1771 | $forms->the_post(); |
1772 | 1772 | global $post; |
1773 | 1773 | |
1774 | 1774 | // Split _give_payment_meta meta. |
1775 | 1775 | // @todo Remove _give_payment_meta after releases 2.0 |
1776 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1776 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1777 | 1777 | |
1778 | - if ( ! empty( $payment_meta ) ) { |
|
1779 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1778 | + if ( ! empty($payment_meta)) { |
|
1779 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1780 | 1780 | } |
1781 | 1781 | |
1782 | 1782 | $deprecated_meta_keys = array( |
@@ -1785,9 +1785,9 @@ discard block |
||
1785 | 1785 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1786 | 1786 | ); |
1787 | 1787 | |
1788 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1788 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1789 | 1789 | // Do not add new meta key if already exist. |
1790 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1790 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1791 | 1791 | continue; |
1792 | 1792 | } |
1793 | 1793 | |
@@ -1796,25 +1796,25 @@ discard block |
||
1796 | 1796 | array( |
1797 | 1797 | 'post_id' => $post->ID, |
1798 | 1798 | 'meta_key' => $new_meta_key, |
1799 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
1799 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
1800 | 1800 | ) |
1801 | 1801 | ); |
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | // Bailout |
1805 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1805 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1806 | 1806 | /* @var Give_Donor $donor */ |
1807 | - $donor = new Give_Donor( $donor_id ); |
|
1807 | + $donor = new Give_Donor($donor_id); |
|
1808 | 1808 | |
1809 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1810 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1811 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1812 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1813 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1814 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1809 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1810 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1811 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1812 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1813 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1814 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1815 | 1815 | |
1816 | 1816 | // Save address. |
1817 | - $donor->add_address( 'billing[]', $address ); |
|
1817 | + $donor->add_address('billing[]', $address); |
|
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | }// End while(). |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1826 | 1826 | |
1827 | 1827 | // No more forms found, finish up. |
1828 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1828 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1829 | 1829 | } |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1841,7 +1841,7 @@ discard block |
||
1841 | 1841 | $give_updates = Give_Updates::get_instance(); |
1842 | 1842 | |
1843 | 1843 | // form query |
1844 | - $forms = new WP_Query( array( |
|
1844 | + $forms = new WP_Query(array( |
|
1845 | 1845 | 'paged' => $give_updates->step, |
1846 | 1846 | 'order' => 'DESC', |
1847 | 1847 | 'post_type' => 'give_log', |
@@ -1850,20 +1850,20 @@ discard block |
||
1850 | 1850 | ) |
1851 | 1851 | ); |
1852 | 1852 | |
1853 | - if ( $forms->have_posts() ) { |
|
1854 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1853 | + if ($forms->have_posts()) { |
|
1854 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1855 | 1855 | |
1856 | - while ( $forms->have_posts() ) { |
|
1856 | + while ($forms->have_posts()) { |
|
1857 | 1857 | $forms->the_post(); |
1858 | 1858 | global $post; |
1859 | 1859 | |
1860 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1860 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1861 | 1861 | continue; |
1862 | 1862 | } |
1863 | 1863 | |
1864 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1865 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1866 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1864 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1865 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1866 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1867 | 1867 | |
1868 | 1868 | $log_data = array( |
1869 | 1869 | 'ID' => $post->ID, |
@@ -1876,29 +1876,29 @@ discard block |
||
1876 | 1876 | ); |
1877 | 1877 | $log_meta = array(); |
1878 | 1878 | |
1879 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1880 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1881 | - switch ( $meta_key ) { |
|
1879 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1880 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1881 | + switch ($meta_key) { |
|
1882 | 1882 | case '_give_log_payment_id': |
1883 | - $log_data['log_parent'] = current( $meta_value ); |
|
1883 | + $log_data['log_parent'] = current($meta_value); |
|
1884 | 1884 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1885 | 1885 | break; |
1886 | 1886 | |
1887 | 1887 | default: |
1888 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1888 | + $log_meta[$meta_key] = current($meta_value); |
|
1889 | 1889 | } |
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - if ( 'api_request' === $term_name ) { |
|
1893 | + if ('api_request' === $term_name) { |
|
1894 | 1894 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1895 | 1895 | } |
1896 | 1896 | |
1897 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1897 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1898 | 1898 | |
1899 | - if ( ! empty( $log_meta ) ) { |
|
1900 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1901 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1899 | + if ( ! empty($log_meta)) { |
|
1900 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1901 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | Give()->logs->delete_cache(); |
1941 | 1941 | |
1942 | 1942 | // No more forms found, finish up. |
1943 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1943 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1944 | 1944 | } |
1945 | 1945 | } |
1946 | 1946 | |
@@ -1956,19 +1956,19 @@ discard block |
||
1956 | 1956 | $give_updates = Give_Updates::get_instance(); |
1957 | 1957 | |
1958 | 1958 | // form query |
1959 | - $payments = new WP_Query( array( |
|
1959 | + $payments = new WP_Query(array( |
|
1960 | 1960 | 'paged' => $give_updates->step, |
1961 | 1961 | 'status' => 'any', |
1962 | 1962 | 'order' => 'ASC', |
1963 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1963 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1964 | 1964 | 'posts_per_page' => 100, |
1965 | 1965 | ) |
1966 | 1966 | ); |
1967 | 1967 | |
1968 | - if ( $payments->have_posts() ) { |
|
1969 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1968 | + if ($payments->have_posts()) { |
|
1969 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1970 | 1970 | |
1971 | - while ( $payments->have_posts() ) { |
|
1971 | + while ($payments->have_posts()) { |
|
1972 | 1972 | $payments->the_post(); |
1973 | 1973 | global $post; |
1974 | 1974 | |
@@ -1980,19 +1980,19 @@ discard block |
||
1980 | 1980 | ARRAY_A |
1981 | 1981 | ); |
1982 | 1982 | |
1983 | - if ( ! empty( $meta_data ) ) { |
|
1984 | - foreach ( $meta_data as $index => $data ) { |
|
1983 | + if ( ! empty($meta_data)) { |
|
1984 | + foreach ($meta_data as $index => $data) { |
|
1985 | 1985 | // Check for duplicate meta values. |
1986 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
1986 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
1987 | 1987 | continue; |
1988 | 1988 | } |
1989 | 1989 | |
1990 | - switch ( $post->post_type ) { |
|
1990 | + switch ($post->post_type) { |
|
1991 | 1991 | case 'give_forms': |
1992 | 1992 | $data['form_id'] = $data['post_id']; |
1993 | - unset( $data['post_id'] ); |
|
1993 | + unset($data['post_id']); |
|
1994 | 1994 | |
1995 | - Give()->form_meta->insert( $data ); |
|
1995 | + Give()->form_meta->insert($data); |
|
1996 | 1996 | // @todo: delete form meta from post meta table after releases 2.0. |
1997 | 1997 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
1998 | 1998 | |
@@ -2000,9 +2000,9 @@ discard block |
||
2000 | 2000 | |
2001 | 2001 | case 'give_payment': |
2002 | 2002 | $data['payment_id'] = $data['post_id']; |
2003 | - unset( $data['post_id'] ); |
|
2003 | + unset($data['post_id']); |
|
2004 | 2004 | |
2005 | - Give()->payment_meta->insert( $data ); |
|
2005 | + Give()->payment_meta->insert($data); |
|
2006 | 2006 | |
2007 | 2007 | // @todo: delete donation meta from post meta table after releases 2.0. |
2008 | 2008 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | wp_reset_postdata(); |
2018 | 2018 | } else { |
2019 | 2019 | // No more forms found, finish up. |
2020 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2020 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | } |
@@ -2033,44 +2033,44 @@ discard block |
||
2033 | 2033 | /* @var Give_Updates $give_updates */ |
2034 | 2034 | $give_updates = Give_Updates::get_instance(); |
2035 | 2035 | |
2036 | - $donors = Give()->donors->get_donors( array( |
|
2036 | + $donors = Give()->donors->get_donors(array( |
|
2037 | 2037 | 'paged' => $give_updates->step, |
2038 | 2038 | 'number' => 100, |
2039 | - ) ); |
|
2039 | + )); |
|
2040 | 2040 | |
2041 | - if ( $donors ) { |
|
2042 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2041 | + if ($donors) { |
|
2042 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2043 | 2043 | // Loop through Donors |
2044 | - foreach ( $donors as $donor ) { |
|
2044 | + foreach ($donors as $donor) { |
|
2045 | 2045 | |
2046 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2047 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2048 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2046 | + $donor_name = explode(' ', $donor->name, 2); |
|
2047 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2048 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2049 | 2049 | |
2050 | 2050 | // If first name meta of donor is not created, then create it. |
2051 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2052 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2051 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2052 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2053 | 2053 | } |
2054 | 2054 | |
2055 | 2055 | // If last name meta of donor is not created, then create it. |
2056 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2057 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2056 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2057 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2058 | 2058 | } |
2059 | 2059 | |
2060 | 2060 | // If Donor is connected with WP User then update user meta. |
2061 | - if ( $donor->user_id ) { |
|
2062 | - if ( isset( $donor_name[0] ) ) { |
|
2063 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2061 | + if ($donor->user_id) { |
|
2062 | + if (isset($donor_name[0])) { |
|
2063 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2064 | 2064 | } |
2065 | - if ( isset( $donor_name[1] ) ) { |
|
2066 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2065 | + if (isset($donor_name[1])) { |
|
2066 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2067 | 2067 | } |
2068 | 2068 | } |
2069 | 2069 | } |
2070 | 2070 | |
2071 | 2071 | } else { |
2072 | 2072 | // The Update Ran. |
2073 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2073 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2074 | 2074 | } |
2075 | 2075 | |
2076 | 2076 | } |
@@ -2099,15 +2099,15 @@ discard block |
||
2099 | 2099 | |
2100 | 2100 | $users = $user_query->get_results(); |
2101 | 2101 | |
2102 | - if ( $users ) { |
|
2103 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2102 | + if ($users) { |
|
2103 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2104 | 2104 | |
2105 | 2105 | // Loop through Donors |
2106 | - foreach ( $users as $user ) { |
|
2106 | + foreach ($users as $user) { |
|
2107 | 2107 | /* @var Give_Donor $donor */ |
2108 | - $donor = new Give_Donor( $user->ID, true ); |
|
2108 | + $donor = new Give_Donor($user->ID, true); |
|
2109 | 2109 | |
2110 | - if ( ! $donor->id ) { |
|
2110 | + if ( ! $donor->id) { |
|
2111 | 2111 | continue; |
2112 | 2112 | } |
2113 | 2113 | |
@@ -2123,10 +2123,10 @@ discard block |
||
2123 | 2123 | ) |
2124 | 2124 | ); |
2125 | 2125 | |
2126 | - if ( ! empty( $address ) ) { |
|
2127 | - $address = maybe_unserialize( $address ); |
|
2128 | - $donor->add_address( 'personal', $address ); |
|
2129 | - $donor->add_address( 'billing[]', $address ); |
|
2126 | + if ( ! empty($address)) { |
|
2127 | + $address = maybe_unserialize($address); |
|
2128 | + $donor->add_address('personal', $address); |
|
2129 | + $donor->add_address('billing[]', $address); |
|
2130 | 2130 | |
2131 | 2131 | |
2132 | 2132 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2136,7 +2136,7 @@ discard block |
||
2136 | 2136 | |
2137 | 2137 | } else { |
2138 | 2138 | // The Update Ran. |
2139 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2139 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2140 | 2140 | } |
2141 | 2141 | |
2142 | 2142 | } |
@@ -2160,15 +2160,15 @@ discard block |
||
2160 | 2160 | ); |
2161 | 2161 | |
2162 | 2162 | // Alter customer table |
2163 | - foreach ( $tables as $old_table => $new_table ) { |
|
2163 | + foreach ($tables as $old_table => $new_table) { |
|
2164 | 2164 | if ( |
2165 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2166 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2165 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2166 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2167 | 2167 | ) { |
2168 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2168 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2169 | 2169 | |
2170 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2171 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2170 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2171 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2172 | 2172 | } |
2173 | 2173 | } |
2174 | 2174 | } |
@@ -2176,7 +2176,7 @@ discard block |
||
2176 | 2176 | $give_updates->percentage = 100; |
2177 | 2177 | |
2178 | 2178 | // No more forms found, finish up. |
2179 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2179 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2180 | 2180 | |
2181 | 2181 | // Re initiate donor classes. |
2182 | 2182 | Give()->donors = new Give_DB_Donors(); |
@@ -2191,22 +2191,22 @@ discard block |
||
2191 | 2191 | * @global wpdb $wpdb |
2192 | 2192 | * @return void |
2193 | 2193 | */ |
2194 | -function give_v201_create_tables(){ |
|
2194 | +function give_v201_create_tables() { |
|
2195 | 2195 | global $wpdb; |
2196 | 2196 | |
2197 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2197 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2198 | 2198 | Give()->payment_meta->create_table(); |
2199 | 2199 | } |
2200 | 2200 | |
2201 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2201 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2202 | 2202 | Give()->form_meta->create_table(); |
2203 | 2203 | } |
2204 | 2204 | |
2205 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2205 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2206 | 2206 | Give()->logs->log_db->create_table(); |
2207 | 2207 | } |
2208 | 2208 | |
2209 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2209 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2210 | 2210 | Give()->logs->logmeta_db->create_table(); |
2211 | 2211 | } |
2212 | 2212 | } |
@@ -2231,31 +2231,31 @@ discard block |
||
2231 | 2231 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2232 | 2232 | ) |
2233 | 2233 | AND $wpdb->posts.post_type = 'give_payment' |
2234 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2234 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2235 | 2235 | ORDER BY $wpdb->posts.post_date ASC |
2236 | 2236 | LIMIT 100 |
2237 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2237 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2238 | 2238 | ); |
2239 | 2239 | |
2240 | - if ( ! empty( $payments ) ) { |
|
2241 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2240 | + if ( ! empty($payments)) { |
|
2241 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2242 | 2242 | |
2243 | - foreach ( $payments as $payment_id ) { |
|
2244 | - $post = get_post( $payment_id ); |
|
2245 | - setup_postdata( $post ); |
|
2243 | + foreach ($payments as $payment_id) { |
|
2244 | + $post = get_post($payment_id); |
|
2245 | + setup_postdata($post); |
|
2246 | 2246 | |
2247 | 2247 | // Do not add new meta keys if already refactored. |
2248 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2248 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2249 | 2249 | continue; |
2250 | 2250 | } |
2251 | 2251 | |
2252 | 2252 | |
2253 | 2253 | // Split _give_payment_meta meta. |
2254 | 2254 | // @todo Remove _give_payment_meta after releases 2.0 |
2255 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2255 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2256 | 2256 | |
2257 | - if ( ! empty( $payment_meta ) ) { |
|
2258 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2257 | + if ( ! empty($payment_meta)) { |
|
2258 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2259 | 2259 | } |
2260 | 2260 | |
2261 | 2261 | $deprecated_meta_keys = array( |
@@ -2264,9 +2264,9 @@ discard block |
||
2264 | 2264 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2265 | 2265 | ); |
2266 | 2266 | |
2267 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2267 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2268 | 2268 | // Do not add new meta key if already exist. |
2269 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2269 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2270 | 2270 | continue; |
2271 | 2271 | } |
2272 | 2272 | |
@@ -2275,25 +2275,25 @@ discard block |
||
2275 | 2275 | array( |
2276 | 2276 | 'post_id' => $post->ID, |
2277 | 2277 | 'meta_key' => $new_meta_key, |
2278 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ) |
|
2278 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true) |
|
2279 | 2279 | ) |
2280 | 2280 | ); |
2281 | 2281 | } |
2282 | 2282 | |
2283 | 2283 | // Bailout |
2284 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2284 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2285 | 2285 | /* @var Give_Donor $donor */ |
2286 | - $donor = new Give_Donor( $donor_id ); |
|
2286 | + $donor = new Give_Donor($donor_id); |
|
2287 | 2287 | |
2288 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2289 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2290 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2291 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2292 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2293 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2288 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2289 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2290 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2291 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2292 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2293 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2294 | 2294 | |
2295 | 2295 | // Save address. |
2296 | - $donor->add_address( 'billing[]', $address ); |
|
2296 | + $donor->add_address('billing[]', $address); |
|
2297 | 2297 | } |
2298 | 2298 | |
2299 | 2299 | }// End while(). |
@@ -2304,7 +2304,7 @@ discard block |
||
2304 | 2304 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2305 | 2305 | |
2306 | 2306 | // No more forms found, finish up. |
2307 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2307 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2308 | 2308 | } |
2309 | 2309 | } |
2310 | 2310 | |
@@ -2324,18 +2324,18 @@ discard block |
||
2324 | 2324 | SELECT ID FROM $wpdb->posts |
2325 | 2325 | WHERE 1=1 |
2326 | 2326 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2327 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2327 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2328 | 2328 | ORDER BY $wpdb->posts.post_date ASC |
2329 | 2329 | LIMIT 100 |
2330 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2330 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2331 | 2331 | ); |
2332 | 2332 | |
2333 | - if ( ! empty( $payments ) ) { |
|
2334 | - $give_updates->set_percentage( give_get_total_post_type_count( array( 'give_forms', 'give_payment' ) ), $give_updates->step * 100 ); |
|
2333 | + if ( ! empty($payments)) { |
|
2334 | + $give_updates->set_percentage(give_get_total_post_type_count(array('give_forms', 'give_payment')), $give_updates->step * 100); |
|
2335 | 2335 | |
2336 | - foreach ( $payments as $payment_id ) { |
|
2337 | - $post = get_post( $payment_id ); |
|
2338 | - setup_postdata( $post ); |
|
2336 | + foreach ($payments as $payment_id) { |
|
2337 | + $post = get_post($payment_id); |
|
2338 | + setup_postdata($post); |
|
2339 | 2339 | |
2340 | 2340 | $meta_data = $wpdb->get_results( |
2341 | 2341 | $wpdb->prepare( |
@@ -2345,19 +2345,19 @@ discard block |
||
2345 | 2345 | ARRAY_A |
2346 | 2346 | ); |
2347 | 2347 | |
2348 | - if ( ! empty( $meta_data ) ) { |
|
2349 | - foreach ( $meta_data as $index => $data ) { |
|
2348 | + if ( ! empty($meta_data)) { |
|
2349 | + foreach ($meta_data as $index => $data) { |
|
2350 | 2350 | // Check for duplicate meta values. |
2351 | - if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2351 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2352 | 2352 | continue; |
2353 | 2353 | } |
2354 | 2354 | |
2355 | - switch ( $post->post_type ) { |
|
2355 | + switch ($post->post_type) { |
|
2356 | 2356 | case 'give_forms': |
2357 | 2357 | $data['form_id'] = $data['post_id']; |
2358 | - unset( $data['post_id'] ); |
|
2358 | + unset($data['post_id']); |
|
2359 | 2359 | |
2360 | - Give()->form_meta->insert( $data ); |
|
2360 | + Give()->form_meta->insert($data); |
|
2361 | 2361 | // @todo: delete form meta from post meta table after releases 2.0. |
2362 | 2362 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2363 | 2363 | |
@@ -2365,9 +2365,9 @@ discard block |
||
2365 | 2365 | |
2366 | 2366 | case 'give_payment': |
2367 | 2367 | $data['payment_id'] = $data['post_id']; |
2368 | - unset( $data['post_id'] ); |
|
2368 | + unset($data['post_id']); |
|
2369 | 2369 | |
2370 | - Give()->payment_meta->insert( $data ); |
|
2370 | + Give()->payment_meta->insert($data); |
|
2371 | 2371 | |
2372 | 2372 | // @todo: delete donation meta from post meta table after releases 2.0. |
2373 | 2373 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2382,7 +2382,7 @@ discard block |
||
2382 | 2382 | wp_reset_postdata(); |
2383 | 2383 | } else { |
2384 | 2384 | // No more forms found, finish up. |
2385 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2385 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2386 | 2386 | } |
2387 | 2387 | |
2388 | 2388 | } |
@@ -2403,26 +2403,26 @@ discard block |
||
2403 | 2403 | SELECT ID FROM $wpdb->posts |
2404 | 2404 | WHERE 1=1 |
2405 | 2405 | AND $wpdb->posts.post_type = 'give_log' |
2406 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2406 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2407 | 2407 | ORDER BY $wpdb->posts.post_date ASC |
2408 | 2408 | LIMIT 100 |
2409 | - OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) ) |
|
2409 | + OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100)) |
|
2410 | 2410 | ); |
2411 | 2411 | |
2412 | - if ( ! empty( $logs ) ) { |
|
2413 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2412 | + if ( ! empty($logs)) { |
|
2413 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2414 | 2414 | |
2415 | - foreach ( $logs as $log_id ) { |
|
2416 | - $post = get_post( $log_id ); |
|
2417 | - setup_postdata( $post ); |
|
2415 | + foreach ($logs as $log_id) { |
|
2416 | + $post = get_post($log_id); |
|
2417 | + setup_postdata($post); |
|
2418 | 2418 | |
2419 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2419 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2420 | 2420 | continue; |
2421 | 2421 | } |
2422 | 2422 | |
2423 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2424 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2425 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2423 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2424 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2425 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2426 | 2426 | |
2427 | 2427 | $log_data = array( |
2428 | 2428 | 'ID' => $post->ID, |
@@ -2435,29 +2435,29 @@ discard block |
||
2435 | 2435 | ); |
2436 | 2436 | $log_meta = array(); |
2437 | 2437 | |
2438 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2439 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2440 | - switch ( $meta_key ) { |
|
2438 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2439 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2440 | + switch ($meta_key) { |
|
2441 | 2441 | case '_give_log_payment_id': |
2442 | - $log_data['log_parent'] = current( $meta_value ); |
|
2442 | + $log_data['log_parent'] = current($meta_value); |
|
2443 | 2443 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2444 | 2444 | break; |
2445 | 2445 | |
2446 | 2446 | default: |
2447 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2447 | + $log_meta[$meta_key] = current($meta_value); |
|
2448 | 2448 | } |
2449 | 2449 | } |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - if ( 'api_request' === $term_name ) { |
|
2452 | + if ('api_request' === $term_name) { |
|
2453 | 2453 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2454 | 2454 | } |
2455 | 2455 | |
2456 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2456 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2457 | 2457 | |
2458 | - if ( ! empty( $log_meta ) ) { |
|
2459 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2460 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2458 | + if ( ! empty($log_meta)) { |
|
2459 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2460 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2461 | 2461 | } |
2462 | 2462 | } |
2463 | 2463 | |
@@ -2470,7 +2470,7 @@ discard block |
||
2470 | 2470 | Give()->logs->delete_cache(); |
2471 | 2471 | |
2472 | 2472 | // No more forms found, finish up. |
2473 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2473 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2474 | 2474 | } |
2475 | 2475 | } |
2476 | 2476 | |
@@ -2481,55 +2481,55 @@ discard block |
||
2481 | 2481 | * @since 2.0.1 |
2482 | 2482 | * @return void |
2483 | 2483 | */ |
2484 | -function give_v201_add_missing_donors_callback(){ |
|
2484 | +function give_v201_add_missing_donors_callback() { |
|
2485 | 2485 | global $wpdb; |
2486 | 2486 | give_v201_create_tables(); |
2487 | 2487 | |
2488 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2489 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2490 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2488 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2489 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2490 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2491 | 2491 | $donor_data = array(); |
2492 | 2492 | |
2493 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2494 | - foreach ( $missing_donors as $donor_id ) { |
|
2493 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2494 | + foreach ($missing_donors as $donor_id) { |
|
2495 | 2495 | $donor_data[] = array( |
2496 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2497 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2496 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2497 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2498 | 2498 | |
2499 | 2499 | ); |
2500 | 2500 | } |
2501 | 2501 | } |
2502 | 2502 | |
2503 | - if( ! empty( $donor_data ) ) { |
|
2503 | + if ( ! empty($donor_data)) { |
|
2504 | 2504 | $donor_table_name = Give()->donors->table_name; |
2505 | 2505 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2506 | 2506 | |
2507 | 2507 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2508 | 2508 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2509 | 2509 | |
2510 | - foreach ( $donor_data as $donor ) { |
|
2510 | + foreach ($donor_data as $donor) { |
|
2511 | 2511 | $donor['info'][0] = (array) $donor['info'][0]; |
2512 | 2512 | |
2513 | 2513 | // Prevent duplicate meta id issue. |
2514 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ){ |
|
2514 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2515 | 2515 | continue; |
2516 | 2516 | } |
2517 | 2517 | |
2518 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2518 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2519 | 2519 | |
2520 | - if( ! empty( $donor['meta'] ) ) { |
|
2521 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2520 | + if ( ! empty($donor['meta'])) { |
|
2521 | + foreach ($donor['meta'] as $donor_meta) { |
|
2522 | 2522 | $donor_meta = (array) $donor_meta; |
2523 | 2523 | |
2524 | 2524 | // Prevent duplicate meta id issue. |
2525 | - if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ){ |
|
2526 | - unset( $donor_meta['meta_id'] ); |
|
2525 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2526 | + unset($donor_meta['meta_id']); |
|
2527 | 2527 | } |
2528 | 2528 | |
2529 | 2529 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2530 | - unset( $donor_meta['customer_id'] ); |
|
2530 | + unset($donor_meta['customer_id']); |
|
2531 | 2531 | |
2532 | - Give()->donor_meta->insert( $donor_meta ); |
|
2532 | + Give()->donor_meta->insert($donor_meta); |
|
2533 | 2533 | } |
2534 | 2534 | } |
2535 | 2535 | |
@@ -2548,35 +2548,35 @@ discard block |
||
2548 | 2548 | ) |
2549 | 2549 | ); |
2550 | 2550 | |
2551 | - $donor = new Give_Donor( $donor_id ); |
|
2551 | + $donor = new Give_Donor($donor_id); |
|
2552 | 2552 | |
2553 | - if ( ! empty( $address ) ) { |
|
2554 | - $address = maybe_unserialize( $address ); |
|
2555 | - $donor->add_address( 'personal', $address ); |
|
2556 | - $donor->add_address( 'billing[]', $address ); |
|
2553 | + if ( ! empty($address)) { |
|
2554 | + $address = maybe_unserialize($address); |
|
2555 | + $donor->add_address('personal', $address); |
|
2556 | + $donor->add_address('billing[]', $address); |
|
2557 | 2557 | } |
2558 | 2558 | |
2559 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2560 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2561 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2559 | + $donor_name = explode(' ', $donor->name, 2); |
|
2560 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2561 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2562 | 2562 | |
2563 | 2563 | // If first name meta of donor is not created, then create it. |
2564 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2565 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2564 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2565 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2566 | 2566 | } |
2567 | 2567 | |
2568 | 2568 | // If last name meta of donor is not created, then create it. |
2569 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2570 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2569 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2570 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2571 | 2571 | } |
2572 | 2572 | |
2573 | 2573 | // If Donor is connected with WP User then update user meta. |
2574 | - if ( $donor->user_id ) { |
|
2575 | - if ( isset( $donor_name[0] ) ) { |
|
2576 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2574 | + if ($donor->user_id) { |
|
2575 | + if (isset($donor_name[0])) { |
|
2576 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2577 | 2577 | } |
2578 | - if ( isset( $donor_name[1] ) ) { |
|
2579 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2578 | + if (isset($donor_name[1])) { |
|
2579 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2580 | 2580 | } |
2581 | 2581 | } |
2582 | 2582 | } |
@@ -2587,5 +2587,5 @@ discard block |
||
2587 | 2587 | } |
2588 | 2588 | |
2589 | 2589 | Give_Updates::get_instance()->percentage = 100; |
2590 | - give_set_upgrade_complete('v201_add_missing_donors' ); |
|
2590 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2591 | 2591 | } |
2592 | 2592 | \ No newline at end of file |