@@ -162,7 +162,7 @@ |
||
162 | 162 | /** |
163 | 163 | * This function is used to delete donor and related donation without redirection. |
164 | 164 | * |
165 | - * @param int|Give_Donor $donor Donor ID or List of Donor IDs. |
|
165 | + * @param Give_Donor $donor Donor ID or List of Donor IDs. |
|
166 | 166 | * @param array $args List of arguments to handle donor and related donation deletion process. |
167 | 167 | * |
168 | 168 | * @type bool delete_donation Delete donor linked donations if set to true. Default is false. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
80 | + 'title' => __('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return array |
100 | 100 | */ |
101 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
101 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
102 | 102 | |
103 | 103 | $donor_id = $donor->id; |
104 | 104 | $previous_user_id = $donor->user_id; |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @since 1.0 |
114 | 114 | */ |
115 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
115 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
116 | 116 | |
117 | 117 | $output = array(); |
118 | 118 | |
119 | - if ( $donor->update( $donor_data ) ) { |
|
119 | + if ($donor->update($donor_data)) { |
|
120 | 120 | |
121 | 121 | // Create and Update Donor First Name and Last Name in Meta Fields. |
122 | - $donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] ); |
|
123 | - $donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] ); |
|
124 | - $donor->update_meta( '_give_donor_title_prefix', $donor_data['title'] ); |
|
122 | + $donor->update_meta('_give_donor_first_name', $donor_data['first_name']); |
|
123 | + $donor->update_meta('_give_donor_last_name', $donor_data['last_name']); |
|
124 | + $donor->update_meta('_give_donor_title_prefix', $donor_data['title']); |
|
125 | 125 | |
126 | 126 | // Fetch disconnected user id, if exists. |
127 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
127 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
128 | 128 | |
129 | 129 | // Flag User and Donor Disconnection. |
130 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
130 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
131 | 131 | |
132 | 132 | // Check whether the disconnected user id and the reconnected user id are same or not. |
133 | 133 | // If both are same then delete user id store in donor meta. |
134 | - if ( $donor_data['user_id'] === $disconnected_user_id ) { |
|
135 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
136 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
134 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
135 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
136 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $output['success'] = true; |
140 | - $donor_data = array_merge( $donor_data, $address ); |
|
140 | + $donor_data = array_merge($donor_data, $address); |
|
141 | 141 | $output['customer_info'] = $donor_data; |
142 | 142 | |
143 | 143 | } else { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
157 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
158 | 158 | |
159 | 159 | return $output; |
160 | 160 | } |
@@ -171,39 +171,39 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return int |
173 | 173 | */ |
174 | -function give_delete_donor_and_related_donation( $donor, $args = array() ) { |
|
174 | +function give_delete_donor_and_related_donation($donor, $args = array()) { |
|
175 | 175 | |
176 | 176 | // Default Arguments. |
177 | 177 | $default_args = array( |
178 | 178 | 'delete_donation' => false, |
179 | 179 | ); |
180 | 180 | |
181 | - $args = wp_parse_args( $args, $default_args ); |
|
181 | + $args = wp_parse_args($args, $default_args); |
|
182 | 182 | |
183 | 183 | // If $donor not an instance of Give_Donor then create one. |
184 | - if ( ! $donor instanceof Give_Donor ) { |
|
185 | - $donor = new Give_Donor( $donor ); |
|
184 | + if ( ! $donor instanceof Give_Donor) { |
|
185 | + $donor = new Give_Donor($donor); |
|
186 | 186 | } |
187 | 187 | |
188 | - if ( $donor->id > 0 ) { |
|
188 | + if ($donor->id > 0) { |
|
189 | 189 | |
190 | 190 | // Delete Donor. |
191 | - $donor_deleted = Give()->donors->delete( $donor->id ); |
|
191 | + $donor_deleted = Give()->donors->delete($donor->id); |
|
192 | 192 | |
193 | 193 | // Fetch linked donations of a particular donor. |
194 | - $donation_ids = explode( ',', $donor->payment_ids ); |
|
194 | + $donation_ids = explode(',', $donor->payment_ids); |
|
195 | 195 | |
196 | 196 | // Proceed to delete related donation, if user opted and donor is deleted successfully. |
197 | - if ( $donor_deleted && $args['delete_donation'] ) { |
|
198 | - foreach ( $donation_ids as $donation_id ) { |
|
199 | - give_delete_donation( $donation_id ); |
|
197 | + if ($donor_deleted && $args['delete_donation']) { |
|
198 | + foreach ($donation_ids as $donation_id) { |
|
199 | + give_delete_donation($donation_id); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return 2; // Donor and linked Donations deleted. |
203 | 203 | |
204 | 204 | } else { |
205 | - foreach ( $donation_ids as $donation_id ) { |
|
206 | - give_update_payment_meta( $donation_id, '_give_payment_donor_id', 0 ); |
|
205 | + foreach ($donation_ids as $donation_id) { |
|
206 | + give_update_payment_meta($donation_id, '_give_payment_donor_id', 0); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 |
@@ -290,7 +290,7 @@ |
||
290 | 290 | * |
291 | 291 | * @since 1.8.12 |
292 | 292 | * |
293 | - * @return int |
|
293 | + * @return double |
|
294 | 294 | */ |
295 | 295 | public function get_percentage_complete() { |
296 | 296 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -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 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param int $_step Steps. |
136 | 136 | */ |
137 | - public function __construct( $_step = 1 ) { |
|
138 | - parent::__construct( $_step ); |
|
137 | + public function __construct($_step = 1) { |
|
138 | + parent::__construct($_step); |
|
139 | 139 | |
140 | 140 | $this->is_writable = true; |
141 | 141 | } |
@@ -154,38 +154,38 @@ discard block |
||
154 | 154 | $donor_ids = array(); |
155 | 155 | |
156 | 156 | // Check if the ajax request if running for the first time. |
157 | - if ( 1 === (int) $this->step ) { |
|
157 | + if (1 === (int) $this->step) { |
|
158 | 158 | |
159 | 159 | // Delete all the form ids. |
160 | - $this->delete_option( $this->form_key ); |
|
160 | + $this->delete_option($this->form_key); |
|
161 | 161 | |
162 | 162 | // Delete all the donation ids. |
163 | - $this->delete_option( $this->donation_key ); |
|
163 | + $this->delete_option($this->donation_key); |
|
164 | 164 | |
165 | 165 | // Delete all the donor ids. |
166 | - $this->delete_option( $this->donor_key ); |
|
166 | + $this->delete_option($this->donor_key); |
|
167 | 167 | |
168 | 168 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
169 | - $this->update_option( $this->step_key, 'count' ); |
|
169 | + $this->update_option($this->step_key, 'count'); |
|
170 | 170 | |
171 | 171 | // Delete tha page count of the step. |
172 | - $this->update_option( $this->step_on_key, '0' ); |
|
172 | + $this->update_option($this->step_on_key, '0'); |
|
173 | 173 | } else { |
174 | 174 | |
175 | 175 | // Get the old donors list. |
176 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
176 | + $donor_ids = $this->get_option($this->donor_key); |
|
177 | 177 | |
178 | 178 | // Get the old donation list. |
179 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
179 | + $donation_ids = $this->get_option($this->donation_key); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
183 | 183 | $step = (int) $this->get_step(); |
184 | - if ( 1 === $step ) { |
|
184 | + if (1 === $step) { |
|
185 | 185 | /** |
186 | 186 | * Will add or update the donation and donor data by running wp query. |
187 | 187 | */ |
188 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
188 | + $this->count($step, $donation_ids, $donor_ids); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this. |
197 | 197 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this. |
198 | 198 | */ |
199 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
199 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
200 | 200 | |
201 | 201 | // Get the Page count by default it's zero. |
202 | 202 | $paged = (int) $this->get_step_page(); |
203 | 203 | |
204 | 204 | // Increased the page count by one. |
205 | - ++ $paged; |
|
205 | + ++$paged; |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Filter add to alter the argument before the wp quest run |
209 | 209 | */ |
210 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
210 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
211 | 211 | 'post_type' => 'give_payment', |
212 | 212 | 'post_status' => 'any', |
213 | 213 | 'posts_per_page' => $this->per_step, |
@@ -215,41 +215,41 @@ discard block |
||
215 | 215 | 'meta_key' => '_give_payment_import', |
216 | 216 | 'meta_value_num' => 1, |
217 | 217 | 'meta_compare' => '=', |
218 | - ) ); |
|
218 | + )); |
|
219 | 219 | |
220 | 220 | // Reset the post data. |
221 | 221 | wp_reset_postdata(); |
222 | 222 | |
223 | 223 | // Getting the new donation. |
224 | - $donation_posts = new WP_Query( $args ); |
|
224 | + $donation_posts = new WP_Query($args); |
|
225 | 225 | |
226 | 226 | // The Loop. |
227 | - if ( $donation_posts->have_posts() ) { |
|
228 | - while ( $donation_posts->have_posts() ) { |
|
227 | + if ($donation_posts->have_posts()) { |
|
228 | + while ($donation_posts->have_posts()) { |
|
229 | 229 | $add_author = true; |
230 | 230 | $donation_posts->the_post(); |
231 | 231 | global $post; |
232 | 232 | // Add the donation id in side the array. |
233 | 233 | $donation_ids[] = $post->ID; |
234 | 234 | |
235 | - $donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true ); |
|
236 | - if ( ! empty( $donor_id ) ) { |
|
237 | - $donor = new Give_Donor( $donor_id ); |
|
238 | - if ( ! empty( $donor->id ) ) { |
|
239 | - if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) { |
|
235 | + $donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true); |
|
236 | + if ( ! empty($donor_id)) { |
|
237 | + $donor = new Give_Donor($donor_id); |
|
238 | + if ( ! empty($donor->id)) { |
|
239 | + if (empty($donor->user_id) && ! empty($donor->payment_ids)) { |
|
240 | 240 | $add_author = false; |
241 | - $count = (int) count( $donor->payment_ids ); |
|
242 | - if ( 1 === $count ) { |
|
243 | - give_delete_donor_and_related_donation( $donor ); |
|
241 | + $count = (int) count($donor->payment_ids); |
|
242 | + if (1 === $count) { |
|
243 | + give_delete_donor_and_related_donation($donor); |
|
244 | 244 | } else { |
245 | - $donor->remove_payment( $post->ID ); |
|
245 | + $donor->remove_payment($post->ID); |
|
246 | 246 | $donor->decrease_donation_count(); |
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - if ( ! empty( $add_author ) ) { |
|
252 | + if ( ! empty($add_author)) { |
|
253 | 253 | // Add the donor id in side the array. |
254 | 254 | $donor_ids[] = (int) $post->post_author; |
255 | 255 | } |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | $max_num_pages = (int) $donation_posts->max_num_pages; |
264 | 264 | |
265 | 265 | // Check current page is less then max number of page or not. |
266 | - if ( $paged < $max_num_pages ) { |
|
266 | + if ($paged < $max_num_pages) { |
|
267 | 267 | |
268 | 268 | // Update the current page variable for the next step. |
269 | - $this->update_option( $this->step_on_key, $paged ); |
|
269 | + $this->update_option($this->step_on_key, $paged); |
|
270 | 270 | |
271 | 271 | // Calculating percentage. |
272 | 272 | $page_remain = $max_num_pages - $paged; |
273 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
273 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
274 | 274 | $this->step_completed = $paged; |
275 | 275 | } else { |
276 | - $donation_ids_count = count( $donor_ids ); |
|
277 | - $this->update_option( $this->step_key, 'donation' ); |
|
278 | - $this->update_option( $this->step_on_key, '0' ); |
|
276 | + $donation_ids_count = count($donor_ids); |
|
277 | + $this->update_option($this->step_key, 'donation'); |
|
278 | + $this->update_option($this->step_on_key, '0'); |
|
279 | 279 | } |
280 | 280 | |
281 | - $donor_ids = array_unique( $donor_ids ); |
|
282 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
283 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
281 | + $donor_ids = array_unique($donor_ids); |
|
282 | + $this->update_option($this->donor_key, $donor_ids); |
|
283 | + $this->update_option($this->donation_key, $donation_ids); |
|
284 | 284 | |
285 | 285 | wp_reset_postdata(); |
286 | 286 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @return int |
294 | 294 | */ |
295 | 295 | public function get_percentage_complete() { |
296 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
296 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function process_step() { |
305 | 305 | |
306 | - if ( ! $this->can_export() ) { |
|
306 | + if ( ! $this->can_export()) { |
|
307 | 307 | wp_die( |
308 | - esc_html__( 'You do not have permission to delete Import transactions.', 'give' ), |
|
309 | - esc_html__( 'Error', 'give' ), |
|
308 | + esc_html__('You do not have permission to delete Import transactions.', 'give'), |
|
309 | + esc_html__('Error', 'give'), |
|
310 | 310 | array( |
311 | 311 | 'response' => 403, |
312 | 312 | ) |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | |
316 | 316 | $had_data = $this->get_data(); |
317 | 317 | |
318 | - if ( $had_data ) { |
|
318 | + if ($had_data) { |
|
319 | 319 | $this->done = false; |
320 | 320 | |
321 | 321 | return true; |
322 | 322 | } else { |
323 | - update_option( 'give_earnings_total', give_get_total_earnings( true ), false ); |
|
324 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
323 | + update_option('give_earnings_total', give_get_total_earnings(true), false); |
|
324 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
325 | 325 | |
326 | - $this->delete_option( $this->donation_key ); |
|
326 | + $this->delete_option($this->donation_key); |
|
327 | 327 | |
328 | 328 | $this->done = true; |
329 | - $this->message = __( 'Imported donor and transactions successfully deleted.', 'give' ); |
|
329 | + $this->message = __('Imported donor and transactions successfully deleted.', 'give'); |
|
330 | 330 | |
331 | 331 | return false; |
332 | 332 | } |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | public function get_data() { |
345 | 345 | |
346 | 346 | // Get the donation id's. |
347 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
347 | + $donation_ids = $this->get_option($this->donation_key); |
|
348 | 348 | |
349 | 349 | /** |
350 | 350 | * Return false id not Import donation is found. |
351 | 351 | */ |
352 | - if ( empty( $donation_ids ) ) { |
|
352 | + if (empty($donation_ids)) { |
|
353 | 353 | $this->is_empty = true; |
354 | 354 | $this->total_step = 1; |
355 | 355 | |
@@ -360,110 +360,110 @@ discard block |
||
360 | 360 | $step = (int) $this->get_step(); |
361 | 361 | |
362 | 362 | // Get the donor ids. |
363 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
363 | + $donor_ids = $this->get_option($this->donor_key); |
|
364 | 364 | |
365 | 365 | // Delete all the imported donations. |
366 | - if ( 2 === $step ) { |
|
366 | + if (2 === $step) { |
|
367 | 367 | $pass_to_donor = false; |
368 | 368 | $page = (int) $this->get_step_page(); |
369 | - $page ++; |
|
370 | - $count = count( $donation_ids ); |
|
369 | + $page++; |
|
370 | + $count = count($donation_ids); |
|
371 | 371 | |
372 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
372 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
373 | 373 | $this->step_completed = $page; |
374 | 374 | |
375 | - if ( $count > $this->per_step ) { |
|
375 | + if ($count > $this->per_step) { |
|
376 | 376 | |
377 | - $this->update_option( $this->step_on_key, $page ); |
|
378 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
379 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
377 | + $this->update_option($this->step_on_key, $page); |
|
378 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
379 | + $current_page = (int) ceil($count / $this->per_step); |
|
380 | 380 | |
381 | - if ( $page === $current_page ) { |
|
381 | + if ($page === $current_page) { |
|
382 | 382 | $pass_to_donor = true; |
383 | 383 | } |
384 | 384 | } else { |
385 | 385 | $pass_to_donor = true; |
386 | 386 | } |
387 | 387 | |
388 | - if ( true === $pass_to_donor ) { |
|
389 | - $this->update_option( $this->step_key, 'donor' ); |
|
390 | - $this->update_option( $this->step_on_key, '0' ); |
|
388 | + if (true === $pass_to_donor) { |
|
389 | + $this->update_option($this->step_key, 'donor'); |
|
390 | + $this->update_option($this->step_on_key, '0'); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | // Get the old form list. |
394 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
394 | + $form_ids = (array) $this->get_option($this->form_key); |
|
395 | 395 | |
396 | - foreach ( $donation_ids as $item ) { |
|
397 | - $form_ids[] = give_get_meta( $item, '_give_payment_form_id', true ); |
|
396 | + foreach ($donation_ids as $item) { |
|
397 | + $form_ids[] = give_get_meta($item, '_give_payment_form_id', true); |
|
398 | 398 | |
399 | 399 | // Delete the main payment. |
400 | - give_delete_donation( absint( $item ) ); |
|
400 | + give_delete_donation(absint($item)); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | // Update the new form list. |
404 | - $this->update_option( $this->form_key, $form_ids ); |
|
404 | + $this->update_option($this->form_key, $form_ids); |
|
405 | 405 | } // End if(). |
406 | 406 | |
407 | 407 | // Delete all the donors. |
408 | - if ( 3 === $step ) { |
|
408 | + if (3 === $step) { |
|
409 | 409 | |
410 | 410 | // Get the old form list. |
411 | - $form_ids = (array) $this->get_option( $this->form_key ); |
|
412 | - if ( ! empty( $form_ids ) ) { |
|
413 | - $form_ids = array_unique( $form_ids ); |
|
414 | - foreach ( $form_ids as $form_id ) { |
|
415 | - give_recount_form_income_donation( (int) $form_id ); |
|
411 | + $form_ids = (array) $this->get_option($this->form_key); |
|
412 | + if ( ! empty($form_ids)) { |
|
413 | + $form_ids = array_unique($form_ids); |
|
414 | + foreach ($form_ids as $form_id) { |
|
415 | + give_recount_form_income_donation((int) $form_id); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | // update the new form list. |
419 | - $this->update_option( $this->form_key, array() ); |
|
419 | + $this->update_option($this->form_key, array()); |
|
420 | 420 | |
421 | 421 | $page = (int) $this->get_step_page(); |
422 | - $count = count( $donor_ids ); |
|
422 | + $count = count($donor_ids); |
|
423 | 423 | |
424 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
425 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
424 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
425 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
426 | 426 | |
427 | - if ( ! empty( $donor_ids[ $page ] ) ) { |
|
428 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
427 | + if ( ! empty($donor_ids[$page])) { |
|
428 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
429 | 429 | 'post_status' => 'any', |
430 | 430 | 'posts_per_page' => 1, |
431 | - 'author' => $donor_ids[ $page ], |
|
432 | - ) ); |
|
431 | + 'author' => $donor_ids[$page], |
|
432 | + )); |
|
433 | 433 | |
434 | 434 | $donations = array(); |
435 | - $payments = new Give_Payments_Query( $args ); |
|
435 | + $payments = new Give_Payments_Query($args); |
|
436 | 436 | $payments = $payments->get_payments(); |
437 | - if ( empty( $payments ) ) { |
|
438 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
437 | + if (empty($payments)) { |
|
438 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
439 | 439 | |
440 | 440 | /** |
441 | 441 | * If Checked then delete WP user. |
442 | 442 | * |
443 | 443 | * @since 1.8.14 |
444 | 444 | */ |
445 | - $delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : ''; |
|
445 | + $delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : ''; |
|
446 | 446 | |
447 | - if ( 'on' === (string) $delete_import_donors ) { |
|
448 | - wp_delete_user( $donor_ids[ $page ] ); |
|
447 | + if ('on' === (string) $delete_import_donors) { |
|
448 | + wp_delete_user($donor_ids[$page]); |
|
449 | 449 | } |
450 | 450 | } else { |
451 | - foreach ( $payments as $payment ) { |
|
451 | + foreach ($payments as $payment) { |
|
452 | 452 | $donations[] = $payment->ID; |
453 | 453 | } |
454 | 454 | |
455 | - $donor = new Give_Donor( $donor_ids[ $page ], true ); |
|
455 | + $donor = new Give_Donor($donor_ids[$page], true); |
|
456 | 456 | $data_to_update = array( |
457 | - 'purchase_count' => count( $donations ), |
|
458 | - 'payment_ids' => implode( ',', $donations ), |
|
457 | + 'purchase_count' => count($donations), |
|
458 | + 'payment_ids' => implode(',', $donations), |
|
459 | 459 | ); |
460 | - $donor->update( $data_to_update ); |
|
460 | + $donor->update($data_to_update); |
|
461 | 461 | } |
462 | 462 | } // End if(). |
463 | 463 | |
464 | - $page ++; |
|
465 | - $this->update_option( $this->step_on_key, $page ); |
|
466 | - if ( $count === $page ) { |
|
464 | + $page++; |
|
465 | + $this->update_option($this->step_on_key, $page); |
|
466 | + if ($count === $page) { |
|
467 | 467 | $this->is_empty = false; |
468 | 468 | |
469 | 469 | return false; |
@@ -483,24 +483,24 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return mixed |
485 | 485 | */ |
486 | - public function get_delete_ids( $donation_ids, $page ) { |
|
487 | - $index = $page --; |
|
488 | - $count = count( $donation_ids ); |
|
486 | + public function get_delete_ids($donation_ids, $page) { |
|
487 | + $index = $page--; |
|
488 | + $count = count($donation_ids); |
|
489 | 489 | $temp = 0; |
490 | 490 | $current_page = 0; |
491 | 491 | $post_delete = $this->per_step; |
492 | 492 | $page_donation_id = array(); |
493 | 493 | |
494 | - foreach ( $donation_ids as $item ) { |
|
495 | - $temp ++; |
|
496 | - $page_donation_id[ $current_page ][] = $item; |
|
497 | - if ( $temp === $post_delete ) { |
|
498 | - $current_page ++; |
|
494 | + foreach ($donation_ids as $item) { |
|
495 | + $temp++; |
|
496 | + $page_donation_id[$current_page][] = $item; |
|
497 | + if ($temp === $post_delete) { |
|
498 | + $current_page++; |
|
499 | 499 | $temp = 0; |
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - return $page_donation_id[ $page ]; |
|
503 | + return $page_donation_id[$page]; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @return mixed Returns the data from the database |
515 | 515 | */ |
516 | - public function get_option( $key, $default_value = false ) { |
|
517 | - return get_option( $key, $default_value ); |
|
516 | + public function get_option($key, $default_value = false) { |
|
517 | + return get_option($key, $default_value); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return void |
529 | 529 | */ |
530 | - public function update_option( $key, $value ) { |
|
531 | - update_option( $key, $value, false ); |
|
530 | + public function update_option($key, $value) { |
|
531 | + update_option($key, $value, false); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return void |
542 | 542 | */ |
543 | - public function delete_option( $key ) { |
|
544 | - delete_option( $key ); |
|
543 | + public function delete_option($key) { |
|
544 | + delete_option($key); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -552,12 +552,12 @@ discard block |
||
552 | 552 | * @return int|string |
553 | 553 | */ |
554 | 554 | private function get_step() { |
555 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
556 | - if ( 'count' === $step_key ) { |
|
555 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
556 | + if ('count' === $step_key) { |
|
557 | 557 | return 1; |
558 | - } elseif ( 'donation' === $step_key ) { |
|
558 | + } elseif ('donation' === $step_key) { |
|
559 | 559 | return 2; |
560 | - } elseif ( 'donor' === $step_key ) { |
|
560 | + } elseif ('donor' === $step_key) { |
|
561 | 561 | return 3; |
562 | 562 | } else { |
563 | 563 | return $step_key; |
@@ -568,6 +568,6 @@ discard block |
||
568 | 568 | * Get the current $page value in the ajax. |
569 | 569 | */ |
570 | 570 | private function get_step_page() { |
571 | - return $this->get_option( $this->step_on_key, false ); |
|
571 | + return $this->get_option($this->step_on_key, false); |
|
572 | 572 | } |
573 | 573 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @param int $comment_id |
446 | 446 | * @param WP_Comment $comment |
447 | 447 | * |
448 | - * @return mixed |
|
448 | + * @return string |
|
449 | 449 | */ |
450 | 450 | public function __get_comment_author( $author, $comment_id, $comment ) { |
451 | 451 | if ( in_array( $comment->comment_type, $this->comment_types ) ) { |
@@ -468,6 +468,7 @@ discard block |
||
468 | 468 | * @access public |
469 | 469 | * |
470 | 470 | * @param array @comment_types |
471 | + * @param string[] $comment_types |
|
471 | 472 | * |
472 | 473 | * @return array |
473 | 474 | */ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return Give_Comment |
47 | 47 | */ |
48 | 48 | public static function get_instance() { |
49 | - if ( null === static::$instance ) { |
|
49 | + if (null === static::$instance) { |
|
50 | 50 | self::$instance = new static(); |
51 | 51 | self::$instance->init(); |
52 | 52 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | $this->comment_types = apply_filters( |
70 | 70 | 'give_comment_type', |
71 | - self::get_comment_types( array( 'payment', 'donor' ) ) |
|
71 | + self::get_comment_types(array('payment', 'donor')) |
|
72 | 72 | ); |
73 | 73 | |
74 | - add_action( 'pre_get_comments', array( $this, 'hide_comments' ), 10 ); |
|
75 | - add_filter( 'comments_clauses', array( $this, 'hide_comments_pre_wp_41' ), 10, 1 ); |
|
76 | - add_filter( 'comment_feed_where', array( $this, 'hide_comments_from_feeds' ), 10, 1 ); |
|
77 | - add_filter( 'wp_count_comments', array( $this, 'remove_comments_from_comment_counts' ), 10, 2 ); |
|
78 | - add_filter( 'get_comment_author', array( $this, '__get_comment_author' ), 10, 3 ); |
|
74 | + add_action('pre_get_comments', array($this, 'hide_comments'), 10); |
|
75 | + add_filter('comments_clauses', array($this, 'hide_comments_pre_wp_41'), 10, 1); |
|
76 | + add_filter('comment_feed_where', array($this, 'hide_comments_from_feeds'), 10, 1); |
|
77 | + add_filter('wp_count_comments', array($this, 'remove_comments_from_comment_counts'), 10, 2); |
|
78 | + add_filter('get_comment_author', array($this, '__get_comment_author'), 10, 3); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return int|WP_Error |
93 | 93 | */ |
94 | - public static function add( $id, $note, $comment_type, $comment_args = array() ) { |
|
94 | + public static function add($id, $note, $comment_type, $comment_args = array()) { |
|
95 | 95 | // Bailout |
96 | - if ( empty( $id ) || empty( $note ) || empty( $comment_type ) ) { |
|
97 | - return new WP_Error( 'give_invalid_required_param', __( 'This comment has invalid ID or comment text or cooment type', 'give' ) ); |
|
96 | + if (empty($id) || empty($note) || empty($comment_type)) { |
|
97 | + return new WP_Error('give_invalid_required_param', __('This comment has invalid ID or comment text or cooment type', 'give')); |
|
98 | 98 | } |
99 | 99 | |
100 | - $is_existing_comment = array_key_exists( 'comment_ID', $comment_args ) && ! empty( $comment_args['comment_ID'] ); |
|
100 | + $is_existing_comment = array_key_exists('comment_ID', $comment_args) && ! empty($comment_args['comment_ID']); |
|
101 | 101 | $action_type = $is_existing_comment ? 'update' : 'insert'; |
102 | 102 | |
103 | 103 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @since 1.0 |
110 | 110 | */ |
111 | - do_action( "give_pre_{$action_type}_{$comment_type}_note", $id, $note ); |
|
111 | + do_action("give_pre_{$action_type}_{$comment_type}_note", $id, $note); |
|
112 | 112 | |
113 | 113 | $comment_args = wp_parse_args( |
114 | 114 | $comment_args, |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | 'comment_post_ID' => $id, |
117 | 117 | 'comment_content' => $note, |
118 | 118 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
119 | - 'comment_date' => current_time( 'mysql' ), |
|
120 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
119 | + 'comment_date' => current_time('mysql'), |
|
120 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
121 | 121 | 'comment_approved' => 1, |
122 | 122 | 'comment_parent' => 0, |
123 | 123 | 'comment_author' => '', |
@@ -131,30 +131,30 @@ discard block |
||
131 | 131 | |
132 | 132 | |
133 | 133 | // Check comment max length. |
134 | - $error = wp_check_comment_data_max_lengths( $comment_args ); |
|
135 | - if( is_wp_error( $error ) ) { |
|
134 | + $error = wp_check_comment_data_max_lengths($comment_args); |
|
135 | + if (is_wp_error($error)) { |
|
136 | 136 | return $error; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Remove moderation emails when comment posted. |
140 | - remove_action( 'comment_post', 'wp_new_comment_notify_moderator' ); |
|
141 | - remove_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); |
|
140 | + remove_action('comment_post', 'wp_new_comment_notify_moderator'); |
|
141 | + remove_action('comment_post', 'wp_new_comment_notify_postauthor'); |
|
142 | 142 | |
143 | 143 | // Remove comment flood check. |
144 | - remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 ); |
|
144 | + remove_action('check_comment_flood', 'check_comment_flood_db', 10); |
|
145 | 145 | |
146 | 146 | $comment_id = $is_existing_comment |
147 | - ? wp_update_comment( $comment_args ) |
|
148 | - : wp_new_comment( $comment_args, true ); |
|
147 | + ? wp_update_comment($comment_args) |
|
148 | + : wp_new_comment($comment_args, true); |
|
149 | 149 | |
150 | 150 | // Add moderation emails when comment posted. |
151 | - add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); |
|
152 | - add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); |
|
151 | + add_action('comment_post', 'wp_new_comment_notify_moderator'); |
|
152 | + add_action('comment_post', 'wp_new_comment_notify_postauthor'); |
|
153 | 153 | |
154 | 154 | // Add comment flood check. |
155 | - add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 ); |
|
155 | + add_action('check_comment_flood', 'check_comment_flood_db', 10, 4); |
|
156 | 156 | |
157 | - update_comment_meta( $comment_id, "_give_{$comment_type}_id", $id ); |
|
157 | + update_comment_meta($comment_id, "_give_{$comment_type}_id", $id); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Fires after payment|donor comment inserted/updated. |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @since 1.0 |
167 | 167 | */ |
168 | - do_action( "give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note ); |
|
168 | + do_action("give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note); |
|
169 | 169 | |
170 | 170 | return $comment_id; |
171 | 171 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return bool True on success, false otherwise. |
187 | 187 | */ |
188 | - public static function delete( $comment_id, $id, $comment_type ) { |
|
188 | + public static function delete($comment_id, $id, $comment_type) { |
|
189 | 189 | $ret = false; |
190 | 190 | |
191 | 191 | // Bailout |
192 | - if ( empty( $id ) || empty( $comment_id ) || empty( $comment_type ) ) { |
|
192 | + if (empty($id) || empty($comment_id) || empty($comment_type)) { |
|
193 | 193 | return $ret; |
194 | 194 | } |
195 | 195 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @since 1.0 |
203 | 203 | */ |
204 | - do_action( "give_pre_delete_{$comment_type}_note", $comment_id, $id ); |
|
204 | + do_action("give_pre_delete_{$comment_type}_note", $comment_id, $id); |
|
205 | 205 | |
206 | - $ret = wp_delete_comment( $comment_id, true ); |
|
206 | + $ret = wp_delete_comment($comment_id, true); |
|
207 | 207 | |
208 | 208 | /** |
209 | 209 | * Fires after donation note deleted. |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @since 1.0 |
216 | 216 | */ |
217 | - do_action( "give_post_delete_{$comment_type}_note", $comment_id, $id, $ret ); |
|
217 | + do_action("give_post_delete_{$comment_type}_note", $comment_id, $id, $ret); |
|
218 | 218 | |
219 | 219 | return $ret; |
220 | 220 | } |
@@ -233,25 +233,25 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return array |
235 | 235 | */ |
236 | - public static function get( $id, $comment_type, $comment_args = array(), $search = '' ) { |
|
236 | + public static function get($id, $comment_type, $comment_args = array(), $search = '') { |
|
237 | 237 | $comments = array(); |
238 | 238 | |
239 | 239 | // Set default meta_query value. |
240 | - if ( ! isset( $comment_args['meta_query'] ) ) { |
|
240 | + if ( ! isset($comment_args['meta_query'])) { |
|
241 | 241 | $comment_args['meta_query'] = array(); |
242 | 242 | } |
243 | 243 | |
244 | 244 | // Bailout |
245 | - if ( empty( $id ) || empty( $comment_type ) ) { |
|
245 | + if (empty($id) || empty($comment_type)) { |
|
246 | 246 | return $comments; |
247 | 247 | } |
248 | 248 | |
249 | - remove_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10 ); |
|
250 | - remove_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10 ); |
|
249 | + remove_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10); |
|
250 | + remove_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10); |
|
251 | 251 | |
252 | - switch ( $comment_type ) { |
|
252 | + switch ($comment_type) { |
|
253 | 253 | case 'payment': |
254 | - $comment_args['meta_query'] = ! empty( $comment_args['meta_query'] ) |
|
254 | + $comment_args['meta_query'] = ! empty($comment_args['meta_query']) |
|
255 | 255 | ? $comment_args['meta_query'] |
256 | 256 | : array( |
257 | 257 | array( |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | ) |
261 | 261 | ); |
262 | 262 | |
263 | - $comments = get_comments( wp_parse_args( |
|
263 | + $comments = get_comments(wp_parse_args( |
|
264 | 264 | $comment_args, |
265 | 265 | array( |
266 | 266 | 'post_id' => $id, |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | 'search' => $search, |
269 | 269 | 'type' => 'give_payment_note' |
270 | 270 | ) |
271 | - ) ); |
|
271 | + )); |
|
272 | 272 | break; |
273 | 273 | |
274 | 274 | case 'donor': |
275 | - $comment_args['meta_query'] = ! empty( $comment_args['meta_query'] ) |
|
275 | + $comment_args['meta_query'] = ! empty($comment_args['meta_query']) |
|
276 | 276 | ? $comment_args['meta_query'] |
277 | 277 | : array( |
278 | 278 | array( |
@@ -281,19 +281,19 @@ discard block |
||
281 | 281 | ) |
282 | 282 | ); |
283 | 283 | |
284 | - $comments = get_comments( wp_parse_args( |
|
284 | + $comments = get_comments(wp_parse_args( |
|
285 | 285 | $comment_args, |
286 | 286 | array( |
287 | 287 | 'order' => 'ASC', |
288 | 288 | 'search' => $search, |
289 | 289 | 'type' => 'give_donor_note' |
290 | 290 | ) |
291 | - ) ); |
|
291 | + )); |
|
292 | 292 | break; |
293 | 293 | } |
294 | 294 | |
295 | - add_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10, 1 ); |
|
296 | - add_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10, 1 ); |
|
295 | + add_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10, 1); |
|
296 | + add_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10, 1); |
|
297 | 297 | |
298 | 298 | return $comments; |
299 | 299 | } |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return void |
311 | 311 | */ |
312 | - public function hide_comments( $query ) { |
|
313 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
314 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
315 | - if ( ! is_array( $types ) ) { |
|
316 | - $types = array( $types ); |
|
312 | + public function hide_comments($query) { |
|
313 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
314 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
315 | + if ( ! is_array($types)) { |
|
316 | + $types = array($types); |
|
317 | 317 | } |
318 | 318 | |
319 | - $types = array_filter( array_merge( $types, $this->comment_types ) ); |
|
319 | + $types = array_filter(array_merge($types, $this->comment_types)); |
|
320 | 320 | |
321 | 321 | $query->query_vars['type__not_in'] = $types; |
322 | 322 | } |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return array $clauses Updated comment clauses. |
334 | 334 | */ |
335 | - public function hide_comments_pre_wp_41( $clauses ) { |
|
336 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
337 | - foreach ( $this->comment_types as $comment_type ) { |
|
335 | + public function hide_comments_pre_wp_41($clauses) { |
|
336 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
337 | + foreach ($this->comment_types as $comment_type) { |
|
338 | 338 | $clauses['where'] .= " AND comment_type != \"{$comment_type}\""; |
339 | 339 | } |
340 | 340 | } |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return string $where |
354 | 354 | */ |
355 | - public function hide_comments_from_feeds( $where ) { |
|
355 | + public function hide_comments_from_feeds($where) { |
|
356 | 356 | global $wpdb; |
357 | 357 | |
358 | - foreach ( $this->comment_types as $comment_type ) { |
|
359 | - $where .= $wpdb->prepare( ' AND comment_type!=%s', $comment_type ); |
|
358 | + foreach ($this->comment_types as $comment_type) { |
|
359 | + $where .= $wpdb->prepare(' AND comment_type!=%s', $comment_type); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | return $where; |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return array|object Array of comment counts. |
375 | 375 | */ |
376 | - public function remove_comments_from_comment_counts( $stats, $post_id ) { |
|
376 | + public function remove_comments_from_comment_counts($stats, $post_id) { |
|
377 | 377 | global $wpdb; |
378 | 378 | |
379 | 379 | $post_id = (int) $post_id; |
380 | 380 | |
381 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
381 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
382 | 382 | return $stats; |
383 | 383 | } |
384 | 384 | |
385 | - $stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' ); |
|
385 | + $stats = Give_Cache::get_group("comments-{$post_id}", 'counts'); |
|
386 | 386 | |
387 | 387 | // Return result from cache. |
388 | - if ( ! is_null( $stats ) ) { |
|
388 | + if ( ! is_null($stats)) { |
|
389 | 389 | return $stats; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $where = 'WHERE'; |
393 | 393 | |
394 | - foreach ( $this->comment_types as $index => $comment_type ) { |
|
395 | - $where .= ( $index ? ' AND ' : ' ' ) . "comment_type != \"{$comment_type}\""; |
|
394 | + foreach ($this->comment_types as $index => $comment_type) { |
|
395 | + $where .= ($index ? ' AND ' : ' ')."comment_type != \"{$comment_type}\""; |
|
396 | 396 | } |
397 | 397 | |
398 | - if ( $post_id > 0 ) { |
|
399 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
398 | + if ($post_id > 0) { |
|
399 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $count = $wpdb->get_results( |
@@ -417,26 +417,26 @@ discard block |
||
417 | 417 | 'post-trashed' => 'post-trashed', |
418 | 418 | ); |
419 | 419 | |
420 | - foreach ( (array) $count as $row ) { |
|
420 | + foreach ((array) $count as $row) { |
|
421 | 421 | // Don't count post-trashed toward totals. |
422 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
422 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
423 | 423 | $total += $row['num_comments']; |
424 | 424 | } |
425 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
426 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
425 | + if (isset($approved[$row['comment_approved']])) { |
|
426 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | $stats['total_comments'] = $stats['all'] = $total; |
431 | - foreach ( $approved as $key ) { |
|
432 | - if ( empty( $stats[ $key ] ) ) { |
|
433 | - $stats[ $key ] = 0; |
|
431 | + foreach ($approved as $key) { |
|
432 | + if (empty($stats[$key])) { |
|
433 | + $stats[$key] = 0; |
|
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | 437 | $stats = (object) $stats; |
438 | 438 | |
439 | - Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' ); |
|
439 | + Give_Cache::set_group("comments-{$post_id}", $stats, 'counts'); |
|
440 | 440 | |
441 | 441 | return $stats; |
442 | 442 | } |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @return mixed |
455 | 455 | */ |
456 | - public function __get_comment_author( $author, $comment_id, $comment ) { |
|
457 | - if ( in_array( $comment->comment_type, $this->comment_types ) ) { |
|
458 | - switch ( $comment->comment_type ) { |
|
456 | + public function __get_comment_author($author, $comment_id, $comment) { |
|
457 | + if (in_array($comment->comment_type, $this->comment_types)) { |
|
458 | + switch ($comment->comment_type) { |
|
459 | 459 | case 'give_payment_note': |
460 | - if ( get_comment_meta( $comment_id, '_give_donor_id', true ) ) { |
|
461 | - $author = give_get_donor_name_by( $comment->comment_post_ID ); |
|
460 | + if (get_comment_meta($comment_id, '_give_donor_id', true)) { |
|
461 | + $author = give_get_donor_name_by($comment->comment_post_ID); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return array |
479 | 479 | */ |
480 | - public static function get_comment_types( $comment_types ) { |
|
480 | + public static function get_comment_types($comment_types) { |
|
481 | 481 | $_comment_types = array(); |
482 | - foreach ( $comment_types as $comment_type ) { |
|
482 | + foreach ($comment_types as $comment_type) { |
|
483 | 483 | $_comment_types[] = "give_{$comment_type}_note"; |
484 | 484 | } |
485 | 485 |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * Rename query clauses for new meta table |
281 | 281 | * |
282 | - * @param $clause |
|
282 | + * @param string $clause |
|
283 | 283 | * @param $filter |
284 | 284 | * |
285 | 285 | * @return mixed |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @since 2.0.4 |
516 | 516 | * @access public |
517 | 517 | * |
518 | - * @return string |
|
518 | + * @return boolean |
|
519 | 519 | */ |
520 | 520 | public function get_meta_type() { |
521 | 521 | return $this->meta_type; |
@@ -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 | |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | parent::__construct(); |
78 | 78 | |
79 | 79 | // Bailout. |
80 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
80 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
85 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
84 | + if (in_array('add_post_metadata', $this->supports)) { |
|
85 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
86 | 86 | } |
87 | 87 | |
88 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
89 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 10, 4 ); |
|
88 | + if (in_array('get_post_metadata', $this->supports)) { |
|
89 | + add_filter('get_post_metadata', array($this, '__get_meta'), 10, 4); |
|
90 | 90 | } |
91 | 91 | |
92 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
93 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
92 | + if (in_array('update_post_metadata', $this->supports)) { |
|
93 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
94 | 94 | } |
95 | 95 | |
96 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
97 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
96 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
97 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
98 | 98 | } |
99 | 99 | |
100 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
101 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
100 | + if (in_array('posts_where', $this->supports)) { |
|
101 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
102 | 102 | } |
103 | 103 | |
104 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
105 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
104 | + if (in_array('posts_join', $this->supports)) { |
|
105 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
106 | 106 | } |
107 | 107 | |
108 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
109 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
108 | + if (in_array('posts_groupby', $this->supports)) { |
|
109 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
113 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
112 | + if (in_array('posts_orderby', $this->supports)) { |
|
113 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
129 | 129 | * is true. |
130 | 130 | */ |
131 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
132 | - $id = $this->sanitize_id( $id ); |
|
131 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
132 | + $id = $this->sanitize_id($id); |
|
133 | 133 | |
134 | 134 | // Bailout. |
135 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
135 | + if ( ! $this->is_valid_post_type($id)) { |
|
136 | 136 | return $this->check; |
137 | 137 | } |
138 | 138 | |
139 | - if ( $this->raw_result ) { |
|
140 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
139 | + if ($this->raw_result) { |
|
140 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
141 | 141 | $value = ''; |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->raw_result = false; |
146 | 146 | |
147 | 147 | } else { |
148 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
148 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $value; |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int|bool False for failure. True for success. |
169 | 169 | */ |
170 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
171 | - $id = $this->sanitize_id( $id ); |
|
170 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
171 | + $id = $this->sanitize_id($id); |
|
172 | 172 | |
173 | 173 | // Bailout. |
174 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
174 | + if ( ! $this->is_valid_post_type($id)) { |
|
175 | 175 | return $this->check; |
176 | 176 | } |
177 | 177 | |
178 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
178 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
179 | 179 | |
180 | - if ( $meta_id ) { |
|
181 | - $this->delete_cache( $id ); |
|
180 | + if ($meta_id) { |
|
181 | + $this->delete_cache($id); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $meta_id; |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return int|bool False on failure, true if success. |
206 | 206 | */ |
207 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
208 | - $id = $this->sanitize_id( $id ); |
|
207 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
208 | + $id = $this->sanitize_id($id); |
|
209 | 209 | |
210 | 210 | // Bailout. |
211 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
211 | + if ( ! $this->is_valid_post_type($id)) { |
|
212 | 212 | return $this->check; |
213 | 213 | } |
214 | 214 | |
215 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
215 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
216 | 216 | |
217 | - if ( $meta_id ) { |
|
218 | - $this->delete_cache( $id ); |
|
217 | + if ($meta_id) { |
|
218 | + $this->delete_cache($id); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $meta_id; |
@@ -238,18 +238,18 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return bool False for failure. True for success. |
240 | 240 | */ |
241 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
242 | - $id = $this->sanitize_id( $id ); |
|
241 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
242 | + $id = $this->sanitize_id($id); |
|
243 | 243 | |
244 | 244 | // Bailout. |
245 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
245 | + if ( ! $this->is_valid_post_type($id)) { |
|
246 | 246 | return $this->check; |
247 | 247 | } |
248 | 248 | |
249 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
249 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
250 | 250 | |
251 | - if ( $is_meta_deleted ) { |
|
252 | - $this->delete_cache( $id ); |
|
251 | + if ($is_meta_deleted) { |
|
252 | + $this->delete_cache($id); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return $is_meta_deleted; |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
269 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
270 | 270 | // Add new table to sql query. |
271 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
272 | - $clause = $this->__rename_meta_table_name( $clause, current_filter() ); |
|
271 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
272 | + $clause = $this->__rename_meta_table_name($clause, current_filter()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $clause; |
@@ -284,42 +284,42 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return mixed |
286 | 286 | */ |
287 | - public function __rename_meta_table_name( $clause, $filter ) { |
|
287 | + public function __rename_meta_table_name($clause, $filter) { |
|
288 | 288 | global $wpdb; |
289 | 289 | |
290 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
291 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
290 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
291 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
292 | 292 | |
293 | - switch ( $filter ) { |
|
293 | + switch ($filter) { |
|
294 | 294 | case 'posts_join': |
295 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
295 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
296 | 296 | |
297 | - foreach ( $joins as $join ) { |
|
298 | - if ( false !== strpos( $clause, $join ) ) { |
|
299 | - $clause = explode( $join, $clause ); |
|
297 | + foreach ($joins as $join) { |
|
298 | + if (false !== strpos($clause, $join)) { |
|
299 | + $clause = explode($join, $clause); |
|
300 | 300 | |
301 | - foreach ( $clause as $key => $clause_part ) { |
|
302 | - if ( empty( $clause_part ) ) { |
|
301 | + foreach ($clause as $key => $clause_part) { |
|
302 | + if (empty($clause_part)) { |
|
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | |
306 | - preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
306 | + preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name); |
|
307 | 307 | |
308 | - if ( isset( $alias_table_name[1] ) ) { |
|
309 | - $clause[ $key ] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
308 | + if (isset($alias_table_name[1])) { |
|
309 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - $clause = implode( "{$join} ", $clause ); |
|
313 | + $clause = implode("{$join} ", $clause); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | break; |
317 | 317 | |
318 | 318 | case 'posts_where': |
319 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( |
|
319 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array( |
|
320 | 320 | "mt2.{$this->meta_type}_id", |
321 | 321 | "mt1.{$this->meta_type}_id" |
322 | - ), $clause ); |
|
322 | + ), $clause); |
|
323 | 323 | break; |
324 | 324 | } |
325 | 325 | |
@@ -337,19 +337,19 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return bool |
339 | 339 | */ |
340 | - protected function is_post_type_query( $wp_query ) { |
|
340 | + protected function is_post_type_query($wp_query) { |
|
341 | 341 | $status = false; |
342 | 342 | |
343 | 343 | // Check if it is payment query. |
344 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
344 | + if ( ! empty($wp_query->query['post_type'])) { |
|
345 | 345 | if ( |
346 | - is_string( $wp_query->query['post_type'] ) && |
|
346 | + is_string($wp_query->query['post_type']) && |
|
347 | 347 | $this->post_type === $wp_query->query['post_type'] |
348 | 348 | ) { |
349 | 349 | $status = true; |
350 | 350 | } elseif ( |
351 | - is_array( $wp_query->query['post_type'] ) && |
|
352 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
351 | + is_array($wp_query->query['post_type']) && |
|
352 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
353 | 353 | ) { |
354 | 354 | $status = true; |
355 | 355 | } |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return bool |
370 | 370 | */ |
371 | - protected function is_valid_post_type( $ID ) { |
|
372 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
371 | + protected function is_valid_post_type($ID) { |
|
372 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return void |
397 | 397 | */ |
398 | - private function delete_cache( $id, $meta_type = '' ) { |
|
399 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
398 | + private function delete_cache($id, $meta_type = '') { |
|
399 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
400 | 400 | |
401 | 401 | $group = array( |
402 | 402 | 'payment' => 'give-donations', // Backward compatibility |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | 'customer' => 'give-donors', // Backward compatibility for pre upgrade in 2.0 |
406 | 406 | ); |
407 | 407 | |
408 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
409 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
408 | + if (array_key_exists($meta_type, $group)) { |
|
409 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return mixed |
423 | 423 | */ |
424 | - public function __call( $name, $arguments ) { |
|
425 | - switch ( $name ) { |
|
424 | + public function __call($name, $arguments) { |
|
425 | + switch ($name) { |
|
426 | 426 | case '__add_meta': |
427 | 427 | $this->check = $arguments[0]; |
428 | 428 | $id = $arguments[1]; |
@@ -431,11 +431,11 @@ discard block |
||
431 | 431 | $unique = $arguments[4]; |
432 | 432 | |
433 | 433 | // Bailout. |
434 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
434 | + if ( ! $this->is_valid_post_type($id)) { |
|
435 | 435 | return $this->check; |
436 | 436 | } |
437 | 437 | |
438 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
438 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
439 | 439 | |
440 | 440 | case '__get_meta': |
441 | 441 | $this->check = $arguments[0]; |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | $single = $arguments[3]; |
445 | 445 | |
446 | 446 | // Bailout. |
447 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
447 | + if ( ! $this->is_valid_post_type($id)) { |
|
448 | 448 | return $this->check; |
449 | 449 | } |
450 | 450 | |
451 | 451 | $this->raw_result = true; |
452 | 452 | |
453 | - return $this->get_meta( $id, $meta_key, $single ); |
|
453 | + return $this->get_meta($id, $meta_key, $single); |
|
454 | 454 | |
455 | 455 | case '__update_meta': |
456 | 456 | $this->check = $arguments[0]; |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | $meta_value = $arguments[3]; |
460 | 460 | |
461 | 461 | // Bailout. |
462 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
462 | + if ( ! $this->is_valid_post_type($id)) { |
|
463 | 463 | return $this->check; |
464 | 464 | } |
465 | 465 | |
466 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
466 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
467 | 467 | |
468 | 468 | case '__delete_meta': |
469 | 469 | $this->check = $arguments[0]; |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | $delete_all = $arguments[3]; |
474 | 474 | |
475 | 475 | // Bailout. |
476 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
476 | + if ( ! $this->is_valid_post_type($id)) { |
|
477 | 477 | return $this->check; |
478 | 478 | } |
479 | 479 | |
480 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
480 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -502,10 +502,10 @@ discard block |
||
502 | 502 | KEY meta_key (meta_key({$this->min_index_length})) |
503 | 503 | ) {$charset_collate};"; |
504 | 504 | |
505 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
506 | - dbDelta( $sql ); |
|
505 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
506 | + dbDelta($sql); |
|
507 | 507 | |
508 | - update_option( $this->table_name . '_db_version', $this->version, false ); |
|
508 | + update_option($this->table_name.'_db_version', $this->version, false); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return bool False for failure. True for success. |
533 | 533 | */ |
534 | - public function delete_all_meta( $id = 0 ) { |
|
534 | + public function delete_all_meta($id = 0) { |
|
535 | 535 | global $wpdb; |
536 | - $status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) ); |
|
536 | + $status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d')); |
|
537 | 537 | |
538 | - if ( $status ) { |
|
539 | - $this->delete_cache( $id, $this->meta_type ); |
|
538 | + if ($status) { |
|
539 | + $this->delete_cache($id, $this->meta_type); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | return $status; |
@@ -1052,7 +1052,7 @@ |
||
1052 | 1052 | * @access public |
1053 | 1053 | * |
1054 | 1054 | * @param string $meta_key Metadata name. Default is empty. |
1055 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
1055 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
1056 | 1056 | * |
1057 | 1057 | * @return bool False for failure. True for success. |
1058 | 1058 | */ |
@@ -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,29 +149,29 @@ 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 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
156 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
160 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
161 | 161 | |
162 | - if ( is_numeric( $_id_or_email ) ) { |
|
162 | + if (is_numeric($_id_or_email)) { |
|
163 | 163 | $field = $by_user_id ? 'user_id' : 'id'; |
164 | 164 | } else { |
165 | 165 | $field = 'email'; |
166 | 166 | } |
167 | 167 | |
168 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
168 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
169 | 169 | |
170 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
170 | + if (empty($donor) || ! is_object($donor)) { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
174 | - $this->setup_donor( $donor ); |
|
174 | + $this->setup_donor($donor); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return bool If the setup was successful or not. |
189 | 189 | */ |
190 | - private function setup_donor( $donor ) { |
|
190 | + private function setup_donor($donor) { |
|
191 | 191 | |
192 | - if ( ! is_object( $donor ) ) { |
|
192 | + if ( ! is_object($donor)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Get cached donors. |
197 | - $donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' ); |
|
197 | + $donor_vars = Give_Cache::get_group($donor->id, 'give-donors'); |
|
198 | 198 | |
199 | - if ( is_null( $donor_vars ) ) { |
|
200 | - foreach ( $donor as $key => $value ) { |
|
199 | + if (is_null($donor_vars)) { |
|
200 | + foreach ($donor as $key => $value) { |
|
201 | 201 | |
202 | - switch ( $key ) { |
|
202 | + switch ($key) { |
|
203 | 203 | |
204 | 204 | case 'notes': |
205 | 205 | $this->$key = $this->get_notes(); |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // Get donor's all email including primary email. |
216 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
217 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
216 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
217 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
218 | 218 | |
219 | 219 | $this->setup_address(); |
220 | 220 | |
221 | - Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' ); |
|
221 | + Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors'); |
|
222 | 222 | } else { |
223 | - foreach ( $donor_vars as $donor_var => $value ) { |
|
223 | + foreach ($donor_vars as $donor_var => $value) { |
|
224 | 224 | $this->$donor_var = $value; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Donor ID and email are the only things that are necessary, make sure they exist. |
229 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
229 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
230 | 230 | return true; |
231 | 231 | } |
232 | 232 | |
@@ -245,25 +245,25 @@ discard block |
||
245 | 245 | global $wpdb; |
246 | 246 | $meta_type = Give()->donor_meta->meta_type; |
247 | 247 | |
248 | - $addresses = $wpdb->get_results( $wpdb->prepare( " |
|
248 | + $addresses = $wpdb->get_results($wpdb->prepare(" |
|
249 | 249 | SELECT meta_key, meta_value FROM {$wpdb->donormeta} |
250 | 250 | WHERE meta_key |
251 | 251 | LIKE '%%%s%%' |
252 | 252 | AND {$meta_type}_id=%d |
253 | - ", 'give_donor_address', $this->id ), ARRAY_N ); |
|
253 | + ", 'give_donor_address', $this->id), ARRAY_N); |
|
254 | 254 | |
255 | - if ( empty( $addresses ) ) { |
|
255 | + if (empty($addresses)) { |
|
256 | 256 | return $this->address; |
257 | 257 | } |
258 | 258 | |
259 | - foreach ( $addresses as $address ) { |
|
260 | - $address[0] = str_replace( '_give_donor_address_', '', $address[0] ); |
|
261 | - $address[0] = explode( '_', $address[0] ); |
|
259 | + foreach ($addresses as $address) { |
|
260 | + $address[0] = str_replace('_give_donor_address_', '', $address[0]); |
|
261 | + $address[0] = explode('_', $address[0]); |
|
262 | 262 | |
263 | - if ( 3 === count( $address[0] ) ) { |
|
264 | - $this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1]; |
|
263 | + if (3 === count($address[0])) { |
|
264 | + $this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1]; |
|
265 | 265 | } else { |
266 | - $this->address[ $address[0][0] ][ $address[0][1] ] = $address[1]; |
|
266 | + $this->address[$address[0][0]][$address[0][1]] = $address[1]; |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return array The donor's address, if any |
281 | 281 | */ |
282 | - public function get_donor_address( $args = array() ) { |
|
282 | + public function get_donor_address($args = array()) { |
|
283 | 283 | $args = wp_parse_args( |
284 | 284 | $args, |
285 | 285 | array( |
@@ -297,24 +297,24 @@ discard block |
||
297 | 297 | ); |
298 | 298 | |
299 | 299 | // Backward compatibility. |
300 | - if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) { |
|
300 | + if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) { |
|
301 | 301 | |
302 | 302 | // Backward compatibility for user id param. |
303 | - return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address ); |
|
303 | + return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
307 | - if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) { |
|
307 | + if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) { |
|
308 | 308 | return $default_address; |
309 | 309 | } |
310 | 310 | |
311 | - switch ( true ) { |
|
312 | - case is_string( end( $this->address[ $args['address_type'] ] ) ): |
|
313 | - $address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address ); |
|
311 | + switch (true) { |
|
312 | + case is_string(end($this->address[$args['address_type']])): |
|
313 | + $address = wp_parse_args($this->address[$args['address_type']], $default_address); |
|
314 | 314 | break; |
315 | 315 | |
316 | - case is_array( end( $this->address[ $args['address_type'] ] ) ): |
|
317 | - $address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address ); |
|
316 | + case is_array(end($this->address[$args['address_type']])): |
|
317 | + $address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address); |
|
318 | 318 | break; |
319 | 319 | } |
320 | 320 | |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return mixed|\WP_Error |
333 | 333 | */ |
334 | - public function __get( $key ) { |
|
334 | + public function __get($key) { |
|
335 | 335 | |
336 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
336 | + if (method_exists($this, 'get_'.$key)) { |
|
337 | 337 | |
338 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
338 | + return call_user_func(array($this, 'get_'.$key)); |
|
339 | 339 | |
340 | 340 | } else { |
341 | 341 | |
342 | 342 | /* translators: %s: property key */ |
343 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
343 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
358 | 358 | */ |
359 | - public function create( $data = array() ) { |
|
359 | + public function create($data = array()) { |
|
360 | 360 | |
361 | - if ( $this->id != 0 || empty( $data ) ) { |
|
361 | + if ($this->id != 0 || empty($data)) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
@@ -366,15 +366,15 @@ discard block |
||
366 | 366 | 'payment_ids' => '', |
367 | 367 | ); |
368 | 368 | |
369 | - $args = wp_parse_args( $data, $defaults ); |
|
370 | - $args = $this->sanitize_columns( $args ); |
|
369 | + $args = wp_parse_args($data, $defaults); |
|
370 | + $args = $this->sanitize_columns($args); |
|
371 | 371 | |
372 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
372 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
373 | 373 | return false; |
374 | 374 | } |
375 | 375 | |
376 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
377 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
376 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
377 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -384,24 +384,24 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @param array $args Donor attributes. |
386 | 386 | */ |
387 | - do_action( 'give_donor_pre_create', $args ); |
|
387 | + do_action('give_donor_pre_create', $args); |
|
388 | 388 | |
389 | 389 | $created = false; |
390 | 390 | |
391 | 391 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
392 | - if ( $this->db->add( $data ) ) { |
|
392 | + if ($this->db->add($data)) { |
|
393 | 393 | |
394 | 394 | // We've successfully added/updated the donor, reset the class vars with the new data |
395 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
395 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
396 | 396 | |
397 | 397 | // Setup the donor data with the values from DB |
398 | - $this->setup_donor( $donor ); |
|
398 | + $this->setup_donor($donor); |
|
399 | 399 | |
400 | 400 | $created = $this->id; |
401 | 401 | |
402 | 402 | // Set donor as non anonymous by default |
403 | - if( $created ) { |
|
404 | - Give()->donor_meta->update_meta( $this->id, '_give_anonymous_donor', 0 ); |
|
403 | + if ($created) { |
|
404 | + Give()->donor_meta->update_meta($this->id, '_give_anonymous_donor', 0); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
414 | 414 | * @param array $args Customer attributes. |
415 | 415 | */ |
416 | - do_action( 'give_donor_post_create', $created, $args ); |
|
416 | + do_action('give_donor_post_create', $created, $args); |
|
417 | 417 | |
418 | 418 | return $created; |
419 | 419 | |
@@ -429,13 +429,13 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @return bool If the update was successful or not. |
431 | 431 | */ |
432 | - public function update( $data = array() ) { |
|
432 | + public function update($data = array()) { |
|
433 | 433 | |
434 | - if ( empty( $data ) ) { |
|
434 | + if (empty($data)) { |
|
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | |
438 | - $data = $this->sanitize_columns( $data ); |
|
438 | + $data = $this->sanitize_columns($data); |
|
439 | 439 | |
440 | 440 | /** |
441 | 441 | * Fires before updating donors. |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @param int $donor_id Donor id. |
446 | 446 | * @param array $data Donor attributes. |
447 | 447 | */ |
448 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
448 | + do_action('give_donor_pre_update', $this->id, $data); |
|
449 | 449 | |
450 | 450 | $updated = false; |
451 | 451 | |
452 | - if ( $this->db->update( $this->id, $data ) ) { |
|
452 | + if ($this->db->update($this->id, $data)) { |
|
453 | 453 | |
454 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
454 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
455 | 455 | |
456 | - $this->setup_donor( $donor ); |
|
456 | + $this->setup_donor($donor); |
|
457 | 457 | |
458 | 458 | $updated = true; |
459 | 459 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @param int $donor_id Donor id. |
468 | 468 | * @param array $data Donor attributes. |
469 | 469 | */ |
470 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
470 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
471 | 471 | |
472 | 472 | return $updated; |
473 | 473 | } |
@@ -485,27 +485,27 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return bool If the attachment was successfully. |
487 | 487 | */ |
488 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
488 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
489 | 489 | |
490 | - if ( empty( $payment_id ) ) { |
|
490 | + if (empty($payment_id)) { |
|
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | |
494 | - if ( empty( $this->payment_ids ) ) { |
|
494 | + if (empty($this->payment_ids)) { |
|
495 | 495 | |
496 | 496 | $new_payment_ids = $payment_id; |
497 | 497 | |
498 | 498 | } else { |
499 | 499 | |
500 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
500 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
501 | 501 | |
502 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
502 | + if (in_array($payment_id, $payment_ids)) { |
|
503 | 503 | $update_stats = false; |
504 | 504 | } |
505 | 505 | |
506 | 506 | $payment_ids[] = $payment_id; |
507 | 507 | |
508 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
508 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
509 | 509 | |
510 | 510 | } |
511 | 511 | |
@@ -517,20 +517,20 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $donor_id Donor id. |
519 | 519 | */ |
520 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
520 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
521 | 521 | |
522 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
522 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
523 | 523 | |
524 | - if ( $payment_added ) { |
|
524 | + if ($payment_added) { |
|
525 | 525 | |
526 | 526 | $this->payment_ids = $new_payment_ids; |
527 | 527 | |
528 | 528 | // We added this payment successfully, increment the stats |
529 | - if ( $update_stats ) { |
|
530 | - $payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) ); |
|
529 | + if ($update_stats) { |
|
530 | + $payment_amount = give_donation_amount($payment_id, array('type' => 'stats')); |
|
531 | 531 | |
532 | - if ( ! empty( $payment_amount ) ) { |
|
533 | - $this->increase_value( $payment_amount ); |
|
532 | + if ( ! empty($payment_amount)) { |
|
533 | + $this->increase_value($payment_amount); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | $this->increase_purchase_count(); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param int $payment_id Payment id. |
547 | 547 | * @param int $donor_id Donor id. |
548 | 548 | */ |
549 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
549 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
550 | 550 | |
551 | 551 | return $payment_added; |
552 | 552 | } |
@@ -564,33 +564,33 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return boolean If the removal was successful. |
566 | 566 | */ |
567 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
567 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
568 | 568 | |
569 | - if ( empty( $payment_id ) ) { |
|
569 | + if (empty($payment_id)) { |
|
570 | 570 | return false; |
571 | 571 | } |
572 | 572 | |
573 | - $payment = new Give_Payment( $payment_id ); |
|
573 | + $payment = new Give_Payment($payment_id); |
|
574 | 574 | |
575 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
575 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
576 | 576 | $update_stats = false; |
577 | 577 | } |
578 | 578 | |
579 | 579 | $new_payment_ids = ''; |
580 | 580 | |
581 | - if ( ! empty( $this->payment_ids ) ) { |
|
581 | + if ( ! empty($this->payment_ids)) { |
|
582 | 582 | |
583 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
583 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
584 | 584 | |
585 | - $pos = array_search( $payment_id, $payment_ids ); |
|
586 | - if ( false === $pos ) { |
|
585 | + $pos = array_search($payment_id, $payment_ids); |
|
586 | + if (false === $pos) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | - unset( $payment_ids[ $pos ] ); |
|
591 | - $payment_ids = array_filter( $payment_ids ); |
|
590 | + unset($payment_ids[$pos]); |
|
591 | + $payment_ids = array_filter($payment_ids); |
|
592 | 592 | |
593 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
593 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
594 | 594 | |
595 | 595 | } |
596 | 596 | |
@@ -602,20 +602,20 @@ discard block |
||
602 | 602 | * @param int $payment_id Payment id. |
603 | 603 | * @param int $donor_id Customer id. |
604 | 604 | */ |
605 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
605 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
606 | 606 | |
607 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
607 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
608 | 608 | |
609 | - if ( $payment_removed ) { |
|
609 | + if ($payment_removed) { |
|
610 | 610 | |
611 | 611 | $this->payment_ids = $new_payment_ids; |
612 | 612 | |
613 | - if ( $update_stats ) { |
|
613 | + if ($update_stats) { |
|
614 | 614 | // We removed this payment successfully, decrement the stats |
615 | - $payment_amount = give_donation_amount( $payment_id ); |
|
615 | + $payment_amount = give_donation_amount($payment_id); |
|
616 | 616 | |
617 | - if ( ! empty( $payment_amount ) ) { |
|
618 | - $this->decrease_value( $payment_amount ); |
|
617 | + if ( ! empty($payment_amount)) { |
|
618 | + $this->decrease_value($payment_amount); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $this->decrease_donation_count(); |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @param int $payment_id Payment id. |
632 | 632 | * @param int $donor_id Donor id. |
633 | 633 | */ |
634 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
634 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
635 | 635 | |
636 | 636 | return $payment_removed; |
637 | 637 | |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return int The donation count. |
649 | 649 | */ |
650 | - public function increase_purchase_count( $count = 1 ) { |
|
650 | + public function increase_purchase_count($count = 1) { |
|
651 | 651 | |
652 | 652 | // Make sure it's numeric and not negative. |
653 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
653 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
654 | 654 | return false; |
655 | 655 | } |
656 | 656 | |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @param int $count The number to increase by. |
665 | 665 | * @param int $donor_id Donor id. |
666 | 666 | */ |
667 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
667 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
668 | 668 | |
669 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
669 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
670 | 670 | $this->purchase_count = $new_total; |
671 | 671 | } |
672 | 672 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @param int $count The number increased by. |
680 | 680 | * @param int $donor_id Donor id. |
681 | 681 | */ |
682 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
682 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
683 | 683 | |
684 | 684 | return $this->purchase_count; |
685 | 685 | } |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @return mixed If successful, the new count, otherwise false. |
696 | 696 | */ |
697 | - public function decrease_donation_count( $count = 1 ) { |
|
697 | + public function decrease_donation_count($count = 1) { |
|
698 | 698 | |
699 | 699 | // Make sure it's numeric and not negative |
700 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
700 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
701 | 701 | return false; |
702 | 702 | } |
703 | 703 | |
704 | 704 | $new_total = (int) $this->purchase_count - (int) $count; |
705 | 705 | |
706 | - if ( $new_total < 0 ) { |
|
706 | + if ($new_total < 0) { |
|
707 | 707 | $new_total = 0; |
708 | 708 | } |
709 | 709 | |
@@ -715,9 +715,9 @@ discard block |
||
715 | 715 | * @param int $count The number to decrease by. |
716 | 716 | * @param int $donor_id Customer id. |
717 | 717 | */ |
718 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
718 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
719 | 719 | |
720 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
720 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
721 | 721 | $this->purchase_count = $new_total; |
722 | 722 | } |
723 | 723 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param int $count The number decreased by. |
731 | 731 | * @param int $donor_id Donor id. |
732 | 732 | */ |
733 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
733 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
734 | 734 | |
735 | 735 | return $this->purchase_count; |
736 | 736 | } |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | * |
746 | 746 | * @return mixed If successful, the new value, otherwise false. |
747 | 747 | */ |
748 | - public function increase_value( $value = 0.00 ) { |
|
748 | + public function increase_value($value = 0.00) { |
|
749 | 749 | |
750 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
750 | + $new_value = floatval($this->purchase_value) + $value; |
|
751 | 751 | |
752 | 752 | /** |
753 | 753 | * Fires before increasing donor lifetime value. |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | * @param float $value The value to increase by. |
758 | 758 | * @param int $donor_id Customer id. |
759 | 759 | */ |
760 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
760 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
761 | 761 | |
762 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
762 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
763 | 763 | $this->purchase_value = $new_value; |
764 | 764 | } |
765 | 765 | |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | * @param float $value The value increased by. |
773 | 773 | * @param int $donor_id Donor id. |
774 | 774 | */ |
775 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
775 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
776 | 776 | |
777 | 777 | return $this->purchase_value; |
778 | 778 | } |
@@ -787,11 +787,11 @@ discard block |
||
787 | 787 | * |
788 | 788 | * @return mixed If successful, the new value, otherwise false. |
789 | 789 | */ |
790 | - public function decrease_value( $value = 0.00 ) { |
|
790 | + public function decrease_value($value = 0.00) { |
|
791 | 791 | |
792 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
792 | + $new_value = floatval($this->purchase_value) - $value; |
|
793 | 793 | |
794 | - if ( $new_value < 0 ) { |
|
794 | + if ($new_value < 0) { |
|
795 | 795 | $new_value = 0.00; |
796 | 796 | } |
797 | 797 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * @param float $value The value to decrease by. |
804 | 804 | * @param int $donor_id Donor id. |
805 | 805 | */ |
806 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
806 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
807 | 807 | |
808 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
808 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
809 | 809 | $this->purchase_value = $new_value; |
810 | 810 | } |
811 | 811 | |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | * @param float $value The value decreased by. |
819 | 819 | * @param int $donor_id Donor id. |
820 | 820 | */ |
821 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
821 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
822 | 822 | |
823 | 823 | return $this->purchase_value; |
824 | 824 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @return mixed If successful, the new donation stat value, otherwise false. |
840 | 840 | */ |
841 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
841 | + public function update_donation_value($curr_amount, $new_amount) { |
|
842 | 842 | /** |
843 | 843 | * Payment total difference value can be: |
844 | 844 | * zero (in case amount not change) |
@@ -848,15 +848,15 @@ discard block |
||
848 | 848 | $payment_total_diff = $new_amount - $curr_amount; |
849 | 849 | |
850 | 850 | // We do not need to update donation stat if donation did not change. |
851 | - if ( ! $payment_total_diff ) { |
|
851 | + if ( ! $payment_total_diff) { |
|
852 | 852 | return false; |
853 | 853 | } |
854 | 854 | |
855 | - if ( $payment_total_diff > 0 ) { |
|
856 | - $this->increase_value( $payment_total_diff ); |
|
855 | + if ($payment_total_diff > 0) { |
|
856 | + $this->increase_value($payment_total_diff); |
|
857 | 857 | } else { |
858 | 858 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
859 | - $this->decrease_value( - $payment_total_diff ); |
|
859 | + $this->decrease_value( -$payment_total_diff ); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | return $this->purchase_value; |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | * |
874 | 874 | * @return array The notes requested. |
875 | 875 | */ |
876 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
876 | + public function get_notes($length = 20, $paged = 1) { |
|
877 | 877 | |
878 | - $length = is_numeric( $length ) ? $length : 20; |
|
879 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
878 | + $length = is_numeric($length) ? $length : 20; |
|
879 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
880 | 880 | |
881 | 881 | $all_notes = $this->get_raw_notes(); |
882 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
882 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
883 | 883 | |
884 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
884 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
885 | 885 | |
886 | 886 | return $desired_notes; |
887 | 887 | |
@@ -898,9 +898,9 @@ discard block |
||
898 | 898 | public function get_notes_count() { |
899 | 899 | |
900 | 900 | $all_notes = $this->get_raw_notes(); |
901 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
901 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
902 | 902 | |
903 | - return count( $notes_array ); |
|
903 | + return count($notes_array); |
|
904 | 904 | |
905 | 905 | } |
906 | 906 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | * |
914 | 914 | * @return string|float |
915 | 915 | */ |
916 | - public function get_total_donation_amount( $args = array() ) { |
|
916 | + public function get_total_donation_amount($args = array()) { |
|
917 | 917 | |
918 | 918 | /** |
919 | 919 | * Filter total donation amount. |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | * @param integer $donor_id Donor ID. |
925 | 925 | * @param array $args Pass additional data. |
926 | 926 | */ |
927 | - return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args ); |
|
927 | + return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -937,22 +937,22 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @return string|boolean The new note if added successfully, false otherwise. |
939 | 939 | */ |
940 | - public function add_note( $note = '' ) { |
|
940 | + public function add_note($note = '') { |
|
941 | 941 | |
942 | - $note = trim( $note ); |
|
943 | - if ( empty( $note ) ) { |
|
942 | + $note = trim($note); |
|
943 | + if (empty($note)) { |
|
944 | 944 | return false; |
945 | 945 | } |
946 | 946 | |
947 | 947 | $notes = $this->get_raw_notes(); |
948 | 948 | |
949 | - if ( empty( $notes ) ) { |
|
949 | + if (empty($notes)) { |
|
950 | 950 | $notes = ''; |
951 | 951 | } |
952 | 952 | |
953 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
954 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
955 | - $notes .= "\n\n" . $new_note; |
|
953 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
954 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
955 | + $notes .= "\n\n".$new_note; |
|
956 | 956 | |
957 | 957 | /** |
958 | 958 | * Fires before donor note is added. |
@@ -962,11 +962,11 @@ discard block |
||
962 | 962 | * @param string $new_note New note to add. |
963 | 963 | * @param int $donor_id Donor id. |
964 | 964 | */ |
965 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
965 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
966 | 966 | |
967 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
967 | + $updated = $this->update(array('notes' => $notes)); |
|
968 | 968 | |
969 | - if ( $updated ) { |
|
969 | + if ($updated) { |
|
970 | 970 | $this->notes = $this->get_notes(); |
971 | 971 | } |
972 | 972 | |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | * @param string $new_note New note added. |
980 | 980 | * @param int $donor_id Donor id. |
981 | 981 | */ |
982 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
982 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
983 | 983 | |
984 | 984 | // Return the formatted note, so we can test, as well as update any displays |
985 | 985 | return $new_note; |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | */ |
997 | 997 | private function get_raw_notes() { |
998 | 998 | |
999 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
999 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
1000 | 1000 | |
1001 | 1001 | return $all_notes; |
1002 | 1002 | |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is |
1015 | 1015 | * true. |
1016 | 1016 | */ |
1017 | - public function get_meta( $meta_key = '', $single = true ) { |
|
1018 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
1017 | + public function get_meta($meta_key = '', $single = true) { |
|
1018 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
1030 | 1030 | * |
1031 | 1031 | * @return bool False for failure. True for success. |
1032 | 1032 | */ |
1033 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
1034 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
1033 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
1034 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | * |
1047 | 1047 | * @return bool False on failure, true if success. |
1048 | 1048 | */ |
1049 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
1050 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
1049 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
1050 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | /** |
@@ -1061,8 +1061,8 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return bool False for failure. True for success. |
1063 | 1063 | */ |
1064 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
1065 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
1064 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
1065 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | /** |
@@ -1075,51 +1075,51 @@ discard block |
||
1075 | 1075 | * |
1076 | 1076 | * @return array The sanitized data, based off column defaults. |
1077 | 1077 | */ |
1078 | - private function sanitize_columns( $data ) { |
|
1078 | + private function sanitize_columns($data) { |
|
1079 | 1079 | |
1080 | 1080 | $columns = $this->db->get_columns(); |
1081 | 1081 | $default_values = $this->db->get_column_defaults(); |
1082 | 1082 | |
1083 | - foreach ( $columns as $key => $type ) { |
|
1083 | + foreach ($columns as $key => $type) { |
|
1084 | 1084 | |
1085 | 1085 | // Only sanitize data that we were provided |
1086 | - if ( ! array_key_exists( $key, $data ) ) { |
|
1086 | + if ( ! array_key_exists($key, $data)) { |
|
1087 | 1087 | continue; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - switch ( $type ) { |
|
1090 | + switch ($type) { |
|
1091 | 1091 | |
1092 | 1092 | case '%s': |
1093 | - if ( 'email' == $key ) { |
|
1094 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
1095 | - } elseif ( 'notes' == $key ) { |
|
1096 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
1093 | + if ('email' == $key) { |
|
1094 | + $data[$key] = sanitize_email($data[$key]); |
|
1095 | + } elseif ('notes' == $key) { |
|
1096 | + $data[$key] = strip_tags($data[$key]); |
|
1097 | 1097 | } else { |
1098 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1098 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1099 | 1099 | } |
1100 | 1100 | break; |
1101 | 1101 | |
1102 | 1102 | case '%d': |
1103 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
1104 | - $data[ $key ] = $default_values[ $key ]; |
|
1103 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
1104 | + $data[$key] = $default_values[$key]; |
|
1105 | 1105 | } else { |
1106 | - $data[ $key ] = absint( $data[ $key ] ); |
|
1106 | + $data[$key] = absint($data[$key]); |
|
1107 | 1107 | } |
1108 | 1108 | break; |
1109 | 1109 | |
1110 | 1110 | case '%f': |
1111 | 1111 | // Convert what was given to a float |
1112 | - $value = floatval( $data[ $key ] ); |
|
1112 | + $value = floatval($data[$key]); |
|
1113 | 1113 | |
1114 | - if ( ! is_float( $value ) ) { |
|
1115 | - $data[ $key ] = $default_values[ $key ]; |
|
1114 | + if ( ! is_float($value)) { |
|
1115 | + $data[$key] = $default_values[$key]; |
|
1116 | 1116 | } else { |
1117 | - $data[ $key ] = $value; |
|
1117 | + $data[$key] = $value; |
|
1118 | 1118 | } |
1119 | 1119 | break; |
1120 | 1120 | |
1121 | 1121 | default: |
1122 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
1122 | + $data[$key] = sanitize_text_field($data[$key]); |
|
1123 | 1123 | break; |
1124 | 1124 | |
1125 | 1125 | } |
@@ -1139,33 +1139,33 @@ discard block |
||
1139 | 1139 | * |
1140 | 1140 | * @return bool If the email was added successfully |
1141 | 1141 | */ |
1142 | - public function add_email( $email = '', $primary = false ) { |
|
1143 | - if ( ! is_email( $email ) ) { |
|
1142 | + public function add_email($email = '', $primary = false) { |
|
1143 | + if ( ! is_email($email)) { |
|
1144 | 1144 | return false; |
1145 | 1145 | } |
1146 | - $existing = new Give_Donor( $email ); |
|
1146 | + $existing = new Give_Donor($email); |
|
1147 | 1147 | |
1148 | - if ( $existing->id > 0 ) { |
|
1148 | + if ($existing->id > 0) { |
|
1149 | 1149 | // Email address already belongs to another donor |
1150 | 1150 | return false; |
1151 | 1151 | } |
1152 | 1152 | |
1153 | - if ( email_exists( $email ) ) { |
|
1154 | - $user = get_user_by( 'email', $email ); |
|
1155 | - if ( $user->ID != $this->user_id ) { |
|
1153 | + if (email_exists($email)) { |
|
1154 | + $user = get_user_by('email', $email); |
|
1155 | + if ($user->ID != $this->user_id) { |
|
1156 | 1156 | return false; |
1157 | 1157 | } |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1160 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1161 | 1161 | |
1162 | 1162 | // Add is used to ensure duplicate emails are not added |
1163 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1163 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1164 | 1164 | |
1165 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1165 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1166 | 1166 | |
1167 | - if ( $ret && true === $primary ) { |
|
1168 | - $this->set_primary_email( $email ); |
|
1167 | + if ($ret && true === $primary) { |
|
1168 | + $this->set_primary_email($email); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | return $ret; |
@@ -1181,16 +1181,16 @@ discard block |
||
1181 | 1181 | * |
1182 | 1182 | * @return bool If the email was removed successfully. |
1183 | 1183 | */ |
1184 | - public function remove_email( $email = '' ) { |
|
1185 | - if ( ! is_email( $email ) ) { |
|
1184 | + public function remove_email($email = '') { |
|
1185 | + if ( ! is_email($email)) { |
|
1186 | 1186 | return false; |
1187 | 1187 | } |
1188 | 1188 | |
1189 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1189 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1190 | 1190 | |
1191 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1191 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1192 | 1192 | |
1193 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1193 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1194 | 1194 | |
1195 | 1195 | return $ret; |
1196 | 1196 | } |
@@ -1207,16 +1207,16 @@ discard block |
||
1207 | 1207 | * |
1208 | 1208 | * @return bool If the email was set as primary successfully. |
1209 | 1209 | */ |
1210 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1211 | - if ( ! is_email( $new_primary_email ) ) { |
|
1210 | + public function set_primary_email($new_primary_email = '') { |
|
1211 | + if ( ! is_email($new_primary_email)) { |
|
1212 | 1212 | return false; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1215 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1216 | 1216 | |
1217 | - $existing = new Give_Donor( $new_primary_email ); |
|
1217 | + $existing = new Give_Donor($new_primary_email); |
|
1218 | 1218 | |
1219 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1219 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1220 | 1220 | // This email belongs to another donor. |
1221 | 1221 | return false; |
1222 | 1222 | } |
@@ -1224,21 +1224,21 @@ discard block |
||
1224 | 1224 | $old_email = $this->email; |
1225 | 1225 | |
1226 | 1226 | // Update donor record with new email. |
1227 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1227 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1228 | 1228 | |
1229 | 1229 | // Remove new primary from list of additional emails. |
1230 | - $remove = $this->remove_email( $new_primary_email ); |
|
1230 | + $remove = $this->remove_email($new_primary_email); |
|
1231 | 1231 | |
1232 | 1232 | // Add old email to additional emails list. |
1233 | - $add = $this->add_email( $old_email ); |
|
1233 | + $add = $this->add_email($old_email); |
|
1234 | 1234 | |
1235 | 1235 | $ret = $update && $remove && $add; |
1236 | 1236 | |
1237 | - if ( $ret ) { |
|
1237 | + if ($ret) { |
|
1238 | 1238 | $this->email = $new_primary_email; |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1241 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1242 | 1242 | |
1243 | 1243 | return $ret; |
1244 | 1244 | } |
@@ -1253,17 +1253,17 @@ discard block |
||
1253 | 1253 | * |
1254 | 1254 | * @return bool |
1255 | 1255 | */ |
1256 | - private function is_valid_address( $address ) { |
|
1256 | + private function is_valid_address($address) { |
|
1257 | 1257 | $is_valid_address = true; |
1258 | 1258 | |
1259 | 1259 | // Address ready to process even if only one value set. |
1260 | - foreach ( $address as $address_type => $value ) { |
|
1260 | + foreach ($address as $address_type => $value) { |
|
1261 | 1261 | // @todo: Handle state field validation on basis of country. |
1262 | - if ( in_array( $address_type, array( 'line2', 'state' ) ) ) { |
|
1262 | + if (in_array($address_type, array('line2', 'state'))) { |
|
1263 | 1263 | continue; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if ( empty( $value ) ) { |
|
1266 | + if (empty($value)) { |
|
1267 | 1267 | $is_valid_address = false; |
1268 | 1268 | break; |
1269 | 1269 | } |
@@ -1290,57 +1290,57 @@ discard block |
||
1290 | 1290 | * |
1291 | 1291 | * @return bool |
1292 | 1292 | */ |
1293 | - public function add_address( $address_type, $address ) { |
|
1293 | + public function add_address($address_type, $address) { |
|
1294 | 1294 | // Bailout. |
1295 | - if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) { |
|
1295 | + if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) { |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // Check if multiple address exist or not and set params. |
1300 | 1300 | $multi_address_id = null; |
1301 | - if ( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) { |
|
1302 | - $address_type = $is_multi_address ? str_replace( '[]', '', $address_type ) : $address_type; |
|
1303 | - } elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ) { |
|
1304 | - $multi_address_id = $is_multi_address ? array_pop( explode( '_', $address_type ) ) : $address_type; |
|
1301 | + if ($is_multi_address = (false !== strpos($address_type, '[]'))) { |
|
1302 | + $address_type = $is_multi_address ? str_replace('[]', '', $address_type) : $address_type; |
|
1303 | + } elseif ($is_multi_address = (false !== strpos($address_type, '_'))) { |
|
1304 | + $multi_address_id = $is_multi_address ? array_pop(explode('_', $address_type)) : $address_type; |
|
1305 | 1305 | |
1306 | - $address_type = $is_multi_address ? array_shift( explode( '_', $address_type ) ) : $address_type; |
|
1306 | + $address_type = $is_multi_address ? array_shift(explode('_', $address_type)) : $address_type; |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | // Bailout: do not save duplicate orders |
1310 | - if ( $this->does_address_exist( $address_type, $address ) ) { |
|
1310 | + if ($this->does_address_exist($address_type, $address)) { |
|
1311 | 1311 | return false; |
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | // Set default address. |
1315 | - $address = wp_parse_args( $address, array( |
|
1315 | + $address = wp_parse_args($address, array( |
|
1316 | 1316 | 'line1' => '', |
1317 | 1317 | 'line2' => '', |
1318 | 1318 | 'city' => '', |
1319 | 1319 | 'state' => '', |
1320 | 1320 | 'country' => '', |
1321 | 1321 | 'zip' => '', |
1322 | - ) ); |
|
1322 | + )); |
|
1323 | 1323 | |
1324 | 1324 | // Set meta key prefix. |
1325 | 1325 | global $wpdb; |
1326 | 1326 | $meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}"; |
1327 | 1327 | $meta_type = Give()->donor_meta->meta_type; |
1328 | 1328 | |
1329 | - if ( $is_multi_address ) { |
|
1330 | - if ( is_null( $multi_address_id ) ) { |
|
1329 | + if ($is_multi_address) { |
|
1330 | + if (is_null($multi_address_id)) { |
|
1331 | 1331 | // Get latest address key to set multi address id. |
1332 | - $multi_address_id = $wpdb->get_var( $wpdb->prepare( " |
|
1332 | + $multi_address_id = $wpdb->get_var($wpdb->prepare(" |
|
1333 | 1333 | SELECT meta_key FROM {$wpdb->donormeta} |
1334 | 1334 | WHERE meta_key |
1335 | 1335 | LIKE '%%%s%%' |
1336 | 1336 | AND {$meta_type}_id=%d |
1337 | 1337 | ORDER BY meta_id DESC |
1338 | 1338 | LIMIT 1 |
1339 | - ", "_give_donor_address_{$address_type}_line1", $this->id ) ); |
|
1339 | + ", "_give_donor_address_{$address_type}_line1", $this->id)); |
|
1340 | 1340 | |
1341 | - if ( ! empty( $multi_address_id ) ) { |
|
1342 | - $multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) ); |
|
1343 | - $multi_address_id ++; |
|
1341 | + if ( ! empty($multi_address_id)) { |
|
1342 | + $multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1)); |
|
1343 | + $multi_address_id++; |
|
1344 | 1344 | } else { |
1345 | 1345 | $multi_address_id = 0; |
1346 | 1346 | } |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | // Save donor address. |
1353 | - foreach ( $address as $type => $value ) { |
|
1354 | - $meta_key = str_replace( '{address_name}', $type, $meta_key_prefix ); |
|
1355 | - Give()->donor_meta->update_meta( $this->id, $meta_key, $value ); |
|
1353 | + foreach ($address as $type => $value) { |
|
1354 | + $meta_key = str_replace('{address_name}', $type, $meta_key_prefix); |
|
1355 | + Give()->donor_meta->update_meta($this->id, $meta_key, $value); |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | $this->setup_address(); |
@@ -1371,31 +1371,31 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @return bool |
1373 | 1373 | */ |
1374 | - public function remove_address( $address_id ) { |
|
1374 | + public function remove_address($address_id) { |
|
1375 | 1375 | global $wpdb; |
1376 | 1376 | |
1377 | 1377 | // Get address type. |
1378 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1378 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1379 | 1379 | |
1380 | - $address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id; |
|
1380 | + $address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id; |
|
1381 | 1381 | |
1382 | - $address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null; |
|
1382 | + $address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null; |
|
1383 | 1383 | |
1384 | 1384 | // Set meta key prefix. |
1385 | 1385 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1386 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1386 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1387 | 1387 | $meta_key_prefix .= "_{$address_count}"; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | $meta_type = Give()->donor_meta->meta_type; |
1391 | 1391 | |
1392 | 1392 | // Process query. |
1393 | - $row_affected = $wpdb->query( $wpdb->prepare( " |
|
1393 | + $row_affected = $wpdb->query($wpdb->prepare(" |
|
1394 | 1394 | DELETE FROM {$wpdb->donormeta} |
1395 | 1395 | WHERE meta_key |
1396 | 1396 | LIKE '%s' |
1397 | 1397 | AND {$meta_type}_id=%d |
1398 | - ", $meta_key_prefix, $this->id ) ); |
|
1398 | + ", $meta_key_prefix, $this->id)); |
|
1399 | 1399 | |
1400 | 1400 | $this->setup_address(); |
1401 | 1401 | |
@@ -1414,39 +1414,39 @@ discard block |
||
1414 | 1414 | * |
1415 | 1415 | * @return bool |
1416 | 1416 | */ |
1417 | - public function update_address( $address_id, $address ) { |
|
1417 | + public function update_address($address_id, $address) { |
|
1418 | 1418 | global $wpdb; |
1419 | 1419 | |
1420 | 1420 | // Get address type. |
1421 | - $is_multi_address = false !== strpos( $address_id, '_' ) ? true : false; |
|
1421 | + $is_multi_address = false !== strpos($address_id, '_') ? true : false; |
|
1422 | 1422 | |
1423 | - $address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id; |
|
1423 | + $address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id; |
|
1424 | 1424 | |
1425 | - $address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null; |
|
1425 | + $address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null; |
|
1426 | 1426 | |
1427 | 1427 | // Set meta key prefix. |
1428 | 1428 | $meta_key_prefix = "_give_donor_address_{$address_type}_%"; |
1429 | - if ( $is_multi_address && is_numeric( $address_count ) ) { |
|
1429 | + if ($is_multi_address && is_numeric($address_count)) { |
|
1430 | 1430 | $meta_key_prefix .= "_{$address_count}"; |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | $meta_type = Give()->donor_meta->meta_type; |
1434 | 1434 | |
1435 | 1435 | // Process query. |
1436 | - $row_affected = $wpdb->get_results( $wpdb->prepare( " |
|
1436 | + $row_affected = $wpdb->get_results($wpdb->prepare(" |
|
1437 | 1437 | SELECT meta_key FROM {$wpdb->donormeta} |
1438 | 1438 | WHERE meta_key |
1439 | 1439 | LIKE '%s' |
1440 | 1440 | AND {$meta_type}_id=%d |
1441 | - ", $meta_key_prefix, $this->id ) ); |
|
1441 | + ", $meta_key_prefix, $this->id)); |
|
1442 | 1442 | |
1443 | 1443 | // Return result. |
1444 | - if ( ! count( $row_affected ) ) { |
|
1444 | + if ( ! count($row_affected)) { |
|
1445 | 1445 | return false; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | // Update address. |
1449 | - if ( ! $this->add_address( $address_id, $address ) ) { |
|
1449 | + if ( ! $this->add_address($address_id, $address)) { |
|
1450 | 1450 | return false; |
1451 | 1451 | } |
1452 | 1452 | |
@@ -1465,39 +1465,39 @@ discard block |
||
1465 | 1465 | * |
1466 | 1466 | * @return bool|null |
1467 | 1467 | */ |
1468 | - public function does_address_exist( $current_address_type, $current_address ) { |
|
1468 | + public function does_address_exist($current_address_type, $current_address) { |
|
1469 | 1469 | $status = false; |
1470 | 1470 | |
1471 | 1471 | // Bailout. |
1472 | - if ( empty( $current_address_type ) || empty( $current_address ) ) { |
|
1472 | + if (empty($current_address_type) || empty($current_address)) { |
|
1473 | 1473 | return null; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | // Bailout. |
1477 | - if ( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) { |
|
1477 | + if (empty($this->address) || empty($this->address[$current_address_type])) { |
|
1478 | 1478 | return $status; |
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | // Get address. |
1482 | - $address = $this->address[ $current_address_type ]; |
|
1482 | + $address = $this->address[$current_address_type]; |
|
1483 | 1483 | |
1484 | - switch ( true ) { |
|
1484 | + switch (true) { |
|
1485 | 1485 | |
1486 | 1486 | // Single address. |
1487 | - case is_string( end( $address ) ) : |
|
1488 | - $status = $this->is_address_match( $current_address, $address ); |
|
1487 | + case is_string(end($address)) : |
|
1488 | + $status = $this->is_address_match($current_address, $address); |
|
1489 | 1489 | break; |
1490 | 1490 | |
1491 | 1491 | // Multi address. |
1492 | - case is_array( end( $address ) ): |
|
1492 | + case is_array(end($address)): |
|
1493 | 1493 | // Compare address. |
1494 | - foreach ( $address as $saved_address ) { |
|
1495 | - if ( empty( $saved_address ) ) { |
|
1494 | + foreach ($address as $saved_address) { |
|
1495 | + if (empty($saved_address)) { |
|
1496 | 1496 | continue; |
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | // Exit loop immediately if address exist. |
1500 | - if ( $status = $this->is_address_match( $current_address, $saved_address ) ) { |
|
1500 | + if ($status = $this->is_address_match($current_address, $saved_address)) { |
|
1501 | 1501 | break; |
1502 | 1502 | } |
1503 | 1503 | } |
@@ -1518,10 +1518,10 @@ discard block |
||
1518 | 1518 | * |
1519 | 1519 | * @return bool |
1520 | 1520 | */ |
1521 | - private function is_address_match( $address_1, $address_2 ) { |
|
1522 | - $result = array_diff( $address_1, $address_2 ); |
|
1521 | + private function is_address_match($address_1, $address_2) { |
|
1522 | + $result = array_diff($address_1, $address_2); |
|
1523 | 1523 | |
1524 | - return empty( $result ); |
|
1524 | + return empty($result); |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
@@ -1532,23 +1532,23 @@ discard block |
||
1532 | 1532 | * @since 2.0 |
1533 | 1533 | * @return object |
1534 | 1534 | */ |
1535 | - public function split_donor_name( $id ) { |
|
1535 | + public function split_donor_name($id) { |
|
1536 | 1536 | $first_name = $last_name = ''; |
1537 | - $donor = new Give_Donor( $id ); |
|
1537 | + $donor = new Give_Donor($id); |
|
1538 | 1538 | |
1539 | - $split_donor_name = explode( ' ', $donor->name, 2 ); |
|
1539 | + $split_donor_name = explode(' ', $donor->name, 2); |
|
1540 | 1540 | |
1541 | 1541 | // Check for existence of first name after split of donor name. |
1542 | - if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) { |
|
1542 | + if (is_array($split_donor_name) && ! empty($split_donor_name[0])) { |
|
1543 | 1543 | $first_name = $split_donor_name[0]; |
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | // Check for existence of last name after split of donor name. |
1547 | - if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) { |
|
1547 | + if (is_array($split_donor_name) && ! empty($split_donor_name[1])) { |
|
1548 | 1548 | $last_name = $split_donor_name[1]; |
1549 | 1549 | } |
1550 | 1550 | |
1551 | - return (object) array( 'first_name' => $first_name, 'last_name' => $last_name ); |
|
1551 | + return (object) array('first_name' => $first_name, 'last_name' => $last_name); |
|
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | /** |
@@ -1558,9 +1558,9 @@ discard block |
||
1558 | 1558 | * @return string |
1559 | 1559 | */ |
1560 | 1560 | public function get_first_name() { |
1561 | - $first_name = $this->get_meta( '_give_donor_first_name' ); |
|
1562 | - if ( ! $first_name ) { |
|
1563 | - $first_name = $this->split_donor_name( $this->id )->first_name; |
|
1561 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1562 | + if ( ! $first_name) { |
|
1563 | + $first_name = $this->split_donor_name($this->id)->first_name; |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | return $first_name; |
@@ -1573,15 +1573,15 @@ discard block |
||
1573 | 1573 | * @return string |
1574 | 1574 | */ |
1575 | 1575 | public function get_last_name() { |
1576 | - $first_name = $this->get_meta( '_give_donor_first_name' ); |
|
1577 | - $last_name = $this->get_meta( '_give_donor_last_name' ); |
|
1576 | + $first_name = $this->get_meta('_give_donor_first_name'); |
|
1577 | + $last_name = $this->get_meta('_give_donor_last_name'); |
|
1578 | 1578 | |
1579 | 1579 | // This condition will prevent unnecessary splitting of donor name to fetch last name. |
1580 | - if ( ! $first_name && ! $last_name ) { |
|
1581 | - $last_name = $this->split_donor_name( $this->id )->last_name; |
|
1580 | + if ( ! $first_name && ! $last_name) { |
|
1581 | + $last_name = $this->split_donor_name($this->id)->last_name; |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | - return ( $last_name ) ? $last_name : ''; |
|
1584 | + return ($last_name) ? $last_name : ''; |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | /** |
@@ -1592,7 +1592,7 @@ discard block |
||
1592 | 1592 | * @return string $company_name Donor Company Name |
1593 | 1593 | */ |
1594 | 1594 | public function get_company_name() { |
1595 | - $company_name = $this->get_meta( '_give_donor_company' ); |
|
1595 | + $company_name = $this->get_meta('_give_donor_company'); |
|
1596 | 1596 | |
1597 | 1597 | return $company_name; |
1598 | 1598 | } |
@@ -1606,9 +1606,9 @@ discard block |
||
1606 | 1606 | */ |
1607 | 1607 | public function get_last_donation() { |
1608 | 1608 | |
1609 | - $payments = array_unique( array_values( explode( ',', $this->payment_ids ) ) ); |
|
1609 | + $payments = array_unique(array_values(explode(',', $this->payment_ids))); |
|
1610 | 1610 | |
1611 | - return end( $payments ); |
|
1611 | + return end($payments); |
|
1612 | 1612 | |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1621,18 +1621,18 @@ discard block |
||
1621 | 1621 | * |
1622 | 1622 | * @return string The date of the last donation. |
1623 | 1623 | */ |
1624 | - public function get_last_donation_date( $formatted = false ) { |
|
1624 | + public function get_last_donation_date($formatted = false) { |
|
1625 | 1625 | $completed_data = ''; |
1626 | 1626 | |
1627 | 1627 | // Return if donation id is invalid. |
1628 | - if( ! ( $last_donation = absint( $this->get_last_donation() ) ) ) { |
|
1628 | + if ( ! ($last_donation = absint($this->get_last_donation()))) { |
|
1629 | 1629 | return $completed_data; |
1630 | 1630 | } |
1631 | 1631 | |
1632 | - $completed_data = give_get_payment_completed_date( $last_donation ); |
|
1632 | + $completed_data = give_get_payment_completed_date($last_donation); |
|
1633 | 1633 | |
1634 | - if ( $formatted ) { |
|
1635 | - return date_i18n( give_date_format(), strtotime( $completed_data ) ); |
|
1634 | + if ($formatted) { |
|
1635 | + return date_i18n(give_date_format(), strtotime($completed_data)); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | return $completed_data; |
@@ -1648,10 +1648,10 @@ discard block |
||
1648 | 1648 | */ |
1649 | 1649 | public function get_donor_initals() { |
1650 | 1650 | |
1651 | - $first_name_initial = mb_substr( $this->get_first_name(), 0, 1, 'utf-8' ); |
|
1652 | - $last_name_initial = mb_substr( $this->get_last_name(), 0, 1, 'utf-8' ); |
|
1651 | + $first_name_initial = mb_substr($this->get_first_name(), 0, 1, 'utf-8'); |
|
1652 | + $last_name_initial = mb_substr($this->get_last_name(), 0, 1, 'utf-8'); |
|
1653 | 1653 | |
1654 | - return apply_filters( 'get_donor_initals', $first_name_initial . $last_name_initial ); |
|
1654 | + return apply_filters('get_donor_initals', $first_name_initial.$last_name_initial); |
|
1655 | 1655 | |
1656 | 1656 | } |
1657 | 1657 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | * |
47 | 47 | * @since 2.2.0 |
48 | 48 | * |
49 | - * @param string|int $id_or_email |
|
49 | + * @param string $id_or_email |
|
50 | 50 | * |
51 | 51 | * @return bool |
52 | 52 | */ |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return string HTML output. |
23 | 23 | */ |
24 | -function give_get_donor_avatar( $donor, $size = 60 ) { |
|
24 | +function give_get_donor_avatar($donor, $size = 60) { |
|
25 | 25 | ob_start(); |
26 | 26 | ?> |
27 | 27 | <div class="give-donor__image"> |
28 | 28 | <?php |
29 | 29 | // Check if gravatar exists. |
30 | - if ( give_validate_gravatar( $donor->email ) ) { |
|
30 | + if (give_validate_gravatar($donor->email)) { |
|
31 | 31 | // Return avatar. |
32 | - echo get_avatar( $donor->email, $size ); |
|
32 | + echo get_avatar($donor->email, $size); |
|
33 | 33 | } else { |
34 | 34 | // No gravatar = output initials. |
35 | 35 | echo $donor->get_donor_initals(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | </div> |
38 | 38 | <?php |
39 | 39 | |
40 | - return apply_filters( 'give_get_donor_avatar', ob_get_clean() ); |
|
40 | + return apply_filters('give_get_donor_avatar', ob_get_clean()); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -50,51 +50,51 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return bool |
52 | 52 | */ |
53 | -function give_validate_gravatar( $id_or_email ) { |
|
53 | +function give_validate_gravatar($id_or_email) { |
|
54 | 54 | |
55 | 55 | //id or email code borrowed from wp-includes/pluggable.php |
56 | 56 | $email = ''; |
57 | - if ( is_numeric( $id_or_email ) ) { |
|
57 | + if (is_numeric($id_or_email)) { |
|
58 | 58 | $id = (int) $id_or_email; |
59 | - $user = get_userdata( $id ); |
|
60 | - if ( $user ) { |
|
59 | + $user = get_userdata($id); |
|
60 | + if ($user) { |
|
61 | 61 | $email = $user->user_email; |
62 | 62 | } |
63 | - } elseif ( is_object( $id_or_email ) ) { |
|
63 | + } elseif (is_object($id_or_email)) { |
|
64 | 64 | // No avatar for pingbacks or trackbacks |
65 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
66 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
65 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
66 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
70 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
70 | + if ( ! empty($id_or_email->user_id)) { |
|
71 | 71 | $id = (int) $id_or_email->user_id; |
72 | - $user = get_userdata( $id ); |
|
73 | - if ( $user ) { |
|
72 | + $user = get_userdata($id); |
|
73 | + if ($user) { |
|
74 | 74 | $email = $user->user_email; |
75 | 75 | } |
76 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
76 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
77 | 77 | $email = $id_or_email->comment_author_email; |
78 | 78 | } |
79 | 79 | } else { |
80 | 80 | $email = $id_or_email; |
81 | 81 | } |
82 | 82 | |
83 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
84 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
83 | + $hashkey = md5(strtolower(trim($email))); |
|
84 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
85 | 85 | |
86 | - $data = wp_cache_get( $hashkey ); |
|
87 | - if ( false === $data ) { |
|
88 | - $response = wp_remote_head( $uri ); |
|
89 | - if ( is_wp_error( $response ) ) { |
|
86 | + $data = wp_cache_get($hashkey); |
|
87 | + if (false === $data) { |
|
88 | + $response = wp_remote_head($uri); |
|
89 | + if (is_wp_error($response)) { |
|
90 | 90 | $data = 'not200'; |
91 | 91 | } else { |
92 | 92 | $data = $response['response']['code']; |
93 | 93 | } |
94 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
94 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
95 | 95 | |
96 | 96 | } |
97 | - if ( $data == '200' ) { |
|
97 | + if ($data == '200') { |
|
98 | 98 | return true; |
99 | 99 | } else { |
100 | 100 | return false; |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return int The new note ID |
116 | 116 | */ |
117 | -function give_insert_donor_donation_comment( $donation_id, $donor, $note, $comment_args = array() ) { |
|
117 | +function give_insert_donor_donation_comment($donation_id, $donor, $note, $comment_args = array()) { |
|
118 | 118 | $comment_args = wp_parse_args( |
119 | 119 | $comment_args, |
120 | 120 | array( |
121 | 121 | 'comment_approved' => 0, |
122 | - 'comment_parent' => give_get_payment_form_id( $donation_id ) |
|
122 | + 'comment_parent' => give_get_payment_form_id($donation_id) |
|
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | |
126 | - $comment_id = Give_Comment::add( $donation_id, $note, 'payment', $comment_args ); |
|
126 | + $comment_id = Give_Comment::add($donation_id, $note, 'payment', $comment_args); |
|
127 | 127 | |
128 | - update_comment_meta( $comment_id, '_give_donor_id', $donor ); |
|
128 | + update_comment_meta($comment_id, '_give_donor_id', $donor); |
|
129 | 129 | |
130 | 130 | return $comment_id; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return WP_Comment|array |
146 | 146 | */ |
147 | -function give_get_donor_donation_comment( $donation_id, $donor_id, $search = '' ) { |
|
147 | +function give_get_donor_donation_comment($donation_id, $donor_id, $search = '') { |
|
148 | 148 | $comments = Give_Comment::get( |
149 | 149 | $donation_id, |
150 | 150 | 'payment', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $search |
161 | 161 | ); |
162 | 162 | |
163 | - return ( ! empty( $comments ) ? current( $comments ) : array() ); |
|
163 | + return ( ! empty($comments) ? current($comments) : array()); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int |
178 | 178 | */ |
179 | -function give_get_donor_donation_comment_id( $donation_id, $donor_id, $search = '' ) { |
|
179 | +function give_get_donor_donation_comment_id($donation_id, $donor_id, $search = '') { |
|
180 | 180 | /* @var WP_Comment|array $comment */ |
181 | - $comment = give_get_donor_donation_comment( $donation_id, $donor_id, $search ); |
|
181 | + $comment = give_get_donor_donation_comment($donation_id, $donor_id, $search); |
|
182 | 182 | $comment_id = $comment instanceof WP_Comment ? $comment->comment_ID : 0; |
183 | 183 | |
184 | 184 | return $comment_id; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return array |
199 | 199 | */ |
200 | -function give_get_donor_donation_comments( $donor_id, $comment_args = array(), $search = '' ) { |
|
200 | +function give_get_donor_donation_comments($donor_id, $comment_args = array(), $search = '') { |
|
201 | 201 | $comments = Give_Comment::get( |
202 | 202 | $donor_id, |
203 | 203 | 'payment', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $search |
206 | 206 | ); |
207 | 207 | |
208 | - return ( ! empty( $comments ) ? $comments : array() ); |
|
208 | + return ( ! empty($comments) ? $comments : array()); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -219,19 +219,19 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return string |
221 | 221 | */ |
222 | -function give_get_donor_donation_comment_html( $comment, $payment_id = 0 ) { |
|
222 | +function give_get_donor_donation_comment_html($comment, $payment_id = 0) { |
|
223 | 223 | |
224 | - if ( is_numeric( $comment ) ) { |
|
225 | - $comment = get_comment( $comment ); |
|
224 | + if (is_numeric($comment)) { |
|
225 | + $comment = get_comment($comment); |
|
226 | 226 | } |
227 | 227 | |
228 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
228 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
229 | 229 | |
230 | 230 | $comment_html = sprintf( |
231 | 231 | '<div class="give-payment-note" id="give-payment-note-%s"><p><strong>%s</strong> – <span style="color:#aaa;font-style:italic;">%s</span><br/>%s</p></div>', |
232 | 232 | $comment->comment_ID, |
233 | - get_comment_author( $comment->comment_ID ), |
|
234 | - date_i18n( $date_format, strtotime( $comment->comment_date ) ), |
|
233 | + get_comment_author($comment->comment_ID), |
|
234 | + date_i18n($date_format, strtotime($comment->comment_date)), |
|
235 | 235 | $comment->comment_content |
236 | 236 | ); |
237 | 237 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return WP_Comment/array |
252 | 252 | */ |
253 | -function give_get_donor_latest_comment( $donor_id, $form_id = 0 ) { |
|
253 | +function give_get_donor_latest_comment($donor_id, $form_id = 0) { |
|
254 | 254 | $comment_args = array( |
255 | 255 | 'post_id' => 0, |
256 | 256 | 'orderby' => 'comment_ID', |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Get donor donation comment for specific form. |
273 | - if ( $form_id ) { |
|
273 | + if ($form_id) { |
|
274 | 274 | $comment_args['parent'] = $form_id; |
275 | 275 | } |
276 | 276 | |
277 | - $comment = current( give_get_donor_donation_comments( $donor_id, $comment_args ) ); |
|
277 | + $comment = current(give_get_donor_donation_comments($donor_id, $comment_args)); |
|
278 | 278 | |
279 | 279 | return $comment; |
280 | 280 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param int|bool $payment_id A given payment. |
407 | 407 | * |
408 | - * @return mixed void|false |
|
408 | + * @return false|null void|false |
|
409 | 409 | */ |
410 | 410 | public function __construct( $payment_id = false ) { |
411 | 411 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * |
1175 | 1175 | * @param string|bool $note The note to add. |
1176 | 1176 | * |
1177 | - * @return bool If the note was specified or not |
|
1177 | + * @return false|null If the note was specified or not |
|
1178 | 1178 | */ |
1179 | 1179 | public function add_note( $note = false ) { |
1180 | 1180 | // 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 | |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return mixed void|false |
409 | 409 | */ |
410 | - public function __construct( $payment_id = false ) { |
|
410 | + public function __construct($payment_id = false) { |
|
411 | 411 | |
412 | - if ( empty( $payment_id ) ) { |
|
412 | + if (empty($payment_id)) { |
|
413 | 413 | return false; |
414 | 414 | } |
415 | 415 | |
416 | - $this->setup_payment( $payment_id ); |
|
416 | + $this->setup_payment($payment_id); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return mixed The value. |
428 | 428 | */ |
429 | - public function __get( $key ) { |
|
429 | + public function __get($key) { |
|
430 | 430 | |
431 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
431 | + if (method_exists($this, 'get_'.$key)) { |
|
432 | 432 | |
433 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
433 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
434 | 434 | |
435 | 435 | } else { |
436 | 436 | |
@@ -452,18 +452,18 @@ discard block |
||
452 | 452 | * @param string $key The property name. |
453 | 453 | * @param mixed $value The value of the property. |
454 | 454 | */ |
455 | - public function __set( $key, $value ) { |
|
456 | - $ignore = array( '_ID' ); |
|
455 | + public function __set($key, $value) { |
|
456 | + $ignore = array('_ID'); |
|
457 | 457 | |
458 | - if ( 'status' === $key ) { |
|
458 | + if ('status' === $key) { |
|
459 | 459 | $this->old_status = $this->status; |
460 | 460 | } |
461 | 461 | |
462 | - if ( ! in_array( $key, $ignore ) ) { |
|
463 | - $this->pending[ $key ] = $value; |
|
462 | + if ( ! in_array($key, $ignore)) { |
|
463 | + $this->pending[$key] = $value; |
|
464 | 464 | } |
465 | 465 | |
466 | - if ( '_ID' !== $key ) { |
|
466 | + if ('_ID' !== $key) { |
|
467 | 467 | $this->$key = $value; |
468 | 468 | } |
469 | 469 | } |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return boolean|null If the item is set or not |
480 | 480 | */ |
481 | - public function __isset( $name ) { |
|
482 | - if ( property_exists( $this, $name ) ) { |
|
483 | - return false === empty( $this->$name ); |
|
481 | + public function __isset($name) { |
|
482 | + if (property_exists($this, $name)) { |
|
483 | + return false === empty($this->$name); |
|
484 | 484 | } else { |
485 | 485 | return null; |
486 | 486 | } |
@@ -496,20 +496,20 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return bool If the setup was successful or not |
498 | 498 | */ |
499 | - private function setup_payment( $payment_id ) { |
|
499 | + private function setup_payment($payment_id) { |
|
500 | 500 | $this->pending = array(); |
501 | 501 | |
502 | - if ( empty( $payment_id ) ) { |
|
502 | + if (empty($payment_id)) { |
|
503 | 503 | return false; |
504 | 504 | } |
505 | 505 | |
506 | - $payment = get_post( absint( $payment_id ) ); |
|
506 | + $payment = get_post(absint($payment_id)); |
|
507 | 507 | |
508 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
508 | + if ( ! $payment || is_wp_error($payment)) { |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
512 | - if ( 'give_payment' !== $payment->post_type ) { |
|
512 | + if ('give_payment' !== $payment->post_type) { |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | * @param Give_Payment $this Payment object. |
524 | 524 | * @param int $payment_id The ID of the payment. |
525 | 525 | */ |
526 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
526 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
527 | 527 | |
528 | 528 | // Get payment from cache. |
529 | - $donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' ); |
|
529 | + $donation_vars = Give_Cache::get_group($payment_id, 'give-donations'); |
|
530 | 530 | |
531 | - if ( is_null( $donation_vars ) ) { |
|
531 | + if (is_null($donation_vars)) { |
|
532 | 532 | // Primary Identifier. |
533 | - $this->ID = absint( $payment_id ); |
|
533 | + $this->ID = absint($payment_id); |
|
534 | 534 | |
535 | 535 | // Protected ID that can never be changed. |
536 | - $this->_ID = absint( $payment_id ); |
|
536 | + $this->_ID = absint($payment_id); |
|
537 | 537 | |
538 | 538 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
539 | 539 | $this->payment_meta = $this->get_meta(); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $this->parent_payment = $payment->post_parent; |
550 | 550 | |
551 | 551 | $all_payment_statuses = give_get_payment_statuses(); |
552 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
552 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
553 | 553 | |
554 | 554 | // Currency Based. |
555 | 555 | $this->total = $this->setup_total(); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $this->address = $this->setup_address(); |
571 | 571 | $this->first_name = $this->user_info['first_name']; |
572 | 572 | $this->last_name = $this->user_info['last_name']; |
573 | - $this->title_prefix = isset( $this->user_info['title'] ) ? $this->user_info['title'] : ''; |
|
573 | + $this->title_prefix = isset($this->user_info['title']) ? $this->user_info['title'] : ''; |
|
574 | 574 | |
575 | 575 | // Other Identifiers. |
576 | 576 | $this->form_title = $this->setup_form_title(); |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | $this->key = $this->setup_payment_key(); |
580 | 580 | $this->number = $this->setup_payment_number(); |
581 | 581 | |
582 | - Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' ); |
|
582 | + Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations'); |
|
583 | 583 | } else { |
584 | 584 | |
585 | - foreach ( $donation_vars as $donation_var => $value ) { |
|
585 | + foreach ($donation_vars as $donation_var => $value) { |
|
586 | 586 | $this->$donation_var = $value; |
587 | 587 | } |
588 | 588 | } // End if(). |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @param Give_Payment $this Payment object. |
598 | 598 | * @param int $payment_id The ID of the payment. |
599 | 599 | */ |
600 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
600 | + do_action('give_setup_payment', $this, $payment_id); |
|
601 | 601 | |
602 | 602 | return true; |
603 | 603 | } |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | * |
617 | 617 | * @return void |
618 | 618 | */ |
619 | - public function update_payment_setup( $payment_id ) { |
|
619 | + public function update_payment_setup($payment_id) { |
|
620 | 620 | // Delete cache. |
621 | - Give_Cache::delete_group( $this->ID,'give-donations' ); |
|
621 | + Give_Cache::delete_group($this->ID, 'give-donations'); |
|
622 | 622 | |
623 | - $this->setup_payment( $payment_id ); |
|
623 | + $this->setup_payment($payment_id); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -635,24 +635,24 @@ discard block |
||
635 | 635 | |
636 | 636 | // Construct the payment title. |
637 | 637 | $payment_title = ''; |
638 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
639 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
640 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
638 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
639 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
640 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
641 | 641 | $payment_title = $this->first_name; |
642 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
642 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
643 | 643 | $payment_title = $this->email; |
644 | 644 | } |
645 | 645 | |
646 | 646 | // Set Key. |
647 | - if ( empty( $this->key ) ) { |
|
647 | + if (empty($this->key)) { |
|
648 | 648 | |
649 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
650 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key. |
|
649 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
650 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key. |
|
651 | 651 | $this->pending['key'] = $this->key; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Set IP. |
655 | - if ( empty( $this->ip ) ) { |
|
655 | + if (empty($this->ip)) { |
|
656 | 656 | |
657 | 657 | $this->ip = give_get_ip(); |
658 | 658 | $this->pending['ip'] = $this->ip; |
@@ -682,19 +682,19 @@ discard block |
||
682 | 682 | 'status' => $this->status, |
683 | 683 | ); |
684 | 684 | |
685 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
685 | + $args = apply_filters('give_insert_payment_args', array( |
|
686 | 686 | 'post_title' => $payment_title, |
687 | 687 | 'post_status' => $this->status, |
688 | 688 | 'post_type' => 'give_payment', |
689 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
690 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
689 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
690 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
691 | 691 | 'post_parent' => $this->parent_payment, |
692 | - ), $payment_data ); |
|
692 | + ), $payment_data); |
|
693 | 693 | |
694 | 694 | // Create a blank payment. |
695 | - $payment_id = wp_insert_post( $args ); |
|
695 | + $payment_id = wp_insert_post($args); |
|
696 | 696 | |
697 | - if ( ! empty( $payment_id ) ) { |
|
697 | + if ( ! empty($payment_id)) { |
|
698 | 698 | |
699 | 699 | $this->ID = $payment_id; |
700 | 700 | $this->_ID = $payment_id; |
@@ -706,43 +706,43 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @since 1.8.13 |
708 | 708 | */ |
709 | - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args ); |
|
709 | + $donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args); |
|
710 | 710 | |
711 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
712 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
711 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
712 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
713 | 713 | |
714 | 714 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
715 | - if ( ! empty( $donor->id ) && $this->email !== $donor->email ) { |
|
716 | - $donor->add_email( $this->email ); |
|
715 | + if ( ! empty($donor->id) && $this->email !== $donor->email) { |
|
716 | + $donor->add_email($this->email); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | - if ( empty( $donor->id ) ) { |
|
721 | - $donor = new Give_Donor( $this->email ); |
|
720 | + if (empty($donor->id)) { |
|
721 | + $donor = new Give_Donor($this->email); |
|
722 | 722 | } |
723 | 723 | |
724 | - if ( empty( $donor->id ) ) { |
|
724 | + if (empty($donor->id)) { |
|
725 | 725 | |
726 | 726 | $donor_data = array( |
727 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
727 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
728 | 728 | 'email' => $this->email, |
729 | 729 | 'user_id' => $this->user_id, |
730 | 730 | ); |
731 | 731 | |
732 | - $donor->create( $donor_data ); |
|
732 | + $donor->create($donor_data); |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Update Donor Meta once donor is created. |
737 | - $donor->update_meta( '_give_donor_first_name', $this->first_name ); |
|
738 | - $donor->update_meta( '_give_donor_last_name', $this->last_name ); |
|
739 | - $donor->update_meta( '_give_donor_title_prefix', $this->title_prefix ); |
|
737 | + $donor->update_meta('_give_donor_first_name', $this->first_name); |
|
738 | + $donor->update_meta('_give_donor_last_name', $this->last_name); |
|
739 | + $donor->update_meta('_give_donor_title_prefix', $this->title_prefix); |
|
740 | 740 | |
741 | 741 | $this->customer_id = $donor->id; |
742 | 742 | $this->pending['customer_id'] = $this->customer_id; |
743 | - $donor->attach_payment( $this->ID, false ); |
|
743 | + $donor->attach_payment($this->ID, false); |
|
744 | 744 | |
745 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
745 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
746 | 746 | |
747 | 747 | /* |
748 | 748 | * _give_payment_meta backward compatibility. |
@@ -750,25 +750,25 @@ discard block |
||
750 | 750 | * @since 2.0.1 |
751 | 751 | */ |
752 | 752 | $custom_payment_meta = array_diff( |
753 | - array_map( 'maybe_serialize', $this->payment_meta ), |
|
754 | - array_map( 'maybe_serialize', $payment_data ) |
|
753 | + array_map('maybe_serialize', $this->payment_meta), |
|
754 | + array_map('maybe_serialize', $payment_data) |
|
755 | 755 | ); |
756 | 756 | |
757 | - if ( ! empty( $custom_payment_meta ) ) { |
|
758 | - 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' ); |
|
757 | + if ( ! empty($custom_payment_meta)) { |
|
758 | + 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'); |
|
759 | 759 | |
760 | - $this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) ); |
|
760 | + $this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta)); |
|
761 | 761 | } |
762 | 762 | |
763 | - $give_company = ( ! empty( $_REQUEST['give_company_name'] ) ? give_clean( $_REQUEST['give_company_name'] ) : '' ); |
|
763 | + $give_company = ( ! empty($_REQUEST['give_company_name']) ? give_clean($_REQUEST['give_company_name']) : ''); |
|
764 | 764 | |
765 | 765 | // Check $page_url is not empty. |
766 | - if ( $give_company ) { |
|
767 | - give_update_meta( $payment_id, '_give_donation_company', $give_company ); |
|
766 | + if ($give_company) { |
|
767 | + give_update_meta($payment_id, '_give_donation_company', $give_company); |
|
768 | 768 | |
769 | - $donor_id = absint( $donor->id ); |
|
770 | - if ( ! empty( $donor_id ) ) { |
|
771 | - Give()->donor_meta->update_meta( $donor_id, '_give_donor_company', $give_company ); |
|
769 | + $donor_id = absint($donor->id); |
|
770 | + if ( ! empty($donor_id)) { |
|
771 | + Give()->donor_meta->update_meta($donor_id, '_give_donor_company', $give_company); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | $saved = false; |
793 | 793 | |
794 | 794 | // Must have an ID. |
795 | - if ( empty( $this->ID ) ) { |
|
795 | + if (empty($this->ID)) { |
|
796 | 796 | |
797 | 797 | $payment_id = $this->insert_payment(); |
798 | 798 | |
799 | - if ( false === $payment_id ) { |
|
799 | + if (false === $payment_id) { |
|
800 | 800 | $saved = false; |
801 | 801 | } else { |
802 | 802 | $this->ID = $payment_id; |
@@ -804,42 +804,42 @@ discard block |
||
804 | 804 | } |
805 | 805 | |
806 | 806 | // Set ID if not matching. |
807 | - if ( $this->ID !== $this->_ID ) { |
|
807 | + if ($this->ID !== $this->_ID) { |
|
808 | 808 | $this->ID = $this->_ID; |
809 | 809 | } |
810 | 810 | |
811 | 811 | // If we have something pending, let's save it. |
812 | - if ( ! empty( $this->pending ) ) { |
|
812 | + if ( ! empty($this->pending)) { |
|
813 | 813 | |
814 | 814 | $total_increase = 0; |
815 | 815 | $total_decrease = 0; |
816 | 816 | |
817 | - foreach ( $this->pending as $key => $value ) { |
|
817 | + foreach ($this->pending as $key => $value) { |
|
818 | 818 | |
819 | - switch ( $key ) { |
|
819 | + switch ($key) { |
|
820 | 820 | |
821 | 821 | case 'donations': |
822 | 822 | // Update totals for pending donations. |
823 | - foreach ( $this->pending[ $key ] as $item ) { |
|
823 | + foreach ($this->pending[$key] as $item) { |
|
824 | 824 | |
825 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
826 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
825 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
826 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
827 | 827 | |
828 | - switch ( $item['action'] ) { |
|
828 | + switch ($item['action']) { |
|
829 | 829 | |
830 | 830 | case 'add': |
831 | 831 | |
832 | 832 | $price = $item['price']; |
833 | 833 | |
834 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
834 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
835 | 835 | |
836 | 836 | // Add donation to logs. |
837 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
838 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
837 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
838 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
839 | 839 | |
840 | - $form = new Give_Donate_Form( $item['id'] ); |
|
841 | - $form->increase_sales( $quantity ); |
|
842 | - $form->increase_earnings( $price, $this->ID ); |
|
840 | + $form = new Give_Donate_Form($item['id']); |
|
841 | + $form->increase_sales($quantity); |
|
842 | + $form->increase_earnings($price, $this->ID); |
|
843 | 843 | |
844 | 844 | $total_increase += $price; |
845 | 845 | } |
@@ -847,10 +847,10 @@ discard block |
||
847 | 847 | |
848 | 848 | case 'remove': |
849 | 849 | $this->delete_sales_logs(); |
850 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
851 | - $form = new Give_Donate_Form( $item['id'] ); |
|
852 | - $form->decrease_sales( $quantity ); |
|
853 | - $form->decrease_earnings( $item['amount'], $this->ID ); |
|
850 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
851 | + $form = new Give_Donate_Form($item['id']); |
|
852 | + $form->decrease_sales($quantity); |
|
853 | + $form->decrease_earnings($item['amount'], $this->ID); |
|
854 | 854 | |
855 | 855 | $total_decrease += $item['amount']; |
856 | 856 | } |
@@ -861,103 +861,103 @@ discard block |
||
861 | 861 | break; |
862 | 862 | |
863 | 863 | case 'status': |
864 | - $this->update_status( $this->status ); |
|
864 | + $this->update_status($this->status); |
|
865 | 865 | break; |
866 | 866 | |
867 | 867 | case 'gateway': |
868 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
868 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
869 | 869 | break; |
870 | 870 | |
871 | 871 | case 'mode': |
872 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
872 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
873 | 873 | break; |
874 | 874 | |
875 | 875 | case 'transaction_id': |
876 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
876 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
877 | 877 | break; |
878 | 878 | |
879 | 879 | case 'ip': |
880 | - $this->update_meta( '_give_payment_donor_ip', $this->ip ); |
|
880 | + $this->update_meta('_give_payment_donor_ip', $this->ip); |
|
881 | 881 | break; |
882 | 882 | |
883 | 883 | case 'customer_id': |
884 | - $this->update_meta( '_give_payment_donor_id', $this->customer_id ); |
|
884 | + $this->update_meta('_give_payment_donor_id', $this->customer_id); |
|
885 | 885 | break; |
886 | 886 | |
887 | 887 | case 'form_title': |
888 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
888 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
889 | 889 | break; |
890 | 890 | |
891 | 891 | case 'form_id': |
892 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
892 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
893 | 893 | break; |
894 | 894 | |
895 | 895 | case 'price_id': |
896 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
896 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
897 | 897 | break; |
898 | 898 | |
899 | 899 | case 'first_name': |
900 | - $this->update_meta( '_give_donor_billing_first_name', $this->first_name ); |
|
900 | + $this->update_meta('_give_donor_billing_first_name', $this->first_name); |
|
901 | 901 | break; |
902 | 902 | |
903 | 903 | case 'last_name': |
904 | - $this->update_meta( '_give_donor_billing_last_name', $this->last_name ); |
|
904 | + $this->update_meta('_give_donor_billing_last_name', $this->last_name); |
|
905 | 905 | break; |
906 | 906 | |
907 | 907 | case 'currency': |
908 | - $this->update_meta( '_give_payment_currency', $this->currency ); |
|
908 | + $this->update_meta('_give_payment_currency', $this->currency); |
|
909 | 909 | break; |
910 | 910 | |
911 | 911 | case 'address': |
912 | - if ( ! empty( $this->address ) ) { |
|
913 | - foreach ( $this->address as $address_name => $address ) { |
|
914 | - switch ( $address_name ) { |
|
912 | + if ( ! empty($this->address)) { |
|
913 | + foreach ($this->address as $address_name => $address) { |
|
914 | + switch ($address_name) { |
|
915 | 915 | case 'line1': |
916 | - $this->update_meta( '_give_donor_billing_address1', $address ); |
|
916 | + $this->update_meta('_give_donor_billing_address1', $address); |
|
917 | 917 | break; |
918 | 918 | |
919 | 919 | case 'line2': |
920 | - $this->update_meta( '_give_donor_billing_address2', $address ); |
|
920 | + $this->update_meta('_give_donor_billing_address2', $address); |
|
921 | 921 | break; |
922 | 922 | |
923 | 923 | default: |
924 | - $this->update_meta( "_give_donor_billing_{$address_name}", $address ); |
|
924 | + $this->update_meta("_give_donor_billing_{$address_name}", $address); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | } |
928 | 928 | break; |
929 | 929 | |
930 | 930 | case 'email': |
931 | - $this->update_meta( '_give_payment_donor_email', $this->email ); |
|
931 | + $this->update_meta('_give_payment_donor_email', $this->email); |
|
932 | 932 | break; |
933 | 933 | |
934 | 934 | case 'title_prefix': |
935 | - $this->update_meta( '_give_payment_donor_title_prefix', $this->title_prefix ); |
|
935 | + $this->update_meta('_give_payment_donor_title_prefix', $this->title_prefix); |
|
936 | 936 | break; |
937 | 937 | |
938 | 938 | case 'key': |
939 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
939 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
940 | 940 | break; |
941 | 941 | |
942 | 942 | case 'number': |
943 | 943 | // @todo: remove unused meta data. |
944 | 944 | // Core is using post_title to store donation serial code ( fi enabled ) instead this meta key. |
945 | 945 | // Do not use this meta key in your logic, can be remove in future |
946 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
946 | + $this->update_meta('_give_payment_number', $this->number); |
|
947 | 947 | break; |
948 | 948 | |
949 | 949 | case 'date': |
950 | 950 | $args = array( |
951 | 951 | 'ID' => $this->ID, |
952 | - 'post_date' => date( 'Y-m-d H:i:s', strtotime( $this->date ) ), |
|
952 | + 'post_date' => date('Y-m-d H:i:s', strtotime($this->date)), |
|
953 | 953 | 'edit_date' => true, |
954 | 954 | ); |
955 | 955 | |
956 | - wp_update_post( $args ); |
|
956 | + wp_update_post($args); |
|
957 | 957 | break; |
958 | 958 | |
959 | 959 | case 'completed_date': |
960 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
960 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
961 | 961 | break; |
962 | 962 | |
963 | 963 | case 'parent_payment': |
@@ -966,11 +966,11 @@ discard block |
||
966 | 966 | 'post_parent' => $this->parent_payment, |
967 | 967 | ); |
968 | 968 | |
969 | - wp_update_post( $args ); |
|
969 | + wp_update_post($args); |
|
970 | 970 | break; |
971 | 971 | |
972 | 972 | case 'total': |
973 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
973 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
974 | 974 | break; |
975 | 975 | |
976 | 976 | default: |
@@ -981,46 +981,46 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @param Give_Payment $this Payment object. |
983 | 983 | */ |
984 | - do_action( 'give_payment_save', $this, $key ); |
|
984 | + do_action('give_payment_save', $this, $key); |
|
985 | 985 | break; |
986 | 986 | } // End switch(). |
987 | 987 | } // End foreach(). |
988 | 988 | |
989 | - if ( 'pending' !== $this->status ) { |
|
989 | + if ('pending' !== $this->status) { |
|
990 | 990 | |
991 | - $donor = new Give_Donor( $this->customer_id ); |
|
991 | + $donor = new Give_Donor($this->customer_id); |
|
992 | 992 | |
993 | 993 | $total_change = $total_increase - $total_decrease; |
994 | - if ( $total_change < 0 ) { |
|
994 | + if ($total_change < 0) { |
|
995 | 995 | |
996 | - $total_change = - ( $total_change ); |
|
996 | + $total_change = - ($total_change); |
|
997 | 997 | |
998 | 998 | // Decrease the donor's donation stats. |
999 | - $donor->decrease_value( $total_change ); |
|
1000 | - give_decrease_total_earnings( $total_change ); |
|
999 | + $donor->decrease_value($total_change); |
|
1000 | + give_decrease_total_earnings($total_change); |
|
1001 | 1001 | |
1002 | 1002 | $donor->decrease_donation_count(); |
1003 | 1003 | |
1004 | - } elseif ( $total_change > 0 ) { |
|
1004 | + } elseif ($total_change > 0) { |
|
1005 | 1005 | |
1006 | 1006 | // Increase the donor's donation stats. |
1007 | - $donor->increase_value( $total_change ); |
|
1008 | - give_increase_total_earnings( $total_change ); |
|
1007 | + $donor->increase_value($total_change); |
|
1008 | + give_increase_total_earnings($total_change); |
|
1009 | 1009 | |
1010 | 1010 | $donor->increase_purchase_count(); |
1011 | 1011 | |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // Verify and update form meta based on the form status. |
1015 | - give_set_form_closed_status( $this->form_id ); |
|
1015 | + give_set_form_closed_status($this->form_id); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | $this->pending = array(); |
1019 | 1019 | $saved = true; |
1020 | 1020 | } // End if(). |
1021 | 1021 | |
1022 | - if ( true === $saved ) { |
|
1023 | - $this->setup_payment( $this->ID ); |
|
1022 | + if (true === $saved) { |
|
1023 | + $this->setup_payment($this->ID); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | return $saved; |
@@ -1038,12 +1038,12 @@ discard block |
||
1038 | 1038 | * |
1039 | 1039 | * @return bool True when successful, false otherwise |
1040 | 1040 | */ |
1041 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1041 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
1042 | 1042 | |
1043 | - $donation = new Give_Donate_Form( $form_id ); |
|
1043 | + $donation = new Give_Donate_Form($form_id); |
|
1044 | 1044 | |
1045 | 1045 | // Bail if this post isn't a give donation form. |
1046 | - if ( ! $donation || 'give_forms' !== $donation->post_type ) { |
|
1046 | + if ( ! $donation || 'give_forms' !== $donation->post_type) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1053,25 +1053,25 @@ discard block |
||
1053 | 1053 | 'price_id' => false, |
1054 | 1054 | ); |
1055 | 1055 | |
1056 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
1056 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
1057 | 1057 | |
1058 | 1058 | // Allow overriding the price. |
1059 | - if ( false !== $args['price'] ) { |
|
1059 | + if (false !== $args['price']) { |
|
1060 | 1060 | $donation_amount = $args['price']; |
1061 | 1061 | } else { |
1062 | 1062 | |
1063 | 1063 | // Deal with variable pricing. |
1064 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
1065 | - $prices = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1064 | + if (give_has_variable_prices($donation->ID)) { |
|
1065 | + $prices = give_get_meta($form_id, '_give_donation_levels', true); |
|
1066 | 1066 | $donation_amount = ''; |
1067 | 1067 | |
1068 | 1068 | // Loop through prices. |
1069 | - foreach ( $prices as $price ) { |
|
1069 | + foreach ($prices as $price) { |
|
1070 | 1070 | // Find a match between price_id and level_id. |
1071 | 1071 | // First verify array keys exists THEN make the match. |
1072 | 1072 | if ( |
1073 | - isset( $args['price_id'] ) && |
|
1074 | - isset( $price['_give_id']['level_id'] ) && |
|
1073 | + isset($args['price_id']) && |
|
1074 | + isset($price['_give_id']['level_id']) && |
|
1075 | 1075 | $args['price_id'] === (int) $price['_give_id']['level_id'] |
1076 | 1076 | ) { |
1077 | 1077 | $donation_amount = $price['_give_amount']; |
@@ -1079,37 +1079,37 @@ discard block |
||
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | // Fallback to the lowest price point. |
1082 | - if ( '' === $donation_amount ) { |
|
1083 | - $donation_amount = give_get_lowest_price_option( $donation->ID ); |
|
1084 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1082 | + if ('' === $donation_amount) { |
|
1083 | + $donation_amount = give_get_lowest_price_option($donation->ID); |
|
1084 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1085 | 1085 | } |
1086 | 1086 | } else { |
1087 | 1087 | // Simple form price. |
1088 | - $donation_amount = give_get_form_price( $donation->ID ); |
|
1088 | + $donation_amount = give_get_form_price($donation->ID); |
|
1089 | 1089 | } |
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | // Sanitizing the price here so we don't have a dozen calls later. |
1093 | - $donation_amount = give_maybe_sanitize_amount( $donation_amount ); |
|
1094 | - $total = round( $donation_amount, give_get_price_decimals( $this->ID ) ); |
|
1093 | + $donation_amount = give_maybe_sanitize_amount($donation_amount); |
|
1094 | + $total = round($donation_amount, give_get_price_decimals($this->ID)); |
|
1095 | 1095 | |
1096 | 1096 | // Add Options. |
1097 | 1097 | $default_options = array(); |
1098 | - if ( false !== $args['price_id'] ) { |
|
1098 | + if (false !== $args['price_id']) { |
|
1099 | 1099 | $default_options['price_id'] = (int) $args['price_id']; |
1100 | 1100 | } |
1101 | - $options = wp_parse_args( $options, $default_options ); |
|
1101 | + $options = wp_parse_args($options, $default_options); |
|
1102 | 1102 | |
1103 | 1103 | // Do not allow totals to go negative. |
1104 | - if ( $total < 0 ) { |
|
1104 | + if ($total < 0) { |
|
1105 | 1105 | $total = 0; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $donation = array( |
1109 | 1109 | 'name' => $donation->post_title, |
1110 | 1110 | 'id' => $donation->ID, |
1111 | - 'price' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1112 | - 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1111 | + 'price' => round($total, give_get_price_decimals($this->ID)), |
|
1112 | + 'subtotal' => round($total, give_get_price_decimals($this->ID)), |
|
1113 | 1113 | 'price_id' => $args['price_id'], |
1114 | 1114 | 'action' => 'add', |
1115 | 1115 | 'options' => $options, |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | $this->pending['donations'][] = $donation; |
1119 | 1119 | |
1120 | - $this->increase_subtotal( $total ); |
|
1120 | + $this->increase_subtotal($total); |
|
1121 | 1121 | |
1122 | 1122 | return true; |
1123 | 1123 | |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | * |
1135 | 1135 | * @return bool If the item was removed or not |
1136 | 1136 | */ |
1137 | - public function remove_donation( $form_id, $args = array() ) { |
|
1137 | + public function remove_donation($form_id, $args = array()) { |
|
1138 | 1138 | |
1139 | 1139 | // Set some defaults. |
1140 | 1140 | $defaults = array( |
@@ -1142,12 +1142,12 @@ discard block |
||
1142 | 1142 | 'price' => false, |
1143 | 1143 | 'price_id' => false, |
1144 | 1144 | ); |
1145 | - $args = wp_parse_args( $args, $defaults ); |
|
1145 | + $args = wp_parse_args($args, $defaults); |
|
1146 | 1146 | |
1147 | - $form = new Give_Donate_Form( $form_id ); |
|
1147 | + $form = new Give_Donate_Form($form_id); |
|
1148 | 1148 | |
1149 | 1149 | // Bail if this post isn't a valid give donation form. |
1150 | - if ( ! $form || 'give_forms' !== $form->post_type ) { |
|
1150 | + if ( ! $form || 'give_forms' !== $form->post_type) { |
|
1151 | 1151 | return false; |
1152 | 1152 | } |
1153 | 1153 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | |
1161 | 1161 | $this->pending['donations'][] = $pending_args; |
1162 | 1162 | |
1163 | - $this->decrease_subtotal( $this->total ); |
|
1163 | + $this->decrease_subtotal($this->total); |
|
1164 | 1164 | |
1165 | 1165 | return true; |
1166 | 1166 | } |
@@ -1176,13 +1176,13 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @return bool If the note was specified or not |
1178 | 1178 | */ |
1179 | - public function add_note( $note = false ) { |
|
1179 | + public function add_note($note = false) { |
|
1180 | 1180 | // Bail if no note specified. |
1181 | - if ( ! $note ) { |
|
1181 | + if ( ! $note) { |
|
1182 | 1182 | return false; |
1183 | 1183 | } |
1184 | 1184 | |
1185 | - give_insert_payment_note( $this->ID, $note ); |
|
1185 | + give_insert_payment_note($this->ID, $note); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
1195 | 1195 | * |
1196 | 1196 | * @return void |
1197 | 1197 | */ |
1198 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1199 | - $amount = (float) $amount; |
|
1198 | + private function increase_subtotal($amount = 0.00) { |
|
1199 | + $amount = (float) $amount; |
|
1200 | 1200 | $this->subtotal += $amount; |
1201 | 1201 | |
1202 | 1202 | $this->recalculate_total(); |
@@ -1212,11 +1212,11 @@ discard block |
||
1212 | 1212 | * |
1213 | 1213 | * @return void |
1214 | 1214 | */ |
1215 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1216 | - $amount = (float) $amount; |
|
1215 | + private function decrease_subtotal($amount = 0.00) { |
|
1216 | + $amount = (float) $amount; |
|
1217 | 1217 | $this->subtotal -= $amount; |
1218 | 1218 | |
1219 | - if ( $this->subtotal < 0 ) { |
|
1219 | + if ($this->subtotal < 0) { |
|
1220 | 1220 | $this->subtotal = 0; |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1246,24 +1246,24 @@ discard block |
||
1246 | 1246 | * |
1247 | 1247 | * @return bool $updated Returns if the status was successfully updated. |
1248 | 1248 | */ |
1249 | - public function update_status( $status = false ) { |
|
1249 | + public function update_status($status = false) { |
|
1250 | 1250 | |
1251 | 1251 | // standardize the 'complete(d)' status. |
1252 | - if ( 'completed' === $status || 'complete' === $status ) { |
|
1252 | + if ('completed' === $status || 'complete' === $status) { |
|
1253 | 1253 | $status = 'publish'; |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1256 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1257 | 1257 | |
1258 | - if ( $old_status === $status ) { |
|
1258 | + if ($old_status === $status) { |
|
1259 | 1259 | return false; // Don't permit status changes that aren't changes. |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1262 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1263 | 1263 | |
1264 | 1264 | $updated = false; |
1265 | 1265 | |
1266 | - if ( $do_change ) { |
|
1266 | + if ($do_change) { |
|
1267 | 1267 | |
1268 | 1268 | /** |
1269 | 1269 | * Fires before changing payment status. |
@@ -1274,21 +1274,21 @@ discard block |
||
1274 | 1274 | * @param string $status The new status. |
1275 | 1275 | * @param string $old_status The old status. |
1276 | 1276 | */ |
1277 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1277 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1278 | 1278 | |
1279 | 1279 | $update_fields = array( |
1280 | 1280 | 'ID' => $this->ID, |
1281 | 1281 | 'post_status' => $status, |
1282 | - 'edit_date' => current_time( 'mysql' ), |
|
1282 | + 'edit_date' => current_time('mysql'), |
|
1283 | 1283 | ); |
1284 | 1284 | |
1285 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1285 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1286 | 1286 | |
1287 | 1287 | $all_payment_statuses = give_get_payment_statuses(); |
1288 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1288 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1289 | 1289 | |
1290 | 1290 | // Process any specific status functions. |
1291 | - $this->process_status( $status ); |
|
1291 | + $this->process_status($status); |
|
1292 | 1292 | |
1293 | 1293 | /** |
1294 | 1294 | * Fires after changing payment status. |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | * @param string $status The new status. |
1300 | 1300 | * @param string $old_status The old status. |
1301 | 1301 | */ |
1302 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1302 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1303 | 1303 | |
1304 | 1304 | } // End if(). |
1305 | 1305 | |
@@ -1334,27 +1334,27 @@ discard block |
||
1334 | 1334 | * |
1335 | 1335 | * @return mixed The value from the post meta |
1336 | 1336 | */ |
1337 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1337 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1338 | 1338 | if ( |
1339 | - ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && |
|
1340 | - ! doing_filter( 'get_post_metadata' ) |
|
1339 | + ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && |
|
1340 | + ! doing_filter('get_post_metadata') |
|
1341 | 1341 | ) { |
1342 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
1342 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1345 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1346 | 1346 | |
1347 | 1347 | /** |
1348 | 1348 | * Filter the specific meta key value. |
1349 | 1349 | * |
1350 | 1350 | * @since 1.5 |
1351 | 1351 | */ |
1352 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1352 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1353 | 1353 | |
1354 | 1354 | // Security check. |
1355 | - if ( is_serialized( $meta ) ) { |
|
1356 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches ); |
|
1357 | - if ( ! empty( $matches ) ) { |
|
1355 | + if (is_serialized($meta)) { |
|
1356 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches); |
|
1357 | + if ( ! empty($matches)) { |
|
1358 | 1358 | $meta = array(); |
1359 | 1359 | } |
1360 | 1360 | } |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | * |
1365 | 1365 | * @since 1.5 |
1366 | 1366 | */ |
1367 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1367 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
@@ -1379,8 +1379,8 @@ discard block |
||
1379 | 1379 | * |
1380 | 1380 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1381 | 1381 | */ |
1382 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1383 | - if ( empty( $meta_key ) ) { |
|
1382 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1383 | + if (empty($meta_key)) { |
|
1384 | 1384 | return false; |
1385 | 1385 | } |
1386 | 1386 | |
@@ -1390,9 +1390,9 @@ discard block |
||
1390 | 1390 | * |
1391 | 1391 | * @since 1.5 |
1392 | 1392 | */ |
1393 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1393 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1394 | 1394 | |
1395 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1395 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | * |
1406 | 1406 | * @return void |
1407 | 1407 | */ |
1408 | - private function process_status( $status ) { |
|
1408 | + private function process_status($status) { |
|
1409 | 1409 | $process = true; |
1410 | 1410 | |
1411 | 1411 | // Bailout, if changed from completed to preapproval/processing. |
@@ -1420,9 +1420,9 @@ discard block |
||
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1423 | - $process = apply_filters( "give_should_process_{$status}", $process, $this ); |
|
1423 | + $process = apply_filters("give_should_process_{$status}", $process, $this); |
|
1424 | 1424 | |
1425 | - if ( false === $process ) { |
|
1425 | + if (false === $process) { |
|
1426 | 1426 | return; |
1427 | 1427 | } |
1428 | 1428 | |
@@ -1433,13 +1433,13 @@ discard block |
||
1433 | 1433 | * |
1434 | 1434 | * @since 1.5 |
1435 | 1435 | */ |
1436 | - do_action( "give_pre_{$status}_payment", $this ); |
|
1436 | + do_action("give_pre_{$status}_payment", $this); |
|
1437 | 1437 | |
1438 | - $decrease_earnings = apply_filters( "give_decrease_earnings_on_{$status}", true, $this ); |
|
1439 | - $decrease_donor_value = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this ); |
|
1440 | - $decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this ); |
|
1438 | + $decrease_earnings = apply_filters("give_decrease_earnings_on_{$status}", true, $this); |
|
1439 | + $decrease_donor_value = apply_filters("give_decrease_donor_value_on_{$status}", true, $this); |
|
1440 | + $decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this); |
|
1441 | 1441 | |
1442 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1442 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1443 | 1443 | $this->delete_sales_logs(); |
1444 | 1444 | |
1445 | 1445 | // @todo: Refresh only range related stat cache |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * |
1453 | 1453 | * @since 1.5 |
1454 | 1454 | */ |
1455 | - do_action( "give_post_{$status}_payment", $this ); |
|
1455 | + do_action("give_post_{$status}_payment", $this); |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | /** |
@@ -1467,25 +1467,25 @@ discard block |
||
1467 | 1467 | * |
1468 | 1468 | * @return void |
1469 | 1469 | */ |
1470 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1470 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1471 | 1471 | |
1472 | - give_undo_donation( $this->ID ); |
|
1472 | + give_undo_donation($this->ID); |
|
1473 | 1473 | |
1474 | 1474 | // Decrease store earnings. |
1475 | - if ( true === $alter_store_earnings ) { |
|
1476 | - give_decrease_total_earnings( $this->total ); |
|
1475 | + if (true === $alter_store_earnings) { |
|
1476 | + give_decrease_total_earnings($this->total); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // Decrement the stats for the donor. |
1480 | - if ( ! empty( $this->customer_id ) ) { |
|
1480 | + if ( ! empty($this->customer_id)) { |
|
1481 | 1481 | |
1482 | - $donor = new Give_Donor( $this->customer_id ); |
|
1482 | + $donor = new Give_Donor($this->customer_id); |
|
1483 | 1483 | |
1484 | - if ( true === $alter_customer_value ) { |
|
1485 | - $donor->decrease_value( $this->total ); |
|
1484 | + if (true === $alter_customer_value) { |
|
1485 | + $donor->decrease_value($this->total); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | - if ( true === $alter_customer_purchase_count ) { |
|
1488 | + if (true === $alter_customer_purchase_count) { |
|
1489 | 1489 | $donor->decrease_donation_count(); |
1490 | 1490 | } |
1491 | 1491 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | */ |
1503 | 1503 | private function delete_sales_logs() { |
1504 | 1504 | // Remove related sale log entries. |
1505 | - Give()->logs->delete_logs( $this->ID ); |
|
1505 | + Give()->logs->delete_logs($this->ID); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | /** |
@@ -1523,13 +1523,13 @@ discard block |
||
1523 | 1523 | * @return string The date the payment was completed |
1524 | 1524 | */ |
1525 | 1525 | private function setup_completed_date() { |
1526 | - $payment = get_post( $this->ID ); |
|
1526 | + $payment = get_post($this->ID); |
|
1527 | 1527 | |
1528 | - if ( 'pending' === $payment->post_status || 'preapproved' === $payment->post_status ) { |
|
1528 | + if ('pending' === $payment->post_status || 'preapproved' === $payment->post_status) { |
|
1529 | 1529 | return false; // This payment was never completed. |
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1532 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1533 | 1533 | |
1534 | 1534 | return $date; |
1535 | 1535 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @return string The payment mode |
1544 | 1544 | */ |
1545 | 1545 | private function setup_mode() { |
1546 | - return $this->get_meta( '_give_payment_mode' ); |
|
1546 | + return $this->get_meta('_give_payment_mode'); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | /** |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | * @return bool The payment import |
1556 | 1556 | */ |
1557 | 1557 | private function setup_import() { |
1558 | - return (bool) $this->get_meta( '_give_payment_import' ); |
|
1558 | + return (bool) $this->get_meta('_give_payment_import'); |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | /** |
@@ -1567,9 +1567,9 @@ discard block |
||
1567 | 1567 | * @return float The payment total |
1568 | 1568 | */ |
1569 | 1569 | private function setup_total() { |
1570 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1570 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1571 | 1571 | |
1572 | - return round( floatval( $amount ), give_get_price_decimals( $this->ID ) ); |
|
1572 | + return round(floatval($amount), give_get_price_decimals($this->ID)); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | /** |
@@ -1596,17 +1596,16 @@ discard block |
||
1596 | 1596 | * @return string The currency for the payment |
1597 | 1597 | */ |
1598 | 1598 | private function setup_currency() { |
1599 | - $currency = $this->get_meta( '_give_payment_currency', true ); |
|
1600 | - $currency = ! empty( $currency ) ? |
|
1601 | - $currency : |
|
1602 | - /** |
|
1599 | + $currency = $this->get_meta('_give_payment_currency', true); |
|
1600 | + $currency = ! empty($currency) ? |
|
1601 | + $currency : /** |
|
1603 | 1602 | * Filter the default donation currency |
1604 | 1603 | * |
1605 | 1604 | * @since 1.5 |
1606 | 1605 | */ |
1607 | 1606 | apply_filters( |
1608 | 1607 | 'give_payment_currency_default', |
1609 | - give_get_currency( $this->form_id, $this ), |
|
1608 | + give_get_currency($this->form_id, $this), |
|
1610 | 1609 | $this |
1611 | 1610 | ); |
1612 | 1611 | |
@@ -1622,7 +1621,7 @@ discard block |
||
1622 | 1621 | * @return string The gateway |
1623 | 1622 | */ |
1624 | 1623 | private function setup_gateway() { |
1625 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1624 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1626 | 1625 | |
1627 | 1626 | return $gateway; |
1628 | 1627 | } |
@@ -1636,11 +1635,11 @@ discard block |
||
1636 | 1635 | * @return string The donation ID |
1637 | 1636 | */ |
1638 | 1637 | private function setup_transaction_id() { |
1639 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1638 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1640 | 1639 | |
1641 | - if ( empty( $transaction_id ) ) { |
|
1640 | + if (empty($transaction_id)) { |
|
1642 | 1641 | $gateway = $this->gateway; |
1643 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1642 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1644 | 1643 | } |
1645 | 1644 | |
1646 | 1645 | return $transaction_id; |
@@ -1656,7 +1655,7 @@ discard block |
||
1656 | 1655 | * @return string The IP address for the payment |
1657 | 1656 | */ |
1658 | 1657 | private function setup_ip() { |
1659 | - $ip = $this->get_meta( '_give_payment_donor_ip', true ); |
|
1658 | + $ip = $this->get_meta('_give_payment_donor_ip', true); |
|
1660 | 1659 | |
1661 | 1660 | return $ip; |
1662 | 1661 | } |
@@ -1671,7 +1670,7 @@ discard block |
||
1671 | 1670 | * @return int The Donor ID. |
1672 | 1671 | */ |
1673 | 1672 | private function setup_donor_id() { |
1674 | - $donor_id = $this->get_meta( '_give_payment_donor_id', true ); |
|
1673 | + $donor_id = $this->get_meta('_give_payment_donor_id', true); |
|
1675 | 1674 | |
1676 | 1675 | return $donor_id; |
1677 | 1676 | } |
@@ -1688,8 +1687,8 @@ discard block |
||
1688 | 1687 | */ |
1689 | 1688 | private function setup_user_id() { |
1690 | 1689 | |
1691 | - $donor = Give()->customers->get_customer_by( 'id', $this->customer_id ); |
|
1692 | - $user_id = $donor ? absint( $donor->user_id ) : 0; |
|
1690 | + $donor = Give()->customers->get_customer_by('id', $this->customer_id); |
|
1691 | + $user_id = $donor ? absint($donor->user_id) : 0; |
|
1693 | 1692 | |
1694 | 1693 | |
1695 | 1694 | return $user_id; |
@@ -1706,10 +1705,10 @@ discard block |
||
1706 | 1705 | * @return string The email address for the payment. |
1707 | 1706 | */ |
1708 | 1707 | private function setup_email() { |
1709 | - $email = $this->get_meta( '_give_payment_donor_email', true ); |
|
1708 | + $email = $this->get_meta('_give_payment_donor_email', true); |
|
1710 | 1709 | |
1711 | - if ( empty( $email ) && $this->customer_id ) { |
|
1712 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1710 | + if (empty($email) && $this->customer_id) { |
|
1711 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1713 | 1712 | } |
1714 | 1713 | |
1715 | 1714 | return $email; |
@@ -1730,22 +1729,22 @@ discard block |
||
1730 | 1729 | 'last_name' => $this->last_name, |
1731 | 1730 | ); |
1732 | 1731 | |
1733 | - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array(); |
|
1732 | + $user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array(); |
|
1734 | 1733 | |
1735 | - if ( is_serialized( $user_info ) ) { |
|
1736 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
1737 | - if ( ! empty( $matches ) ) { |
|
1734 | + if (is_serialized($user_info)) { |
|
1735 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
1736 | + if ( ! empty($matches)) { |
|
1738 | 1737 | $user_info = array(); |
1739 | 1738 | } |
1740 | 1739 | } |
1741 | 1740 | |
1742 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1741 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1743 | 1742 | |
1744 | - if ( empty( $user_info ) ) { |
|
1743 | + if (empty($user_info)) { |
|
1745 | 1744 | // Get the donor, but only if it's been created. |
1746 | - $donor = new Give_Donor( $this->customer_id ); |
|
1745 | + $donor = new Give_Donor($this->customer_id); |
|
1747 | 1746 | |
1748 | - if ( $donor->id > 0 ) { |
|
1747 | + if ($donor->id > 0) { |
|
1749 | 1748 | $user_info = array( |
1750 | 1749 | 'first_name' => $donor->get_first_name(), |
1751 | 1750 | 'last_name' => $donor->get_last_name(), |
@@ -1755,29 +1754,29 @@ discard block |
||
1755 | 1754 | } |
1756 | 1755 | } else { |
1757 | 1756 | // Get the donor, but only if it's been created. |
1758 | - $donor = new Give_Donor( $this->customer_id ); |
|
1757 | + $donor = new Give_Donor($this->customer_id); |
|
1759 | 1758 | |
1760 | - if ( $donor->id > 0 ) { |
|
1761 | - foreach ( $user_info as $key => $value ) { |
|
1762 | - if ( ! empty( $value ) ) { |
|
1759 | + if ($donor->id > 0) { |
|
1760 | + foreach ($user_info as $key => $value) { |
|
1761 | + if ( ! empty($value)) { |
|
1763 | 1762 | continue; |
1764 | 1763 | } |
1765 | 1764 | |
1766 | - switch ( $key ) { |
|
1765 | + switch ($key) { |
|
1767 | 1766 | case 'title': |
1768 | - $user_info[ $key ] = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); |
|
1767 | + $user_info[$key] = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true); |
|
1769 | 1768 | break; |
1770 | 1769 | |
1771 | 1770 | case 'first_name': |
1772 | - $user_info[ $key ] = $donor->get_first_name(); |
|
1771 | + $user_info[$key] = $donor->get_first_name(); |
|
1773 | 1772 | break; |
1774 | 1773 | |
1775 | 1774 | case 'last_name': |
1776 | - $user_info[ $key ] = $donor->get_last_name(); |
|
1775 | + $user_info[$key] = $donor->get_last_name(); |
|
1777 | 1776 | break; |
1778 | 1777 | |
1779 | 1778 | case 'email': |
1780 | - $user_info[ $key ] = $donor->email; |
|
1779 | + $user_info[$key] = $donor->email; |
|
1781 | 1780 | break; |
1782 | 1781 | } |
1783 | 1782 | } |
@@ -1797,12 +1796,12 @@ discard block |
||
1797 | 1796 | * @return array The Address information for the payment. |
1798 | 1797 | */ |
1799 | 1798 | private function setup_address() { |
1800 | - $address['line1'] = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' ); |
|
1801 | - $address['line2'] = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' ); |
|
1802 | - $address['city'] = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' ); |
|
1803 | - $address['state'] = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' ); |
|
1804 | - $address['zip'] = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' ); |
|
1805 | - $address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' ); |
|
1799 | + $address['line1'] = give_get_meta($this->ID, '_give_donor_billing_address1', true, ''); |
|
1800 | + $address['line2'] = give_get_meta($this->ID, '_give_donor_billing_address2', true, ''); |
|
1801 | + $address['city'] = give_get_meta($this->ID, '_give_donor_billing_city', true, ''); |
|
1802 | + $address['state'] = give_get_meta($this->ID, '_give_donor_billing_state', true, ''); |
|
1803 | + $address['zip'] = give_get_meta($this->ID, '_give_donor_billing_zip', true, ''); |
|
1804 | + $address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, ''); |
|
1806 | 1805 | |
1807 | 1806 | return $address; |
1808 | 1807 | } |
@@ -1817,7 +1816,7 @@ discard block |
||
1817 | 1816 | */ |
1818 | 1817 | private function setup_form_title() { |
1819 | 1818 | |
1820 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1819 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1821 | 1820 | |
1822 | 1821 | return $form_id; |
1823 | 1822 | } |
@@ -1832,7 +1831,7 @@ discard block |
||
1832 | 1831 | */ |
1833 | 1832 | private function setup_form_id() { |
1834 | 1833 | |
1835 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1834 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1836 | 1835 | |
1837 | 1836 | return $form_id; |
1838 | 1837 | } |
@@ -1846,7 +1845,7 @@ discard block |
||
1846 | 1845 | * @return int The Form Price ID. |
1847 | 1846 | */ |
1848 | 1847 | private function setup_price_id() { |
1849 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1848 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1850 | 1849 | |
1851 | 1850 | return $price_id; |
1852 | 1851 | } |
@@ -1860,7 +1859,7 @@ discard block |
||
1860 | 1859 | * @return string The Payment Key. |
1861 | 1860 | */ |
1862 | 1861 | private function setup_payment_key() { |
1863 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1862 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1864 | 1863 | |
1865 | 1864 | return $key; |
1866 | 1865 | } |
@@ -1885,7 +1884,7 @@ discard block |
||
1885 | 1884 | * @return array The payment object as an array. |
1886 | 1885 | */ |
1887 | 1886 | public function array_convert() { |
1888 | - return get_object_vars( $this ); |
|
1887 | + return get_object_vars($this); |
|
1889 | 1888 | } |
1890 | 1889 | |
1891 | 1890 | |
@@ -1898,7 +1897,7 @@ discard block |
||
1898 | 1897 | * @return bool |
1899 | 1898 | */ |
1900 | 1899 | public function is_completed() { |
1901 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1900 | + return ('publish' === $this->status && $this->completed_date); |
|
1902 | 1901 | } |
1903 | 1902 | |
1904 | 1903 | /** |
@@ -1910,7 +1909,7 @@ discard block |
||
1910 | 1909 | * @return string Date payment was completed. |
1911 | 1910 | */ |
1912 | 1911 | private function get_completed_date() { |
1913 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1912 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1914 | 1913 | } |
1915 | 1914 | |
1916 | 1915 | /** |
@@ -1922,7 +1921,7 @@ discard block |
||
1922 | 1921 | * @return float Payment subtotal. |
1923 | 1922 | */ |
1924 | 1923 | private function get_subtotal() { |
1925 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1924 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1926 | 1925 | } |
1927 | 1926 | |
1928 | 1927 | /** |
@@ -1934,7 +1933,7 @@ discard block |
||
1934 | 1933 | * @return string Payment currency code. |
1935 | 1934 | */ |
1936 | 1935 | private function get_currency() { |
1937 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1936 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1938 | 1937 | } |
1939 | 1938 | |
1940 | 1939 | /** |
@@ -1946,7 +1945,7 @@ discard block |
||
1946 | 1945 | * @return string Gateway used. |
1947 | 1946 | */ |
1948 | 1947 | private function get_gateway() { |
1949 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1948 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1950 | 1949 | } |
1951 | 1950 | |
1952 | 1951 | /** |
@@ -1958,7 +1957,7 @@ discard block |
||
1958 | 1957 | * @return string Donation ID from merchant processor. |
1959 | 1958 | */ |
1960 | 1959 | private function get_transaction_id() { |
1961 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1960 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1962 | 1961 | } |
1963 | 1962 | |
1964 | 1963 | /** |
@@ -1970,7 +1969,7 @@ discard block |
||
1970 | 1969 | * @return string Payment IP address |
1971 | 1970 | */ |
1972 | 1971 | private function get_ip() { |
1973 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
1972 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
1974 | 1973 | } |
1975 | 1974 | |
1976 | 1975 | /** |
@@ -1982,7 +1981,7 @@ discard block |
||
1982 | 1981 | * @return int Payment donor ID. |
1983 | 1982 | */ |
1984 | 1983 | private function get_donor_id() { |
1985 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
1984 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
1986 | 1985 | } |
1987 | 1986 | |
1988 | 1987 | /** |
@@ -1994,7 +1993,7 @@ discard block |
||
1994 | 1993 | * @return int Payment user ID. |
1995 | 1994 | */ |
1996 | 1995 | private function get_user_id() { |
1997 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
1996 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
1998 | 1997 | } |
1999 | 1998 | |
2000 | 1999 | /** |
@@ -2006,7 +2005,7 @@ discard block |
||
2006 | 2005 | * @return string Payment donor email. |
2007 | 2006 | */ |
2008 | 2007 | private function get_email() { |
2009 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
2008 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
2010 | 2009 | } |
2011 | 2010 | |
2012 | 2011 | /** |
@@ -2018,7 +2017,7 @@ discard block |
||
2018 | 2017 | * @return array Payment user info. |
2019 | 2018 | */ |
2020 | 2019 | private function get_user_info() { |
2021 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2020 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
2022 | 2021 | } |
2023 | 2022 | |
2024 | 2023 | /** |
@@ -2030,7 +2029,7 @@ discard block |
||
2030 | 2029 | * @return array Payment billing address. |
2031 | 2030 | */ |
2032 | 2031 | private function get_address() { |
2033 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2032 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2034 | 2033 | } |
2035 | 2034 | |
2036 | 2035 | /** |
@@ -2042,7 +2041,7 @@ discard block |
||
2042 | 2041 | * @return string Payment key. |
2043 | 2042 | */ |
2044 | 2043 | private function get_key() { |
2045 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2044 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2046 | 2045 | } |
2047 | 2046 | |
2048 | 2047 | /** |
@@ -2054,7 +2053,7 @@ discard block |
||
2054 | 2053 | * @return string Payment form id |
2055 | 2054 | */ |
2056 | 2055 | private function get_form_id() { |
2057 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2056 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2058 | 2057 | } |
2059 | 2058 | |
2060 | 2059 | /** |
@@ -2066,7 +2065,7 @@ discard block |
||
2066 | 2065 | * @return int|string Payment number |
2067 | 2066 | */ |
2068 | 2067 | private function get_number() { |
2069 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2068 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2070 | 2069 | } |
2071 | 2070 | |
2072 | 2071 | /** |
@@ -2078,7 +2077,7 @@ discard block |
||
2078 | 2077 | * |
2079 | 2078 | * @return string |
2080 | 2079 | */ |
2081 | - public function get_serial_code( $args = array() ) { |
|
2082 | - return Give()->seq_donation_number->get_serial_code( $this, $args ); |
|
2080 | + public function get_serial_code($args = array()) { |
|
2081 | + return Give()->seq_donation_number->get_serial_code($this, $args); |
|
2083 | 2082 | } |
2084 | 2083 | } |
@@ -789,7 +789,7 @@ |
||
789 | 789 | * @type string $display_style How the form is displayed, either in new page or modal popup. |
790 | 790 | * Default 'redirect'. Accepts 'redirect', 'modal'. |
791 | 791 | * } |
792 | - * @return string|bool The markup of the form grid or false. |
|
792 | + * @return string|null The markup of the form grid or false. |
|
793 | 793 | */ |
794 | 794 | function give_form_grid_shortcode( $atts ) { |
795 | 795 |
@@ -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 | |
@@ -26,42 +26,42 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string|bool |
28 | 28 | */ |
29 | -function give_donation_history( $atts, $content = false ) { |
|
29 | +function give_donation_history($atts, $content = false) { |
|
30 | 30 | |
31 | - $donation_history_args = shortcode_atts( array( |
|
31 | + $donation_history_args = shortcode_atts(array( |
|
32 | 32 | 'id' => true, |
33 | 33 | 'date' => true, |
34 | 34 | 'donor' => false, |
35 | 35 | 'amount' => true, |
36 | 36 | 'status' => false, |
37 | 37 | 'payment_method' => false, |
38 | - ), $atts, 'donation_history' ); |
|
38 | + ), $atts, 'donation_history'); |
|
39 | 39 | |
40 | 40 | // Always show receipt link. |
41 | 41 | $donation_history_args['details'] = true; |
42 | 42 | |
43 | 43 | // Set Donation History Shortcode Arguments in session variable. |
44 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
44 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
45 | 45 | |
46 | 46 | // If payment_key query arg exists, return receipt instead of donation history. |
47 | - if ( isset( $_GET['payment_key'] ) ) { |
|
47 | + if (isset($_GET['payment_key'])) { |
|
48 | 48 | ob_start(); |
49 | 49 | |
50 | - echo give_receipt_shortcode( array() ); |
|
50 | + echo give_receipt_shortcode(array()); |
|
51 | 51 | |
52 | 52 | // Display donation history link only if Receipt Access Session is available. |
53 | - if ( give_get_receipt_session() ) { |
|
53 | + if (give_get_receipt_session()) { |
|
54 | 54 | echo sprintf( |
55 | 55 | '<a href="%s">%s</a>', |
56 | - esc_url( give_get_history_page_uri() ), |
|
57 | - __( '« Return to All Donations', 'give' ) |
|
56 | + esc_url(give_get_history_page_uri()), |
|
57 | + __('« Return to All Donations', 'give') |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | 61 | return ob_get_clean(); |
62 | 62 | } |
63 | 63 | |
64 | - $email_access = give_get_option( 'email_access' ); |
|
64 | + $email_access = give_get_option('email_access'); |
|
65 | 65 | |
66 | 66 | ob_start(); |
67 | 67 | |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | if ( |
75 | 75 | is_user_logged_in() |
76 | 76 | || false !== Give()->session->get_session_expiration() |
77 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
77 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
78 | 78 | || true === give_get_history_session() |
79 | 79 | ) { |
80 | - give_get_template_part( 'history', 'donations' ); |
|
80 | + give_get_template_part('history', 'donations'); |
|
81 | 81 | |
82 | - if ( ! empty( $content ) ) { |
|
83 | - echo do_shortcode( $content ); |
|
82 | + if ( ! empty($content)) { |
|
83 | + echo do_shortcode($content); |
|
84 | 84 | } |
85 | 85 | |
86 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
86 | + } elseif (give_is_setting_enabled($email_access)) { |
|
87 | 87 | // Is Email-based access enabled? |
88 | - give_get_template_part( 'email', 'login-form' ); |
|
88 | + give_get_template_part('email', 'login-form'); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - echo apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
93 | - echo do_shortcode( '[give_login]' ); |
|
92 | + echo apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
93 | + echo do_shortcode('[give_login]'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return string HTML content |
106 | 106 | */ |
107 | - return apply_filters( 'give_donation_history_shortcode_html', ob_get_clean(), $atts, $content ); |
|
107 | + return apply_filters('give_donation_history_shortcode_html', ob_get_clean(), $atts, $content); |
|
108 | 108 | } |
109 | 109 | |
110 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
110 | +add_shortcode('donation_history', 'give_donation_history'); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Donation Form Shortcode |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_form_shortcode( $atts ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_form_shortcode($atts) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_title' => true, |
127 | 127 | 'show_goal' => true, |
@@ -129,21 +129,21 @@ discard block |
||
129 | 129 | 'float_labels' => '', |
130 | 130 | 'display_style' => '', |
131 | 131 | 'continue_button_title' => '', |
132 | - ), $atts, 'give_form' ); |
|
132 | + ), $atts, 'give_form'); |
|
133 | 133 | |
134 | 134 | // Convert string to bool. |
135 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
136 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
135 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
136 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
137 | 137 | |
138 | 138 | // get the Give Form |
139 | 139 | ob_start(); |
140 | - give_get_donation_form( $atts ); |
|
140 | + give_get_donation_form($atts); |
|
141 | 141 | $final_output = ob_get_clean(); |
142 | 142 | |
143 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
143 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
144 | 144 | } |
145 | 145 | |
146 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
146 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Donation Form Goal Shortcode. |
@@ -156,36 +156,36 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string |
158 | 158 | */ |
159 | -function give_goal_shortcode( $atts ) { |
|
160 | - $atts = shortcode_atts( array( |
|
159 | +function give_goal_shortcode($atts) { |
|
160 | + $atts = shortcode_atts(array( |
|
161 | 161 | 'id' => '', |
162 | 162 | 'show_text' => true, |
163 | 163 | 'show_bar' => true, |
164 | - ), $atts, 'give_goal' ); |
|
164 | + ), $atts, 'give_goal'); |
|
165 | 165 | |
166 | 166 | // get the Give Form. |
167 | 167 | ob_start(); |
168 | 168 | |
169 | 169 | // Sanity check 1: ensure there is an ID Provided. |
170 | - if ( empty( $atts['id'] ) ) { |
|
171 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
170 | + if (empty($atts['id'])) { |
|
171 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Sanity check 2: Check the form even has Goals enabled. |
175 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
175 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
176 | 176 | |
177 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
177 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
178 | 178 | } else { |
179 | 179 | // Passed all sanity checks: output Goal. |
180 | - give_show_goal_progress( $atts['id'], $atts ); |
|
180 | + give_show_goal_progress($atts['id'], $atts); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $final_output = ob_get_clean(); |
184 | 184 | |
185 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
185 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
186 | 186 | } |
187 | 187 | |
188 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
188 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
189 | 189 | |
190 | 190 | |
191 | 191 | /** |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | -function give_login_form_shortcode( $atts ) { |
|
205 | +function give_login_form_shortcode($atts) { |
|
206 | 206 | |
207 | - $atts = shortcode_atts( array( |
|
207 | + $atts = shortcode_atts(array( |
|
208 | 208 | // Add backward compatibility for redirect attribute. |
209 | 209 | 'redirect' => '', |
210 | 210 | 'login-redirect' => '', |
211 | 211 | 'logout-redirect' => '', |
212 | - ), $atts, 'give_login' ); |
|
212 | + ), $atts, 'give_login'); |
|
213 | 213 | |
214 | 214 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
215 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
215 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
216 | 216 | |
217 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
217 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
220 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Register Shortcode. |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_register_form_shortcode( $atts ) { |
|
236 | - $atts = shortcode_atts( array( |
|
235 | +function give_register_form_shortcode($atts) { |
|
236 | + $atts = shortcode_atts(array( |
|
237 | 237 | 'redirect' => '', |
238 | - ), $atts, 'give_register' ); |
|
238 | + ), $atts, 'give_register'); |
|
239 | 239 | |
240 | - return give_register_form( $atts['redirect'] ); |
|
240 | + return give_register_form($atts['redirect']); |
|
241 | 241 | } |
242 | 242 | |
243 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
243 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Receipt Shortcode. |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string |
255 | 255 | */ |
256 | -function give_receipt_shortcode( $atts ) { |
|
256 | +function give_receipt_shortcode($atts) { |
|
257 | 257 | |
258 | 258 | global $give_receipt_args; |
259 | 259 | $payment_key = ''; |
260 | 260 | |
261 | - $give_receipt_args = shortcode_atts( array( |
|
262 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
261 | + $give_receipt_args = shortcode_atts(array( |
|
262 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
263 | 263 | 'price' => true, |
264 | 264 | 'donor' => true, |
265 | 265 | 'date' => true, |
@@ -269,62 +269,62 @@ discard block |
||
269 | 269 | 'payment_status' => false, |
270 | 270 | 'company_name' => false, |
271 | 271 | 'status_notice' => true, |
272 | - ), $atts, 'give_receipt' ); |
|
272 | + ), $atts, 'give_receipt'); |
|
273 | 273 | |
274 | 274 | // set $session var |
275 | 275 | $session = give_get_purchase_session(); |
276 | 276 | |
277 | 277 | // set payment key var |
278 | - if ( isset( $_GET['payment_key'] ) ) { |
|
279 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
280 | - } elseif ( $session ) { |
|
278 | + if (isset($_GET['payment_key'])) { |
|
279 | + $payment_key = urldecode($_GET['payment_key']); |
|
280 | + } elseif ($session) { |
|
281 | 281 | $payment_key = $session['purchase_key']; |
282 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
282 | + } elseif ($give_receipt_args['payment_key']) { |
|
283 | 283 | $payment_key = $give_receipt_args['payment_key']; |
284 | 284 | } |
285 | 285 | |
286 | - if( ! wp_doing_ajax() ) { |
|
286 | + if ( ! wp_doing_ajax()) { |
|
287 | 287 | ob_start(); |
288 | - give_get_template_part( 'receipt/placeholder' ); |
|
288 | + give_get_template_part('receipt/placeholder'); |
|
289 | 289 | $placeholder = ob_get_clean(); |
290 | 290 | |
291 | 291 | return sprintf( |
292 | 292 | '<div id="give-receipt" data-shortcode="%s" data-donation-key="%s">%s</div>', |
293 | - urlencode_deep( wp_json_encode( $atts ) ), |
|
293 | + urlencode_deep(wp_json_encode($atts)), |
|
294 | 294 | $payment_key, |
295 | 295 | $placeholder |
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
299 | - $email_access = give_get_option( 'email_access' ); |
|
299 | + $email_access = give_get_option('email_access'); |
|
300 | 300 | |
301 | 301 | // No payment_key found & Email Access is Turned on. |
302 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
302 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
303 | 303 | |
304 | 304 | ob_start(); |
305 | 305 | |
306 | - give_get_template_part( 'email-login-form' ); |
|
306 | + give_get_template_part('email-login-form'); |
|
307 | 307 | |
308 | 308 | return ob_get_clean(); |
309 | 309 | |
310 | - } elseif ( ! isset( $payment_key ) ) { |
|
310 | + } elseif ( ! isset($payment_key)) { |
|
311 | 311 | |
312 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
312 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
316 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
316 | + $user_can_view = give_can_view_receipt($payment_key); |
|
317 | 317 | |
318 | 318 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
319 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
319 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
320 | 320 | |
321 | 321 | ob_start(); |
322 | 322 | |
323 | - give_get_template_part( 'email-login-form' ); |
|
323 | + give_get_template_part('email-login-form'); |
|
324 | 324 | |
325 | 325 | return ob_get_clean(); |
326 | 326 | |
327 | - } elseif ( ! $user_can_view ) { |
|
327 | + } elseif ( ! $user_can_view) { |
|
328 | 328 | |
329 | 329 | global $give_login_redirect; |
330 | 330 | |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | |
333 | 333 | ob_start(); |
334 | 334 | |
335 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
335 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
336 | 336 | |
337 | - give_get_template_part( 'shortcode', 'login' ); |
|
337 | + give_get_template_part('shortcode', 'login'); |
|
338 | 338 | |
339 | 339 | $login_form = ob_get_clean(); |
340 | 340 | |
@@ -348,20 +348,20 @@ discard block |
||
348 | 348 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
349 | 349 | * or if user is logged in and the user can view sensitive shop data. |
350 | 350 | */ |
351 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
352 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
351 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
352 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | ob_start(); |
356 | 356 | |
357 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
357 | + give_get_template_part('shortcode', 'receipt'); |
|
358 | 358 | |
359 | 359 | $display = ob_get_clean(); |
360 | 360 | |
361 | 361 | return $display; |
362 | 362 | } |
363 | 363 | |
364 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
364 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
365 | 365 | |
366 | 366 | /** |
367 | 367 | * Profile Editor Shortcode. |
@@ -380,26 +380,26 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return string Output generated from the profile editor |
382 | 382 | */ |
383 | -function give_profile_editor_shortcode( $atts ) { |
|
383 | +function give_profile_editor_shortcode($atts) { |
|
384 | 384 | |
385 | 385 | ob_start(); |
386 | 386 | |
387 | 387 | // Restrict access to donor profile, if donor and user are disconnected. |
388 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
389 | - if ( is_user_logged_in() && $is_donor_disconnected ) { |
|
390 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
388 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
389 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
390 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
391 | 391 | |
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
395 | + give_get_template_part('shortcode', 'profile-editor'); |
|
396 | 396 | |
397 | 397 | $display = ob_get_clean(); |
398 | 398 | |
399 | 399 | return $display; |
400 | 400 | } |
401 | 401 | |
402 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
402 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
403 | 403 | |
404 | 404 | /** |
405 | 405 | * Process Profile Updater Form. |
@@ -412,31 +412,31 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return bool |
414 | 414 | */ |
415 | -function give_process_profile_editor_updates( $data ) { |
|
415 | +function give_process_profile_editor_updates($data) { |
|
416 | 416 | // Profile field change request. |
417 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
417 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
418 | 418 | return false; |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Nonce security. |
422 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
422 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
423 | 423 | return false; |
424 | 424 | } |
425 | 425 | |
426 | 426 | $user_id = get_current_user_id(); |
427 | - $old_user_data = get_userdata( $user_id ); |
|
427 | + $old_user_data = get_userdata($user_id); |
|
428 | 428 | |
429 | 429 | /* @var Give_Donor $donor */ |
430 | - $donor = new Give_Donor( $user_id, true ); |
|
430 | + $donor = new Give_Donor($user_id, true); |
|
431 | 431 | $old_company_name = $donor->get_company_name(); |
432 | 432 | |
433 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
434 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
435 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
436 | - $company_name = ! empty( $data['give_company_name'] ) ? sanitize_text_field( $data['give_company_name'] ) : $old_company_name; |
|
437 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
438 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
439 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
433 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
434 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
435 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
436 | + $company_name = ! empty($data['give_company_name']) ? sanitize_text_field($data['give_company_name']) : $old_company_name; |
|
437 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
438 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
439 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
440 | 440 | |
441 | 441 | $userdata = array( |
442 | 442 | 'ID' => $user_id, |
@@ -456,60 +456,60 @@ discard block |
||
456 | 456 | * @param int $user_id The ID of the user. |
457 | 457 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
458 | 458 | */ |
459 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
459 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
460 | 460 | |
461 | 461 | // Make sure to validate first name of existing donors. |
462 | - if ( empty( $first_name ) ) { |
|
462 | + if (empty($first_name)) { |
|
463 | 463 | // Empty First Name. |
464 | - give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) ); |
|
464 | + give_set_error('empty_first_name', __('Please enter your first name.', 'give')); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | // Make sure to validate passwords for existing Donors. |
468 | - give_validate_user_password( $password, $confirm_password ); |
|
468 | + give_validate_user_password($password, $confirm_password); |
|
469 | 469 | |
470 | - if ( empty( $email ) ) { |
|
470 | + if (empty($email)) { |
|
471 | 471 | // Make sure email should not be empty. |
472 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
472 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
473 | 473 | |
474 | - } elseif ( ! is_email( $email ) ) { |
|
474 | + } elseif ( ! is_email($email)) { |
|
475 | 475 | // Make sure email should be valid. |
476 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
476 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
477 | 477 | |
478 | - } elseif ( $email != $old_user_data->user_email ) { |
|
478 | + } elseif ($email != $old_user_data->user_email) { |
|
479 | 479 | // Make sure the new email doesn't belong to another user. |
480 | - if ( email_exists( $email ) ) { |
|
481 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
482 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
480 | + if (email_exists($email)) { |
|
481 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
482 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
483 | 483 | // Make sure the new email doesn't belong to another user. |
484 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
484 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | // Check for errors. |
489 | 489 | $errors = give_get_errors(); |
490 | 490 | |
491 | - if ( $errors ) { |
|
491 | + if ($errors) { |
|
492 | 492 | // Send back to the profile editor if there are errors. |
493 | - wp_redirect( $data['give_redirect'] ); |
|
493 | + wp_redirect($data['give_redirect']); |
|
494 | 494 | give_die(); |
495 | 495 | } |
496 | 496 | |
497 | 497 | // Update Donor First Name and Last Name. |
498 | - Give()->donors->update( $donor->id, array( |
|
499 | - 'name' => trim( "{$first_name} {$last_name}" ), |
|
500 | - ) ); |
|
501 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
502 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
503 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_company', $company_name ); |
|
498 | + Give()->donors->update($donor->id, array( |
|
499 | + 'name' => trim("{$first_name} {$last_name}"), |
|
500 | + )); |
|
501 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
502 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
503 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_company', $company_name); |
|
504 | 504 | |
505 | 505 | $current_user = wp_get_current_user(); |
506 | 506 | |
507 | 507 | // Compares new values with old values to detect change in values. |
508 | - $email_update = ( $email !== $current_user->user_email ) ? true : false; |
|
509 | - $display_name_update = ( $display_name !== $current_user->display_name ) ? true : false; |
|
510 | - $first_name_update = ( $first_name !== $current_user->first_name ) ? true : false; |
|
511 | - $last_name_update = ( $last_name !== $current_user->last_name ) ? true : false; |
|
512 | - $company_name_update = ( $company_name !== $old_company_name ) ? true : false; |
|
508 | + $email_update = ($email !== $current_user->user_email) ? true : false; |
|
509 | + $display_name_update = ($display_name !== $current_user->display_name) ? true : false; |
|
510 | + $first_name_update = ($first_name !== $current_user->first_name) ? true : false; |
|
511 | + $last_name_update = ($last_name !== $current_user->last_name) ? true : false; |
|
512 | + $company_name_update = ($company_name !== $old_company_name) ? true : false; |
|
513 | 513 | $update_code = 0; |
514 | 514 | |
515 | 515 | /** |
@@ -517,35 +517,35 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @var boolean |
519 | 519 | */ |
520 | - $profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update ); |
|
520 | + $profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update); |
|
521 | 521 | |
522 | 522 | /** |
523 | 523 | * True if password fields are filled. |
524 | 524 | * |
525 | 525 | * @var boolean |
526 | 526 | */ |
527 | - $password_update = ( ! empty( $password ) && ! empty( $confirm_password ) ); |
|
527 | + $password_update = ( ! empty($password) && ! empty($confirm_password)); |
|
528 | 528 | |
529 | - if ( $profile_update ) { |
|
529 | + if ($profile_update) { |
|
530 | 530 | |
531 | 531 | // If only profile fields are updated. |
532 | 532 | $update_code = '1'; |
533 | 533 | |
534 | - if ( $password_update ) { |
|
534 | + if ($password_update) { |
|
535 | 535 | |
536 | 536 | // If profile fields AND password both are updated. |
537 | 537 | $update_code = '2'; |
538 | 538 | } |
539 | - } elseif ( $password_update ) { |
|
539 | + } elseif ($password_update) { |
|
540 | 540 | |
541 | 541 | // If only password is updated. |
542 | 542 | $update_code = '3'; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Update the user. |
546 | - $updated = wp_update_user( $userdata ); |
|
546 | + $updated = wp_update_user($userdata); |
|
547 | 547 | |
548 | - if ( $updated ) { |
|
548 | + if ($updated) { |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Fires after updating user profile. |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | * @param int $user_id The ID of the user. |
556 | 556 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
557 | 557 | */ |
558 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
558 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
559 | 559 | |
560 | 560 | $profile_edit_redirect_args = array( |
561 | 561 | 'updated' => 'true', |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | * Update codes '2' and '3' indicate a password change. |
567 | 567 | * If the password is changed, then logout and redirect to the same page. |
568 | 568 | */ |
569 | - if ( '2' === $update_code || '3' === $update_code ) { |
|
570 | - wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) ); |
|
569 | + if ('2' === $update_code || '3' === $update_code) { |
|
570 | + wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']))); |
|
571 | 571 | } else { |
572 | - wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ); |
|
572 | + wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | give_die(); |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | |
581 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
581 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
582 | 582 | |
583 | 583 | /** |
584 | 584 | * Give totals Shortcode. |
@@ -591,24 +591,24 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return string |
593 | 593 | */ |
594 | -function give_totals_shortcode( $atts ) { |
|
595 | - $total = get_option( 'give_earnings_total', false ); |
|
594 | +function give_totals_shortcode($atts) { |
|
595 | + $total = get_option('give_earnings_total', false); |
|
596 | 596 | |
597 | - $message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ); |
|
597 | + $message = apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')); |
|
598 | 598 | |
599 | - $atts = shortcode_atts( array( |
|
599 | + $atts = shortcode_atts(array( |
|
600 | 600 | 'total_goal' => 0, // integer |
601 | 601 | 'ids' => 0, // integer|array |
602 | 602 | 'cats' => 0, // integer|array |
603 | 603 | 'tags' => 0, // integer|array |
604 | 604 | 'message' => $message, |
605 | 605 | 'link' => '', // URL |
606 | - 'link_text' => __( 'Donate Now', 'give' ), // string, |
|
606 | + 'link_text' => __('Donate Now', 'give'), // string, |
|
607 | 607 | 'progress_bar' => true, // boolean |
608 | - ), $atts, 'give_totals' ); |
|
608 | + ), $atts, 'give_totals'); |
|
609 | 609 | |
610 | 610 | // Total Goal. |
611 | - $total_goal = give_maybe_sanitize_amount( $atts['total_goal'] ); |
|
611 | + $total_goal = give_maybe_sanitize_amount($atts['total_goal']); |
|
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Give Action fire before the shortcode is rendering is started. |
@@ -617,14 +617,14 @@ discard block |
||
617 | 617 | * |
618 | 618 | * @param array $atts shortcode attribute. |
619 | 619 | */ |
620 | - do_action( 'give_totals_goal_shortcode_before_render', $atts ); |
|
620 | + do_action('give_totals_goal_shortcode_before_render', $atts); |
|
621 | 621 | |
622 | 622 | // Build query based on cat, tag and Form ids. |
623 | - if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) { |
|
623 | + if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) { |
|
624 | 624 | |
625 | 625 | $form_ids = array(); |
626 | - if ( ! empty( $atts['ids'] ) ) { |
|
627 | - $form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
626 | + if ( ! empty($atts['ids'])) { |
|
627 | + $form_ids = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -638,23 +638,23 @@ discard block |
||
638 | 638 | 'post_type' => 'give_forms', |
639 | 639 | 'post_status' => 'publish', |
640 | 640 | 'post__in' => $form_ids, |
641 | - 'posts_per_page' => - 1, |
|
641 | + 'posts_per_page' => -1, |
|
642 | 642 | 'fields' => 'ids', |
643 | 643 | 'tax_query' => array( |
644 | 644 | 'relation' => 'AND', |
645 | 645 | ), |
646 | 646 | ); |
647 | 647 | |
648 | - if ( ! empty( $atts['cats'] ) ) { |
|
649 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
648 | + if ( ! empty($atts['cats'])) { |
|
649 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
650 | 650 | $form_args['tax_query'][] = array( |
651 | 651 | 'taxonomy' => 'give_forms_category', |
652 | 652 | 'terms' => $cats, |
653 | 653 | ); |
654 | 654 | } |
655 | 655 | |
656 | - if ( ! empty( $atts['tags'] ) ) { |
|
657 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
656 | + if ( ! empty($atts['tags'])) { |
|
657 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
658 | 658 | $form_args['tax_query'][] = array( |
659 | 659 | 'taxonomy' => 'give_forms_tag', |
660 | 660 | 'terms' => $tags, |
@@ -670,15 +670,15 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return array $form_args WP query argument for Total Goal. |
672 | 672 | */ |
673 | - $form_args = (array) apply_filters( 'give_totals_goal_shortcode_query_args', $form_args ); |
|
673 | + $form_args = (array) apply_filters('give_totals_goal_shortcode_query_args', $form_args); |
|
674 | 674 | |
675 | - $forms = new WP_Query( $form_args ); |
|
675 | + $forms = new WP_Query($form_args); |
|
676 | 676 | |
677 | - if ( isset( $forms->posts ) ) { |
|
677 | + if (isset($forms->posts)) { |
|
678 | 678 | $total = 0; |
679 | - foreach ( $forms->posts as $post ) { |
|
680 | - $form_earning = give_get_meta( $post, '_give_form_earnings', true ); |
|
681 | - $form_earning = ! empty( $form_earning ) ? $form_earning : 0; |
|
679 | + foreach ($forms->posts as $post) { |
|
680 | + $form_earning = give_get_meta($post, '_give_form_earnings', true); |
|
681 | + $form_earning = ! empty($form_earning) ? $form_earning : 0; |
|
682 | 682 | |
683 | 683 | /** |
684 | 684 | * Update Form earnings. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param int $post Form ID. |
689 | 689 | * @param string $form_earning Total earning of Form. |
690 | 690 | */ |
691 | - $total += apply_filters( 'give_totals_form_earning', $form_earning, $post ); |
|
691 | + $total += apply_filters('give_totals_form_earning', $form_earning, $post); |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | |
@@ -696,23 +696,23 @@ discard block |
||
696 | 696 | |
697 | 697 | // Append link with text. |
698 | 698 | $donate_link = ''; |
699 | - if ( ! empty( $atts['link'] ) ) { |
|
700 | - $donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) ); |
|
699 | + if ( ! empty($atts['link'])) { |
|
700 | + $donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text'])); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | // Replace {total} in message. |
704 | - $message = str_replace( '{total}', give_currency_filter( |
|
705 | - give_format_amount( $total, |
|
706 | - array( 'sanitize' => false ) |
|
704 | + $message = str_replace('{total}', give_currency_filter( |
|
705 | + give_format_amount($total, |
|
706 | + array('sanitize' => false) |
|
707 | 707 | ) |
708 | - ), esc_html( $atts['message'] ) ); |
|
708 | + ), esc_html($atts['message'])); |
|
709 | 709 | |
710 | 710 | // Replace {total_goal} in message. |
711 | - $message = str_replace( '{total_goal}', give_currency_filter( |
|
712 | - give_format_amount( $total_goal, |
|
713 | - array( 'sanitize' => true ) |
|
711 | + $message = str_replace('{total_goal}', give_currency_filter( |
|
712 | + give_format_amount($total_goal, |
|
713 | + array('sanitize' => true) |
|
714 | 714 | ) |
715 | - ), $message ); |
|
715 | + ), $message); |
|
716 | 716 | |
717 | 717 | /** |
718 | 718 | * Update Give totals shortcode output. |
@@ -722,19 +722,19 @@ discard block |
||
722 | 722 | * @param string $message Shortcode Message. |
723 | 723 | * @param array $atts ShortCode attributes. |
724 | 724 | */ |
725 | - $message = apply_filters( 'give_totals_shortcode_message', $message, $atts ); |
|
725 | + $message = apply_filters('give_totals_shortcode_message', $message, $atts); |
|
726 | 726 | |
727 | 727 | ob_start(); |
728 | 728 | ?> |
729 | 729 | <div class="give-totals-shortcode-wrap"> |
730 | 730 | <?php |
731 | 731 | // Show Progress Bar if progress_bar set true. |
732 | - $show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
733 | - if ( $show_progress_bar ) { |
|
734 | - give_show_goal_totals_progress( $total, $total_goal ); |
|
732 | + $show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
733 | + if ($show_progress_bar) { |
|
734 | + give_show_goal_totals_progress($total, $total_goal); |
|
735 | 735 | } |
736 | 736 | |
737 | - echo sprintf( $message ) . $donate_link; |
|
737 | + echo sprintf($message).$donate_link; |
|
738 | 738 | ?> |
739 | 739 | </div> |
740 | 740 | <?php |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @param array $atts shortcode attribute. |
750 | 750 | * @param string $give_totals_output shortcode output. |
751 | 751 | */ |
752 | - do_action( 'give_totals_goal_shortcode_after_render', $atts, $give_totals_output ); |
|
752 | + do_action('give_totals_goal_shortcode_after_render', $atts, $give_totals_output); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Give Totals Shortcode output. |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @param string $give_totals_output |
760 | 760 | */ |
761 | - return apply_filters( 'give_totals_shortcode_output', $give_totals_output ); |
|
761 | + return apply_filters('give_totals_shortcode_output', $give_totals_output); |
|
762 | 762 | |
763 | 763 | } |
764 | 764 | |
765 | -add_shortcode( 'give_totals', 'give_totals_shortcode' ); |
|
765 | +add_shortcode('give_totals', 'give_totals_shortcode'); |
|
766 | 766 | |
767 | 767 | |
768 | 768 | /** |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | * } |
794 | 794 | * @return string|bool The markup of the form grid or false. |
795 | 795 | */ |
796 | -function give_form_grid_shortcode( $atts ) { |
|
796 | +function give_form_grid_shortcode($atts) { |
|
797 | 797 | |
798 | 798 | $give_settings = give_get_settings(); |
799 | 799 | |
800 | - $atts = shortcode_atts( array( |
|
800 | + $atts = shortcode_atts(array( |
|
801 | 801 | 'forms_per_page' => 12, |
802 | 802 | 'paged' => true, |
803 | 803 | 'ids' => '', |
@@ -814,11 +814,11 @@ discard block |
||
814 | 814 | 'excerpt_length' => 16, |
815 | 815 | 'display_style' => 'modal_reveal', |
816 | 816 | 'status' => '', // open or closed |
817 | - ), $atts ); |
|
817 | + ), $atts); |
|
818 | 818 | |
819 | 819 | // Validate integer attributes. |
820 | - $atts['forms_per_page'] = intval( $atts['forms_per_page'] ); |
|
821 | - $atts['excerpt_length'] = intval( $atts['excerpt_length'] ); |
|
820 | + $atts['forms_per_page'] = intval($atts['forms_per_page']); |
|
821 | + $atts['excerpt_length'] = intval($atts['excerpt_length']); |
|
822 | 822 | |
823 | 823 | // Validate boolean attributes. |
824 | 824 | $boolean_attributes = array( |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | 'show_featured_image', |
830 | 830 | ); |
831 | 831 | |
832 | - foreach ( $boolean_attributes as $att ) { |
|
833 | - $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN ); |
|
832 | + foreach ($boolean_attributes as $att) { |
|
833 | + $atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | // Set default form query args. |
@@ -844,9 +844,9 @@ discard block |
||
844 | 844 | ); |
845 | 845 | |
846 | 846 | // Filter results of form grid based on form status. |
847 | - $form_closed_status = trim( $atts['status'] ); |
|
847 | + $form_closed_status = trim($atts['status']); |
|
848 | 848 | |
849 | - if ( ! empty( $form_closed_status ) ) { |
|
849 | + if ( ! empty($form_closed_status)) { |
|
850 | 850 | $form_args['meta_query'] = array( |
851 | 851 | array( |
852 | 852 | 'key' => '_give_form_status', |
@@ -856,25 +856,25 @@ discard block |
||
856 | 856 | } |
857 | 857 | |
858 | 858 | // Maybe add pagination. |
859 | - if ( true === $atts['paged'] ) { |
|
860 | - $form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; |
|
859 | + if (true === $atts['paged']) { |
|
860 | + $form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | // Maybe filter forms by IDs. |
864 | - if ( ! empty( $atts['ids'] ) ) { |
|
865 | - $form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
864 | + if ( ! empty($atts['ids'])) { |
|
865 | + $form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | // Convert comma-separated form IDs into array. |
869 | - if ( ! empty( $atts['exclude'] ) ) { |
|
870 | - $form_args['post__not_in'] = array_filter( array_map( function( $item ) { |
|
871 | - return intval( trim( $item ) ); |
|
872 | - }, explode( ',', $atts['exclude'] ) ) ); |
|
869 | + if ( ! empty($atts['exclude'])) { |
|
870 | + $form_args['post__not_in'] = array_filter(array_map(function($item) { |
|
871 | + return intval(trim($item)); |
|
872 | + }, explode(',', $atts['exclude']))); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | // Maybe filter by form category. |
876 | - if ( ! empty( $atts['cats'] ) ) { |
|
877 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
876 | + if ( ! empty($atts['cats'])) { |
|
877 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
878 | 878 | $tax_query = array( |
879 | 879 | 'taxonomy' => 'give_forms_category', |
880 | 880 | 'terms' => $cats, |
@@ -883,8 +883,8 @@ discard block |
||
883 | 883 | } |
884 | 884 | |
885 | 885 | // Maybe filter by form tag. |
886 | - if ( ! empty( $atts['tags'] ) ) { |
|
887 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
886 | + if ( ! empty($atts['tags'])) { |
|
887 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
888 | 888 | $tax_query = array( |
889 | 889 | 'taxonomy' => 'give_forms_tag', |
890 | 890 | 'terms' => $tags, |
@@ -893,24 +893,24 @@ discard block |
||
893 | 893 | } |
894 | 894 | |
895 | 895 | // Query to output donation forms. |
896 | - $form_query = new WP_Query( $form_args ); |
|
896 | + $form_query = new WP_Query($form_args); |
|
897 | 897 | |
898 | - if ( $form_query->have_posts() ) { |
|
898 | + if ($form_query->have_posts()) { |
|
899 | 899 | ob_start(); |
900 | 900 | |
901 | - add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 ); |
|
902 | - add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 ); |
|
903 | - add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 ); |
|
904 | - add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 ); |
|
901 | + add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1); |
|
902 | + add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1); |
|
903 | + add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3); |
|
904 | + add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3); |
|
905 | 905 | |
906 | 906 | echo '<div class="give-wrap">'; |
907 | - echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">'; |
|
907 | + echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">'; |
|
908 | 908 | |
909 | - while ( $form_query->have_posts() ) { |
|
909 | + while ($form_query->have_posts()) { |
|
910 | 910 | $form_query->the_post(); |
911 | 911 | |
912 | 912 | // Give/templates/shortcode-form-grid.php. |
913 | - give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) ); |
|
913 | + give_get_template('shortcode-form-grid', array($give_settings, $atts)); |
|
914 | 914 | |
915 | 915 | } |
916 | 916 | |
@@ -918,28 +918,28 @@ discard block |
||
918 | 918 | |
919 | 919 | echo '</div><!-- .give-grid -->'; |
920 | 920 | |
921 | - remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' ); |
|
922 | - remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' ); |
|
923 | - remove_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10 ); |
|
924 | - remove_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10 ); |
|
921 | + remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class'); |
|
922 | + remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class'); |
|
923 | + remove_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10); |
|
924 | + remove_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10); |
|
925 | 925 | |
926 | - if ( false !== $atts['paged'] ) { |
|
926 | + if (false !== $atts['paged']) { |
|
927 | 927 | $paginate_args = array( |
928 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
928 | + 'current' => max(1, get_query_var('paged')), |
|
929 | 929 | 'total' => $form_query->max_num_pages, |
930 | 930 | 'show_all' => false, |
931 | 931 | 'end_size' => 1, |
932 | 932 | 'mid_size' => 2, |
933 | 933 | 'prev_next' => true, |
934 | - 'prev_text' => __( '« Previous', 'give' ), |
|
935 | - 'next_text' => __( 'Next »', 'give' ), |
|
934 | + 'prev_text' => __('« Previous', 'give'), |
|
935 | + 'next_text' => __('Next »', 'give'), |
|
936 | 936 | 'type' => 'plain', |
937 | 937 | 'add_args' => false, |
938 | 938 | ); |
939 | 939 | |
940 | 940 | printf( |
941 | 941 | '<div class="give-page-numbers">%s</div>', |
942 | - paginate_links( $paginate_args ) |
|
942 | + paginate_links($paginate_args) |
|
943 | 943 | ); |
944 | 944 | } |
945 | 945 | echo '</div><!-- .give-wrap -->'; |
@@ -948,4 +948,4 @@ discard block |
||
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | -add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' ); |
|
951 | +add_shortcode('give_form_grid', 'give_form_grid_shortcode'); |
@@ -6,29 +6,29 @@ discard block |
||
6 | 6 | global $give_receipt_args, $payment; |
7 | 7 | |
8 | 8 | // Validation: Ensure $payment var is set. |
9 | -if ( empty( $payment ) ) { |
|
10 | - $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; |
|
9 | +if (empty($payment)) { |
|
10 | + $payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | // Double-Validation: Check for $payment global. |
14 | -if ( empty( $payment ) ) { |
|
15 | - Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); |
|
14 | +if (empty($payment)) { |
|
15 | + Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give')); |
|
16 | 16 | |
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $donation_id = $payment->ID; |
21 | -$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
22 | -$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); |
|
23 | -$donation = give_get_donation_form_title( $donation_id ); |
|
24 | -$user = give_get_payment_meta_user_info( $donation_id ); |
|
25 | -$email = give_get_payment_user_email( $donation_id ); |
|
21 | +$donation_number = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
22 | +$form_id = give_get_payment_meta($donation_id, '_give_payment_form_id', true); |
|
23 | +$donation = give_get_donation_form_title($donation_id); |
|
24 | +$user = give_get_payment_meta_user_info($donation_id); |
|
25 | +$email = give_get_payment_user_email($donation_id); |
|
26 | 26 | $status = $payment->post_status; |
27 | -$status_label = give_get_payment_status( $payment, true ); |
|
28 | -$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); |
|
27 | +$status_label = give_get_payment_status($payment, true); |
|
28 | +$company_name = give_get_payment_meta($donation_id, '_give_donation_company', true); |
|
29 | 29 | |
30 | 30 | // Update donor name, if title prefix is set. |
31 | -$full_name = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" ); |
|
31 | +$full_name = give_get_donor_name_with_title_prefixes($user['title'], "{$user['first_name']} {$user['last_name']}"); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Generate Donation Receipt Arguments. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @since 1.8.8 |
40 | 40 | */ |
41 | 41 | $give_receipt_args['donation_receipt']['donor'] = array( |
42 | - 'name' => __( 'Donor', 'give' ), |
|
42 | + 'name' => __('Donor', 'give'), |
|
43 | 43 | 'value' => $full_name, |
44 | 44 | 'display' => $give_receipt_args['donor'], |
45 | 45 | ); |
@@ -54,51 +54,51 @@ discard block |
||
54 | 54 | * @return bool show/hide company name in donation receipt page. |
55 | 55 | */ |
56 | 56 | $give_receipt_args['donation_receipt']['company_name'] = array( |
57 | - 'name' => __( 'Company Name', 'give' ), |
|
58 | - 'value' => esc_attr( $company_name ), |
|
57 | + 'name' => __('Company Name', 'give'), |
|
58 | + 'value' => esc_attr($company_name), |
|
59 | 59 | // Do not show company field if empty |
60 | - 'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'], |
|
60 | + 'display' => empty($company_name) ? false : $give_receipt_args['company_name'], |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $give_receipt_args['donation_receipt']['date'] = array( |
64 | - 'name' => __( 'Date', 'give' ), |
|
65 | - 'value' => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ), |
|
64 | + 'name' => __('Date', 'give'), |
|
65 | + 'value' => date_i18n(give_date_format(), strtotime(give_get_payment_completed_date($donation_id))), |
|
66 | 66 | 'display' => $give_receipt_args['date'], |
67 | 67 | ); |
68 | 68 | |
69 | 69 | $give_receipt_args['donation_receipt']['total_donation'] = array( |
70 | - 'name' => __( 'Total Donation', 'give' ), |
|
71 | - 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), |
|
70 | + 'name' => __('Total Donation', 'give'), |
|
71 | + 'value' => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')), |
|
72 | 72 | 'display' => $give_receipt_args['price'], |
73 | 73 | ); |
74 | 74 | |
75 | 75 | $give_receipt_args['donation_receipt']['donation'] = array( |
76 | - 'name' => __( 'Donation', 'give' ), |
|
76 | + 'name' => __('Donation', 'give'), |
|
77 | 77 | 'value' => $donation, |
78 | 78 | 'display' => true, |
79 | 79 | ); |
80 | 80 | |
81 | 81 | $give_receipt_args['donation_receipt']['donation_status'] = array( |
82 | - 'name' => __( 'Donation Status', 'give' ), |
|
83 | - 'value' => esc_attr( $status_label ), |
|
82 | + 'name' => __('Donation Status', 'give'), |
|
83 | + 'value' => esc_attr($status_label), |
|
84 | 84 | 'display' => $give_receipt_args['payment_status'], |
85 | 85 | ); |
86 | 86 | |
87 | 87 | $give_receipt_args['donation_receipt']['donation_id'] = array( |
88 | - 'name' => __( 'Donation ID', 'give' ), |
|
88 | + 'name' => __('Donation ID', 'give'), |
|
89 | 89 | 'value' => $donation_number, |
90 | 90 | 'display' => $give_receipt_args['payment_id'], |
91 | 91 | ); |
92 | 92 | |
93 | 93 | $give_receipt_args['donation_receipt']['payment_key'] = array( |
94 | - 'name' => __( 'Payment Key', 'give' ), |
|
95 | - 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), |
|
94 | + 'name' => __('Payment Key', 'give'), |
|
95 | + 'value' => get_post_meta($donation_id, '_give_payment_purchase_key', true), |
|
96 | 96 | 'display' => $give_receipt_args['payment_key'], |
97 | 97 | ); |
98 | 98 | |
99 | 99 | $give_receipt_args['donation_receipt']['payment_method'] = array( |
100 | - 'name' => __( 'Payment Method', 'give' ), |
|
101 | - 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
|
100 | + 'name' => __('Payment Method', 'give'), |
|
101 | + 'value' => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)), |
|
102 | 102 | 'display' => $give_receipt_args['payment_method'], |
103 | 103 | ); |
104 | 104 | |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8.8 |
115 | 115 | */ |
116 | -$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
|
116 | +$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id); |
|
117 | 117 | |
118 | 118 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
119 | -if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { |
|
119 | +if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) { |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Before the offline donation receipt content starts. |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @param Give_Payment $payment Donation payment object. |
127 | 127 | * @param array $give_receipt_args Receipt Arguments. |
128 | 128 | */ |
129 | - do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); |
|
129 | + do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args); |
|
130 | 130 | ?> |
131 | - <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
|
132 | - <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
|
131 | + <h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2> |
|
132 | + <div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>"> |
|
133 | 133 | <?php |
134 | 134 | // Instruction for offline donation. |
135 | - $offline_instruction = give_get_offline_payment_instruction( $form_id, true ); |
|
135 | + $offline_instruction = give_get_offline_payment_instruction($form_id, true); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Instruction for the offline donation. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param Give_Payment $payment Payment object. |
144 | 144 | * @param integer $form_id Donation form id. |
145 | 145 | */ |
146 | - echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); |
|
146 | + echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id); |
|
147 | 147 | ?> |
148 | 148 | </div> |
149 | 149 | <?php |
@@ -155,52 +155,52 @@ discard block |
||
155 | 155 | * @param Give_Payment $payment Donation payment object. |
156 | 156 | * @param array $give_receipt_args Receipt Arguments. |
157 | 157 | */ |
158 | - do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); |
|
158 | + do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args); |
|
159 | 159 | |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Show payment status notice based on shortcode attribute. |
164 | -if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
164 | +if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) { |
|
165 | 165 | $notice_message = ''; |
166 | 166 | $notice_type = 'warning'; |
167 | 167 | |
168 | - switch ( $status ) { |
|
168 | + switch ($status) { |
|
169 | 169 | case 'publish': |
170 | - $notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' ); |
|
170 | + $notice_message = __('Payment Complete: Thank you for your donation.', 'give'); |
|
171 | 171 | $notice_type = 'success'; |
172 | 172 | break; |
173 | 173 | case 'pending': |
174 | - $notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' ); |
|
174 | + $notice_message = __('Payment Pending: Your donation is currently processing.', 'give'); |
|
175 | 175 | $notice_type = 'warning'; |
176 | 176 | break; |
177 | 177 | case 'refunded': |
178 | - $notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' ); |
|
178 | + $notice_message = __('Payment Refunded: Your donation has been refunded.', 'give'); |
|
179 | 179 | $notice_type = 'warning'; |
180 | 180 | break; |
181 | 181 | case 'preapproval': |
182 | - $notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' ); |
|
182 | + $notice_message = __('Payment Preapproved: Thank you for your donation.', 'give'); |
|
183 | 183 | $notice_type = 'warning'; |
184 | 184 | break; |
185 | 185 | case 'failed': |
186 | - $notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' ); |
|
186 | + $notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give'); |
|
187 | 187 | $notice_type = 'error'; |
188 | 188 | break; |
189 | 189 | case 'cancelled': |
190 | - $notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' ); |
|
190 | + $notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give'); |
|
191 | 191 | $notice_type = 'error'; |
192 | 192 | break; |
193 | 193 | case 'abandoned': |
194 | - $notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' ); |
|
194 | + $notice_message = __('Payment Abandoned: This donation has not been completed.', 'give'); |
|
195 | 195 | $notice_type = 'error'; |
196 | 196 | break; |
197 | 197 | case 'revoked': |
198 | - $notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' ); |
|
198 | + $notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give'); |
|
199 | 199 | $notice_type = 'error'; |
200 | 200 | break; |
201 | 201 | } |
202 | 202 | |
203 | - if ( ! empty( $notice_message ) ) { |
|
203 | + if ( ! empty($notice_message)) { |
|
204 | 204 | /** |
205 | 205 | * Filters payment status notice for receipts. |
206 | 206 | * |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param string $status Payment status. |
216 | 216 | * @param int $donation_id Donation ID. |
217 | 217 | */ |
218 | - echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); |
|
218 | + echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $donation_id); |
|
219 | 219 | } |
220 | 220 | }// End if(). |
221 | 221 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param object $payment The payment object. |
230 | 230 | * @param array $give_receipt_args Receipt_argument. |
231 | 231 | */ |
232 | -do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); |
|
232 | +do_action('give_payment_receipt_before_table', $payment, $give_receipt_args); |
|
233 | 233 | ?> |
234 | 234 | |
235 | 235 | <table id="give_donation_receipt" class="give-table"> |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param object $payment The payment object. |
246 | 246 | * @param array $give_receipt_args Receipt_argument. |
247 | 247 | */ |
248 | - do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); |
|
248 | + do_action('give_payment_receipt_header_before', $payment, $give_receipt_args); |
|
249 | 249 | ?> |
250 | 250 | <tr> |
251 | 251 | <th scope="colgroup" colspan="2"> |
252 | - <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> |
|
252 | + <span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span> |
|
253 | 253 | </th> |
254 | 254 | </tr> |
255 | 255 | <?php |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param object $payment The payment object. |
264 | 264 | * @param array $give_receipt_args Receipt_argument. |
265 | 265 | */ |
266 | - do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); |
|
266 | + do_action('give_payment_receipt_header_after', $payment, $give_receipt_args); |
|
267 | 267 | ?> |
268 | 268 | </thead> |
269 | 269 | |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | * @param object $payment The payment object. |
280 | 280 | * @param array $give_receipt_args Receipt_argument. |
281 | 281 | */ |
282 | - do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); |
|
282 | + do_action('give_payment_receipt_before', $payment, $give_receipt_args); |
|
283 | 283 | ?> |
284 | 284 | |
285 | - <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
|
286 | - <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
285 | + <?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?> |
|
286 | + <?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
287 | 287 | <tr> |
288 | 288 | <td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td> |
289 | 289 | <td><?php echo $receipt_item['value']; ?></td> |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param object $payment The payment object. |
303 | 303 | * @param array $give_receipt_args Receipt_argument. |
304 | 304 | */ |
305 | - do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); |
|
305 | + do_action('give_payment_receipt_after', $payment, $give_receipt_args); |
|
306 | 306 | ?> |
307 | 307 | </tbody> |
308 | 308 | </table> |
@@ -318,5 +318,5 @@ discard block |
||
318 | 318 | * @param object $payment The payment object. |
319 | 319 | * @param array $give_receipt_args Receipt_argument. |
320 | 320 | */ |
321 | -do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); |
|
321 | +do_action('give_payment_receipt_after_table', $payment, $give_receipt_args); |
|
322 | 322 | ?> |