@@ -6,7 +6,7 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly. |
|
10 | 10 | |
11 | 11 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 12 |
@@ -6,7 +6,10 @@ |
||
6 | 6 | * @version 1.0 |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
9 | +if ( ! defined( 'ABSPATH' ) ) { |
|
10 | + exit; |
|
11 | +} |
|
12 | +// Exit if accessed directly. |
|
10 | 13 | |
11 | 14 | // {email} is replaced by the content entered in Donations > Settings > Emails |
12 | 15 |
@@ -39,8 +39,8 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
42 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | + && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
44 | 44 | ) { |
45 | 45 | |
46 | 46 | $forms_singular_option = give_get_option( 'forms_singular' ); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
37 | + if ( ! function_exists('is_plugin_active')) { |
|
38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
44 | 44 | ) { |
45 | 45 | |
46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
48 | 48 | |
49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
50 | 50 | if ( |
51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
53 | 53 | ) { |
54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * This is support for the plugin Elementor. This function |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Is the plugin: Elementor activated? |
80 | 80 | */ |
81 | - if ( is_plugin_active( 'elementor/elementor.php' ) ) { |
|
81 | + if (is_plugin_active('elementor/elementor.php')) { |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Check user is on the Elementor's editor page, then hide Give Shortcodes Button. |
85 | 85 | */ |
86 | - if ( isset( $_GET['action'] ) && 'elementor' === give_clean( $_GET['action'] ) ) { |
|
86 | + if (isset($_GET['action']) && 'elementor' === give_clean($_GET['action'])) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | } |
@@ -91,4 +91,4 @@ discard block |
||
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | |
94 | -add_filter( 'give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11 ); |
|
94 | +add_filter('give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * Return the calculated completion percentage. |
217 | 217 | * |
218 | 218 | * @since 1.8.12 |
219 | - * @return int |
|
219 | + * @return double |
|
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | + /** |
|
357 | + * @param integer $page |
|
358 | + */ |
|
356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
357 | 360 | $index = $page --; |
358 | 361 | $count = count( $donation_ids ); |
@@ -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 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * Constructor. |
107 | 107 | */ |
108 | - public function __construct( $_step = 1 ) { |
|
109 | - parent::__construct( $_step ); |
|
108 | + public function __construct($_step = 1) { |
|
109 | + parent::__construct($_step); |
|
110 | 110 | |
111 | 111 | $this->is_writable = true; |
112 | 112 | } |
@@ -125,34 +125,34 @@ discard block |
||
125 | 125 | $donor_ids = array(); |
126 | 126 | |
127 | 127 | // Check if the ajax request if running for the first time. |
128 | - if ( 1 === (int) $this->step ) { |
|
128 | + if (1 === (int) $this->step) { |
|
129 | 129 | // Delete all the form ids. |
130 | - $this->delete_option( $this->form_key ); |
|
130 | + $this->delete_option($this->form_key); |
|
131 | 131 | // Delete all the donation ids. |
132 | - $this->delete_option( $this->donation_key ); |
|
132 | + $this->delete_option($this->donation_key); |
|
133 | 133 | // Delete all the donor ids. |
134 | - $this->delete_option( $this->donor_key ); |
|
134 | + $this->delete_option($this->donor_key); |
|
135 | 135 | |
136 | 136 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
137 | - $this->update_option( $this->step_key, 'count' ); |
|
137 | + $this->update_option($this->step_key, 'count'); |
|
138 | 138 | |
139 | 139 | // Delete tha page count of the step. |
140 | - $this->update_option( $this->step_on_key, '0' ); |
|
140 | + $this->update_option($this->step_on_key, '0'); |
|
141 | 141 | } else { |
142 | 142 | // Get the old donors list. |
143 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
143 | + $donor_ids = $this->get_option($this->donor_key); |
|
144 | 144 | |
145 | 145 | // Get the old donation list. |
146 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
146 | + $donation_ids = $this->get_option($this->donation_key); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
150 | 150 | $step = (int) $this->get_step(); |
151 | - if ( 1 === $step ) { |
|
151 | + if (1 === $step) { |
|
152 | 152 | /** |
153 | 153 | * Will add or update the donation and donor data by running wp query. |
154 | 154 | */ |
155 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
155 | + $this->count($step, $donation_ids, $donor_ids); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
164 | 164 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
165 | 165 | */ |
166 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
166 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
167 | 167 | |
168 | 168 | // Get the Page count by default it's zero. |
169 | 169 | $paged = (int) $this->get_step_page(); |
170 | 170 | // Incresed the page count by one. |
171 | - ++ $paged; |
|
171 | + ++$paged; |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Filter add to alter the argument before the wp quest run |
175 | 175 | */ |
176 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
176 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
177 | 177 | 'post_type' => 'give_payment', |
178 | 178 | 'post_status' => 'any', |
179 | 179 | 'posts_per_page' => $this->per_step, |
@@ -181,40 +181,40 @@ discard block |
||
181 | 181 | 'meta_key' => '_give_payment_import', |
182 | 182 | 'meta_value_num' => 1, |
183 | 183 | 'meta_compare' => '=', |
184 | - ) ); |
|
184 | + )); |
|
185 | 185 | |
186 | 186 | // Reset the post data. |
187 | 187 | wp_reset_postdata(); |
188 | 188 | // Getting the new donation. |
189 | - $donation_posts = new WP_Query( $args ); |
|
189 | + $donation_posts = new WP_Query($args); |
|
190 | 190 | |
191 | 191 | // The Loop. |
192 | - if ( $donation_posts->have_posts() ) { |
|
193 | - while ( $donation_posts->have_posts() ) { |
|
192 | + if ($donation_posts->have_posts()) { |
|
193 | + while ($donation_posts->have_posts()) { |
|
194 | 194 | $add_author = true; |
195 | 195 | $donation_posts->the_post(); |
196 | 196 | global $post; |
197 | 197 | // Add the donation id in side the array. |
198 | 198 | $donation_ids[] = $post->ID; |
199 | 199 | |
200 | - $donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true ); |
|
201 | - if ( ! empty( $donor_id ) ) { |
|
202 | - $donor = new Give_Donor( $donor_id ); |
|
203 | - if ( ! empty( $donor->id ) ) { |
|
204 | - if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) { |
|
200 | + $donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true); |
|
201 | + if ( ! empty($donor_id)) { |
|
202 | + $donor = new Give_Donor($donor_id); |
|
203 | + if ( ! empty($donor->id)) { |
|
204 | + if (empty($donor->user_id) && ! empty($donor->payment_ids)) { |
|
205 | 205 | $add_author = false; |
206 | - $count = (int) count( $donor->payment_ids ); |
|
207 | - if ( 1 === $count ) { |
|
208 | - Give()->donors->delete( $donor->id ); |
|
206 | + $count = (int) count($donor->payment_ids); |
|
207 | + if (1 === $count) { |
|
208 | + Give()->donors->delete($donor->id); |
|
209 | 209 | } else { |
210 | - $donor->remove_payment( $post->ID ); |
|
210 | + $donor->remove_payment($post->ID); |
|
211 | 211 | $donor->decrease_donation_count(); |
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! empty( $add_author ) ) { |
|
217 | + if ( ! empty($add_author)) { |
|
218 | 218 | // Add the donor id in side the array. |
219 | 219 | $donor_ids[] = (int) $post->post_author; |
220 | 220 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | $max_num_pages = (int) $donation_posts->max_num_pages; |
230 | 230 | |
231 | 231 | // Check current page is less then max number of page or not |
232 | - if ( $paged < $max_num_pages ) { |
|
232 | + if ($paged < $max_num_pages) { |
|
233 | 233 | // Update the curretn page virable for the next step |
234 | - $this->update_option( $this->step_on_key, $paged ); |
|
234 | + $this->update_option($this->step_on_key, $paged); |
|
235 | 235 | |
236 | 236 | // Calculating percentage. |
237 | 237 | $page_remain = $max_num_pages - $paged; |
238 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
238 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
239 | 239 | $this->step_completed = $paged; |
240 | 240 | } else { |
241 | - $donation_ids_count = count( $donor_ids ); |
|
242 | - $this->update_option( $this->step_key, 'donation' ); |
|
243 | - $this->update_option( $this->step_on_key, '0' ); |
|
241 | + $donation_ids_count = count($donor_ids); |
|
242 | + $this->update_option($this->step_key, 'donation'); |
|
243 | + $this->update_option($this->step_on_key, '0'); |
|
244 | 244 | } |
245 | 245 | |
246 | - $donor_ids = array_unique( $donor_ids ); |
|
247 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
248 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
246 | + $donor_ids = array_unique($donor_ids); |
|
247 | + $this->update_option($this->donor_key, $donor_ids); |
|
248 | + $this->update_option($this->donation_key, $donation_ids); |
|
249 | 249 | |
250 | 250 | wp_reset_postdata(); |
251 | 251 | } |
@@ -257,33 +257,33 @@ discard block |
||
257 | 257 | * @return int |
258 | 258 | */ |
259 | 259 | public function get_percentage_complete() { |
260 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
260 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public function process_step() { |
264 | 264 | |
265 | - if ( ! $this->can_export() ) { |
|
265 | + if ( ! $this->can_export()) { |
|
266 | 266 | wp_die( |
267 | - esc_html__( 'You do not have permission to delete Import transactions.', 'give' ), |
|
268 | - esc_html__( 'Error', 'give' ), |
|
269 | - array( 'response' => 403 ) |
|
267 | + esc_html__('You do not have permission to delete Import transactions.', 'give'), |
|
268 | + esc_html__('Error', 'give'), |
|
269 | + array('response' => 403) |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | |
273 | 273 | $had_data = $this->get_data(); |
274 | 274 | |
275 | - if ( $had_data ) { |
|
275 | + if ($had_data) { |
|
276 | 276 | $this->done = false; |
277 | 277 | |
278 | 278 | return true; |
279 | 279 | } else { |
280 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
281 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
280 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
281 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
282 | 282 | |
283 | - $this->delete_option( $this->donation_key ); |
|
283 | + $this->delete_option($this->donation_key); |
|
284 | 284 | |
285 | 285 | $this->done = true; |
286 | - $this->message = __( 'Imported donor and transactions successfully deleted.', 'give' ); |
|
286 | + $this->message = __('Imported donor and transactions successfully deleted.', 'give'); |
|
287 | 287 | |
288 | 288 | return false; |
289 | 289 | } |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | public function get_data() { |
302 | 302 | |
303 | 303 | // Get the donation id's. |
304 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
304 | + $donation_ids = $this->get_option($this->donation_key); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Return false id not Import donation is found. |
308 | 308 | */ |
309 | - if ( empty( $donation_ids ) ) { |
|
309 | + if (empty($donation_ids)) { |
|
310 | 310 | $this->is_empty = true; |
311 | 311 | $this->total_step = 1; |
312 | 312 | |
@@ -317,110 +317,110 @@ discard block |
||
317 | 317 | $step = (int) $this->get_step(); |
318 | 318 | |
319 | 319 | // get teh donor ids. |
320 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
320 | + $donor_ids = $this->get_option($this->donor_key); |
|
321 | 321 | |
322 | 322 | // In step to we delete all the donation in loop. |
323 | - if ( 2 === $step ) { |
|
323 | + if (2 === $step) { |
|
324 | 324 | $pass_to_donor = false; |
325 | 325 | $page = (int) $this->get_step_page(); |
326 | - $page ++; |
|
327 | - $count = count( $donation_ids ); |
|
326 | + $page++; |
|
327 | + $count = count($donation_ids); |
|
328 | 328 | |
329 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
329 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
330 | 330 | $this->step_completed = $page; |
331 | 331 | |
332 | - if ( $count > $this->per_step ) { |
|
332 | + if ($count > $this->per_step) { |
|
333 | 333 | |
334 | - $this->update_option( $this->step_on_key, $page ); |
|
335 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
336 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
334 | + $this->update_option($this->step_on_key, $page); |
|
335 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
336 | + $current_page = (int) ceil($count / $this->per_step); |
|
337 | 337 | |
338 | - if ( $page === $current_page ) { |
|
338 | + if ($page === $current_page) { |
|
339 | 339 | $pass_to_donor = true; |
340 | 340 | } |
341 | 341 | } else { |
342 | 342 | $pass_to_donor = true; |
343 | 343 | } |
344 | 344 | |
345 | - if ( true === $pass_to_donor ) { |
|
346 | - $this->update_option( $this->step_key, 'donor' ); |
|
347 | - $this->update_option( $this->step_on_key, '0' ); |
|
345 | + if (true === $pass_to_donor) { |
|
346 | + $this->update_option($this->step_key, 'donor'); |
|
347 | + $this->update_option($this->step_on_key, '0'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Get the old form list. |
351 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
351 | + $form_ids = (array) $this->get_option($this->form_key); |
|
352 | 352 | |
353 | - foreach ( $donation_ids as $item ) { |
|
354 | - $form_ids[] = give_get_meta( $item, '_give_payment_form_id', true ); |
|
353 | + foreach ($donation_ids as $item) { |
|
354 | + $form_ids[] = give_get_meta($item, '_give_payment_form_id', true); |
|
355 | 355 | |
356 | 356 | // Delete the main payment. |
357 | - give_delete_donation( absint( $item ) ); |
|
357 | + give_delete_donation(absint($item)); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | // update the new form list. |
361 | - $this->update_option( $this->form_key, $form_ids ); |
|
361 | + $this->update_option($this->form_key, $form_ids); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Here we delete all the donor |
365 | - if ( 3 === $step ) { |
|
365 | + if (3 === $step) { |
|
366 | 366 | |
367 | 367 | // Get the old form list. |
368 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
369 | - if ( ! empty( $form_ids ) ) { |
|
370 | - $form_ids = array_unique( $form_ids ); |
|
371 | - foreach ( $form_ids as $form_id ) { |
|
372 | - give_recount_form_income_donation( (int) $form_id ); |
|
368 | + $form_ids = (array) $this->get_option($this->form_key); |
|
369 | + if ( ! empty($form_ids)) { |
|
370 | + $form_ids = array_unique($form_ids); |
|
371 | + foreach ($form_ids as $form_id) { |
|
372 | + give_recount_form_income_donation((int) $form_id); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | // update the new form list. |
376 | - $this->update_option( $this->form_key, array() ); |
|
376 | + $this->update_option($this->form_key, array()); |
|
377 | 377 | |
378 | 378 | $page = (int) $this->get_step_page(); |
379 | - $count = count( $donor_ids ); |
|
379 | + $count = count($donor_ids); |
|
380 | 380 | |
381 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
382 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
381 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
382 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
383 | 383 | |
384 | - if ( ! empty( $donor_ids[ $page ] ) ) { |
|
385 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
384 | + if ( ! empty($donor_ids[$page])) { |
|
385 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
386 | 386 | 'post_status' => 'any', |
387 | 387 | 'posts_per_page' => 1, |
388 | - 'author' => $donor_ids[ $page ], |
|
389 | - ) ); |
|
388 | + 'author' => $donor_ids[$page], |
|
389 | + )); |
|
390 | 390 | |
391 | 391 | $donations = array(); |
392 | - $payments = new Give_Payments_Query( $args ); |
|
392 | + $payments = new Give_Payments_Query($args); |
|
393 | 393 | $payments = $payments->get_payments(); |
394 | - if ( empty( $payments ) ) { |
|
395 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
394 | + if (empty($payments)) { |
|
395 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * If Checked then delete WP user. |
399 | 399 | * |
400 | 400 | * @since 1.8.14 |
401 | 401 | */ |
402 | - $delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : ''; |
|
402 | + $delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : ''; |
|
403 | 403 | |
404 | - if ( 'on' === (string) $delete_import_donors ) { |
|
405 | - wp_delete_user( $donor_ids[ $page ] ); |
|
404 | + if ('on' === (string) $delete_import_donors) { |
|
405 | + wp_delete_user($donor_ids[$page]); |
|
406 | 406 | } |
407 | 407 | } else { |
408 | - foreach ( $payments as $payment ) { |
|
408 | + foreach ($payments as $payment) { |
|
409 | 409 | $donations[] = $payment->ID; |
410 | 410 | } |
411 | 411 | |
412 | - $donor = new Give_Donor( $donor_ids[ $page ], true ); |
|
412 | + $donor = new Give_Donor($donor_ids[$page], true); |
|
413 | 413 | $data_to_update = array( |
414 | - 'purchase_count' => count( $donations ), |
|
415 | - 'payment_ids' => implode( ',', $donations ), |
|
414 | + 'purchase_count' => count($donations), |
|
415 | + 'payment_ids' => implode(',', $donations), |
|
416 | 416 | ); |
417 | - $donor->update( $data_to_update ); |
|
417 | + $donor->update($data_to_update); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | - $page ++; |
|
422 | - $this->update_option( $this->step_on_key, $page ); |
|
423 | - if ( $count === $page ) { |
|
421 | + $page++; |
|
422 | + $this->update_option($this->step_on_key, $page); |
|
423 | + if ($count === $page) { |
|
424 | 424 | $this->is_empty = false; |
425 | 425 | |
426 | 426 | return false; |
@@ -432,24 +432,24 @@ discard block |
||
432 | 432 | return true; |
433 | 433 | } |
434 | 434 | |
435 | - public function get_delete_ids( $donation_ids, $page ) { |
|
436 | - $index = $page --; |
|
437 | - $count = count( $donation_ids ); |
|
435 | + public function get_delete_ids($donation_ids, $page) { |
|
436 | + $index = $page--; |
|
437 | + $count = count($donation_ids); |
|
438 | 438 | $temp = 0; |
439 | 439 | $current_page = 0; |
440 | 440 | $post_delete = $this->per_step; |
441 | 441 | $page_donation_id = array(); |
442 | 442 | |
443 | - foreach ( $donation_ids as $item ) { |
|
444 | - $temp ++; |
|
445 | - $page_donation_id[ $current_page ][] = $item; |
|
446 | - if ( $temp === $post_delete ) { |
|
447 | - $current_page ++; |
|
443 | + foreach ($donation_ids as $item) { |
|
444 | + $temp++; |
|
445 | + $page_donation_id[$current_page][] = $item; |
|
446 | + if ($temp === $post_delete) { |
|
447 | + $current_page++; |
|
448 | 448 | $temp = 0; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | - return $page_donation_id[ $page ]; |
|
452 | + return $page_donation_id[$page]; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return mixed Returns the data from the database |
463 | 463 | */ |
464 | - public function get_option( $key, $defalut_value = false ) { |
|
465 | - return get_option( $key, $defalut_value ); |
|
464 | + public function get_option($key, $defalut_value = false) { |
|
465 | + return get_option($key, $defalut_value); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return void |
477 | 477 | */ |
478 | - public function update_option( $key, $value ) { |
|
479 | - update_option( $key, $value, false ); |
|
478 | + public function update_option($key, $value) { |
|
479 | + update_option($key, $value, false); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return void |
490 | 490 | */ |
491 | - public function delete_option( $key ) { |
|
492 | - delete_option( $key ); |
|
491 | + public function delete_option($key) { |
|
492 | + delete_option($key); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | * @return int|string |
501 | 501 | */ |
502 | 502 | private function get_step() { |
503 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
504 | - if ( 'count' === $step_key ) { |
|
503 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
504 | + if ('count' === $step_key) { |
|
505 | 505 | return 1; |
506 | - } elseif ( 'donation' === $step_key ) { |
|
506 | + } elseif ('donation' === $step_key) { |
|
507 | 507 | return 2; |
508 | - } elseif ( 'donor' === $step_key ) { |
|
508 | + } elseif ('donor' === $step_key) { |
|
509 | 509 | return 3; |
510 | 510 | } else { |
511 | 511 | return $step_key; |
@@ -516,6 +516,6 @@ discard block |
||
516 | 516 | * Get the current $page value in the ajax. |
517 | 517 | */ |
518 | 518 | private function get_step_page() { |
519 | - return $this->get_option( $this->step_on_key, false ); |
|
519 | + return $this->get_option($this->step_on_key, false); |
|
520 | 520 | } |
521 | 521 | } |
@@ -918,7 +918,7 @@ |
||
918 | 918 | * @access public |
919 | 919 | * |
920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -149,32 +149,32 @@ discard block |
||
149 | 149 | * @param int|bool $_id_or_email |
150 | 150 | * @param bool $by_user_id |
151 | 151 | */ |
152 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
152 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
153 | 153 | |
154 | 154 | $this->db = Give()->donors; |
155 | 155 | |
156 | 156 | if ( |
157 | 157 | false === $_id_or_email |
158 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
158 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
159 | 159 | ) { |
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
163 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
164 | 164 | |
165 | - if ( is_numeric( $_id_or_email ) ) { |
|
165 | + if (is_numeric($_id_or_email)) { |
|
166 | 166 | $field = $by_user_id ? 'user_id' : 'id'; |
167 | 167 | } else { |
168 | 168 | $field = 'email'; |
169 | 169 | } |
170 | 170 | |
171 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
171 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
172 | 172 | |
173 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
173 | + if (empty($donor) || ! is_object($donor)) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - $this->setup_donor( $donor ); |
|
177 | + $this->setup_donor($donor); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return bool If the setup was successful or not. |
192 | 192 | */ |
193 | - private function setup_donor( $donor ) { |
|
193 | + private function setup_donor($donor) { |
|
194 | 194 | |
195 | - if ( ! is_object( $donor ) ) { |
|
195 | + if ( ! is_object($donor)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Get cached donors. |
200 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
200 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
201 | 201 | |
202 | - if( is_null( $donor_vars ) ){ |
|
203 | - foreach ( $donor as $key => $value ) { |
|
202 | + if (is_null($donor_vars)) { |
|
203 | + foreach ($donor as $key => $value) { |
|
204 | 204 | |
205 | - switch ( $key ) { |
|
205 | + switch ($key) { |
|
206 | 206 | |
207 | 207 | case 'notes': |
208 | 208 | $this->$key = $this->get_notes(); |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get donor's all email including primary email. |
219 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
220 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
219 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
220 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
221 | 221 | |
222 | 222 | $this->setup_address(); |
223 | 223 | |
224 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
225 | - } else{ |
|
226 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
224 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
225 | + } else { |
|
226 | + foreach ($donor_vars as $donor_var => $value) { |
|
227 | 227 | $this->$donor_var = $value; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Donor ID and email are the only things that are necessary, make sure they exist. |
232 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
232 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | ARRAY_N |
263 | 263 | ); |
264 | 264 | |
265 | - if ( empty( $addresses ) ) { |
|
265 | + if (empty($addresses)) { |
|
266 | 266 | return $this->address; |
267 | 267 | } |
268 | 268 | |
269 | - foreach ( $addresses as $address ) { |
|
270 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
271 | - $address[0] = explode( '_', $address[0] ); |
|
269 | + foreach ($addresses as $address) { |
|
270 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
271 | + $address[0] = explode('_', $address[0]); |
|
272 | 272 | |
273 | - if ( 3 === count( $address[0] ) ) { |
|
274 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
273 | + if (3 === count($address[0])) { |
|
274 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
275 | 275 | } else { |
276 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
276 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return array The donor's address, if any |
291 | 291 | */ |
292 | - public function get_donor_address( $args = array() ) { |
|
292 | + public function get_donor_address($args = array()) { |
|
293 | 293 | $args = wp_parse_args( |
294 | 294 | $args, |
295 | 295 | array( |
@@ -307,24 +307,24 @@ discard block |
||
307 | 307 | ); |
308 | 308 | |
309 | 309 | // Backward compatibility. |
310 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { |
|
310 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { |
|
311 | 311 | |
312 | 312 | // Backward compatibility for user id param. |
313 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); |
|
313 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { |
|
317 | + if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { |
|
318 | 318 | return $default_address; |
319 | 319 | } |
320 | 320 | |
321 | - switch ( true ) { |
|
322 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): |
|
323 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); |
|
321 | + switch (true) { |
|
322 | + case is_string(end($this->address[$args['address_type']])): |
|
323 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); |
|
324 | 324 | break; |
325 | 325 | |
326 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): |
|
327 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); |
|
326 | + case is_array(end($this->address[$args['address_type']])): |
|
327 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); |
|
328 | 328 | break; |
329 | 329 | } |
330 | 330 | |
@@ -340,16 +340,16 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return mixed|\WP_Error |
342 | 342 | */ |
343 | - public function __get( $key ) { |
|
343 | + public function __get($key) { |
|
344 | 344 | |
345 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
345 | + if (method_exists($this, 'get_'.$key)) { |
|
346 | 346 | |
347 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
347 | + return call_user_func(array($this, 'get_'.$key)); |
|
348 | 348 | |
349 | 349 | } else { |
350 | 350 | |
351 | 351 | /* translators: %s: property key */ |
352 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
352 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
367 | 367 | */ |
368 | - public function create( $data = array() ) { |
|
368 | + public function create($data = array()) { |
|
369 | 369 | |
370 | - if ( $this->id != 0 || empty( $data ) ) { |
|
370 | + if ($this->id != 0 || empty($data)) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
@@ -375,15 +375,15 @@ discard block |
||
375 | 375 | 'payment_ids' => '', |
376 | 376 | ); |
377 | 377 | |
378 | - $args = wp_parse_args( $data, $defaults ); |
|
379 | - $args = $this->sanitize_columns( $args ); |
|
378 | + $args = wp_parse_args($data, $defaults); |
|
379 | + $args = $this->sanitize_columns($args); |
|
380 | 380 | |
381 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
381 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
386 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
385 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
386 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,18 +393,18 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @param array $args Donor attributes. |
395 | 395 | */ |
396 | - do_action( 'give_donor_pre_create', $args ); |
|
396 | + do_action('give_donor_pre_create', $args); |
|
397 | 397 | |
398 | 398 | $created = false; |
399 | 399 | |
400 | 400 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
401 | - if ( $this->db->add( $data ) ) { |
|
401 | + if ($this->db->add($data)) { |
|
402 | 402 | |
403 | 403 | // We've successfully added/updated the donor, reset the class vars with the new data |
404 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
404 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
405 | 405 | |
406 | 406 | // Setup the donor data with the values from DB |
407 | - $this->setup_donor( $donor ); |
|
407 | + $this->setup_donor($donor); |
|
408 | 408 | |
409 | 409 | $created = $this->id; |
410 | 410 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
418 | 418 | * @param array $args Customer attributes. |
419 | 419 | */ |
420 | - do_action( 'give_donor_post_create', $created, $args ); |
|
420 | + do_action('give_donor_post_create', $created, $args); |
|
421 | 421 | |
422 | 422 | return $created; |
423 | 423 | |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool If the update was successful or not. |
435 | 435 | */ |
436 | - public function update( $data = array() ) { |
|
436 | + public function update($data = array()) { |
|
437 | 437 | |
438 | - if ( empty( $data ) ) { |
|
438 | + if (empty($data)) { |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | - $data = $this->sanitize_columns( $data ); |
|
442 | + $data = $this->sanitize_columns($data); |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Fires before updating donors. |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @param int $donor_id Donor id. |
450 | 450 | * @param array $data Donor attributes. |
451 | 451 | */ |
452 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
452 | + do_action('give_donor_pre_update', $this->id, $data); |
|
453 | 453 | |
454 | 454 | $updated = false; |
455 | 455 | |
456 | - if ( $this->db->update( $this->id, $data ) ) { |
|
456 | + if ($this->db->update($this->id, $data)) { |
|
457 | 457 | |
458 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
458 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
459 | 459 | |
460 | - $this->setup_donor( $donor ); |
|
460 | + $this->setup_donor($donor); |
|
461 | 461 | |
462 | 462 | $updated = true; |
463 | 463 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @param int $donor_id Donor id. |
472 | 472 | * @param array $data Donor attributes. |
473 | 473 | */ |
474 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
474 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
475 | 475 | |
476 | 476 | return $updated; |
477 | 477 | } |
@@ -489,27 +489,27 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool If the attachment was successfully. |
491 | 491 | */ |
492 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
492 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
493 | 493 | |
494 | - if ( empty( $payment_id ) ) { |
|
494 | + if (empty($payment_id)) { |
|
495 | 495 | return false; |
496 | 496 | } |
497 | 497 | |
498 | - if ( empty( $this->payment_ids ) ) { |
|
498 | + if (empty($this->payment_ids)) { |
|
499 | 499 | |
500 | 500 | $new_payment_ids = $payment_id; |
501 | 501 | |
502 | 502 | } else { |
503 | 503 | |
504 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
504 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
505 | 505 | |
506 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
506 | + if (in_array($payment_id, $payment_ids)) { |
|
507 | 507 | $update_stats = false; |
508 | 508 | } |
509 | 509 | |
510 | 510 | $payment_ids[] = $payment_id; |
511 | 511 | |
512 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
512 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
513 | 513 | |
514 | 514 | } |
515 | 515 | |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | * @param int $payment_id Payment id. |
522 | 522 | * @param int $donor_id Customer id. |
523 | 523 | */ |
524 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
524 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
525 | 525 | |
526 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
526 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
527 | 527 | |
528 | - if ( $payment_added ) { |
|
528 | + if ($payment_added) { |
|
529 | 529 | |
530 | 530 | $this->payment_ids = $new_payment_ids; |
531 | 531 | |
532 | 532 | // We added this payment successfully, increment the stats |
533 | - if ( $update_stats ) { |
|
534 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
533 | + if ($update_stats) { |
|
534 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
535 | 535 | |
536 | - if ( ! empty( $payment_amount ) ) { |
|
537 | - $this->increase_value( $payment_amount ); |
|
536 | + if ( ! empty($payment_amount)) { |
|
537 | + $this->increase_value($payment_amount); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $this->increase_purchase_count(); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param int $payment_id Payment id. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
553 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
554 | 554 | |
555 | 555 | return $payment_added; |
556 | 556 | } |
@@ -568,33 +568,33 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return boolean If the removal was successful. |
570 | 570 | */ |
571 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
571 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
572 | 572 | |
573 | - if ( empty( $payment_id ) ) { |
|
573 | + if (empty($payment_id)) { |
|
574 | 574 | return false; |
575 | 575 | } |
576 | 576 | |
577 | - $payment = new Give_Payment( $payment_id ); |
|
577 | + $payment = new Give_Payment($payment_id); |
|
578 | 578 | |
579 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
579 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
580 | 580 | $update_stats = false; |
581 | 581 | } |
582 | 582 | |
583 | 583 | $new_payment_ids = ''; |
584 | 584 | |
585 | - if ( ! empty( $this->payment_ids ) ) { |
|
585 | + if ( ! empty($this->payment_ids)) { |
|
586 | 586 | |
587 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
587 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
588 | 588 | |
589 | - $pos = array_search( $payment_id, $payment_ids ); |
|
590 | - if ( false === $pos ) { |
|
589 | + $pos = array_search($payment_id, $payment_ids); |
|
590 | + if (false === $pos) { |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | |
594 | - unset( $payment_ids[ $pos ] ); |
|
595 | - $payment_ids = array_filter( $payment_ids ); |
|
594 | + unset($payment_ids[$pos]); |
|
595 | + $payment_ids = array_filter($payment_ids); |
|
596 | 596 | |
597 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
597 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
598 | 598 | |
599 | 599 | } |
600 | 600 | |
@@ -606,20 +606,20 @@ discard block |
||
606 | 606 | * @param int $payment_id Payment id. |
607 | 607 | * @param int $donor_id Customer id. |
608 | 608 | */ |
609 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
609 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
610 | 610 | |
611 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
611 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
612 | 612 | |
613 | - if ( $payment_removed ) { |
|
613 | + if ($payment_removed) { |
|
614 | 614 | |
615 | 615 | $this->payment_ids = $new_payment_ids; |
616 | 616 | |
617 | - if ( $update_stats ) { |
|
617 | + if ($update_stats) { |
|
618 | 618 | // We removed this payment successfully, decrement the stats |
619 | - $payment_amount = give_donation_amount( $payment_id ); |
|
619 | + $payment_amount = give_donation_amount($payment_id); |
|
620 | 620 | |
621 | - if ( ! empty( $payment_amount ) ) { |
|
622 | - $this->decrease_value( $payment_amount ); |
|
621 | + if ( ! empty($payment_amount)) { |
|
622 | + $this->decrease_value($payment_amount); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | $this->decrease_donation_count(); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param int $payment_id Payment id. |
636 | 636 | * @param int $donor_id Donor id. |
637 | 637 | */ |
638 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
638 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
639 | 639 | |
640 | 640 | return $payment_removed; |
641 | 641 | |
@@ -651,10 +651,10 @@ discard block |
||
651 | 651 | * |
652 | 652 | * @return int The donation count. |
653 | 653 | */ |
654 | - public function increase_purchase_count( $count = 1 ) { |
|
654 | + public function increase_purchase_count($count = 1) { |
|
655 | 655 | |
656 | 656 | // Make sure it's numeric and not negative. |
657 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
657 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
658 | 658 | return false; |
659 | 659 | } |
660 | 660 | |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * @param int $count The number to increase by. |
669 | 669 | * @param int $donor_id Donor id. |
670 | 670 | */ |
671 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
671 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
672 | 672 | |
673 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
673 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
674 | 674 | $this->purchase_count = $new_total; |
675 | 675 | } |
676 | 676 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param int $count The number increased by. |
684 | 684 | * @param int $donor_id Donor id. |
685 | 685 | */ |
686 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
686 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
687 | 687 | |
688 | 688 | return $this->purchase_count; |
689 | 689 | } |
@@ -698,16 +698,16 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return mixed If successful, the new count, otherwise false. |
700 | 700 | */ |
701 | - public function decrease_donation_count( $count = 1 ) { |
|
701 | + public function decrease_donation_count($count = 1) { |
|
702 | 702 | |
703 | 703 | // Make sure it's numeric and not negative |
704 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
704 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
705 | 705 | return false; |
706 | 706 | } |
707 | 707 | |
708 | 708 | $new_total = (int) $this->purchase_count - (int) $count; |
709 | 709 | |
710 | - if ( $new_total < 0 ) { |
|
710 | + if ($new_total < 0) { |
|
711 | 711 | $new_total = 0; |
712 | 712 | } |
713 | 713 | |
@@ -719,9 +719,9 @@ discard block |
||
719 | 719 | * @param int $count The number to decrease by. |
720 | 720 | * @param int $donor_id Customer id. |
721 | 721 | */ |
722 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
722 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
723 | 723 | |
724 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
724 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
725 | 725 | $this->purchase_count = $new_total; |
726 | 726 | } |
727 | 727 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * @param int $count The number decreased by. |
735 | 735 | * @param int $donor_id Donor id. |
736 | 736 | */ |
737 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
737 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
738 | 738 | |
739 | 739 | return $this->purchase_count; |
740 | 740 | } |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | * |
750 | 750 | * @return mixed If successful, the new value, otherwise false. |
751 | 751 | */ |
752 | - public function increase_value( $value = 0.00 ) { |
|
752 | + public function increase_value($value = 0.00) { |
|
753 | 753 | |
754 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
754 | + $new_value = floatval($this->purchase_value) + $value; |
|
755 | 755 | |
756 | 756 | /** |
757 | 757 | * Fires before increasing donor lifetime value. |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | * @param float $value The value to increase by. |
762 | 762 | * @param int $donor_id Customer id. |
763 | 763 | */ |
764 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
764 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
765 | 765 | |
766 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
766 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
767 | 767 | $this->purchase_value = $new_value; |
768 | 768 | } |
769 | 769 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | * @param float $value The value increased by. |
777 | 777 | * @param int $donor_id Donor id. |
778 | 778 | */ |
779 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
779 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
780 | 780 | |
781 | 781 | return $this->purchase_value; |
782 | 782 | } |
@@ -791,11 +791,11 @@ discard block |
||
791 | 791 | * |
792 | 792 | * @return mixed If successful, the new value, otherwise false. |
793 | 793 | */ |
794 | - public function decrease_value( $value = 0.00 ) { |
|
794 | + public function decrease_value($value = 0.00) { |
|
795 | 795 | |
796 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
796 | + $new_value = floatval($this->purchase_value) - $value; |
|
797 | 797 | |
798 | - if ( $new_value < 0 ) { |
|
798 | + if ($new_value < 0) { |
|
799 | 799 | $new_value = 0.00; |
800 | 800 | } |
801 | 801 | |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | * @param float $value The value to decrease by. |
808 | 808 | * @param int $donor_id Donor id. |
809 | 809 | */ |
810 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
810 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
811 | 811 | |
812 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
812 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
813 | 813 | $this->purchase_value = $new_value; |
814 | 814 | } |
815 | 815 | |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * @param float $value The value decreased by. |
823 | 823 | * @param int $donor_id Donor id. |
824 | 824 | */ |
825 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
825 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
826 | 826 | |
827 | 827 | return $this->purchase_value; |
828 | 828 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return mixed If successful, the new donation stat value, otherwise false. |
843 | 843 | */ |
844 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
844 | + public function update_donation_value($curr_amount, $new_amount) { |
|
845 | 845 | /** |
846 | 846 | * Payment total difference value can be: |
847 | 847 | * zero (in case amount not change) |
@@ -851,15 +851,15 @@ discard block |
||
851 | 851 | $payment_total_diff = $new_amount - $curr_amount; |
852 | 852 | |
853 | 853 | // We do not need to update donation stat if donation did not change. |
854 | - if ( ! $payment_total_diff ) { |
|
854 | + if ( ! $payment_total_diff) { |
|
855 | 855 | return false; |
856 | 856 | } |
857 | 857 | |
858 | - if ( $payment_total_diff > 0 ) { |
|
859 | - $this->increase_value( $payment_total_diff ); |
|
858 | + if ($payment_total_diff > 0) { |
|
859 | + $this->increase_value($payment_total_diff); |
|
860 | 860 | } else { |
861 | 861 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
862 | - $this->decrease_value( - $payment_total_diff ); |
|
862 | + $this->decrease_value( -$payment_total_diff ); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | return $this->purchase_value; |
@@ -876,15 +876,15 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return array The notes requested. |
878 | 878 | */ |
879 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
879 | + public function get_notes($length = 20, $paged = 1) { |
|
880 | 880 | |
881 | - $length = is_numeric( $length ) ? $length : 20; |
|
882 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
881 | + $length = is_numeric($length) ? $length : 20; |
|
882 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
883 | 883 | |
884 | 884 | $all_notes = $this->get_raw_notes(); |
885 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
885 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
886 | 886 | |
887 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
887 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
888 | 888 | |
889 | 889 | return $desired_notes; |
890 | 890 | |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | public function get_notes_count() { |
902 | 902 | |
903 | 903 | $all_notes = $this->get_raw_notes(); |
904 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
904 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
905 | 905 | |
906 | - return count( $notes_array ); |
|
906 | + return count($notes_array); |
|
907 | 907 | |
908 | 908 | } |
909 | 909 | |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | * |
917 | 917 | * @return string|float |
918 | 918 | */ |
919 | - public function get_total_donation_amount( $args = array() ) { |
|
919 | + public function get_total_donation_amount($args = array()) { |
|
920 | 920 | |
921 | 921 | /** |
922 | 922 | * Filter total donation amount. |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param integer $donor_id Donor ID. |
928 | 928 | * @param array $args Pass additional data. |
929 | 929 | */ |
930 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
930 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,22 +940,22 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string|boolean The new note if added successfully, false otherwise. |
942 | 942 | */ |
943 | - public function add_note( $note = '' ) { |
|
943 | + public function add_note($note = '') { |
|
944 | 944 | |
945 | - $note = trim( $note ); |
|
946 | - if ( empty( $note ) ) { |
|
945 | + $note = trim($note); |
|
946 | + if (empty($note)) { |
|
947 | 947 | return false; |
948 | 948 | } |
949 | 949 | |
950 | 950 | $notes = $this->get_raw_notes(); |
951 | 951 | |
952 | - if ( empty( $notes ) ) { |
|
952 | + if (empty($notes)) { |
|
953 | 953 | $notes = ''; |
954 | 954 | } |
955 | 955 | |
956 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
957 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
958 | - $notes .= "\n\n" . $new_note; |
|
956 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
957 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
958 | + $notes .= "\n\n".$new_note; |
|
959 | 959 | |
960 | 960 | /** |
961 | 961 | * Fires before donor note is added. |
@@ -965,11 +965,11 @@ discard block |
||
965 | 965 | * @param string $new_note New note to add. |
966 | 966 | * @param int $donor_id Donor id. |
967 | 967 | */ |
968 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
968 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
969 | 969 | |
970 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
970 | + $updated = $this->update(array('notes' => $notes)); |
|
971 | 971 | |
972 | - if ( $updated ) { |
|
972 | + if ($updated) { |
|
973 | 973 | $this->notes = $this->get_notes(); |
974 | 974 | } |
975 | 975 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @param string $new_note New note added. |
983 | 983 | * @param int $donor_id Donor id. |
984 | 984 | */ |
985 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
985 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
986 | 986 | |
987 | 987 | // Return the formatted note, so we can test, as well as update any displays |
988 | 988 | return $new_note; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | */ |
1000 | 1000 | private function get_raw_notes() { |
1001 | 1001 | |
1002 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
1002 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
1003 | 1003 | |
1004 | 1004 | return $all_notes; |
1005 | 1005 | |
@@ -1016,8 +1016,8 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
1018 | 1018 | */ |
1019 | - public function get_meta( $meta_key = '', $single = true ) { |
|
1020 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
1019 | + public function get_meta($meta_key = '', $single = true) { |
|
1020 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | * |
1033 | 1033 | * @return bool False for failure. True for success. |
1034 | 1034 | */ |
1035 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
1036 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
1035 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
1036 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return bool False on failure, true if success. |
1050 | 1050 | */ |
1051 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
1052 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
1051 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
1052 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @return bool False for failure. True for success. |
1065 | 1065 | */ |
1066 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
1067 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
1066 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
1067 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1077,51 +1077,51 @@ discard block |
||
1077 | 1077 | * |
1078 | 1078 | * @return array The sanitized data, based off column defaults. |
1079 | 1079 | */ |
1080 | - private function sanitize_columns( $data ) { |
|
1080 | + private function sanitize_columns($data) { |
|
1081 | 1081 | |
1082 | 1082 | $columns = $this->db->get_columns(); |
1083 | 1083 | $default_values = $this->db->get_column_defaults(); |
1084 | 1084 | |
1085 | - foreach ( $columns as $key => $type ) { |
|
1085 | + foreach ($columns as $key => $type) { |
|
1086 | 1086 | |
1087 | 1087 | // Only sanitize data that we were provided |
1088 | - if ( ! array_key_exists( $key, $data ) ) { |
|
1088 | + if ( ! array_key_exists($key, $data)) { |
|
1089 | 1089 | continue; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | - switch ( $type ) { |
|
1092 | + switch ($type) { |
|
1093 | 1093 | |
1094 | 1094 | case '%s': |
1095 | - if ( 'email' == $key ) { |
|
1096 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
1097 | - } elseif ( 'notes' == $key ) { |
|
1098 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
1095 | + if ('email' == $key) { |
|
1096 | + $data[$key] = sanitize_email($data[$key]); |
|
1097 | + } elseif ('notes' == $key) { |
|
1098 | + $data[$key] = strip_tags($data[$key]); |
|
1099 | 1099 | } else { |
1100 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1100 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1101 | 1101 | } |
1102 | 1102 | break; |
1103 | 1103 | |
1104 | 1104 | case '%d': |
1105 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
1106 | - $data[ $key ] = $default_values[ $key ]; |
|
1105 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
1106 | + $data[$key] = $default_values[$key]; |
|
1107 | 1107 | } else { |
1108 | - $data[ $key ] = absint( $data[ $key ] ); |
|
1108 | + $data[$key] = absint($data[$key]); |
|
1109 | 1109 | } |
1110 | 1110 | break; |
1111 | 1111 | |
1112 | 1112 | case '%f': |
1113 | 1113 | // Convert what was given to a float |
1114 | - $value = floatval( $data[ $key ] ); |
|
1114 | + $value = floatval($data[$key]); |
|
1115 | 1115 | |
1116 | - if ( ! is_float( $value ) ) { |
|
1117 | - $data[ $key ] = $default_values[ $key ]; |
|
1116 | + if ( ! is_float($value)) { |
|
1117 | + $data[$key] = $default_values[$key]; |
|
1118 | 1118 | } else { |
1119 | - $data[ $key ] = $value; |
|
1119 | + $data[$key] = $value; |
|
1120 | 1120 | } |
1121 | 1121 | break; |
1122 | 1122 | |
1123 | 1123 | default: |
1124 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1124 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1125 | 1125 | break; |
1126 | 1126 | |
1127 | 1127 | } |
@@ -1141,33 +1141,33 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool If the email was added successfully |
1143 | 1143 | */ |
1144 | - public function add_email( $email = '', $primary = false ) { |
|
1145 | - if ( ! is_email( $email ) ) { |
|
1144 | + public function add_email($email = '', $primary = false) { |
|
1145 | + if ( ! is_email($email)) { |
|
1146 | 1146 | return false; |
1147 | 1147 | } |
1148 | - $existing = new Give_Donor( $email ); |
|
1148 | + $existing = new Give_Donor($email); |
|
1149 | 1149 | |
1150 | - if ( $existing->id > 0 ) { |
|
1150 | + if ($existing->id > 0) { |
|
1151 | 1151 | // Email address already belongs to another donor |
1152 | 1152 | return false; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - if ( email_exists( $email ) ) { |
|
1156 | - $user = get_user_by( 'email', $email ); |
|
1157 | - if ( $user->ID != $this->user_id ) { |
|
1155 | + if (email_exists($email)) { |
|
1156 | + $user = get_user_by('email', $email); |
|
1157 | + if ($user->ID != $this->user_id) { |
|
1158 | 1158 | return false; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1162 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1163 | 1163 | |
1164 | 1164 | // Add is used to ensure duplicate emails are not added |
1165 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1165 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1166 | 1166 | |
1167 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1167 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1168 | 1168 | |
1169 | - if ( $ret && true === $primary ) { |
|
1170 | - $this->set_primary_email( $email ); |
|
1169 | + if ($ret && true === $primary) { |
|
1170 | + $this->set_primary_email($email); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | return $ret; |
@@ -1183,16 +1183,16 @@ discard block |
||
1183 | 1183 | * |
1184 | 1184 | * @return bool If the email was removed successfully. |
1185 | 1185 | */ |
1186 | - public function remove_email( $email = '' ) { |
|
1187 | - if ( ! is_email( $email ) ) { |
|
1186 | + public function remove_email($email = '') { |
|
1187 | + if ( ! is_email($email)) { |
|
1188 | 1188 | return false; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1191 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1192 | 1192 | |
1193 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1193 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1194 | 1194 | |
1195 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1195 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1196 | 1196 | |
1197 | 1197 | return $ret; |
1198 | 1198 | } |
@@ -1209,16 +1209,16 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return bool If the email was set as primary successfully. |
1211 | 1211 | */ |
1212 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1213 | - if ( ! is_email( $new_primary_email ) ) { |
|
1212 | + public function set_primary_email($new_primary_email = '') { |
|
1213 | + if ( ! is_email($new_primary_email)) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1217 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1218 | 1218 | |
1219 | - $existing = new Give_Donor( $new_primary_email ); |
|
1219 | + $existing = new Give_Donor($new_primary_email); |
|
1220 | 1220 | |
1221 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1221 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1222 | 1222 | // This email belongs to another donor. |
1223 | 1223 | return false; |
1224 | 1224 | } |
@@ -1226,21 +1226,21 @@ discard block |
||
1226 | 1226 | $old_email = $this->email; |
1227 | 1227 | |
1228 | 1228 | // Update donor record with new email. |
1229 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1229 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1230 | 1230 | |
1231 | 1231 | // Remove new primary from list of additional emails. |
1232 | - $remove = $this->remove_email( $new_primary_email ); |
|
1232 | + $remove = $this->remove_email($new_primary_email); |
|
1233 | 1233 | |
1234 | 1234 | // Add old email to additional emails list. |
1235 | - $add = $this->add_email( $old_email ); |
|
1235 | + $add = $this->add_email($old_email); |
|
1236 | 1236 | |
1237 | 1237 | $ret = $update && $remove && $add; |
1238 | 1238 | |
1239 | - if ( $ret ) { |
|
1239 | + if ($ret) { |
|
1240 | 1240 | $this->email = $new_primary_email; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1243 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1244 | 1244 | |
1245 | 1245 | return $ret; |
1246 | 1246 | } |
@@ -1255,17 +1255,17 @@ discard block |
||
1255 | 1255 | * |
1256 | 1256 | * @return bool |
1257 | 1257 | */ |
1258 | - private function is_valid_address( $address ) { |
|
1258 | + private function is_valid_address($address) { |
|
1259 | 1259 | $is_valid_address = true; |
1260 | 1260 | |
1261 | 1261 | // Address ready to process even if only one value set. |
1262 | - foreach ( $address as $address_type => $value ) { |
|
1262 | + foreach ($address as $address_type => $value) { |
|
1263 | 1263 | // @todo: Handle state field validation on basis of country. |
1264 | - if( in_array( $address_type, array( 'line2', 'state' )) ) { |
|
1264 | + if (in_array($address_type, array('line2', 'state'))) { |
|
1265 | 1265 | continue; |
1266 | 1266 | } |
1267 | 1267 | |
1268 | - if ( empty( $value ) ) { |
|
1268 | + if (empty($value)) { |
|
1269 | 1269 | $is_valid_address = false; |
1270 | 1270 | break; |
1271 | 1271 | } |
@@ -1292,30 +1292,27 @@ discard block |
||
1292 | 1292 | * |
1293 | 1293 | * @return bool |
1294 | 1294 | */ |
1295 | - public function add_address( $address_type, $address ) { |
|
1295 | + public function add_address($address_type, $address) { |
|
1296 | 1296 | // Bailout. |
1297 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
1297 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
1298 | 1298 | return false; |
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | // Check if multiple address exist or not and set params. |
1302 | 1302 | $multi_address_id = null; |
1303 | - if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
1304 | - $address_type = $is_multi_address ? |
|
1305 | - str_replace( '[]', '', $address_type ) : |
|
1306 | - $address_type; |
|
1307 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){ |
|
1308 | - $multi_address_id = $is_multi_address ? |
|
1309 | - array_pop( explode( '_', $address_type ) ) : |
|
1310 | - $address_type; |
|
1303 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
1304 | + $address_type = $is_multi_address ? |
|
1305 | + str_replace('[]', '', $address_type) : $address_type; |
|
1306 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
1307 | + $multi_address_id = $is_multi_address ? |
|
1308 | + array_pop(explode('_', $address_type)) : $address_type; |
|
1311 | 1309 | |
1312 | - $address_type = $is_multi_address ? |
|
1313 | - array_shift( explode( '_', $address_type ) ) : |
|
1314 | - $address_type; |
|
1310 | + $address_type = $is_multi_address ? |
|
1311 | + array_shift(explode('_', $address_type)) : $address_type; |
|
1315 | 1312 | } |
1316 | 1313 | |
1317 | 1314 | // Bailout: do not save duplicate orders |
1318 | - if( $this->is_address_exist( $address_type, $address ) ) { |
|
1315 | + if ($this->is_address_exist($address_type, $address)) { |
|
1319 | 1316 | return false; |
1320 | 1317 | } |
1321 | 1318 | |
@@ -1337,8 +1334,8 @@ discard block |
||
1337 | 1334 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
1338 | 1335 | $meta_type = Give()->donor_meta->meta_type; |
1339 | 1336 | |
1340 | - if ( $is_multi_address ) { |
|
1341 | - if ( is_null( $multi_address_id ) ) { |
|
1337 | + if ($is_multi_address) { |
|
1338 | + if (is_null($multi_address_id)) { |
|
1342 | 1339 | // Get latest address key to set multi address id. |
1343 | 1340 | $multi_address_id = $wpdb->get_var( |
1344 | 1341 | $wpdb->prepare( |
@@ -1355,10 +1352,10 @@ discard block |
||
1355 | 1352 | ) |
1356 | 1353 | ); |
1357 | 1354 | |
1358 | - if( ! empty( $multi_address_id ) ) { |
|
1359 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
1355 | + if ( ! empty($multi_address_id)) { |
|
1356 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
1360 | 1357 | $multi_address_id++; |
1361 | - } else{ |
|
1358 | + } else { |
|
1362 | 1359 | $multi_address_id = 0; |
1363 | 1360 | } |
1364 | 1361 | } |
@@ -1367,9 +1364,9 @@ discard block |
||
1367 | 1364 | } |
1368 | 1365 | |
1369 | 1366 | // Save donor address. |
1370 | - foreach ( $address as $type => $value ) { |
|
1371 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
1372 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
1367 | + foreach ($address as $type => $value) { |
|
1368 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
1369 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
1373 | 1370 | } |
1374 | 1371 | |
1375 | 1372 | $this->setup_address(); |
@@ -1388,23 +1385,21 @@ discard block |
||
1388 | 1385 | * |
1389 | 1386 | * @return bool |
1390 | 1387 | */ |
1391 | - public function remove_address( $address_id ) { |
|
1388 | + public function remove_address($address_id) { |
|
1392 | 1389 | global $wpdb; |
1393 | 1390 | |
1394 | 1391 | // Get address type. |
1395 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1392 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1396 | 1393 | |
1397 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1398 | - array_shift( explode( '_', $address_id ) ) : |
|
1399 | - $address_id; |
|
1394 | + $address_type = false !== strpos($address_id, '_') ? |
|
1395 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1400 | 1396 | |
1401 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1402 | - array_pop( explode( '_', $address_id ) ) : |
|
1403 | - null; |
|
1397 | + $address_count = false !== strpos($address_id, '_') ? |
|
1398 | + array_pop(explode('_', $address_id)) : null; |
|
1404 | 1399 | |
1405 | 1400 | // Set meta key prefix. |
1406 | 1401 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1407 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1402 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1408 | 1403 | $meta_key_prefix .= "_{$address_count}"; |
1409 | 1404 | } |
1410 | 1405 | |
@@ -1441,23 +1436,21 @@ discard block |
||
1441 | 1436 | * |
1442 | 1437 | * @return bool |
1443 | 1438 | */ |
1444 | - public function update_address( $address_id, $address ) { |
|
1439 | + public function update_address($address_id, $address) { |
|
1445 | 1440 | global $wpdb; |
1446 | 1441 | |
1447 | 1442 | // Get address type. |
1448 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1443 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1449 | 1444 | |
1450 | - $address_type = false !== strpos( $address_id, '_' ) ? |
|
1451 | - array_shift( explode( '_', $address_id ) ) : |
|
1452 | - $address_id; |
|
1445 | + $address_type = false !== strpos($address_id, '_') ? |
|
1446 | + array_shift(explode('_', $address_id)) : $address_id; |
|
1453 | 1447 | |
1454 | - $address_count = false !== strpos( $address_id, '_' ) ? |
|
1455 | - array_pop( explode( '_', $address_id ) ) : |
|
1456 | - null; |
|
1448 | + $address_count = false !== strpos($address_id, '_') ? |
|
1449 | + array_pop(explode('_', $address_id)) : null; |
|
1457 | 1450 | |
1458 | 1451 | // Set meta key prefix. |
1459 | 1452 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1460 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1453 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1461 | 1454 | $meta_key_prefix .= "_{$address_count}"; |
1462 | 1455 | } |
1463 | 1456 | |
@@ -1478,12 +1471,12 @@ discard block |
||
1478 | 1471 | ); |
1479 | 1472 | |
1480 | 1473 | // Return result. |
1481 | - if( ! count( $row_affected ) ) { |
|
1474 | + if ( ! count($row_affected)) { |
|
1482 | 1475 | return false; |
1483 | 1476 | } |
1484 | 1477 | |
1485 | 1478 | // Update address. |
1486 | - if( ! $this->add_address( $address_id, $address ) ) { |
|
1479 | + if ( ! $this->add_address($address_id, $address)) { |
|
1487 | 1480 | return false; |
1488 | 1481 | } |
1489 | 1482 | |
@@ -1502,39 +1495,39 @@ discard block |
||
1502 | 1495 | * |
1503 | 1496 | * @return bool|null |
1504 | 1497 | */ |
1505 | - public function is_address_exist( $current_address_type, $current_address ) { |
|
1498 | + public function is_address_exist($current_address_type, $current_address) { |
|
1506 | 1499 | $status = false; |
1507 | 1500 | |
1508 | 1501 | // Bailout. |
1509 | - if( empty( $current_address_type ) || empty( $current_address ) ) { |
|
1502 | + if (empty($current_address_type) || empty($current_address)) { |
|
1510 | 1503 | return null; |
1511 | 1504 | } |
1512 | 1505 | |
1513 | 1506 | // Bailout. |
1514 | - if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
1507 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
1515 | 1508 | return $status; |
1516 | 1509 | } |
1517 | 1510 | |
1518 | 1511 | // Get address. |
1519 | - $address = $this->address[ $current_address_type ]; |
|
1512 | + $address = $this->address[$current_address_type]; |
|
1520 | 1513 | |
1521 | - switch ( true ){ |
|
1514 | + switch (true) { |
|
1522 | 1515 | |
1523 | 1516 | // Single address. |
1524 | - case is_string( end( $address ) ) : |
|
1525 | - $status = $this->is_address_match( $current_address, $address ); |
|
1517 | + case is_string(end($address)) : |
|
1518 | + $status = $this->is_address_match($current_address, $address); |
|
1526 | 1519 | break; |
1527 | 1520 | |
1528 | 1521 | // Multi address. |
1529 | - case is_array( end( $address ) ): |
|
1522 | + case is_array(end($address)): |
|
1530 | 1523 | // Compare address. |
1531 | - foreach ( $address as $saved_address ) { |
|
1532 | - if( empty( $saved_address ) ) { |
|
1524 | + foreach ($address as $saved_address) { |
|
1525 | + if (empty($saved_address)) { |
|
1533 | 1526 | continue; |
1534 | 1527 | } |
1535 | 1528 | |
1536 | 1529 | // Exit loop immediately if address exist. |
1537 | - if( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
1530 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
1538 | 1531 | break; |
1539 | 1532 | } |
1540 | 1533 | } |
@@ -1555,10 +1548,10 @@ discard block |
||
1555 | 1548 | * |
1556 | 1549 | * @return bool |
1557 | 1550 | */ |
1558 | - private function is_address_match( $address_1, $address_2 ) { |
|
1559 | - $result = array_diff( $address_1, $address_2 ); |
|
1551 | + private function is_address_match($address_1, $address_2) { |
|
1552 | + $result = array_diff($address_1, $address_2); |
|
1560 | 1553 | |
1561 | - return empty( $result ); |
|
1554 | + return empty($result); |
|
1562 | 1555 | } |
1563 | 1556 | |
1564 | 1557 | /** |
@@ -1568,22 +1561,22 @@ discard block |
||
1568 | 1561 | * @since 2.0 |
1569 | 1562 | * @return object |
1570 | 1563 | */ |
1571 | - public function split_donor_name( $id ) { |
|
1572 | - $first_name = $last_name = ''; |
|
1573 | - $donor = new Give_Donor( $id ); |
|
1564 | + public function split_donor_name($id) { |
|
1565 | + $first_name = $last_name = ''; |
|
1566 | + $donor = new Give_Donor($id); |
|
1574 | 1567 | |
1575 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
1568 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
1576 | 1569 | |
1577 | 1570 | // Check for existence of first name after split of donor name. |
1578 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
1571 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
1579 | 1572 | $first_name = $split_donor_name[0]; |
1580 | 1573 | } |
1581 | 1574 | |
1582 | 1575 | // Check for existence of last name after split of donor name. |
1583 | - if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
1576 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
1584 | 1577 | $last_name = $split_donor_name[1]; |
1585 | 1578 | } |
1586 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
1579 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
1587 | 1580 | } |
1588 | 1581 | |
1589 | 1582 | /** |
@@ -1593,9 +1586,9 @@ discard block |
||
1593 | 1586 | * @return string |
1594 | 1587 | */ |
1595 | 1588 | public function get_first_name() { |
1596 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1597 | - if( ! $first_name ) { |
|
1598 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
1589 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1590 | + if ( ! $first_name) { |
|
1591 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
1599 | 1592 | } |
1600 | 1593 | |
1601 | 1594 | return $first_name; |
@@ -1608,15 +1601,15 @@ discard block |
||
1608 | 1601 | * @return string |
1609 | 1602 | */ |
1610 | 1603 | public function get_last_name() { |
1611 | - $first_name = $this->get_meta( '_give_donor_first_name'); |
|
1612 | - $last_name = $this->get_meta( '_give_donor_last_name'); |
|
1604 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1605 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
1613 | 1606 | |
1614 | 1607 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
1615 | - if( ! $first_name && ! $last_name ) { |
|
1616 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
1608 | + if ( ! $first_name && ! $last_name) { |
|
1609 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
1617 | 1610 | } |
1618 | 1611 | |
1619 | - return ( $last_name ) ? $last_name : ''; |
|
1612 | + return ($last_name) ? $last_name : ''; |
|
1620 | 1613 | } |
1621 | 1614 | |
1622 | 1615 | /** |
@@ -1627,7 +1620,7 @@ discard block |
||
1627 | 1620 | * @return string $company_name Donor Company Name |
1628 | 1621 | */ |
1629 | 1622 | public function get_company_name() { |
1630 | - $company_name = $this->get_meta( '_give_donor_company' ); |
|
1623 | + $company_name = $this->get_meta('_give_donor_company'); |
|
1631 | 1624 | |
1632 | 1625 | return $company_name; |
1633 | 1626 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string|array Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | $return = false; |
182 | 182 | |
183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
184 | 184 | |
185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
186 | - if ( ! empty( $matches ) ) { |
|
187 | - $this->set( $key, null ); |
|
185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
186 | + if ( ! empty($matches)) { |
|
187 | + $this->set($key, null); |
|
188 | 188 | |
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
193 | - $return = $this->session[ $key ]; |
|
192 | + if (is_numeric($this->session[$key])) { |
|
193 | + $return = $this->session[$key]; |
|
194 | 194 | } else { |
195 | 195 | |
196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
196 | + $maybe_json = json_decode($this->session[$key]); |
|
197 | 197 | |
198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
199 | - if ( is_null( $maybe_json ) ) { |
|
200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
201 | - if ( $is_serialized ) { |
|
202 | - $value = @unserialize( $this->session[ $key ] ); |
|
203 | - $this->set( $key, (array) $value ); |
|
199 | + if (is_null($maybe_json)) { |
|
200 | + $is_serialized = is_serialized($this->session[$key]); |
|
201 | + if ($is_serialized) { |
|
202 | + $value = @unserialize($this->session[$key]); |
|
203 | + $this->set($key, (array) $value); |
|
204 | 204 | $return = $value; |
205 | 205 | } else { |
206 | - $return = $this->session[ $key ]; |
|
206 | + $return = $this->session[$key]; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | - $return = json_decode( $this->session[ $key ], true ); |
|
209 | + $return = json_decode($this->session[$key], true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string Session variable. |
231 | 231 | */ |
232 | - public function set( $key, $value ) { |
|
232 | + public function set($key, $value) { |
|
233 | 233 | |
234 | - $key = sanitize_key( $key ); |
|
234 | + $key = sanitize_key($key); |
|
235 | 235 | |
236 | - if ( is_array( $value ) ) { |
|
237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
236 | + if (is_array($value)) { |
|
237 | + $this->session[$key] = wp_json_encode($value); |
|
238 | 238 | } else { |
239 | - $this->session[ $key ] = esc_attr( $value ); |
|
239 | + $this->session[$key] = esc_attr($value); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( $this->use_php_sessions ) { |
|
243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
242 | + if ($this->use_php_sessions) { |
|
243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
244 | 244 | } |
245 | 245 | |
246 | - return $this->session[ $key ]; |
|
246 | + return $this->session[$key]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | * @hook |
259 | 259 | */ |
260 | 260 | public function set_session_cookies() { |
261 | - if ( ! headers_sent() ) { |
|
262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
261 | + if ( ! headers_sent()) { |
|
262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function set_expiration_variant_time() { |
279 | 279 | |
280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function set_expiration_time() { |
294 | 294 | |
295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | $ret = false; |
311 | 311 | |
312 | 312 | // If the database variable is already set, no need to run auto detection. |
313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
314 | 314 | |
315 | - if ( ! $give_use_php_sessions ) { |
|
315 | + if ( ! $give_use_php_sessions) { |
|
316 | 316 | |
317 | 317 | // Attempt to detect if the server supports PHP sessions. |
318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
319 | 319 | |
320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
320 | + $this->set('give_use_php_sessions', 1); |
|
321 | 321 | |
322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
322 | + if ($this->get('give_use_php_sessions')) { |
|
323 | 323 | |
324 | 324 | $ret = true; |
325 | 325 | |
326 | 326 | // Set the database option. |
327 | - update_option( 'give_use_php_sessions', true ); |
|
327 | + update_option('give_use_php_sessions', true); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
338 | 338 | $ret = true; |
339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
340 | 340 | $ret = false; |
341 | 341 | } |
342 | 342 | |
343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $start_session = true; |
359 | 359 | |
360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
361 | 361 | |
362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
363 | 363 | 'feed', |
364 | 364 | 'feed', |
365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
367 | 367 | 'feed/rdf', |
368 | 368 | 'feed/atom', |
369 | 369 | 'comments/feed/', |
370 | - ) ); |
|
371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
372 | - $uri = untrailingslashit( $uri ); |
|
373 | - if ( in_array( $uri, $blacklist ) ) { |
|
370 | + )); |
|
371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
372 | + $uri = untrailingslashit($uri); |
|
373 | + if (in_array($uri, $blacklist)) { |
|
374 | 374 | $start_session = false; |
375 | 375 | } |
376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
376 | + if (false !== strpos($uri, 'feed=')) { |
|
377 | 377 | $start_session = false; |
378 | 378 | } |
379 | - if ( is_admin() ) { |
|
379 | + if (is_admin()) { |
|
380 | 380 | $start_session = false; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_start_session', $start_session ); |
|
384 | + return apply_filters('give_start_session', $start_session); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_start_session() { |
399 | 399 | |
400 | - if ( ! $this->should_start_session() ) { |
|
400 | + if ( ! $this->should_start_session()) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! session_id() && ! headers_sent() ) { |
|
404 | + if ( ! session_id() && ! headers_sent()) { |
|
405 | 405 | session_start(); |
406 | 406 | } |
407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | |
421 | 421 | $expiration = false; |
422 | 422 | |
423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
424 | 424 | |
425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 |
@@ -95,5 +95,8 @@ |
||
95 | 95 | <?php endif; ?> |
96 | 96 | <?php echo $form_close_tag; ?> |
97 | 97 | </div> |
98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
98 | +<?php else { |
|
99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
100 | +} |
|
101 | +?> |
|
99 | 102 | <?php endif; ?> |
100 | 103 | \ No newline at end of file |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Admin View: Settings |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | // Bailout: Do not output anything if setting tab is not defined. |
10 | -if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
10 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
11 | 11 | /** |
12 | 12 | * Filter the form action. |
13 | 13 | * |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @since 1.8 |
19 | 19 | */ |
20 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
20 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Filter the main form tab. |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8 |
31 | 31 | */ |
32 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
33 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
32 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
33 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
34 | 34 | |
35 | - $wrapper_class = implode( ' ', |
|
35 | + $wrapper_class = implode(' ', |
|
36 | 36 | array( |
37 | - self::$setting_filter_prefix . '-setting-page', |
|
38 | - self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section', |
|
39 | - self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab', |
|
37 | + self::$setting_filter_prefix.'-setting-page', |
|
38 | + self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section', |
|
39 | + self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab', |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | ?> |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | /* @var Give_Settings_Page $current_setting_obj */ |
48 | 48 | if ( |
49 | - ! empty( $current_setting_obj ) && |
|
50 | - method_exists( $current_setting_obj, 'get_heading_html' ) |
|
49 | + ! empty($current_setting_obj) && |
|
50 | + method_exists($current_setting_obj, 'get_heading_html') |
|
51 | 51 | ) { |
52 | 52 | echo $current_setting_obj->get_heading_html(); |
53 | 53 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | // Backward compatibility. |
56 | 56 | echo sprintf( |
57 | 57 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
58 | - esc_html( $tabs[ $current_tab ] ) |
|
58 | + esc_html($tabs[$current_tab]) |
|
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | ?> |
64 | 64 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
65 | 65 | <?php |
66 | - foreach ( $tabs as $name => $label ) { |
|
67 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>'; |
|
66 | + foreach ($tabs as $name => $label) { |
|
67 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @since 1.8 |
78 | 78 | */ |
79 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
79 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
80 | 80 | ?> |
81 | 81 | <div class="give-sub-nav-tab-wrapper"> |
82 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
82 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
83 | 83 | </a> |
84 | 84 | <nav class="give-sub-nav-tab give-hidden"></nav> |
85 | 85 | </div> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @since 1.8 |
97 | 97 | */ |
98 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
98 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Trigger Action. |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @since 1.8 |
108 | 108 | */ |
109 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
109 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
110 | 110 | |
111 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
111 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
112 | 112 | |
113 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
113 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
114 | 114 | <div class="give-submit-wrap"> |
115 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/> |
|
115 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/> |
|
116 | 116 | </div> |
117 | 117 | <?php endif; ?> |
118 | 118 | <?php echo $form_close_tag; ?> |
119 | 119 | </div> |
120 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
120 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
121 | 121 | <?php endif; ?> |
122 | 122 | \ No newline at end of file |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="give-blank-slate"> |
20 | - <?php if ( ! empty( $content['image_url'] ) ) : ?> |
|
21 | - <img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>"> |
|
20 | + <?php if ( ! empty($content['image_url'])) : ?> |
|
21 | + <img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>"> |
|
22 | 22 | <?php endif; ?> |
23 | 23 | |
24 | - <?php if ( ! empty( $content['heading'] ) ) : ?> |
|
25 | - <h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2> |
|
24 | + <?php if ( ! empty($content['heading'])) : ?> |
|
25 | + <h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2> |
|
26 | 26 | <?php endif; ?> |
27 | 27 | |
28 | - <?php if ( ! empty( $content['message'] ) ) : ?> |
|
29 | - <p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p> |
|
28 | + <?php if ( ! empty($content['message'])) : ?> |
|
29 | + <p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p> |
|
30 | 30 | <?php endif; ?> |
31 | 31 | |
32 | - <?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?> |
|
33 | - <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a> |
|
32 | + <?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?> |
|
33 | + <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a> |
|
34 | 34 | <?php endif; ?> |
35 | 35 | |
36 | - <?php if ( ! empty( $content['help'] ) ) : ?> |
|
36 | + <?php if ( ! empty($content['help'])) : ?> |
|
37 | 37 | <p class="give-blank-slate__help"> |
38 | 38 | <?php |
39 | 39 | $allowed_html = array( |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'code' => array(), |
48 | 48 | ); |
49 | 49 | |
50 | - echo wp_kses( $content['help'], $allowed_html ); |
|
50 | + echo wp_kses($content['help'], $allowed_html); |
|
51 | 51 | ?> |
52 | 52 | </p> |
53 | 53 | <?php endif; ?> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @since 1.5 |
21 | 21 | */ |
22 | 22 | function give_register_batch_recount_export_classes() { |
23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
24 | 24 | } |
25 | 25 | |
26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -35,39 +35,39 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return void |
37 | 37 | */ |
38 | -function give_include_batch_export_class( $class ) { |
|
39 | - switch ( $class ) { |
|
38 | +function give_include_batch_export_class($class) { |
|
39 | + switch ($class) { |
|
40 | 40 | |
41 | 41 | case 'Give_Tools_Delete_Donors': |
42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
43 | 43 | break; |
44 | 44 | |
45 | 45 | case 'Give_Tools_Import_Donors': |
46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
47 | 47 | break; |
48 | 48 | |
49 | 49 | case 'Give_Tools_Delete_Test_Transactions': |
50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
51 | 51 | break; |
52 | 52 | |
53 | 53 | case 'Give_Tools_Recount_Donor_Stats': |
54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
55 | 55 | break; |
56 | 56 | |
57 | 57 | case 'Give_Tools_Reset_Stats': |
58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
59 | 59 | break; |
60 | 60 | |
61 | 61 | case 'Give_Tools_Recount_All_Stats': |
62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
63 | 63 | break; |
64 | 64 | |
65 | 65 | case 'Give_Tools_Recount_Form_Stats': |
66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
67 | 67 | break; |
68 | 68 | |
69 | 69 | case 'Give_Tools_Recount_Income': |
70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
71 | 71 | break; |
72 | 72 | } |
73 | 73 | } |
@@ -1012,7 +1012,7 @@ |
||
1012 | 1012 | // Find a match between price_id and level_id. |
1013 | 1013 | // First verify array keys exists THEN make the match. |
1014 | 1014 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
1015 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
1015 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
1016 | 1016 | ) { |
1017 | 1017 | $donation_amount = $price['_give_amount']; |
1018 | 1018 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param int|bool $payment_id A given payment |
393 | 393 | * |
394 | - * @return mixed void|false |
|
394 | + * @return false|null void|false |
|
395 | 395 | */ |
396 | 396 | public function __construct( $payment_id = false ) { |
397 | 397 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * |
1116 | 1116 | * @param string|bool $note The note to add |
1117 | 1117 | * |
1118 | - * @return bool If the note was specified or not |
|
1118 | + * @return false|null If the note was specified or not |
|
1119 | 1119 | */ |
1120 | 1120 | public function add_note( $note = false ) { |
1121 | 1121 | // Bail if no note specified. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return mixed void|false |
397 | 397 | */ |
398 | - public function __construct( $payment_id = false ) { |
|
398 | + public function __construct($payment_id = false) { |
|
399 | 399 | |
400 | - if ( empty( $payment_id ) ) { |
|
400 | + if (empty($payment_id)) { |
|
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - $this->setup_payment( $payment_id ); |
|
404 | + $this->setup_payment($payment_id); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return mixed The value. |
416 | 416 | */ |
417 | - public function __get( $key ) { |
|
417 | + public function __get($key) { |
|
418 | 418 | |
419 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
419 | + if (method_exists($this, 'get_'.$key)) { |
|
420 | 420 | |
421 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
421 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
422 | 422 | |
423 | 423 | } else { |
424 | 424 | |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @param string $key The property name |
441 | 441 | * @param mixed $value The value of the property |
442 | 442 | */ |
443 | - public function __set( $key, $value ) { |
|
444 | - $ignore = array( '_ID' ); |
|
443 | + public function __set($key, $value) { |
|
444 | + $ignore = array('_ID'); |
|
445 | 445 | |
446 | - if ( 'status' === $key ) { |
|
446 | + if ('status' === $key) { |
|
447 | 447 | $this->old_status = $this->status; |
448 | 448 | } |
449 | 449 | |
450 | - if ( ! in_array( $key, $ignore ) ) { |
|
451 | - $this->pending[ $key ] = $value; |
|
450 | + if ( ! in_array($key, $ignore)) { |
|
451 | + $this->pending[$key] = $value; |
|
452 | 452 | } |
453 | 453 | |
454 | - if ( '_ID' !== $key ) { |
|
454 | + if ('_ID' !== $key) { |
|
455 | 455 | $this->$key = $value; |
456 | 456 | } |
457 | 457 | } |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return boolean|null If the item is set or not |
468 | 468 | */ |
469 | - public function __isset( $name ) { |
|
470 | - if ( property_exists( $this, $name ) ) { |
|
471 | - return false === empty( $this->$name ); |
|
469 | + public function __isset($name) { |
|
470 | + if (property_exists($this, $name)) { |
|
471 | + return false === empty($this->$name); |
|
472 | 472 | } else { |
473 | 473 | return null; |
474 | 474 | } |
@@ -484,20 +484,20 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return bool If the setup was successful or not |
486 | 486 | */ |
487 | - private function setup_payment( $payment_id ) { |
|
487 | + private function setup_payment($payment_id) { |
|
488 | 488 | $this->pending = array(); |
489 | 489 | |
490 | - if ( empty( $payment_id ) ) { |
|
490 | + if (empty($payment_id)) { |
|
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | |
494 | - $payment = get_post( absint( $payment_id ) ); |
|
494 | + $payment = get_post(absint($payment_id)); |
|
495 | 495 | |
496 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
496 | + if ( ! $payment || is_wp_error($payment)) { |
|
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - if ( 'give_payment' !== $payment->post_type ) { |
|
500 | + if ('give_payment' !== $payment->post_type) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
@@ -511,17 +511,17 @@ discard block |
||
511 | 511 | * @param Give_Payment $this Payment object. |
512 | 512 | * @param int $payment_id The ID of the payment. |
513 | 513 | */ |
514 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
514 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
515 | 515 | |
516 | 516 | // Get payment from cache. |
517 | - $donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' ); |
|
517 | + $donation_vars = Give_Cache::get_group($payment_id, 'give-donations'); |
|
518 | 518 | |
519 | - if ( is_null( $donation_vars ) ) { |
|
519 | + if (is_null($donation_vars)) { |
|
520 | 520 | // Primary Identifier. |
521 | - $this->ID = absint( $payment_id ); |
|
521 | + $this->ID = absint($payment_id); |
|
522 | 522 | |
523 | 523 | // Protected ID that can never be changed. |
524 | - $this->_ID = absint( $payment_id ); |
|
524 | + $this->_ID = absint($payment_id); |
|
525 | 525 | |
526 | 526 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
527 | 527 | $this->payment_meta = $this->get_meta(); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $this->parent_payment = $payment->post_parent; |
538 | 538 | |
539 | 539 | $all_payment_statuses = give_get_payment_statuses(); |
540 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
540 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
541 | 541 | |
542 | 542 | // Currency Based. |
543 | 543 | $this->total = $this->setup_total(); |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | $this->key = $this->setup_payment_key(); |
567 | 567 | $this->number = $this->setup_payment_number(); |
568 | 568 | |
569 | - Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' ); |
|
569 | + Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations'); |
|
570 | 570 | } else { |
571 | 571 | |
572 | - foreach ( $donation_vars as $donation_var => $value ) { |
|
572 | + foreach ($donation_vars as $donation_var => $value) { |
|
573 | 573 | $this->$donation_var = $value; |
574 | 574 | } |
575 | 575 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param Give_Payment $this Payment object. |
585 | 585 | * @param int $payment_id The ID of the payment. |
586 | 586 | */ |
587 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
587 | + do_action('give_setup_payment', $this, $payment_id); |
|
588 | 588 | |
589 | 589 | return true; |
590 | 590 | } |
@@ -603,11 +603,11 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @return void |
605 | 605 | */ |
606 | - public function update_payment_setup( $payment_id ) { |
|
606 | + public function update_payment_setup($payment_id) { |
|
607 | 607 | // Delete cache. |
608 | - Give_Cache::delete_group( $this->ID,'give-donations' ); |
|
608 | + Give_Cache::delete_group($this->ID, 'give-donations'); |
|
609 | 609 | |
610 | - $this->setup_payment( $payment_id ); |
|
610 | + $this->setup_payment($payment_id); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -622,24 +622,24 @@ discard block |
||
622 | 622 | |
623 | 623 | // Construct the payment title. |
624 | 624 | $payment_title = ''; |
625 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
626 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
627 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
625 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
626 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
627 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
628 | 628 | $payment_title = $this->first_name; |
629 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
629 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
630 | 630 | $payment_title = $this->email; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Set Key. |
634 | - if ( empty( $this->key ) ) { |
|
634 | + if (empty($this->key)) { |
|
635 | 635 | |
636 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
637 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
636 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
637 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
638 | 638 | $this->pending['key'] = $this->key; |
639 | 639 | } |
640 | 640 | |
641 | 641 | // Set IP. |
642 | - if ( empty( $this->ip ) ) { |
|
642 | + if (empty($this->ip)) { |
|
643 | 643 | |
644 | 644 | $this->ip = give_get_ip(); |
645 | 645 | $this->pending['ip'] = $this->ip; |
@@ -668,19 +668,19 @@ discard block |
||
668 | 668 | 'status' => $this->status, |
669 | 669 | ); |
670 | 670 | |
671 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
671 | + $args = apply_filters('give_insert_payment_args', array( |
|
672 | 672 | 'post_title' => $payment_title, |
673 | 673 | 'post_status' => $this->status, |
674 | 674 | 'post_type' => 'give_payment', |
675 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
676 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
675 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
676 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
677 | 677 | 'post_parent' => $this->parent_payment, |
678 | - ), $payment_data ); |
|
678 | + ), $payment_data); |
|
679 | 679 | |
680 | 680 | // Create a blank payment |
681 | - $payment_id = wp_insert_post( $args ); |
|
681 | + $payment_id = wp_insert_post($args); |
|
682 | 682 | |
683 | - if ( ! empty( $payment_id ) ) { |
|
683 | + if ( ! empty($payment_id)) { |
|
684 | 684 | |
685 | 685 | $this->ID = $payment_id; |
686 | 686 | $this->_ID = $payment_id; |
@@ -692,42 +692,42 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @since 1.8.13 |
694 | 694 | */ |
695 | - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args ); |
|
695 | + $donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args); |
|
696 | 696 | |
697 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
698 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
697 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
698 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
699 | 699 | |
700 | 700 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
701 | - if ( ! empty( $donor->id ) && $this->email !== $donor->email ) { |
|
702 | - $donor->add_email( $this->email ); |
|
701 | + if ( ! empty($donor->id) && $this->email !== $donor->email) { |
|
702 | + $donor->add_email($this->email); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | - if ( empty( $donor->id ) ) { |
|
707 | - $donor = new Give_Donor( $this->email ); |
|
706 | + if (empty($donor->id)) { |
|
707 | + $donor = new Give_Donor($this->email); |
|
708 | 708 | } |
709 | 709 | |
710 | - if ( empty( $donor->id ) ) { |
|
710 | + if (empty($donor->id)) { |
|
711 | 711 | |
712 | 712 | $donor_data = array( |
713 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
713 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
714 | 714 | 'email' => $this->email, |
715 | 715 | 'user_id' => $this->user_id, |
716 | 716 | ); |
717 | 717 | |
718 | - $donor->create( $donor_data ); |
|
718 | + $donor->create($donor_data); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Update Donor Meta once donor is created. |
723 | - $donor->update_meta( '_give_donor_first_name', $this->first_name ); |
|
724 | - $donor->update_meta( '_give_donor_last_name', $this->last_name ); |
|
723 | + $donor->update_meta('_give_donor_first_name', $this->first_name); |
|
724 | + $donor->update_meta('_give_donor_last_name', $this->last_name); |
|
725 | 725 | |
726 | 726 | $this->customer_id = $donor->id; |
727 | 727 | $this->pending['customer_id'] = $this->customer_id; |
728 | - $donor->attach_payment( $this->ID, false ); |
|
728 | + $donor->attach_payment($this->ID, false); |
|
729 | 729 | |
730 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
730 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
731 | 731 | |
732 | 732 | /* |
733 | 733 | * _give_payment_meta backward compatibility. |
@@ -735,25 +735,25 @@ discard block |
||
735 | 735 | * @since 2.0.1 |
736 | 736 | */ |
737 | 737 | $custom_payment_meta = array_diff( |
738 | - array_map( 'maybe_serialize', $this->payment_meta ), |
|
739 | - array_map( 'maybe_serialize', $payment_data ) |
|
738 | + array_map('maybe_serialize', $this->payment_meta), |
|
739 | + array_map('maybe_serialize', $payment_data) |
|
740 | 740 | ); |
741 | 741 | |
742 | - if( ! empty( $custom_payment_meta ) ) { |
|
743 | - give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' ); |
|
742 | + if ( ! empty($custom_payment_meta)) { |
|
743 | + give_doing_it_wrong('_give_payment_meta', __('This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give'), '2.0.0'); |
|
744 | 744 | |
745 | - $this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) ); |
|
745 | + $this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta)); |
|
746 | 746 | } |
747 | 747 | |
748 | - $give_company = ( ! empty( $_REQUEST['give_company_name'] ) ? give_clean( $_REQUEST['give_company_name'] ) : '' ); |
|
748 | + $give_company = ( ! empty($_REQUEST['give_company_name']) ? give_clean($_REQUEST['give_company_name']) : ''); |
|
749 | 749 | |
750 | 750 | // Check $page_url is not empty. |
751 | - if ( $give_company ) { |
|
752 | - give_update_meta( $payment_id, '_give_donation_company', $give_company ); |
|
751 | + if ($give_company) { |
|
752 | + give_update_meta($payment_id, '_give_donation_company', $give_company); |
|
753 | 753 | |
754 | - $donor_id = absint( $donor->id ); |
|
755 | - if ( ! empty( $donor_id ) ) { |
|
756 | - Give()->donor_meta->update_meta( $donor_id, '_give_donor_company', $give_company ); |
|
754 | + $donor_id = absint($donor->id); |
|
755 | + if ( ! empty($donor_id)) { |
|
756 | + Give()->donor_meta->update_meta($donor_id, '_give_donor_company', $give_company); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
@@ -777,11 +777,11 @@ discard block |
||
777 | 777 | $saved = false; |
778 | 778 | |
779 | 779 | // Must have an ID. |
780 | - if ( empty( $this->ID ) ) { |
|
780 | + if (empty($this->ID)) { |
|
781 | 781 | |
782 | 782 | $payment_id = $this->insert_payment(); |
783 | 783 | |
784 | - if ( false === $payment_id ) { |
|
784 | + if (false === $payment_id) { |
|
785 | 785 | $saved = false; |
786 | 786 | } else { |
787 | 787 | $this->ID = $payment_id; |
@@ -789,42 +789,42 @@ discard block |
||
789 | 789 | } |
790 | 790 | |
791 | 791 | // Set ID if not matching. |
792 | - if ( $this->ID !== $this->_ID ) { |
|
792 | + if ($this->ID !== $this->_ID) { |
|
793 | 793 | $this->ID = $this->_ID; |
794 | 794 | } |
795 | 795 | |
796 | 796 | // If we have something pending, let's save it. |
797 | - if ( ! empty( $this->pending ) ) { |
|
797 | + if ( ! empty($this->pending)) { |
|
798 | 798 | |
799 | 799 | $total_increase = 0; |
800 | 800 | $total_decrease = 0; |
801 | 801 | |
802 | - foreach ( $this->pending as $key => $value ) { |
|
802 | + foreach ($this->pending as $key => $value) { |
|
803 | 803 | |
804 | - switch ( $key ) { |
|
804 | + switch ($key) { |
|
805 | 805 | |
806 | 806 | case 'donations': |
807 | 807 | // Update totals for pending donations. |
808 | - foreach ( $this->pending[ $key ] as $item ) { |
|
808 | + foreach ($this->pending[$key] as $item) { |
|
809 | 809 | |
810 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
811 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
810 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
811 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
812 | 812 | |
813 | - switch ( $item['action'] ) { |
|
813 | + switch ($item['action']) { |
|
814 | 814 | |
815 | 815 | case 'add': |
816 | 816 | |
817 | 817 | $price = $item['price']; |
818 | 818 | |
819 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
819 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
820 | 820 | |
821 | 821 | // Add donation to logs. |
822 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
823 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
822 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
823 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
824 | 824 | |
825 | - $form = new Give_Donate_Form( $item['id'] ); |
|
826 | - $form->increase_sales( $quantity ); |
|
827 | - $form->increase_earnings( $price, $this->ID ); |
|
825 | + $form = new Give_Donate_Form($item['id']); |
|
826 | + $form->increase_sales($quantity); |
|
827 | + $form->increase_earnings($price, $this->ID); |
|
828 | 828 | |
829 | 829 | $total_increase += $price; |
830 | 830 | } |
@@ -832,10 +832,10 @@ discard block |
||
832 | 832 | |
833 | 833 | case 'remove': |
834 | 834 | $this->delete_sales_logs(); |
835 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
836 | - $form = new Give_Donate_Form( $item['id'] ); |
|
837 | - $form->decrease_sales( $quantity ); |
|
838 | - $form->decrease_earnings( $item['amount'], $this->ID ); |
|
835 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
836 | + $form = new Give_Donate_Form($item['id']); |
|
837 | + $form->decrease_sales($quantity); |
|
838 | + $form->decrease_earnings($item['amount'], $this->ID); |
|
839 | 839 | |
840 | 840 | $total_decrease += $item['amount']; |
841 | 841 | } |
@@ -846,27 +846,27 @@ discard block |
||
846 | 846 | break; |
847 | 847 | |
848 | 848 | case 'status': |
849 | - $this->update_status( $this->status ); |
|
849 | + $this->update_status($this->status); |
|
850 | 850 | break; |
851 | 851 | |
852 | 852 | case 'gateway': |
853 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
853 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
854 | 854 | break; |
855 | 855 | |
856 | 856 | case 'mode': |
857 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
857 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
858 | 858 | break; |
859 | 859 | |
860 | 860 | case 'transaction_id': |
861 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
861 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
862 | 862 | break; |
863 | 863 | |
864 | 864 | case 'ip': |
865 | - $this->update_meta( '_give_payment_donor_ip', $this->ip ); |
|
865 | + $this->update_meta('_give_payment_donor_ip', $this->ip); |
|
866 | 866 | break; |
867 | 867 | |
868 | 868 | case 'customer_id': |
869 | - $this->update_meta( '_give_payment_donor_id', $this->customer_id ); |
|
869 | + $this->update_meta('_give_payment_donor_id', $this->customer_id); |
|
870 | 870 | break; |
871 | 871 | |
872 | 872 | // case 'user_id': |
@@ -874,61 +874,61 @@ discard block |
||
874 | 874 | // break; |
875 | 875 | |
876 | 876 | case 'form_title': |
877 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
877 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
878 | 878 | break; |
879 | 879 | |
880 | 880 | case 'form_id': |
881 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
881 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | case 'price_id': |
885 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
885 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
886 | 886 | break; |
887 | 887 | |
888 | 888 | case 'first_name': |
889 | - $this->update_meta( '_give_donor_billing_first_name', $this->first_name ); |
|
889 | + $this->update_meta('_give_donor_billing_first_name', $this->first_name); |
|
890 | 890 | break; |
891 | 891 | |
892 | 892 | case 'last_name': |
893 | - $this->update_meta( '_give_donor_billing_last_name', $this->last_name ); |
|
893 | + $this->update_meta('_give_donor_billing_last_name', $this->last_name); |
|
894 | 894 | break; |
895 | 895 | |
896 | 896 | case 'currency': |
897 | - $this->update_meta( '_give_payment_currency', $this->currency ); |
|
897 | + $this->update_meta('_give_payment_currency', $this->currency); |
|
898 | 898 | break; |
899 | 899 | |
900 | 900 | case 'address': |
901 | - if ( ! empty( $this->address ) ) { |
|
902 | - foreach ( $this->address as $address_name => $address ) { |
|
903 | - switch ( $address_name ) { |
|
901 | + if ( ! empty($this->address)) { |
|
902 | + foreach ($this->address as $address_name => $address) { |
|
903 | + switch ($address_name) { |
|
904 | 904 | case 'line1': |
905 | - $this->update_meta( '_give_donor_billing_address1', $address ); |
|
905 | + $this->update_meta('_give_donor_billing_address1', $address); |
|
906 | 906 | break; |
907 | 907 | |
908 | 908 | case 'line2': |
909 | - $this->update_meta( '_give_donor_billing_address2', $address ); |
|
909 | + $this->update_meta('_give_donor_billing_address2', $address); |
|
910 | 910 | break; |
911 | 911 | |
912 | 912 | default: |
913 | - $this->update_meta( "_give_donor_billing_{$address_name}", $address ); |
|
913 | + $this->update_meta("_give_donor_billing_{$address_name}", $address); |
|
914 | 914 | } |
915 | 915 | } |
916 | 916 | } |
917 | 917 | break; |
918 | 918 | |
919 | 919 | case 'email': |
920 | - $this->update_meta( '_give_payment_donor_email', $this->email ); |
|
920 | + $this->update_meta('_give_payment_donor_email', $this->email); |
|
921 | 921 | break; |
922 | 922 | |
923 | 923 | case 'key': |
924 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
924 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
925 | 925 | break; |
926 | 926 | |
927 | 927 | case 'number': |
928 | 928 | // @todo: remove unused meta data. |
929 | 929 | // Core is using post_title to store donation serial code ( fi enabled ) instead this meta key. |
930 | 930 | // Do not use this meta key in your logic, can be remove in future |
931 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
931 | + $this->update_meta('_give_payment_number', $this->number); |
|
932 | 932 | break; |
933 | 933 | |
934 | 934 | case 'date': |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | 'edit_date' => true, |
939 | 939 | ); |
940 | 940 | |
941 | - wp_update_post( $args ); |
|
941 | + wp_update_post($args); |
|
942 | 942 | break; |
943 | 943 | |
944 | 944 | case 'completed_date': |
945 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
945 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
946 | 946 | break; |
947 | 947 | |
948 | 948 | case 'parent_payment': |
@@ -951,11 +951,11 @@ discard block |
||
951 | 951 | 'post_parent' => $this->parent_payment, |
952 | 952 | ); |
953 | 953 | |
954 | - wp_update_post( $args ); |
|
954 | + wp_update_post($args); |
|
955 | 955 | break; |
956 | 956 | |
957 | 957 | case 'total': |
958 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
958 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
959 | 959 | break; |
960 | 960 | |
961 | 961 | default: |
@@ -966,46 +966,46 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @param Give_Payment $this Payment object. |
968 | 968 | */ |
969 | - do_action( 'give_payment_save', $this, $key ); |
|
969 | + do_action('give_payment_save', $this, $key); |
|
970 | 970 | break; |
971 | 971 | }// End switch(). |
972 | 972 | }// End foreach(). |
973 | 973 | |
974 | - if ( 'pending' !== $this->status ) { |
|
974 | + if ('pending' !== $this->status) { |
|
975 | 975 | |
976 | - $donor = new Give_Donor( $this->customer_id ); |
|
976 | + $donor = new Give_Donor($this->customer_id); |
|
977 | 977 | |
978 | 978 | $total_change = $total_increase - $total_decrease; |
979 | - if ( $total_change < 0 ) { |
|
979 | + if ($total_change < 0) { |
|
980 | 980 | |
981 | - $total_change = - ( $total_change ); |
|
981 | + $total_change = - ($total_change); |
|
982 | 982 | |
983 | 983 | // Decrease the donor's donation stats. |
984 | - $donor->decrease_value( $total_change ); |
|
985 | - give_decrease_total_earnings( $total_change ); |
|
984 | + $donor->decrease_value($total_change); |
|
985 | + give_decrease_total_earnings($total_change); |
|
986 | 986 | |
987 | 987 | $donor->decrease_donation_count(); |
988 | 988 | |
989 | - } elseif ( $total_change > 0 ) { |
|
989 | + } elseif ($total_change > 0) { |
|
990 | 990 | |
991 | 991 | // Increase the donor's donation stats. |
992 | - $donor->increase_value( $total_change ); |
|
993 | - give_increase_total_earnings( $total_change ); |
|
992 | + $donor->increase_value($total_change); |
|
993 | + give_increase_total_earnings($total_change); |
|
994 | 994 | |
995 | 995 | $donor->increase_purchase_count(); |
996 | 996 | |
997 | 997 | } |
998 | 998 | |
999 | 999 | // Verify and update form meta based on the form status. |
1000 | - give_set_form_closed_status( $this->form_id ); |
|
1000 | + give_set_form_closed_status($this->form_id); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | $this->pending = array(); |
1004 | 1004 | $saved = true; |
1005 | 1005 | }// End if(). |
1006 | 1006 | |
1007 | - if ( true === $saved ) { |
|
1008 | - $this->setup_payment( $this->ID ); |
|
1007 | + if (true === $saved) { |
|
1008 | + $this->setup_payment($this->ID); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | return $saved; |
@@ -1023,12 +1023,12 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @return bool True when successful, false otherwise |
1025 | 1025 | */ |
1026 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1026 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
1027 | 1027 | |
1028 | - $donation = new Give_Donate_Form( $form_id ); |
|
1028 | + $donation = new Give_Donate_Form($form_id); |
|
1029 | 1029 | |
1030 | 1030 | // Bail if this post isn't a give donation form. |
1031 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
1031 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
1032 | 1032 | return false; |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1038,59 +1038,59 @@ discard block |
||
1038 | 1038 | 'price_id' => false, |
1039 | 1039 | ); |
1040 | 1040 | |
1041 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
1041 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
1042 | 1042 | |
1043 | 1043 | // Allow overriding the price. |
1044 | - if ( false !== $args['price'] ) { |
|
1044 | + if (false !== $args['price']) { |
|
1045 | 1045 | $donation_amount = $args['price']; |
1046 | 1046 | } else { |
1047 | 1047 | |
1048 | 1048 | // Deal with variable pricing. |
1049 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
1050 | - $prices = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1049 | + if (give_has_variable_prices($donation->ID)) { |
|
1050 | + $prices = give_get_meta($form_id, '_give_donation_levels', true); |
|
1051 | 1051 | $donation_amount = ''; |
1052 | 1052 | // Loop through prices. |
1053 | - foreach ( $prices as $price ) { |
|
1053 | + foreach ($prices as $price) { |
|
1054 | 1054 | // Find a match between price_id and level_id. |
1055 | 1055 | // First verify array keys exists THEN make the match. |
1056 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
1056 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
1057 | 1057 | && $args['price_id'] == $price['_give_id']['level_id'] |
1058 | 1058 | ) { |
1059 | 1059 | $donation_amount = $price['_give_amount']; |
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | // Fallback to the lowest price point. |
1063 | - if ( $donation_amount == '' ) { |
|
1064 | - $donation_amount = give_get_lowest_price_option( $donation->ID ); |
|
1065 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1063 | + if ($donation_amount == '') { |
|
1064 | + $donation_amount = give_get_lowest_price_option($donation->ID); |
|
1065 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1066 | 1066 | } |
1067 | 1067 | } else { |
1068 | 1068 | // Simple form price. |
1069 | - $donation_amount = give_get_form_price( $donation->ID ); |
|
1069 | + $donation_amount = give_get_form_price($donation->ID); |
|
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | // Sanitizing the price here so we don't have a dozen calls later. |
1074 | - $donation_amount = give_maybe_sanitize_amount( $donation_amount ); |
|
1075 | - $total = round( $donation_amount, give_get_price_decimals( $this->ID ) ); |
|
1074 | + $donation_amount = give_maybe_sanitize_amount($donation_amount); |
|
1075 | + $total = round($donation_amount, give_get_price_decimals($this->ID)); |
|
1076 | 1076 | |
1077 | 1077 | // Add Options. |
1078 | 1078 | $default_options = array(); |
1079 | - if ( false !== $args['price_id'] ) { |
|
1079 | + if (false !== $args['price_id']) { |
|
1080 | 1080 | $default_options['price_id'] = (int) $args['price_id']; |
1081 | 1081 | } |
1082 | - $options = wp_parse_args( $options, $default_options ); |
|
1082 | + $options = wp_parse_args($options, $default_options); |
|
1083 | 1083 | |
1084 | 1084 | // Do not allow totals to go negative. |
1085 | - if ( $total < 0 ) { |
|
1085 | + if ($total < 0) { |
|
1086 | 1086 | $total = 0; |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | $donation = array( |
1090 | 1090 | 'name' => $donation->post_title, |
1091 | 1091 | 'id' => $donation->ID, |
1092 | - 'price' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1093 | - 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1092 | + 'price' => round($total, give_get_price_decimals($this->ID)), |
|
1093 | + 'subtotal' => round($total, give_get_price_decimals($this->ID)), |
|
1094 | 1094 | 'price_id' => $args['price_id'], |
1095 | 1095 | 'action' => 'add', |
1096 | 1096 | 'options' => $options, |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | $this->pending['donations'][] = $donation; |
1100 | 1100 | |
1101 | - $this->increase_subtotal( $total ); |
|
1101 | + $this->increase_subtotal($total); |
|
1102 | 1102 | |
1103 | 1103 | return true; |
1104 | 1104 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * |
1116 | 1116 | * @return bool If the item was removed or not |
1117 | 1117 | */ |
1118 | - public function remove_donation( $form_id, $args = array() ) { |
|
1118 | + public function remove_donation($form_id, $args = array()) { |
|
1119 | 1119 | |
1120 | 1120 | // Set some defaults. |
1121 | 1121 | $defaults = array( |
@@ -1123,12 +1123,12 @@ discard block |
||
1123 | 1123 | 'price' => false, |
1124 | 1124 | 'price_id' => false, |
1125 | 1125 | ); |
1126 | - $args = wp_parse_args( $args, $defaults ); |
|
1126 | + $args = wp_parse_args($args, $defaults); |
|
1127 | 1127 | |
1128 | - $form = new Give_Donate_Form( $form_id ); |
|
1128 | + $form = new Give_Donate_Form($form_id); |
|
1129 | 1129 | |
1130 | 1130 | // Bail if this post isn't a valid give donation form. |
1131 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1131 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1132 | 1132 | return false; |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | $this->pending['donations'][] = $pending_args; |
1143 | 1143 | |
1144 | - $this->decrease_subtotal( $this->total ); |
|
1144 | + $this->decrease_subtotal($this->total); |
|
1145 | 1145 | |
1146 | 1146 | return true; |
1147 | 1147 | } |
@@ -1157,13 +1157,13 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @return bool If the note was specified or not |
1159 | 1159 | */ |
1160 | - public function add_note( $note = false ) { |
|
1160 | + public function add_note($note = false) { |
|
1161 | 1161 | // Bail if no note specified. |
1162 | - if ( ! $note ) { |
|
1162 | + if ( ! $note) { |
|
1163 | 1163 | return false; |
1164 | 1164 | } |
1165 | 1165 | |
1166 | - give_insert_payment_note( $this->ID, $note ); |
|
1166 | + give_insert_payment_note($this->ID, $note); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1176,8 +1176,8 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @return void |
1178 | 1178 | */ |
1179 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1180 | - $amount = (float) $amount; |
|
1179 | + private function increase_subtotal($amount = 0.00) { |
|
1180 | + $amount = (float) $amount; |
|
1181 | 1181 | $this->subtotal += $amount; |
1182 | 1182 | |
1183 | 1183 | $this->recalculate_total(); |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | * |
1194 | 1194 | * @return void |
1195 | 1195 | */ |
1196 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1197 | - $amount = (float) $amount; |
|
1196 | + private function decrease_subtotal($amount = 0.00) { |
|
1197 | + $amount = (float) $amount; |
|
1198 | 1198 | $this->subtotal -= $amount; |
1199 | 1199 | |
1200 | - if ( $this->subtotal < 0 ) { |
|
1200 | + if ($this->subtotal < 0) { |
|
1201 | 1201 | $this->subtotal = 0; |
1202 | 1202 | } |
1203 | 1203 | |
@@ -1227,24 +1227,24 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return bool $updated Returns if the status was successfully updated. |
1229 | 1229 | */ |
1230 | - public function update_status( $status = false ) { |
|
1230 | + public function update_status($status = false) { |
|
1231 | 1231 | |
1232 | 1232 | // standardize the 'complete(d)' status. |
1233 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1233 | + if ($status == 'completed' || $status == 'complete') { |
|
1234 | 1234 | $status = 'publish'; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1237 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1238 | 1238 | |
1239 | - if ( $old_status === $status ) { |
|
1239 | + if ($old_status === $status) { |
|
1240 | 1240 | return false; // Don't permit status changes that aren't changes. |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1243 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1244 | 1244 | |
1245 | 1245 | $updated = false; |
1246 | 1246 | |
1247 | - if ( $do_change ) { |
|
1247 | + if ($do_change) { |
|
1248 | 1248 | |
1249 | 1249 | /** |
1250 | 1250 | * Fires before changing payment status. |
@@ -1255,21 +1255,21 @@ discard block |
||
1255 | 1255 | * @param string $status The new status. |
1256 | 1256 | * @param string $old_status The old status. |
1257 | 1257 | */ |
1258 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1258 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1259 | 1259 | |
1260 | 1260 | $update_fields = array( |
1261 | 1261 | 'ID' => $this->ID, |
1262 | 1262 | 'post_status' => $status, |
1263 | - 'edit_date' => current_time( 'mysql' ), |
|
1263 | + 'edit_date' => current_time('mysql'), |
|
1264 | 1264 | ); |
1265 | 1265 | |
1266 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1266 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1267 | 1267 | |
1268 | 1268 | $all_payment_statuses = give_get_payment_statuses(); |
1269 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1269 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1270 | 1270 | |
1271 | 1271 | // Process any specific status functions. |
1272 | - $this->process_status( $status ); |
|
1272 | + $this->process_status($status); |
|
1273 | 1273 | |
1274 | 1274 | /** |
1275 | 1275 | * Fires after changing payment status. |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | * @param string $status The new status. |
1281 | 1281 | * @param string $old_status The old status. |
1282 | 1282 | */ |
1283 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1283 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1284 | 1284 | |
1285 | 1285 | }// End if(). |
1286 | 1286 | |
@@ -1315,24 +1315,24 @@ discard block |
||
1315 | 1315 | * |
1316 | 1316 | * @return mixed The value from the post meta |
1317 | 1317 | */ |
1318 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1319 | - if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) { |
|
1320 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
1318 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1319 | + if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) { |
|
1320 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1323 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1324 | 1324 | |
1325 | 1325 | /** |
1326 | 1326 | * Filter the specific meta key value. |
1327 | 1327 | * |
1328 | 1328 | * @since 1.5 |
1329 | 1329 | */ |
1330 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1330 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1331 | 1331 | |
1332 | 1332 | // Security check. |
1333 | - if ( is_serialized( $meta ) ) { |
|
1334 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches ); |
|
1335 | - if ( ! empty( $matches ) ) { |
|
1333 | + if (is_serialized($meta)) { |
|
1334 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches); |
|
1335 | + if ( ! empty($matches)) { |
|
1336 | 1336 | $meta = array(); |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * |
1343 | 1343 | * @since 1.5 |
1344 | 1344 | */ |
1345 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1345 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | /** |
@@ -1357,8 +1357,8 @@ discard block |
||
1357 | 1357 | * |
1358 | 1358 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1359 | 1359 | */ |
1360 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1361 | - if ( empty( $meta_key ) ) { |
|
1360 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1361 | + if (empty($meta_key)) { |
|
1362 | 1362 | return false; |
1363 | 1363 | } |
1364 | 1364 | |
@@ -1368,9 +1368,9 @@ discard block |
||
1368 | 1368 | * |
1369 | 1369 | * @since 1.5 |
1370 | 1370 | */ |
1371 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1371 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1372 | 1372 | |
1373 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1373 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | /** |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | * |
1384 | 1384 | * @return void |
1385 | 1385 | */ |
1386 | - private function process_status( $status ) { |
|
1386 | + private function process_status($status) { |
|
1387 | 1387 | $process = true; |
1388 | 1388 | |
1389 | 1389 | // Bailout, if changed from completed to preapproval/processing. |
@@ -1398,9 +1398,9 @@ discard block |
||
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1401 | - $process = apply_filters( "give_should_process_{$status}", $process, $this ); |
|
1401 | + $process = apply_filters("give_should_process_{$status}", $process, $this); |
|
1402 | 1402 | |
1403 | - if ( false === $process ) { |
|
1403 | + if (false === $process) { |
|
1404 | 1404 | return; |
1405 | 1405 | } |
1406 | 1406 | |
@@ -1411,13 +1411,13 @@ discard block |
||
1411 | 1411 | * |
1412 | 1412 | * @since 1.5 |
1413 | 1413 | */ |
1414 | - do_action( "give_pre_{$status}_payment", $this ); |
|
1414 | + do_action("give_pre_{$status}_payment", $this); |
|
1415 | 1415 | |
1416 | - $decrease_earnings = apply_filters( "give_decrease_earnings_on_{$status}", true, $this ); |
|
1417 | - $decrease_donor_value = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this ); |
|
1418 | - $decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this ); |
|
1416 | + $decrease_earnings = apply_filters("give_decrease_earnings_on_{$status}", true, $this); |
|
1417 | + $decrease_donor_value = apply_filters("give_decrease_donor_value_on_{$status}", true, $this); |
|
1418 | + $decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this); |
|
1419 | 1419 | |
1420 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1420 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1421 | 1421 | $this->delete_sales_logs(); |
1422 | 1422 | |
1423 | 1423 | // @todo: Refresh only range related stat cache |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @since 1.5 |
1432 | 1432 | */ |
1433 | - do_action( "give_post_{$status}_payment", $this ); |
|
1433 | + do_action("give_post_{$status}_payment", $this); |
|
1434 | 1434 | } |
1435 | 1435 | |
1436 | 1436 | /** |
@@ -1445,25 +1445,25 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @return void |
1447 | 1447 | */ |
1448 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1448 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1449 | 1449 | |
1450 | - give_undo_donation( $this->ID ); |
|
1450 | + give_undo_donation($this->ID); |
|
1451 | 1451 | |
1452 | 1452 | // Decrease store earnings. |
1453 | - if ( true === $alter_store_earnings ) { |
|
1454 | - give_decrease_total_earnings( $this->total ); |
|
1453 | + if (true === $alter_store_earnings) { |
|
1454 | + give_decrease_total_earnings($this->total); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | // Decrement the stats for the donor. |
1458 | - if ( ! empty( $this->customer_id ) ) { |
|
1458 | + if ( ! empty($this->customer_id)) { |
|
1459 | 1459 | |
1460 | - $donor = new Give_Donor( $this->customer_id ); |
|
1460 | + $donor = new Give_Donor($this->customer_id); |
|
1461 | 1461 | |
1462 | - if ( true === $alter_customer_value ) { |
|
1463 | - $donor->decrease_value( $this->total ); |
|
1462 | + if (true === $alter_customer_value) { |
|
1463 | + $donor->decrease_value($this->total); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | - if ( true === $alter_customer_purchase_count ) { |
|
1466 | + if (true === $alter_customer_purchase_count) { |
|
1467 | 1467 | $donor->decrease_donation_count(); |
1468 | 1468 | } |
1469 | 1469 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | */ |
1481 | 1481 | private function delete_sales_logs() { |
1482 | 1482 | // Remove related sale log entries. |
1483 | - Give()->logs->delete_logs( $this->ID ); |
|
1483 | + Give()->logs->delete_logs($this->ID); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1501,13 +1501,13 @@ discard block |
||
1501 | 1501 | * @return string The date the payment was completed |
1502 | 1502 | */ |
1503 | 1503 | private function setup_completed_date() { |
1504 | - $payment = get_post( $this->ID ); |
|
1504 | + $payment = get_post($this->ID); |
|
1505 | 1505 | |
1506 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1506 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1507 | 1507 | return false; // This payment was never completed. |
1508 | 1508 | } |
1509 | 1509 | |
1510 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1510 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1511 | 1511 | |
1512 | 1512 | return $date; |
1513 | 1513 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
1521 | 1521 | * @return string The payment mode |
1522 | 1522 | */ |
1523 | 1523 | private function setup_mode() { |
1524 | - return $this->get_meta( '_give_payment_mode' ); |
|
1524 | + return $this->get_meta('_give_payment_mode'); |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
@@ -1533,7 +1533,7 @@ discard block |
||
1533 | 1533 | * @return bool The payment import |
1534 | 1534 | */ |
1535 | 1535 | private function setup_import() { |
1536 | - return (bool) $this->get_meta( '_give_payment_import' ); |
|
1536 | + return (bool) $this->get_meta('_give_payment_import'); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | /** |
@@ -1545,9 +1545,9 @@ discard block |
||
1545 | 1545 | * @return float The payment total |
1546 | 1546 | */ |
1547 | 1547 | private function setup_total() { |
1548 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1548 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1549 | 1549 | |
1550 | - return round( floatval( $amount ), give_get_price_decimals( $this->ID ) ); |
|
1550 | + return round(floatval($amount), give_get_price_decimals($this->ID)); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | /** |
@@ -1574,17 +1574,16 @@ discard block |
||
1574 | 1574 | * @return string The currency for the payment |
1575 | 1575 | */ |
1576 | 1576 | private function setup_currency() { |
1577 | - $currency = $this->get_meta( '_give_payment_currency', true ); |
|
1578 | - $currency = ! empty( $currency ) ? |
|
1579 | - $currency : |
|
1580 | - /** |
|
1577 | + $currency = $this->get_meta('_give_payment_currency', true); |
|
1578 | + $currency = ! empty($currency) ? |
|
1579 | + $currency : /** |
|
1581 | 1580 | * Filter the default donation currency |
1582 | 1581 | * |
1583 | 1582 | * @since 1.5 |
1584 | 1583 | */ |
1585 | 1584 | apply_filters( |
1586 | 1585 | 'give_payment_currency_default', |
1587 | - give_get_currency( $this->form_id, $this ), |
|
1586 | + give_get_currency($this->form_id, $this), |
|
1588 | 1587 | $this |
1589 | 1588 | ); |
1590 | 1589 | |
@@ -1600,7 +1599,7 @@ discard block |
||
1600 | 1599 | * @return string The gateway |
1601 | 1600 | */ |
1602 | 1601 | private function setup_gateway() { |
1603 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1602 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1604 | 1603 | |
1605 | 1604 | return $gateway; |
1606 | 1605 | } |
@@ -1614,11 +1613,11 @@ discard block |
||
1614 | 1613 | * @return string The donation ID |
1615 | 1614 | */ |
1616 | 1615 | private function setup_transaction_id() { |
1617 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1616 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1618 | 1617 | |
1619 | - if ( empty( $transaction_id ) ) { |
|
1618 | + if (empty($transaction_id)) { |
|
1620 | 1619 | $gateway = $this->gateway; |
1621 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1620 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1622 | 1621 | } |
1623 | 1622 | |
1624 | 1623 | return $transaction_id; |
@@ -1634,7 +1633,7 @@ discard block |
||
1634 | 1633 | * @return string The IP address for the payment |
1635 | 1634 | */ |
1636 | 1635 | private function setup_ip() { |
1637 | - $ip = $this->get_meta( '_give_payment_donor_ip', true ); |
|
1636 | + $ip = $this->get_meta('_give_payment_donor_ip', true); |
|
1638 | 1637 | |
1639 | 1638 | return $ip; |
1640 | 1639 | } |
@@ -1649,7 +1648,7 @@ discard block |
||
1649 | 1648 | * @return int The Donor ID. |
1650 | 1649 | */ |
1651 | 1650 | private function setup_donor_id() { |
1652 | - $donor_id = $this->get_meta( '_give_payment_donor_id', true ); |
|
1651 | + $donor_id = $this->get_meta('_give_payment_donor_id', true); |
|
1653 | 1652 | |
1654 | 1653 | return $donor_id; |
1655 | 1654 | } |
@@ -1666,8 +1665,8 @@ discard block |
||
1666 | 1665 | */ |
1667 | 1666 | private function setup_user_id() { |
1668 | 1667 | |
1669 | - $donor = Give()->customers->get_customer_by( 'id', $this->customer_id ); |
|
1670 | - $user_id = $donor ? absint( $donor->user_id ) : 0; |
|
1668 | + $donor = Give()->customers->get_customer_by('id', $this->customer_id); |
|
1669 | + $user_id = $donor ? absint($donor->user_id) : 0; |
|
1671 | 1670 | |
1672 | 1671 | |
1673 | 1672 | return $user_id; |
@@ -1684,10 +1683,10 @@ discard block |
||
1684 | 1683 | * @return string The email address for the payment. |
1685 | 1684 | */ |
1686 | 1685 | private function setup_email() { |
1687 | - $email = $this->get_meta( '_give_payment_donor_email', true ); |
|
1686 | + $email = $this->get_meta('_give_payment_donor_email', true); |
|
1688 | 1687 | |
1689 | - if ( empty( $email ) && $this->customer_id ) { |
|
1690 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1688 | + if (empty($email) && $this->customer_id) { |
|
1689 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1691 | 1690 | } |
1692 | 1691 | |
1693 | 1692 | return $email; |
@@ -1707,22 +1706,22 @@ discard block |
||
1707 | 1706 | 'last_name' => $this->last_name, |
1708 | 1707 | ); |
1709 | 1708 | |
1710 | - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array(); |
|
1709 | + $user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array(); |
|
1711 | 1710 | |
1712 | - if ( is_serialized( $user_info ) ) { |
|
1713 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
1714 | - if ( ! empty( $matches ) ) { |
|
1711 | + if (is_serialized($user_info)) { |
|
1712 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
1713 | + if ( ! empty($matches)) { |
|
1715 | 1714 | $user_info = array(); |
1716 | 1715 | } |
1717 | 1716 | } |
1718 | 1717 | |
1719 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1718 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1720 | 1719 | |
1721 | - if ( empty( $user_info ) ) { |
|
1720 | + if (empty($user_info)) { |
|
1722 | 1721 | // Get the donor, but only if it's been created. |
1723 | - $donor = new Give_Donor( $this->customer_id ); |
|
1722 | + $donor = new Give_Donor($this->customer_id); |
|
1724 | 1723 | |
1725 | - if ( $donor->id > 0 ) { |
|
1724 | + if ($donor->id > 0) { |
|
1726 | 1725 | $user_info = array( |
1727 | 1726 | 'first_name' => $donor->get_first_name(), |
1728 | 1727 | 'last_name' => $donor->get_last_name(), |
@@ -1732,25 +1731,25 @@ discard block |
||
1732 | 1731 | } |
1733 | 1732 | } else { |
1734 | 1733 | // Get the donor, but only if it's been created. |
1735 | - $donor = new Give_Donor( $this->customer_id ); |
|
1734 | + $donor = new Give_Donor($this->customer_id); |
|
1736 | 1735 | |
1737 | - if ( $donor->id > 0 ) { |
|
1738 | - foreach ( $user_info as $key => $value ) { |
|
1739 | - if ( ! empty( $value ) ) { |
|
1736 | + if ($donor->id > 0) { |
|
1737 | + foreach ($user_info as $key => $value) { |
|
1738 | + if ( ! empty($value)) { |
|
1740 | 1739 | continue; |
1741 | 1740 | } |
1742 | 1741 | |
1743 | - switch ( $key ) { |
|
1742 | + switch ($key) { |
|
1744 | 1743 | case 'first_name': |
1745 | - $user_info[ $key ] = $donor->get_first_name(); |
|
1744 | + $user_info[$key] = $donor->get_first_name(); |
|
1746 | 1745 | break; |
1747 | 1746 | |
1748 | 1747 | case 'last_name': |
1749 | - $user_info[ $key ] = $donor->get_last_name(); |
|
1748 | + $user_info[$key] = $donor->get_last_name(); |
|
1750 | 1749 | break; |
1751 | 1750 | |
1752 | 1751 | case 'email': |
1753 | - $user_info[ $key ] = $donor->email; |
|
1752 | + $user_info[$key] = $donor->email; |
|
1754 | 1753 | break; |
1755 | 1754 | } |
1756 | 1755 | } |
@@ -1770,12 +1769,12 @@ discard block |
||
1770 | 1769 | * @return array The Address information for the payment. |
1771 | 1770 | */ |
1772 | 1771 | private function setup_address() { |
1773 | - $address['line1'] = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' ); |
|
1774 | - $address['line2'] = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' ); |
|
1775 | - $address['city'] = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' ); |
|
1776 | - $address['state'] = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' ); |
|
1777 | - $address['zip'] = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' ); |
|
1778 | - $address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' ); |
|
1772 | + $address['line1'] = give_get_meta($this->ID, '_give_donor_billing_address1', true, ''); |
|
1773 | + $address['line2'] = give_get_meta($this->ID, '_give_donor_billing_address2', true, ''); |
|
1774 | + $address['city'] = give_get_meta($this->ID, '_give_donor_billing_city', true, ''); |
|
1775 | + $address['state'] = give_get_meta($this->ID, '_give_donor_billing_state', true, ''); |
|
1776 | + $address['zip'] = give_get_meta($this->ID, '_give_donor_billing_zip', true, ''); |
|
1777 | + $address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, ''); |
|
1779 | 1778 | |
1780 | 1779 | return $address; |
1781 | 1780 | } |
@@ -1790,7 +1789,7 @@ discard block |
||
1790 | 1789 | */ |
1791 | 1790 | private function setup_form_title() { |
1792 | 1791 | |
1793 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1792 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1794 | 1793 | |
1795 | 1794 | return $form_id; |
1796 | 1795 | } |
@@ -1805,7 +1804,7 @@ discard block |
||
1805 | 1804 | */ |
1806 | 1805 | private function setup_form_id() { |
1807 | 1806 | |
1808 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1807 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1809 | 1808 | |
1810 | 1809 | return $form_id; |
1811 | 1810 | } |
@@ -1819,7 +1818,7 @@ discard block |
||
1819 | 1818 | * @return int The Form Price ID. |
1820 | 1819 | */ |
1821 | 1820 | private function setup_price_id() { |
1822 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1821 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1823 | 1822 | |
1824 | 1823 | return $price_id; |
1825 | 1824 | } |
@@ -1833,7 +1832,7 @@ discard block |
||
1833 | 1832 | * @return string The Payment Key. |
1834 | 1833 | */ |
1835 | 1834 | private function setup_payment_key() { |
1836 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1835 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1837 | 1836 | |
1838 | 1837 | return $key; |
1839 | 1838 | } |
@@ -1858,7 +1857,7 @@ discard block |
||
1858 | 1857 | * @return array The payment object as an array. |
1859 | 1858 | */ |
1860 | 1859 | public function array_convert() { |
1861 | - return get_object_vars( $this ); |
|
1860 | + return get_object_vars($this); |
|
1862 | 1861 | } |
1863 | 1862 | |
1864 | 1863 | |
@@ -1871,7 +1870,7 @@ discard block |
||
1871 | 1870 | * @return bool |
1872 | 1871 | */ |
1873 | 1872 | public function is_completed() { |
1874 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1873 | + return ('publish' === $this->status && $this->completed_date); |
|
1875 | 1874 | } |
1876 | 1875 | |
1877 | 1876 | /** |
@@ -1883,7 +1882,7 @@ discard block |
||
1883 | 1882 | * @return string Date payment was completed. |
1884 | 1883 | */ |
1885 | 1884 | private function get_completed_date() { |
1886 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1885 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1887 | 1886 | } |
1888 | 1887 | |
1889 | 1888 | /** |
@@ -1895,7 +1894,7 @@ discard block |
||
1895 | 1894 | * @return float Payment subtotal. |
1896 | 1895 | */ |
1897 | 1896 | private function get_subtotal() { |
1898 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1897 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1899 | 1898 | } |
1900 | 1899 | |
1901 | 1900 | /** |
@@ -1907,7 +1906,7 @@ discard block |
||
1907 | 1906 | * @return string Payment currency code. |
1908 | 1907 | */ |
1909 | 1908 | private function get_currency() { |
1910 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1909 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1911 | 1910 | } |
1912 | 1911 | |
1913 | 1912 | /** |
@@ -1919,7 +1918,7 @@ discard block |
||
1919 | 1918 | * @return string Gateway used. |
1920 | 1919 | */ |
1921 | 1920 | private function get_gateway() { |
1922 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1921 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1923 | 1922 | } |
1924 | 1923 | |
1925 | 1924 | /** |
@@ -1931,7 +1930,7 @@ discard block |
||
1931 | 1930 | * @return string Donation ID from merchant processor. |
1932 | 1931 | */ |
1933 | 1932 | private function get_transaction_id() { |
1934 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1933 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1935 | 1934 | } |
1936 | 1935 | |
1937 | 1936 | /** |
@@ -1943,7 +1942,7 @@ discard block |
||
1943 | 1942 | * @return string Payment IP address |
1944 | 1943 | */ |
1945 | 1944 | private function get_ip() { |
1946 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
1945 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
1947 | 1946 | } |
1948 | 1947 | |
1949 | 1948 | /** |
@@ -1955,7 +1954,7 @@ discard block |
||
1955 | 1954 | * @return int Payment donor ID. |
1956 | 1955 | */ |
1957 | 1956 | private function get_donor_id() { |
1958 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
1957 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
1959 | 1958 | } |
1960 | 1959 | |
1961 | 1960 | /** |
@@ -1967,7 +1966,7 @@ discard block |
||
1967 | 1966 | * @return int Payment user ID. |
1968 | 1967 | */ |
1969 | 1968 | private function get_user_id() { |
1970 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
1969 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
1971 | 1970 | } |
1972 | 1971 | |
1973 | 1972 | /** |
@@ -1979,7 +1978,7 @@ discard block |
||
1979 | 1978 | * @return string Payment donor email. |
1980 | 1979 | */ |
1981 | 1980 | private function get_email() { |
1982 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
1981 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
1983 | 1982 | } |
1984 | 1983 | |
1985 | 1984 | /** |
@@ -1991,7 +1990,7 @@ discard block |
||
1991 | 1990 | * @return array Payment user info. |
1992 | 1991 | */ |
1993 | 1992 | private function get_user_info() { |
1994 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
1993 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
1995 | 1994 | } |
1996 | 1995 | |
1997 | 1996 | /** |
@@ -2003,7 +2002,7 @@ discard block |
||
2003 | 2002 | * @return array Payment billing address. |
2004 | 2003 | */ |
2005 | 2004 | private function get_address() { |
2006 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2005 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2007 | 2006 | } |
2008 | 2007 | |
2009 | 2008 | /** |
@@ -2015,7 +2014,7 @@ discard block |
||
2015 | 2014 | * @return string Payment key. |
2016 | 2015 | */ |
2017 | 2016 | private function get_key() { |
2018 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2017 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2019 | 2018 | } |
2020 | 2019 | |
2021 | 2020 | /** |
@@ -2027,7 +2026,7 @@ discard block |
||
2027 | 2026 | * @return string Payment form id |
2028 | 2027 | */ |
2029 | 2028 | private function get_form_id() { |
2030 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2029 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2031 | 2030 | } |
2032 | 2031 | |
2033 | 2032 | /** |
@@ -2039,7 +2038,7 @@ discard block |
||
2039 | 2038 | * @return int|string Payment number |
2040 | 2039 | */ |
2041 | 2040 | private function get_number() { |
2042 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2041 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2043 | 2042 | } |
2044 | 2043 | |
2045 | 2044 | /** |
@@ -2051,7 +2050,7 @@ discard block |
||
2051 | 2050 | * |
2052 | 2051 | * @return string |
2053 | 2052 | */ |
2054 | - public function get_serial_code( $args = array() ) { |
|
2055 | - return Give()->seq_donation_number->get_serial_code( $this, $args ); |
|
2053 | + public function get_serial_code($args = array()) { |
|
2054 | + return Give()->seq_donation_number->get_serial_code($this, $args); |
|
2056 | 2055 | } |
2057 | 2056 | } |