@@ -666,6 +666,7 @@ |
||
666 | 666 | * Check if Import donation is duplicate |
667 | 667 | * |
668 | 668 | * @since 1.8.13 |
669 | + * @param Give_Donate_Form $form |
|
669 | 670 | */ |
670 | 671 | function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
671 | 672 | $return = 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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.8.13 |
21 | 21 | */ |
22 | 22 | function give_import_donation_report() { |
23 | - return get_option( 'give_import_donation_report', array() ); |
|
23 | + return get_option('give_import_donation_report', array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8.13 |
31 | 31 | */ |
32 | -function give_import_donation_report_update( $value = array() ) { |
|
33 | - update_option( 'give_import_donation_report', $value ); |
|
32 | +function give_import_donation_report_update($value = array()) { |
|
33 | + update_option('give_import_donation_report', $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @since 1.8.13 |
41 | 41 | */ |
42 | 42 | function give_import_donation_report_reset() { |
43 | - update_option( 'give_import_donation_report', array() ); |
|
43 | + update_option('give_import_donation_report', array()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
54 | 54 | */ |
55 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
55 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
56 | 56 | $new_form = false; |
57 | 57 | |
58 | 58 | // Get the import report |
@@ -61,58 +61,58 @@ discard block |
||
61 | 61 | $form = false; |
62 | 62 | $meta = array(); |
63 | 63 | |
64 | - if ( ! empty( $data['form_id'] ) ) { |
|
65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
64 | + if ( ! empty($data['form_id'])) { |
|
65 | + $form = new Give_Donate_Form($data['form_id']); |
|
66 | 66 | // Add support to older php version. |
67 | 67 | $form_id = $form->get_ID(); |
68 | - if ( empty( $form_id ) ) { |
|
69 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
68 | + if (empty($form_id)) { |
|
69 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
70 | 70 | $form = false; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
75 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
74 | + if (false === $form && ! empty($data['form_title'])) { |
|
75 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
76 | 76 | |
77 | - if ( ! empty( $form->ID ) ) { |
|
77 | + if ( ! empty($form->ID)) { |
|
78 | 78 | |
79 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
79 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
80 | 80 | |
81 | - $form = new Give_Donate_Form( $form->ID ); |
|
81 | + $form = new Give_Donate_Form($form->ID); |
|
82 | 82 | } else { |
83 | 83 | $form = new Give_Donate_Form(); |
84 | 84 | $args = array( |
85 | 85 | 'post_title' => $data['form_title'], |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | ); |
88 | - $form = $form->create( $args ); |
|
89 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
88 | + $form = $form->create($args); |
|
89 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
90 | 90 | $new_form = true; |
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
95 | - $form = new Give_Donate_Form( $form->ID ); |
|
94 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
95 | + $form = new Give_Donate_Form($form->ID); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $form ) && $form->get_ID() ) { |
|
99 | - if ( ! empty( $data['form_level'] ) && 'custom' != (string) strtolower( $data['form_level'] ) ) { |
|
98 | + if ( ! empty($form) && $form->get_ID()) { |
|
99 | + if ( ! empty($data['form_level']) && 'custom' != (string) strtolower($data['form_level'])) { |
|
100 | 100 | $prices = (array) $form->get_prices(); |
101 | 101 | $price_text = array(); |
102 | - foreach ( $prices as $key => $price ) { |
|
103 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
104 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? $price['_give_text'] : '' ); |
|
102 | + foreach ($prices as $key => $price) { |
|
103 | + if (isset($price['_give_id']['level_id'])) { |
|
104 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? $price['_give_text'] : ''); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! in_array( $data['form_level'], $price_text ) ) { |
|
108 | + if ( ! in_array($data['form_level'], $price_text)) { |
|
109 | 109 | |
110 | 110 | // For generating unquiet level id. |
111 | 111 | $count = 1; |
112 | - $new_level = count( $prices ) + $count; |
|
113 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
114 | - $count ++; |
|
115 | - $new_level = count( $prices ) + $count; |
|
112 | + $new_level = count($prices) + $count; |
|
113 | + while (array_key_exists($new_level, $price_text)) { |
|
114 | + $count++; |
|
115 | + $new_level = count($prices) + $count; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $multi_level_donations = array( |
@@ -120,57 +120,57 @@ discard block |
||
120 | 120 | '_give_id' => array( |
121 | 121 | 'level_id' => $new_level, |
122 | 122 | ), |
123 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
123 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
124 | 124 | '_give_text' => $data['form_level'], |
125 | 125 | ), |
126 | 126 | ); |
127 | 127 | |
128 | - $price_text[ $new_level ] = $data['form_level']; |
|
128 | + $price_text[$new_level] = $data['form_level']; |
|
129 | 129 | |
130 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
131 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
130 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
131 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
132 | 132 | |
133 | 133 | // Sort $prices by amount in ascending order. |
134 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
134 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
135 | 135 | } else { |
136 | 136 | $prices = $multi_level_donations; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Unset _give_default key from $prices. |
140 | - foreach ( $prices as $key => $price ) { |
|
141 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
142 | - unset( $prices[ $key ]['_give_default'] ); |
|
140 | + foreach ($prices as $key => $price) { |
|
141 | + if (isset($prices[$key]['_give_default'])) { |
|
142 | + unset($prices[$key]['_give_default']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Set the first $price of the $prices as defalut. |
147 | 147 | $prices[0]['_give_default'] = 'default'; |
148 | 148 | } |
149 | - $form->price_id = array_search( $data['form_level'], $price_text ); |
|
149 | + $form->price_id = array_search($data['form_level'], $price_text); |
|
150 | 150 | |
151 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
152 | - $min_amount = min( $donation_levels_amounts ); |
|
153 | - $max_amount = max( $donation_levels_amounts ); |
|
151 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
152 | + $min_amount = min($donation_levels_amounts); |
|
153 | + $max_amount = max($donation_levels_amounts); |
|
154 | 154 | |
155 | 155 | $meta = array( |
156 | 156 | '_give_levels_minimum_amount' => $min_amount, |
157 | 157 | '_give_levels_maximum_amount' => $max_amount, |
158 | 158 | '_give_price_option' => 'multi', |
159 | - '_give_donation_levels' => array_values( $prices ), |
|
159 | + '_give_donation_levels' => array_values($prices), |
|
160 | 160 | ); |
161 | 161 | } else { |
162 | 162 | $form->price_id = 'custom'; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $defaults = array( |
166 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
166 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
167 | 167 | '_give_price_option' => 'set', |
168 | 168 | ); |
169 | 169 | |
170 | 170 | // If new form is created. |
171 | - if ( ! empty( $new_form ) ) { |
|
171 | + if ( ! empty($new_form)) { |
|
172 | 172 | $new_form = array( |
173 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
173 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
174 | 174 | '_give_logged_in_only' => 'enabled', |
175 | 175 | '_give_custom_amount' => 'enabled', |
176 | 176 | '_give_payment_import' => true, |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | '_give_default_gateway' => 'global', |
182 | 182 | '_give_show_register_form' => 'both', |
183 | 183 | ); |
184 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
184 | + $defaults = wp_parse_args($defaults, $new_form); |
|
185 | 185 | } |
186 | 186 | |
187 | - $meta = wp_parse_args( $meta, $defaults ); |
|
187 | + $meta = wp_parse_args($meta, $defaults); |
|
188 | 188 | |
189 | - foreach ( $meta as $key => $value ) { |
|
190 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
189 | + foreach ($meta as $key => $value) { |
|
190 | + give_update_meta($form->get_ID(), $key, $value); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | // update the report |
195 | - give_import_donation_report_update( $report ); |
|
195 | + give_import_donation_report_update($report); |
|
196 | 196 | |
197 | 197 | return $form; |
198 | 198 | } |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return bool|false|WP_User |
208 | 208 | */ |
209 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
209 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
210 | 210 | $report = give_import_donation_report(); |
211 | 211 | $donor_data = false; |
212 | 212 | $customer_id = false; |
213 | 213 | |
214 | 214 | // check if donor id is not empty |
215 | - if ( ! empty( $data['donor_id'] ) ) { |
|
216 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
217 | - if ( ! empty( $donor_data->id ) ) { |
|
218 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
215 | + if ( ! empty($data['donor_id'])) { |
|
216 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
217 | + if ( ! empty($donor_data->id)) { |
|
218 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
222 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
223 | 223 | $user_id = (int) $data['user_id']; |
224 | - $donor_data = new Give_Donor( $user_id, true ); |
|
224 | + $donor_data = new Give_Donor($user_id, true); |
|
225 | 225 | |
226 | 226 | |
227 | - if ( empty( $donor_data->id ) ) { |
|
228 | - $donor_data = get_user_by( 'id', $user_id ); |
|
229 | - if ( ! empty( $donor_data->ID ) ) { |
|
230 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
231 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
232 | - $name = $first_name . ' ' . $last_name; |
|
227 | + if (empty($donor_data->id)) { |
|
228 | + $donor_data = get_user_by('id', $user_id); |
|
229 | + if ( ! empty($donor_data->ID)) { |
|
230 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
231 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
232 | + $name = $first_name.' '.$last_name; |
|
233 | 233 | $user_email = $donor_data->user_email; |
234 | 234 | $donor_args = array( |
235 | 235 | 'name' => $name, |
@@ -238,44 +238,44 @@ discard block |
||
238 | 238 | ); |
239 | 239 | |
240 | 240 | $donor_data = new Give_Donor(); |
241 | - $donor_data->create( $donor_args ); |
|
241 | + $donor_data->create($donor_args); |
|
242 | 242 | |
243 | 243 | // Adding notes that donor is being imported from CSV. |
244 | 244 | $current_user = wp_get_current_user(); |
245 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
245 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
246 | 246 | |
247 | 247 | // Add is used to ensure duplicate emails are not added |
248 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
249 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
248 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
249 | + $donor_data->add_meta('additional_email', $data['email']); |
|
250 | 250 | } |
251 | 251 | |
252 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
252 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
253 | 253 | } else { |
254 | 254 | } |
255 | 255 | } else { |
256 | 256 | // Add is used to ensure duplicate emails are not added |
257 | - if ( $donor_data->email != $data['email'] ) { |
|
258 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
257 | + if ($donor_data->email != $data['email']) { |
|
258 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
259 | 259 | } |
260 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
260 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
264 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
265 | 265 | |
266 | - $donor_data = new Give_Donor( $data['email'] ); |
|
267 | - if ( empty( $donor_data->id ) ) { |
|
268 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
266 | + $donor_data = new Give_Donor($data['email']); |
|
267 | + if (empty($donor_data->id)) { |
|
268 | + $donor_data = get_user_by('email', $data['email']); |
|
269 | 269 | |
270 | - if ( empty( $donor_data->ID ) && ! empty( $data['first_name'] ) && ! empty( $data['last_name'] ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
271 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
270 | + if (empty($donor_data->ID) && ! empty($data['first_name']) && ! empty($data['last_name']) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
271 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
272 | 272 | $donor_args = array( |
273 | 273 | 'user_login' => $data['email'], |
274 | 274 | 'user_email' => $data['email'], |
275 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
275 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
276 | 276 | 'user_first' => $data['first_name'], |
277 | 277 | 'user_last' => $data['last_name'], |
278 | - 'user_pass' => wp_generate_password( 8, true ), |
|
278 | + 'user_pass' => wp_generate_password(8, true), |
|
279 | 279 | 'role' => $give_role, |
280 | 280 | ); |
281 | 281 | |
@@ -284,56 +284,56 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 1.8.13 |
286 | 286 | */ |
287 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
287 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
288 | 288 | |
289 | 289 | // This action was added to remove the login when using the give register function. |
290 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
291 | - $customer_id = give_register_and_login_new_user( $donor_args ); |
|
292 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
290 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
291 | + $customer_id = give_register_and_login_new_user($donor_args); |
|
292 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
293 | 293 | |
294 | - update_user_meta( $customer_id, '_give_payment_import', true ); |
|
295 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
294 | + update_user_meta($customer_id, '_give_payment_import', true); |
|
295 | + $donor_data = new Give_Donor($customer_id, true); |
|
296 | 296 | } else { |
297 | - $customer_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
297 | + $customer_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
298 | 298 | } |
299 | 299 | |
300 | - if ( ! empty( $customer_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
301 | - $donor_data = new Give_Donor( $customer_id, true ); |
|
300 | + if ( ! empty($customer_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
301 | + $donor_data = new Give_Donor($customer_id, true); |
|
302 | 302 | |
303 | - if ( empty( $donor_data->id ) ) { |
|
303 | + if (empty($donor_data->id)) { |
|
304 | 304 | |
305 | - if ( ! empty( $data['form_id'] ) ) { |
|
306 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
305 | + if ( ! empty($data['form_id'])) { |
|
306 | + $form = new Give_Donate_Form($data['form_id']); |
|
307 | 307 | } |
308 | 308 | |
309 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
309 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
310 | 310 | $donor_args = array( |
311 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
311 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
312 | 312 | 'email' => $data['email'], |
313 | 313 | ); |
314 | 314 | |
315 | - if ( ! empty( $customer_id ) ) { |
|
315 | + if ( ! empty($customer_id)) { |
|
316 | 316 | $donor_args['user_id'] = $customer_id; |
317 | 317 | } |
318 | 318 | |
319 | - $donor_data->create( $donor_args ); |
|
319 | + $donor_data->create($donor_args); |
|
320 | 320 | |
321 | 321 | // Adding notes that donor is being imported from CSV. |
322 | 322 | $current_user = wp_get_current_user(); |
323 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
323 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
324 | 324 | |
325 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
325 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
326 | 326 | } else { |
327 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
327 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } else { |
331 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
331 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | 335 | // update the report |
336 | - give_import_donation_report_update( $report ); |
|
336 | + give_import_donation_report_update($report); |
|
337 | 337 | |
338 | 338 | return $donor_data; |
339 | 339 | } |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return array |
353 | 353 | */ |
354 | - return (array) apply_filters( 'give_import_default_options', array( |
|
355 | - '' => __( 'Do not import', 'give' ), |
|
356 | - ) ); |
|
354 | + return (array) apply_filters('give_import_default_options', array( |
|
355 | + '' => __('Do not import', 'give'), |
|
356 | + )); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -369,33 +369,33 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return array |
371 | 371 | */ |
372 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
373 | - 'id' => __( 'Donation ID', 'give' ), |
|
374 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
375 | - 'post_date' => __( 'Donation Date', 'give' ), |
|
376 | - 'first_name' => __( 'Donor First Name', 'give' ), |
|
377 | - 'last_name' => __( 'Donor Last Name', 'give' ), |
|
378 | - 'line1' => __( 'Address 1', 'give' ), |
|
379 | - 'line2' => __( 'Address 2', 'give' ), |
|
380 | - 'city' => __( 'City', 'give' ), |
|
381 | - 'state' => __( 'State', 'give' ), |
|
372 | + return (array) apply_filters('give_import_donations_options', array( |
|
373 | + 'id' => __('Donation ID', 'give'), |
|
374 | + 'amount' => __('Donation Amount', 'give'), |
|
375 | + 'post_date' => __('Donation Date', 'give'), |
|
376 | + 'first_name' => __('Donor First Name', 'give'), |
|
377 | + 'last_name' => __('Donor Last Name', 'give'), |
|
378 | + 'line1' => __('Address 1', 'give'), |
|
379 | + 'line2' => __('Address 2', 'give'), |
|
380 | + 'city' => __('City', 'give'), |
|
381 | + 'state' => __('State', 'give'), |
|
382 | 382 | 'country' => array( |
383 | - __( 'Country', 'give' ), |
|
384 | - __( 'County', 'give' ), |
|
385 | - __( 'Region', 'give' ), |
|
386 | - __( 'Province', 'give' ), |
|
383 | + __('Country', 'give'), |
|
384 | + __('County', 'give'), |
|
385 | + __('Region', 'give'), |
|
386 | + __('Province', 'give'), |
|
387 | 387 | ), |
388 | 388 | 'zip' => array( |
389 | - __( 'Zip', 'give' ), |
|
390 | - __( 'Postal Code', 'give' ), |
|
389 | + __('Zip', 'give'), |
|
390 | + __('Postal Code', 'give'), |
|
391 | 391 | ), |
392 | - 'email' => __( 'Donor Email', 'give' ), |
|
393 | - 'post_status' => __( 'Donation Status', 'give' ), |
|
394 | - 'gateway' => __( 'Payment Method', 'give' ), |
|
395 | - 'notes' => __( 'Notes', 'give' ), |
|
396 | - 'mode' => __( 'Test Mode', 'give' ), |
|
397 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
398 | - ) ); |
|
392 | + 'email' => __('Donor Email', 'give'), |
|
393 | + 'post_status' => __('Donation Status', 'give'), |
|
394 | + 'gateway' => __('Payment Method', 'give'), |
|
395 | + 'notes' => __('Notes', 'give'), |
|
396 | + 'mode' => __('Test Mode', 'give'), |
|
397 | + 'post_meta' => __('Import as Meta', 'give'), |
|
398 | + )); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return array |
413 | 413 | */ |
414 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
415 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
416 | - 'user_id' => __( 'User ID', 'give' ), |
|
417 | - ) ); |
|
414 | + return (array) apply_filters('give_import_donor_options', array( |
|
415 | + 'donor_id' => __('Donor ID', 'give'), |
|
416 | + 'user_id' => __('User ID', 'give'), |
|
417 | + )); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return array |
432 | 432 | */ |
433 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
434 | - 'form_title' => __( 'Donation Form Title', 'give' ), |
|
435 | - 'form_id' => __( 'Donation Form ID', 'give' ), |
|
436 | - 'form_level' => __( 'Donation Level', 'give' ), |
|
437 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
438 | - ) ); |
|
433 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
434 | + 'form_title' => __('Donation Form Title', 'give'), |
|
435 | + 'form_id' => __('Donation Form ID', 'give'), |
|
436 | + 'form_level' => __('Donation Level', 'give'), |
|
437 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
438 | + )); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return array |
450 | 450 | */ |
451 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
451 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
452 | 452 | /** |
453 | 453 | * Filter to modify delimiter of Import. |
454 | 454 | * |
@@ -457,19 +457,19 @@ discard block |
||
457 | 457 | * |
458 | 458 | * Return string $delimiter. |
459 | 459 | */ |
460 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
460 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
461 | 461 | |
462 | 462 | $raw_data = array(); |
463 | - $file_dir = get_attached_file( $file_id ); |
|
463 | + $file_dir = get_attached_file($file_id); |
|
464 | 464 | $count = 0; |
465 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
466 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
467 | - if ( $count >= $start && $count <= $end ) { |
|
465 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
466 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
467 | + if ($count >= $start && $count <= $end) { |
|
468 | 468 | $raw_data[] = $row; |
469 | 469 | } |
470 | - $count ++; |
|
470 | + $count++; |
|
471 | 471 | } |
472 | - fclose( $handle ); |
|
472 | + fclose($handle); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $raw_data; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return bool |
487 | 487 | */ |
488 | -function give_log_user_in_on_register_callback( $value ) { |
|
488 | +function give_log_user_in_on_register_callback($value) { |
|
489 | 489 | return false; |
490 | 490 | } |
491 | 491 | |
@@ -501,22 +501,22 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @return bool |
503 | 503 | */ |
504 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
505 | - $data = array_combine( $raw_key, $row_data ); |
|
504 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
505 | + $data = array_combine($raw_key, $row_data); |
|
506 | 506 | $price_id = false; |
507 | 507 | $customer_id = 0; |
508 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
508 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
509 | 509 | |
510 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
510 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
511 | 511 | |
512 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
512 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
513 | 513 | |
514 | 514 | // Here come the login function. |
515 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
516 | - if ( ! empty( $donor_data->id ) ) { |
|
517 | - if ( ! empty( $donor_data->user_id ) ) { |
|
515 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
516 | + if ( ! empty($donor_data->id)) { |
|
517 | + if ( ! empty($donor_data->user_id)) { |
|
518 | 518 | $customer_id = $donor_data->user_id; |
519 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
519 | + } elseif ( ! empty($data['user_id'])) { |
|
520 | 520 | $customer_id = $data['user_id']; |
521 | 521 | } |
522 | 522 | } else { |
@@ -524,95 +524,95 @@ discard block |
||
524 | 524 | } |
525 | 525 | |
526 | 526 | // get form data or register a form data. |
527 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
528 | - if ( false == $form ) { |
|
527 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
528 | + if (false == $form) { |
|
529 | 529 | return false; |
530 | 530 | } else { |
531 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
531 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
535 | 535 | $address = array( |
536 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
537 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
538 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
539 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
540 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
541 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
536 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
537 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
538 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
539 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
540 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
541 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
542 | 542 | ); |
543 | 543 | |
544 | 544 | //Create payment_data array |
545 | 545 | $payment_data = array( |
546 | 546 | 'donor_id' => $donor_data->id, |
547 | 547 | 'price' => $data['amount'], |
548 | - 'status' => ( ! empty( $data['post_status'] ) ? $data['post_status'] : 'publish' ), |
|
548 | + 'status' => ( ! empty($data['post_status']) ? $data['post_status'] : 'publish'), |
|
549 | 549 | 'currency' => give_get_currency(), |
550 | 550 | 'user_info' => array( |
551 | 551 | 'id' => $customer_id, |
552 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
553 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $customer_id ) && ( $first_name = get_user_meta( $customer_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
554 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $customer_id ) && ( $last_name = get_user_meta( $customer_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
552 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
553 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($customer_id) && ($first_name = get_user_meta($customer_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
554 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($customer_id) && ($last_name = get_user_meta($customer_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
555 | 555 | 'address' => $address, |
556 | 556 | ), |
557 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
558 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
557 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
558 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
559 | 559 | 'give_form_id' => (string) $form->get_ID(), |
560 | 560 | 'give_price_id' => $price_id, |
561 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
561 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
562 | 562 | 'user_email' => $data['email'], |
563 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
564 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
563 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
564 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
565 | 565 | ); |
566 | 566 | |
567 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
567 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
568 | 568 | |
569 | 569 | // Get the report |
570 | 570 | $report = give_import_donation_report(); |
571 | 571 | |
572 | 572 | // Check for duplicate code. |
573 | - if ( true === give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) ) { |
|
574 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
573 | + if (true === give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data)) { |
|
574 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
575 | 575 | } else { |
576 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
577 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
578 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
579 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
580 | - $payment = give_insert_payment( $payment_data ); |
|
581 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
582 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
583 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
584 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
576 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
577 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
578 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
579 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
580 | + $payment = give_insert_payment($payment_data); |
|
581 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
582 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
583 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
584 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
585 | 585 | |
586 | - if ( $payment ) { |
|
586 | + if ($payment) { |
|
587 | 587 | |
588 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
588 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
589 | 589 | |
590 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
590 | + update_post_meta($payment, '_give_payment_import', true); |
|
591 | 591 | |
592 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
593 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
592 | + if ( ! empty($import_setting['csv'])) { |
|
593 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | // Insert Notes. |
597 | - if ( ! empty( $data['notes'] ) ) { |
|
598 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
597 | + if ( ! empty($data['notes'])) { |
|
598 | + give_insert_payment_note($payment, $data['notes']); |
|
599 | 599 | } |
600 | 600 | |
601 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
602 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
603 | - foreach ( $meta_exists as $meta_exist ) { |
|
604 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
605 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
601 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
602 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
603 | + foreach ($meta_exists as $meta_exist) { |
|
604 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
605 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | } |
609 | 609 | } else { |
610 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
610 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
614 | 614 | // update the report |
615 | - give_import_donation_report_update( $report ); |
|
615 | + give_import_donation_report_update($report); |
|
616 | 616 | |
617 | 617 | return true; |
618 | 618 | } |
@@ -628,12 +628,12 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @return Give_Donor |
630 | 630 | */ |
631 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
631 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
632 | 632 | $old_donor = $donor; |
633 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
634 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
635 | - $donor = new Give_Donor( $donor_id ); |
|
636 | - if ( ! empty( $donor->id ) ) { |
|
633 | + if ( ! empty($payment_data['donor_id'])) { |
|
634 | + $donor_id = absint($payment_data['donor_id']); |
|
635 | + $donor = new Give_Donor($donor_id); |
|
636 | + if ( ! empty($donor->id)) { |
|
637 | 637 | return $donor; |
638 | 638 | } |
639 | 639 | } |
@@ -646,12 +646,12 @@ discard block |
||
646 | 646 | * |
647 | 647 | * @since 1.8.13 |
648 | 648 | */ |
649 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
649 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
650 | 650 | // Update Give Customers purchase_count |
651 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
652 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
653 | - if ( ! empty( $donor_id ) ) { |
|
654 | - $donor = new Give_Donor( $donor_id ); |
|
651 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
652 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
653 | + if ( ! empty($donor_id)) { |
|
654 | + $donor = new Give_Donor($donor_id); |
|
655 | 655 | $donor->increase_purchase_count(); |
656 | 656 | } |
657 | 657 | } |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @since 1.8.13 |
664 | 664 | */ |
665 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
666 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
665 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
666 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
667 | 667 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
668 | 668 | } |
669 | 669 | |
@@ -675,11 +675,11 @@ discard block |
||
675 | 675 | * |
676 | 676 | * @since 1.8.13 |
677 | 677 | */ |
678 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
678 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
679 | 679 | $return = false; |
680 | - if ( ! empty( $data['post_date'] ) ) { |
|
681 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
682 | - $post_date = explode( '-', $post_date ); |
|
680 | + if ( ! empty($data['post_date'])) { |
|
681 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
682 | + $post_date = explode('-', $post_date); |
|
683 | 683 | $args = array( |
684 | 684 | 'post_type' => 'give_payment', |
685 | 685 | 'cache_results' => false, |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'meta_query' => array( |
701 | 701 | array( |
702 | 702 | 'key' => '_give_payment_total', |
703 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
703 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
704 | 704 | 'compare' => 'LIKE', |
705 | 705 | ), |
706 | 706 | array( |
@@ -717,9 +717,9 @@ discard block |
||
717 | 717 | ), |
718 | 718 | ); |
719 | 719 | |
720 | - $payments = new Give_Payments_Query( $args ); |
|
720 | + $payments = new Give_Payments_Query($args); |
|
721 | 721 | $donations = $payments->get_payments(); |
722 | - if ( ! empty( $donations ) ) { |
|
722 | + if ( ! empty($donations)) { |
|
723 | 723 | return true; |
724 | 724 | } |
725 | 725 | } |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return void |
738 | 738 | */ |
739 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
739 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
740 | 740 | $current_user = wp_get_current_user(); |
741 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
741 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @return string URL |
752 | 752 | */ |
753 | -function give_import_page_url( $parameter = array() ) { |
|
753 | +function give_import_page_url($parameter = array()) { |
|
754 | 754 | $defalut_query_arg = array( |
755 | 755 | 'post_type' => 'give_forms', |
756 | 756 | 'page' => 'give-tools', |
757 | 757 | 'tab' => 'import', |
758 | 758 | 'importer-type' => 'import_donations', |
759 | 759 | ); |
760 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
760 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
761 | 761 | |
762 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
762 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
763 | 763 | } |
764 | 764 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Advanced' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Advanced')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Advanced. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'advanced'; |
30 | - $this->label = __( 'Advanced', 'give' ); |
|
30 | + $this->label = __('Advanced', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'advanced-options'; |
33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $current_section = give_get_current_setting_section(); |
47 | 47 | |
48 | - switch ( $current_section ) { |
|
48 | + switch ($current_section) { |
|
49 | 49 | case 'advanced-options': |
50 | 50 | $settings = array( |
51 | 51 | array( |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | 'type' => 'title', |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => __( 'Remove Data on Uninstall', 'give' ), |
|
57 | - 'desc' => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
|
56 | + 'name' => __('Remove Data on Uninstall', 'give'), |
|
57 | + 'desc' => __('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'), |
|
58 | 58 | 'id' => 'uninstall_on_delete', |
59 | 59 | 'type' => 'radio_inline', |
60 | 60 | 'default' => 'disabled', |
61 | 61 | 'options' => array( |
62 | - 'enabled' => __( 'Yes, Remove all data', 'give' ), |
|
63 | - 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ), |
|
62 | + 'enabled' => __('Yes, Remove all data', 'give'), |
|
63 | + 'disabled' => __('No, keep my Give settings and donation data', 'give'), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'Default User Role', 'give' ), |
|
68 | - 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ), |
|
67 | + 'name' => __('Default User Role', 'give'), |
|
68 | + 'desc' => __('Assign default user roles for donors when donors opt to register as a WP User.', 'give'), |
|
69 | 69 | 'id' => 'donor_default_user_role', |
70 | 70 | 'type' => 'select', |
71 | 71 | 'default' => 'give_donor', |
@@ -73,44 +73,44 @@ discard block |
||
73 | 73 | ), |
74 | 74 | array( |
75 | 75 | /* translators: %s: the_content */ |
76 | - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
|
76 | + 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'), |
|
77 | 77 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
78 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
78 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
79 | 79 | 'id' => 'the_content_filter', |
80 | 80 | 'default' => 'enabled', |
81 | 81 | 'type' => 'radio_inline', |
82 | 82 | 'options' => array( |
83 | - 'enabled' => __( 'Enabled', 'give' ), |
|
84 | - 'disabled' => __( 'Disabled', 'give' ), |
|
83 | + 'enabled' => __('Enabled', 'give'), |
|
84 | + 'disabled' => __('Disabled', 'give'), |
|
85 | 85 | ), |
86 | 86 | ), |
87 | 87 | array( |
88 | - 'name' => __( 'Script Loading Location', 'give' ), |
|
89 | - 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
|
88 | + 'name' => __('Script Loading Location', 'give'), |
|
89 | + 'desc' => __('This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give'), |
|
90 | 90 | 'id' => 'scripts_footer', |
91 | 91 | 'type' => 'radio_inline', |
92 | 92 | 'default' => 'disabled', |
93 | 93 | 'options' => array( |
94 | - 'enabled' => __( 'Footer', 'give' ), |
|
95 | - 'disabled' => __( 'Head', 'give' ), |
|
94 | + 'enabled' => __('Footer', 'give'), |
|
95 | + 'disabled' => __('Head', 'give'), |
|
96 | 96 | ), |
97 | 97 | ), |
98 | 98 | array( |
99 | - 'name' => __( 'Akismet SPAM Protection', 'give' ), |
|
100 | - 'desc' => __( 'Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give' ), |
|
99 | + 'name' => __('Akismet SPAM Protection', 'give'), |
|
100 | + 'desc' => __('Add a layer of SPAM protection to your donation submissions with Akismet. When enabled, donation submissions will be first sent to Akismet\'s API if you have the plugin activated and configured.', 'give'), |
|
101 | 101 | 'id' => 'akismet_spam_protection', |
102 | 102 | 'type' => 'radio_inline', |
103 | - 'default' => ( give_check_akismet_key() ) ? 'enabled' : 'disabled', |
|
103 | + 'default' => (give_check_akismet_key()) ? 'enabled' : 'disabled', |
|
104 | 104 | 'options' => array( |
105 | - 'enabled' => __( 'Enabled', 'give' ), |
|
106 | - 'disabled' => __( 'Disabled', 'give' ), |
|
105 | + 'enabled' => __('Enabled', 'give'), |
|
106 | + 'disabled' => __('Disabled', 'give'), |
|
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | array( |
110 | - 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
110 | + 'name' => __('Advanced Settings Docs Link', 'give'), |
|
111 | 111 | 'id' => 'advanced_settings_docs_link', |
112 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
113 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
112 | + 'url' => esc_url('http://docs.givewp.com/settings-advanced'), |
|
113 | + 'title' => __('Advanced Settings', 'give'), |
|
114 | 114 | 'type' => 'give_docs_link', |
115 | 115 | ), |
116 | 116 | array( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * Filter the advanced settings. |
127 | 127 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
128 | 128 | */ |
129 | - $settings = apply_filters( 'give_settings_advanced', $settings ); |
|
129 | + $settings = apply_filters('give_settings_advanced', $settings); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Filter the settings. |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $settings |
137 | 137 | */ |
138 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
138 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
139 | 139 | |
140 | 140 | // Output. |
141 | 141 | return $settings; |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function get_sections() { |
151 | 151 | $sections = array( |
152 | - 'advanced-options' => __( 'Advanced Options', 'give' ), |
|
152 | + 'advanced-options' => __('Advanced Options', 'give'), |
|
153 | 153 | ); |
154 | 154 | |
155 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
155 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $font_style = ''; |
60 | 60 | |
61 | 61 | if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) && |
62 | - in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
62 | + in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
63 | 63 | TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
64 | 64 | $custom_font = 'CODE2000'; |
65 | 65 | $font_style = 'B'; |
@@ -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 | |
@@ -25,130 +25,130 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( ! file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php' ) ) { |
|
39 | - wp_die( __( 'Dependency missing.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
38 | + if ( ! file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php')) { |
|
39 | + wp_die(__('Dependency missing.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
40 | 40 | } |
41 | 41 | |
42 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/give-pdf.php'; |
|
42 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/give-pdf.php'; |
|
43 | 43 | |
44 | 44 | $daterange = utf8_decode( |
45 | 45 | sprintf( |
46 | 46 | /* translators: 1: start date 2: end date */ |
47 | - __( '%1$s to %2$s', 'give' ), |
|
48 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
49 | - date_i18n( give_date_format() ) |
|
47 | + __('%1$s to %2$s', 'give'), |
|
48 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
49 | + date_i18n(give_date_format()) |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
54 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
53 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
54 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
55 | 55 | |
56 | - $pdf = new Give_PDF( 'L', 'mm', 'A', true, 'UTF-8', false ); |
|
57 | - $default_font = apply_filters( 'give_pdf_default_font', 'Helvetica' ); |
|
56 | + $pdf = new Give_PDF('L', 'mm', 'A', true, 'UTF-8', false); |
|
57 | + $default_font = apply_filters('give_pdf_default_font', 'Helvetica'); |
|
58 | 58 | $custom_font = 'dejavusans'; |
59 | 59 | $font_style = ''; |
60 | 60 | |
61 | - if ( file_exists( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF' ) && |
|
62 | - in_array( give_get_currency(), array( 'RIAL', 'RUB' ) ) ) { |
|
63 | - TCPDF_FONTS::addTTFfont( GIVE_PLUGIN_DIR . '/includes/libraries/tcpdf/fonts/CODE2000.TTF', '' ); |
|
61 | + if (file_exists(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF') && |
|
62 | + in_array(give_get_currency(), array('RIAL', 'RUB'))) { |
|
63 | + TCPDF_FONTS::addTTFfont(GIVE_PLUGIN_DIR.'/includes/libraries/tcpdf/fonts/CODE2000.TTF', ''); |
|
64 | 64 | $custom_font = 'CODE2000'; |
65 | 65 | $font_style = 'B'; |
66 | 66 | } |
67 | 67 | |
68 | - $pdf->AddPage( 'L', 'A4' ); |
|
69 | - $pdf->setImageScale( 1.5 ); |
|
70 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
71 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
72 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
68 | + $pdf->AddPage('L', 'A4'); |
|
69 | + $pdf->setImageScale(1.5); |
|
70 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
71 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
72 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
73 | 73 | |
74 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
74 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
75 | 75 | |
76 | - $pdf->SetMargins( 8, 8, 8 ); |
|
77 | - $pdf->SetX( 8 ); |
|
76 | + $pdf->SetMargins(8, 8, 8); |
|
77 | + $pdf->SetX(8); |
|
78 | 78 | |
79 | - $pdf->SetFont( $default_font, '', 16 ); |
|
80 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
81 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
79 | + $pdf->SetFont($default_font, '', 16); |
|
80 | + $pdf->SetTextColor(50, 50, 50); |
|
81 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
82 | 82 | |
83 | - $pdf->SetFont( $default_font, '', 13 ); |
|
84 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
85 | - $pdf->Ln( 1 ); |
|
86 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
83 | + $pdf->SetFont($default_font, '', 13); |
|
84 | + $pdf->SetTextColor(150, 150, 150); |
|
85 | + $pdf->Ln(1); |
|
86 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
87 | 87 | $pdf->Ln(); |
88 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
89 | - $pdf->SetFont( $default_font, '', 14 ); |
|
90 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
91 | - $pdf->SetFont( $default_font, '', 12 ); |
|
88 | + $pdf->SetTextColor(50, 50, 50); |
|
89 | + $pdf->SetFont($default_font, '', 14); |
|
90 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
91 | + $pdf->SetFont($default_font, '', 12); |
|
92 | 92 | |
93 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
94 | - $pdf->SetTextColor( 0, 0, 0, 100 ); // Set Black color. |
|
95 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
96 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
93 | + $pdf->SetFillColor(238, 238, 238); |
|
94 | + $pdf->SetTextColor(0, 0, 0, 100); // Set Black color. |
|
95 | + $pdf->Cell(50, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
96 | + $pdf->Cell(50, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
97 | 97 | |
98 | 98 | // Display Categories Heading only, if user has opted for it. |
99 | - if ( $categories_enabled ) { |
|
100 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
99 | + if ($categories_enabled) { |
|
100 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Display Tags Heading only, if user has opted for it. |
104 | - if ( $tags_enabled ) { |
|
105 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
104 | + if ($tags_enabled) { |
|
105 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
106 | 106 | } |
107 | 107 | |
108 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
109 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
108 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
109 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
110 | 110 | |
111 | 111 | // Set Custom Font to support various currencies. |
112 | - $pdf->SetFont( apply_filters( 'give_pdf_custom_font', $custom_font ), $font_style, 12 ); |
|
112 | + $pdf->SetFont(apply_filters('give_pdf_custom_font', $custom_font), $font_style, 12); |
|
113 | 113 | |
114 | - $year = date( 'Y' ); |
|
115 | - $give_forms = get_posts( array( |
|
114 | + $year = date('Y'); |
|
115 | + $give_forms = get_posts(array( |
|
116 | 116 | 'post_type' => 'give_forms', |
117 | 117 | 'year' => $year, |
118 | - 'posts_per_page' => - 1, |
|
118 | + 'posts_per_page' => -1, |
|
119 | 119 | 'supply_filter' => false, |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - if ( $give_forms ) { |
|
123 | - $pdf->SetWidths( array( 50, 50, 45, 45, 45, 45 ) ); |
|
122 | + if ($give_forms) { |
|
123 | + $pdf->SetWidths(array(50, 50, 45, 45, 45, 45)); |
|
124 | 124 | |
125 | - foreach ( $give_forms as $form ): |
|
126 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
125 | + foreach ($give_forms as $form): |
|
126 | + $pdf->SetFillColor(255, 255, 255); |
|
127 | 127 | |
128 | 128 | $title = $form->post_title; |
129 | 129 | |
130 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
131 | - $price = html_entity_decode( give_price_range( $form->ID, false ) ); |
|
130 | + if (give_has_variable_prices($form->ID)) { |
|
131 | + $price = html_entity_decode(give_price_range($form->ID, false)); |
|
132 | 132 | } else { |
133 | - $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
|
133 | + $price = give_currency_filter(give_get_form_price($form->ID), '', true); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Display Categories Data only, if user has opted for it. |
137 | 137 | $categories = array(); |
138 | - if ( $categories_enabled ) { |
|
139 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
140 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
138 | + if ($categories_enabled) { |
|
139 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
140 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // Display Tags Data only, if user has opted for it. |
144 | 144 | $tags = array(); |
145 | - if ( $tags_enabled ) { |
|
146 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
147 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
145 | + if ($tags_enabled) { |
|
146 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
147 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
148 | 148 | } |
149 | 149 | |
150 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
151 | - $earnings = give_currency_filter( give_format_amount( give_get_form_earnings_stats( $form->ID ), array( 'sanitize' => false, ) ), '', true ); |
|
150 | + $sales = give_get_form_sales_stats($form->ID); |
|
151 | + $earnings = give_currency_filter(give_format_amount(give_get_form_earnings_stats($form->ID), array('sanitize' => false,)), '', true); |
|
152 | 152 | |
153 | 153 | // This will help filter data before appending it to PDF Receipt. |
154 | 154 | $prepare_pdf_data = array(); |
@@ -156,53 +156,53 @@ discard block |
||
156 | 156 | $prepare_pdf_data[] = $price; |
157 | 157 | |
158 | 158 | // Append Categories Data only, if user has opted for it. |
159 | - if ( $categories_enabled ) { |
|
159 | + if ($categories_enabled) { |
|
160 | 160 | $prepare_pdf_data[] = $categories; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Append Tags Data only, if user has opted for it. |
164 | - if ( $tags_enabled ) { |
|
164 | + if ($tags_enabled) { |
|
165 | 165 | $prepare_pdf_data[] = $tags; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $prepare_pdf_data[] = $sales; |
169 | 169 | $prepare_pdf_data[] = $earnings; |
170 | 170 | |
171 | - $pdf->Row( $prepare_pdf_data ); |
|
171 | + $pdf->Row($prepare_pdf_data); |
|
172 | 172 | |
173 | 173 | endforeach; |
174 | 174 | } else { |
175 | 175 | |
176 | 176 | // Fix: Minor Styling Alignment Issue for PDF. |
177 | - if ( $categories_enabled && $tags_enabled ) { |
|
177 | + if ($categories_enabled && $tags_enabled) { |
|
178 | 178 | $no_found_width = 280; |
179 | - } elseif ( $categories_enabled || $tags_enabled ) { |
|
179 | + } elseif ($categories_enabled || $tags_enabled) { |
|
180 | 180 | $no_found_width = 235; |
181 | 181 | } else { |
182 | 182 | $no_found_width = 190; |
183 | 183 | } |
184 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
185 | - $pdf->MultiCell( $no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false ); |
|
184 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
185 | + $pdf->MultiCell($no_found_width, 5, $title, 1, 'C', false, 1, '', '', true, 0, false, true, 0, 'T', false); |
|
186 | 186 | }// End if(). |
187 | 187 | $pdf->Ln(); |
188 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
189 | - $pdf->SetFont( $default_font, '', 14 ); |
|
188 | + $pdf->SetTextColor(50, 50, 50); |
|
189 | + $pdf->SetFont($default_font, '', 14); |
|
190 | 190 | |
191 | 191 | // Output Graph on a new page. |
192 | - $pdf->AddPage( 'L', 'A4' ); |
|
193 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
194 | - $pdf->SetFont( $default_font, '', 12 ); |
|
192 | + $pdf->AddPage('L', 'A4'); |
|
193 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
194 | + $pdf->SetFont($default_font, '', 12); |
|
195 | 195 | |
196 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
197 | - $image = str_replace( ' ', '%20', $image ); |
|
196 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
197 | + $image = str_replace(' ', '%20', $image); |
|
198 | 198 | |
199 | - $pdf->SetX( 25 ); |
|
200 | - $pdf->Image( $image . '&file=.png' ); |
|
201 | - $pdf->Ln( 7 ); |
|
202 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
199 | + $pdf->SetX(25); |
|
200 | + $pdf->Image($image.'&file=.png'); |
|
201 | + $pdf->Ln(7); |
|
202 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
203 | 203 | } |
204 | 204 | |
205 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
205 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Draws Chart for PDF Report. |
@@ -219,38 +219,38 @@ discard block |
||
219 | 219 | * @return string $chart->getUrl() URL for the Google Chart |
220 | 220 | */ |
221 | 221 | function give_draw_chart_image() { |
222 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
223 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
224 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
222 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
223 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
224 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
225 | 225 | |
226 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
226 | + $chart = new GoogleChart('lc', 900, 330); |
|
227 | 227 | |
228 | 228 | $i = 1; |
229 | 229 | $earnings = ""; |
230 | 230 | $sales = ""; |
231 | 231 | |
232 | - while ( $i <= 12 ) : |
|
233 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
234 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
235 | - $i ++; |
|
232 | + while ($i <= 12) : |
|
233 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
234 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
235 | + $i++; |
|
236 | 236 | endwhile; |
237 | 237 | |
238 | - $earnings_array = explode( ",", $earnings ); |
|
239 | - $sales_array = explode( ",", $sales ); |
|
238 | + $earnings_array = explode(",", $earnings); |
|
239 | + $sales_array = explode(",", $sales); |
|
240 | 240 | |
241 | 241 | $i = 0; |
242 | - while ( $i <= 11 ) { |
|
243 | - if ( empty( $sales_array[ $i ] ) ) { |
|
244 | - $sales_array[ $i ] = 0; |
|
242 | + while ($i <= 11) { |
|
243 | + if (empty($sales_array[$i])) { |
|
244 | + $sales_array[$i] = 0; |
|
245 | 245 | } |
246 | - $i ++; |
|
246 | + $i++; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $min_earnings = 0; |
250 | - $max_earnings = max( $earnings_array ); |
|
251 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
250 | + $max_earnings = max($earnings_array); |
|
251 | + $earnings_scale = round($max_earnings, - 1); |
|
252 | 252 | |
253 | - $data = new GoogleChartData( array( |
|
253 | + $data = new GoogleChartData(array( |
|
254 | 254 | $earnings_array[0], |
255 | 255 | $earnings_array[1], |
256 | 256 | $earnings_array[2], |
@@ -263,25 +263,25 @@ discard block |
||
263 | 263 | $earnings_array[9], |
264 | 264 | $earnings_array[10], |
265 | 265 | $earnings_array[11], |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | |
268 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
269 | - $data->setColor( '1b58a3' ); |
|
270 | - $chart->addData( $data ); |
|
268 | + $data->setLegend(__('Income', 'give')); |
|
269 | + $data->setColor('1b58a3'); |
|
270 | + $chart->addData($data); |
|
271 | 271 | |
272 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
273 | - $shape_marker->setColor( '000000' ); |
|
274 | - $shape_marker->setSize( 7 ); |
|
275 | - $shape_marker->setBorder( 2 ); |
|
276 | - $shape_marker->setData( $data ); |
|
277 | - $chart->addMarker( $shape_marker ); |
|
272 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
273 | + $shape_marker->setColor('000000'); |
|
274 | + $shape_marker->setSize(7); |
|
275 | + $shape_marker->setBorder(2); |
|
276 | + $shape_marker->setData($data); |
|
277 | + $chart->addMarker($shape_marker); |
|
278 | 278 | |
279 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
280 | - $value_marker->setColor( '000000' ); |
|
281 | - $value_marker->setData( $data ); |
|
282 | - $chart->addMarker( $value_marker ); |
|
279 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
280 | + $value_marker->setColor('000000'); |
|
281 | + $value_marker->setData($data); |
|
282 | + $chart->addMarker($value_marker); |
|
283 | 283 | |
284 | - $data = new GoogleChartData( array( |
|
284 | + $data = new GoogleChartData(array( |
|
285 | 285 | $sales_array[0], |
286 | 286 | $sales_array[1], |
287 | 287 | $sales_array[2], |
@@ -294,46 +294,46 @@ discard block |
||
294 | 294 | $sales_array[9], |
295 | 295 | $sales_array[10], |
296 | 296 | $sales_array[11], |
297 | - ) ); |
|
298 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
299 | - $data->setColor( 'ff6c1c' ); |
|
300 | - $chart->addData( $data ); |
|
301 | - |
|
302 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
303 | - |
|
304 | - $chart->setScale( 0, $max_earnings ); |
|
305 | - |
|
306 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
307 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
308 | - $chart->addAxis( $y_axis ); |
|
309 | - |
|
310 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
311 | - $x_axis->setTickMarks( 5 ); |
|
312 | - $x_axis->setLabels( array( |
|
313 | - __( 'Jan', 'give' ), |
|
314 | - __( 'Feb', 'give' ), |
|
315 | - __( 'Mar', 'give' ), |
|
316 | - __( 'Apr', 'give' ), |
|
317 | - __( 'May', 'give' ), |
|
318 | - __( 'June', 'give' ), |
|
319 | - __( 'July', 'give' ), |
|
320 | - __( 'Aug', 'give' ), |
|
321 | - __( 'Sept', 'give' ), |
|
322 | - __( 'Oct', 'give' ), |
|
323 | - __( 'Nov', 'give' ), |
|
324 | - __( 'Dec', 'give' ), |
|
325 | - ) ); |
|
326 | - $chart->addAxis( $x_axis ); |
|
327 | - |
|
328 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
329 | - $shape_marker->setSize( 6 ); |
|
330 | - $shape_marker->setBorder( 2 ); |
|
331 | - $shape_marker->setData( $data ); |
|
332 | - $chart->addMarker( $shape_marker ); |
|
333 | - |
|
334 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
335 | - $value_marker->setData( $data ); |
|
336 | - $chart->addMarker( $value_marker ); |
|
297 | + )); |
|
298 | + $data->setLegend(__('Donations', 'give')); |
|
299 | + $data->setColor('ff6c1c'); |
|
300 | + $chart->addData($data); |
|
301 | + |
|
302 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
303 | + |
|
304 | + $chart->setScale(0, $max_earnings); |
|
305 | + |
|
306 | + $y_axis = new GoogleChartAxis('y'); |
|
307 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
308 | + $chart->addAxis($y_axis); |
|
309 | + |
|
310 | + $x_axis = new GoogleChartAxis('x'); |
|
311 | + $x_axis->setTickMarks(5); |
|
312 | + $x_axis->setLabels(array( |
|
313 | + __('Jan', 'give'), |
|
314 | + __('Feb', 'give'), |
|
315 | + __('Mar', 'give'), |
|
316 | + __('Apr', 'give'), |
|
317 | + __('May', 'give'), |
|
318 | + __('June', 'give'), |
|
319 | + __('July', 'give'), |
|
320 | + __('Aug', 'give'), |
|
321 | + __('Sept', 'give'), |
|
322 | + __('Oct', 'give'), |
|
323 | + __('Nov', 'give'), |
|
324 | + __('Dec', 'give'), |
|
325 | + )); |
|
326 | + $chart->addAxis($x_axis); |
|
327 | + |
|
328 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
329 | + $shape_marker->setSize(6); |
|
330 | + $shape_marker->setBorder(2); |
|
331 | + $shape_marker->setData($data); |
|
332 | + $chart->addMarker($shape_marker); |
|
333 | + |
|
334 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
335 | + $value_marker->setData($data); |
|
336 | + $chart->addMarker($value_marker); |
|
337 | 337 | |
338 | 338 | return $chart->getUrl(); |
339 | 339 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @todo Remove this, when WordPress Core ticket is resolved (https://core.trac.wordpress.org/ticket/16828). |
1159 | 1159 | * |
1160 | - * @return bool |
|
1160 | + * @return false|null |
|
1161 | 1161 | */ |
1162 | 1162 | function give_donation_metabox_menu() { |
1163 | 1163 | |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | * @param int $id |
1541 | 1541 | * @param string $meta_key |
1542 | 1542 | * @param mixed $meta_value |
1543 | - * @param mixed $prev_value |
|
1543 | + * @param string $prev_value |
|
1544 | 1544 | * |
1545 | 1545 | * @return mixed |
1546 | 1546 | */ |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | * @since 1.8.13 |
1748 | 1748 | * |
1749 | 1749 | * @param array $list List of objects or arrays |
1750 | - * @param int|string $field Field from the object to place instead of the entire object |
|
1750 | + * @param string $field Field from the object to place instead of the entire object |
|
1751 | 1751 | * @param int|string $index_key Optional. Field from the object to use as keys for the new array. |
1752 | 1752 | * Default null. |
1753 | 1753 | * |
@@ -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,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return string The currency code |
42 | 42 | */ |
43 | -function give_get_currency( $donation_or_form_id = null, $args = array() ) { |
|
43 | +function give_get_currency($donation_or_form_id = null, $args = array()) { |
|
44 | 44 | |
45 | 45 | // Get currency from donation |
46 | - if ( is_numeric( $donation_or_form_id ) && 'give_payment' === get_post_type( $donation_or_form_id ) ) { |
|
47 | - $donation_meta = give_get_meta( $donation_or_form_id, '_give_payment_meta', true ); |
|
46 | + if (is_numeric($donation_or_form_id) && 'give_payment' === get_post_type($donation_or_form_id)) { |
|
47 | + $donation_meta = give_get_meta($donation_or_form_id, '_give_payment_meta', true); |
|
48 | 48 | |
49 | - if ( ! empty( $donation_meta['currency'] ) ) { |
|
49 | + if ( ! empty($donation_meta['currency'])) { |
|
50 | 50 | $currency = $donation_meta['currency']; |
51 | 51 | } else { |
52 | - $currency = give_get_option( 'currency', 'USD' ); |
|
52 | + $currency = give_get_option('currency', 'USD'); |
|
53 | 53 | } |
54 | 54 | } else { |
55 | - $currency = give_get_option( 'currency', 'USD' ); |
|
55 | + $currency = give_get_option('currency', 'USD'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.0 |
62 | 62 | */ |
63 | - return apply_filters( 'give_currency', $currency, $donation_or_form_id, $args ); |
|
63 | + return apply_filters('give_currency', $currency, $donation_or_form_id, $args); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function give_get_currency_position() { |
74 | 74 | |
75 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
75 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
76 | 76 | |
77 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
77 | + return apply_filters('give_currency_position', $currency_pos); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return array $currencies A list of the available currencies |
89 | 89 | */ |
90 | -function give_get_currencies( $info = 'admin_label' ) { |
|
90 | +function give_get_currencies($info = 'admin_label') { |
|
91 | 91 | $currencies = array( |
92 | 92 | 'USD' => array( |
93 | - 'admin_label' => __( 'US Dollars ($)', 'give' ), |
|
93 | + 'admin_label' => __('US Dollars ($)', 'give'), |
|
94 | 94 | 'symbol' => '$', |
95 | 95 | 'setting' => array( |
96 | 96 | 'currency_position' => 'before', |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ), |
101 | 101 | ), |
102 | 102 | 'EUR' => array( |
103 | - 'admin_label' => __( 'Euros (€)', 'give' ), |
|
103 | + 'admin_label' => __('Euros (€)', 'give'), |
|
104 | 104 | 'symbol' => '€', |
105 | 105 | 'setting' => array( |
106 | 106 | 'currency_position' => 'before', |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ), |
111 | 111 | ), |
112 | 112 | 'GBP' => array( |
113 | - 'admin_label' => __( 'Pounds Sterling (£)', 'give' ), |
|
113 | + 'admin_label' => __('Pounds Sterling (£)', 'give'), |
|
114 | 114 | 'symbol' => '£', |
115 | 115 | 'setting' => array( |
116 | 116 | 'currency_position' => 'before', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ), |
121 | 121 | ), |
122 | 122 | 'AUD' => array( |
123 | - 'admin_label' => __( 'Australian Dollars ($)', 'give' ), |
|
123 | + 'admin_label' => __('Australian Dollars ($)', 'give'), |
|
124 | 124 | 'symbol' => '$', |
125 | 125 | 'setting' => array( |
126 | 126 | 'currency_position' => 'before', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ), |
131 | 131 | ), |
132 | 132 | 'BRL' => array( |
133 | - 'admin_label' => __( 'Brazilian Real (R$)', 'give' ), |
|
133 | + 'admin_label' => __('Brazilian Real (R$)', 'give'), |
|
134 | 134 | 'symbol' => 'R$', |
135 | 135 | 'setting' => array( |
136 | 136 | 'currency_position' => 'before', |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ), |
141 | 141 | ), |
142 | 142 | 'CAD' => array( |
143 | - 'admin_label' => __( 'Canadian Dollars ($)', 'give' ), |
|
143 | + 'admin_label' => __('Canadian Dollars ($)', 'give'), |
|
144 | 144 | 'symbol' => '$', |
145 | 145 | 'setting' => array( |
146 | 146 | 'currency_position' => 'before', |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ), |
151 | 151 | ), |
152 | 152 | 'CZK' => array( |
153 | - 'admin_label' => __( 'Czech Koruna (Kč)', 'give' ), |
|
153 | + 'admin_label' => __('Czech Koruna (Kč)', 'give'), |
|
154 | 154 | 'symbol' => 'Kč', |
155 | 155 | 'setting' => array( |
156 | 156 | 'currency_position' => 'before', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ), |
161 | 161 | ), |
162 | 162 | 'DKK' => array( |
163 | - 'admin_label' => __( 'Danish Krone (kr.)', 'give' ), |
|
163 | + 'admin_label' => __('Danish Krone (kr.)', 'give'), |
|
164 | 164 | 'symbol' => ' kr. ', |
165 | 165 | 'setting' => array( |
166 | 166 | 'currency_position' => 'before', |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | ), |
171 | 171 | ), |
172 | 172 | 'HKD' => array( |
173 | - 'admin_label' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
173 | + 'admin_label' => __('Hong Kong Dollar ($)', 'give'), |
|
174 | 174 | 'symbol' => '$', |
175 | 175 | 'setting' => array( |
176 | 176 | 'currency_position' => 'before', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ), |
181 | 181 | ), |
182 | 182 | 'HUF' => array( |
183 | - 'admin_label' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
183 | + 'admin_label' => __('Hungarian Forint (Ft)', 'give'), |
|
184 | 184 | 'symbol' => 'Ft', |
185 | 185 | 'setting' => array( |
186 | 186 | 'currency_position' => 'before', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ), |
191 | 191 | ), |
192 | 192 | 'ILS' => array( |
193 | - 'admin_label' => __( 'Israeli Shekel (₪)', 'give' ), |
|
193 | + 'admin_label' => __('Israeli Shekel (₪)', 'give'), |
|
194 | 194 | 'symbol' => '₪', |
195 | 195 | 'setting' => array( |
196 | 196 | 'currency_position' => 'before', |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ), |
201 | 201 | ), |
202 | 202 | 'JPY' => array( |
203 | - 'admin_label' => __( 'Japanese Yen (¥)', 'give' ), |
|
203 | + 'admin_label' => __('Japanese Yen (¥)', 'give'), |
|
204 | 204 | 'symbol' => '¥', |
205 | 205 | 'setting' => array( |
206 | 206 | 'currency_position' => 'before', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ), |
211 | 211 | ), |
212 | 212 | 'MYR' => array( |
213 | - 'admin_label' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
213 | + 'admin_label' => __('Malaysian Ringgits (RM)', 'give'), |
|
214 | 214 | 'symbol' => 'RM', |
215 | 215 | 'setting' => array( |
216 | 216 | 'currency_position' => 'before', |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ), |
221 | 221 | ), |
222 | 222 | 'MXN' => array( |
223 | - 'admin_label' => __( 'Mexican Peso ($)', 'give' ), |
|
223 | + 'admin_label' => __('Mexican Peso ($)', 'give'), |
|
224 | 224 | 'symbol' => '$', |
225 | 225 | 'setting' => array( |
226 | 226 | 'currency_position' => 'before', |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ), |
231 | 231 | ), |
232 | 232 | 'MAD' => array( |
233 | - 'admin_label' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
233 | + 'admin_label' => __('Moroccan Dirham (.د.م)', 'give'), |
|
234 | 234 | 'symbol' => '.د.م', |
235 | 235 | 'setting' => array( |
236 | 236 | 'currency_position' => 'before', |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ), |
241 | 241 | ), |
242 | 242 | 'NZD' => array( |
243 | - 'admin_label' => __( 'New Zealand Dollar ($)', 'give' ), |
|
243 | + 'admin_label' => __('New Zealand Dollar ($)', 'give'), |
|
244 | 244 | 'symbol' => '$', |
245 | 245 | 'setting' => array( |
246 | 246 | 'currency_position' => 'before', |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | ), |
251 | 251 | ), |
252 | 252 | 'NOK' => array( |
253 | - 'admin_label' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
253 | + 'admin_label' => __('Norwegian Krone (Kr.)', 'give'), |
|
254 | 254 | 'symbol' => 'kr.', |
255 | 255 | 'setting' => array( |
256 | 256 | 'currency_position' => 'before', |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | ), |
261 | 261 | ), |
262 | 262 | 'PHP' => array( |
263 | - 'admin_label' => __( 'Philippine Pesos (₱)', 'give' ), |
|
263 | + 'admin_label' => __('Philippine Pesos (₱)', 'give'), |
|
264 | 264 | 'symbol' => '₱', |
265 | 265 | 'setting' => array( |
266 | 266 | 'currency_position' => 'before', |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | ), |
271 | 271 | ), |
272 | 272 | 'PLN' => array( |
273 | - 'admin_label' => __( 'Polish Zloty (zł)', 'give' ), |
|
273 | + 'admin_label' => __('Polish Zloty (zł)', 'give'), |
|
274 | 274 | 'symbol' => 'zł', |
275 | 275 | 'setting' => array( |
276 | 276 | 'currency_position' => 'before', |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ), |
281 | 281 | ), |
282 | 282 | 'SGD' => array( |
283 | - 'admin_label' => __( 'Singapore Dollar ($)', 'give' ), |
|
283 | + 'admin_label' => __('Singapore Dollar ($)', 'give'), |
|
284 | 284 | 'symbol' => '$', |
285 | 285 | 'setting' => array( |
286 | 286 | 'currency_position' => 'before', |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | ), |
291 | 291 | ), |
292 | 292 | 'KRW' => array( |
293 | - 'admin_label' => __( 'South Korean Won (₩)', 'give' ), |
|
293 | + 'admin_label' => __('South Korean Won (₩)', 'give'), |
|
294 | 294 | 'symbol' => '₩', |
295 | 295 | 'setting' => array( |
296 | 296 | 'currency_position' => 'before', |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ), |
301 | 301 | ), |
302 | 302 | 'ZAR' => array( |
303 | - 'admin_label' => __( 'South African Rand (R)', 'give' ), |
|
303 | + 'admin_label' => __('South African Rand (R)', 'give'), |
|
304 | 304 | 'symbol' => 'R', |
305 | 305 | 'setting' => array( |
306 | 306 | 'currency_position' => 'before', |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | ), |
311 | 311 | ), |
312 | 312 | 'SEK' => array( |
313 | - 'admin_label' => __( 'Swedish Krona (kr)', 'give' ), |
|
313 | + 'admin_label' => __('Swedish Krona (kr)', 'give'), |
|
314 | 314 | 'symbol' => ' kr. ', |
315 | 315 | 'setting' => array( |
316 | 316 | 'currency_position' => 'before', |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ), |
321 | 321 | ), |
322 | 322 | 'CHF' => array( |
323 | - 'admin_label' => __( 'Swiss Franc (CHF)', 'give' ), |
|
323 | + 'admin_label' => __('Swiss Franc (CHF)', 'give'), |
|
324 | 324 | 'symbol' => 'CHF', |
325 | 325 | 'setting' => array( |
326 | 326 | 'currency_position' => 'before', |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | ), |
331 | 331 | ), |
332 | 332 | 'TWD' => array( |
333 | - 'admin_label' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
333 | + 'admin_label' => __('Taiwan New Dollars (NT$)', 'give'), |
|
334 | 334 | 'symbol' => 'NT$', |
335 | 335 | 'setting' => array( |
336 | 336 | 'currency_position' => 'before', |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | ), |
341 | 341 | ), |
342 | 342 | 'THB' => array( |
343 | - 'admin_label' => __( 'Thai Baht (฿)', 'give' ), |
|
343 | + 'admin_label' => __('Thai Baht (฿)', 'give'), |
|
344 | 344 | 'symbol' => '฿', |
345 | 345 | 'setting' => array( |
346 | 346 | 'currency_position' => 'before', |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | ), |
351 | 351 | ), |
352 | 352 | 'INR' => array( |
353 | - 'admin_label' => __( 'Indian Rupee (₹)', 'give' ), |
|
353 | + 'admin_label' => __('Indian Rupee (₹)', 'give'), |
|
354 | 354 | 'symbol' => '₹', |
355 | 355 | 'setting' => array( |
356 | 356 | 'currency_position' => 'before', |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | ), |
361 | 361 | ), |
362 | 362 | 'TRY' => array( |
363 | - 'admin_label' => __( 'Turkish Lira (₺)', 'give' ), |
|
363 | + 'admin_label' => __('Turkish Lira (₺)', 'give'), |
|
364 | 364 | 'symbol' => '₺', |
365 | 365 | 'setting' => array( |
366 | 366 | 'currency_position' => 'before', |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | ), |
371 | 371 | ), |
372 | 372 | 'RIAL' => array( |
373 | - 'admin_label' => __( 'Iranian Rial (﷼)', 'give' ), |
|
373 | + 'admin_label' => __('Iranian Rial (﷼)', 'give'), |
|
374 | 374 | 'symbol' => '﷼', |
375 | 375 | 'setting' => array( |
376 | 376 | 'currency_position' => 'after', |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ), |
381 | 381 | ), |
382 | 382 | 'RUB' => array( |
383 | - 'admin_label' => __( 'Russian Rubles (руб)', 'give' ), |
|
383 | + 'admin_label' => __('Russian Rubles (руб)', 'give'), |
|
384 | 384 | 'symbol' => '₽', |
385 | 385 | 'setting' => array( |
386 | 386 | 'currency_position' => 'before', |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @param array $currencies |
408 | 408 | */ |
409 | - $currencies = apply_filters( 'give_currencies', $currencies ); |
|
409 | + $currencies = apply_filters('give_currencies', $currencies); |
|
410 | 410 | |
411 | 411 | // Backward compatibility: handle old way of currency registration. |
412 | 412 | // Backward compatibility: Return desired result. |
413 | - if ( ! empty( $currencies ) ) { |
|
414 | - foreach ( $currencies as $currency_code => $currency_setting ) { |
|
415 | - if ( is_string( $currency_setting ) ) { |
|
416 | - $currencies[ $currency_code ] = array( |
|
413 | + if ( ! empty($currencies)) { |
|
414 | + foreach ($currencies as $currency_code => $currency_setting) { |
|
415 | + if (is_string($currency_setting)) { |
|
416 | + $currencies[$currency_code] = array( |
|
417 | 417 | 'admin_label' => $currency_setting, |
418 | 418 | 'symbol' => '', |
419 | 419 | 'setting' => array(), |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if ( ! empty( $info ) && is_string( $info ) && 'all' !== $info ) { |
|
425 | - $currencies = wp_list_pluck( $currencies, $info ); |
|
424 | + if ( ! empty($info) && is_string($info) && 'all' !== $info) { |
|
425 | + $currencies = wp_list_pluck($currencies, $info); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return array |
441 | 441 | */ |
442 | -function give_currency_symbols( $decode_currencies = false ) { |
|
443 | - $currencies = give_get_currencies('symbol' ); |
|
442 | +function give_currency_symbols($decode_currencies = false) { |
|
443 | + $currencies = give_get_currencies('symbol'); |
|
444 | 444 | |
445 | - if ( $decode_currencies ) { |
|
446 | - $currencies = array_map( 'html_entity_decode', $currencies ); |
|
445 | + if ($decode_currencies) { |
|
446 | + $currencies = array_map('html_entity_decode', $currencies); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param array $currencies |
455 | 455 | */ |
456 | - return apply_filters( 'give_currency_symbols', $currencies ); |
|
456 | + return apply_filters('give_currency_symbols', $currencies); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return string The symbol to use for the currency |
472 | 472 | */ |
473 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
473 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
474 | 474 | |
475 | - if ( empty( $currency ) ) { |
|
475 | + if (empty($currency)) { |
|
476 | 476 | $currency = give_get_currency(); |
477 | 477 | } |
478 | 478 | |
479 | - $currencies = give_currency_symbols( $decode_currency ); |
|
480 | - $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency; |
|
479 | + $currencies = give_currency_symbols($decode_currency); |
|
480 | + $symbol = array_key_exists($currency, $currencies) ? $currencies[$currency] : $currency; |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Filter the currency symbol |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param string $symbol |
488 | 488 | * @param string $currency |
489 | 489 | */ |
490 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
490 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string |
502 | 502 | */ |
503 | -function give_get_currency_name( $currency_code ) { |
|
503 | +function give_get_currency_name($currency_code) { |
|
504 | 504 | $currency_name = ''; |
505 | 505 | $currency_names = give_get_currencies(); |
506 | 506 | |
507 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
508 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
509 | - $currency_name = trim( current( $currency_name ) ); |
|
507 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
508 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
509 | + $currency_name = trim(current($currency_name)); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param string $currency_name |
518 | 518 | * @param string $currency_code |
519 | 519 | */ |
520 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
520 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | |
532 | 532 | global $wp; |
533 | 533 | |
534 | - if ( get_option( 'permalink_structure' ) ) { |
|
535 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
534 | + if (get_option('permalink_structure')) { |
|
535 | + $base = trailingslashit(home_url($wp->request)); |
|
536 | 536 | } else { |
537 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
538 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
537 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
538 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | $scheme = is_ssl() ? 'https' : 'http'; |
542 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
542 | + $current_uri = set_url_scheme($base, $scheme); |
|
543 | 543 | |
544 | - if ( is_front_page() ) { |
|
545 | - $current_uri = home_url( '/' ); |
|
544 | + if (is_front_page()) { |
|
545 | + $current_uri = home_url('/'); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @param string $current_uri |
554 | 554 | */ |
555 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
555 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
556 | 556 | |
557 | 557 | } |
558 | 558 | |
@@ -574,11 +574,11 @@ discard block |
||
574 | 574 | */ |
575 | 575 | $gateways = give_get_enabled_payment_gateways(); |
576 | 576 | |
577 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
577 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
578 | 578 | $ret = true; |
579 | - } elseif ( count( $gateways ) == 1 ) { |
|
579 | + } elseif (count($gateways) == 1) { |
|
580 | 580 | $ret = false; |
581 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
581 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
582 | 582 | $ret = false; |
583 | 583 | } |
584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @param bool $ret |
591 | 591 | */ |
592 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); |
|
592 | + return (bool) apply_filters('give_is_cc_verify_enabled', $ret); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -601,26 +601,26 @@ discard block |
||
601 | 601 | function give_get_timezone_id() { |
602 | 602 | |
603 | 603 | // if site timezone string exists, return it. |
604 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
604 | + if ($timezone = get_option('timezone_string')) { |
|
605 | 605 | return $timezone; |
606 | 606 | } |
607 | 607 | |
608 | 608 | // get UTC offset, if it isn't set return UTC. |
609 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
609 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
610 | 610 | return 'UTC'; |
611 | 611 | } |
612 | 612 | |
613 | 613 | // attempt to guess the timezone string from the UTC offset. |
614 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
614 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
615 | 615 | |
616 | 616 | // last try, guess timezone string manually. |
617 | - if ( $timezone === false ) { |
|
617 | + if ($timezone === false) { |
|
618 | 618 | |
619 | - $is_dst = date( 'I' ); |
|
619 | + $is_dst = date('I'); |
|
620 | 620 | |
621 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
622 | - foreach ( $abbr as $city ) { |
|
623 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
621 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
622 | + foreach ($abbr as $city) { |
|
623 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
624 | 624 | return $city['timezone_id']; |
625 | 625 | } |
626 | 626 | } |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | |
645 | 645 | $ip = '127.0.0.1'; |
646 | 646 | |
647 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
647 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
648 | 648 | // check ip from share internet |
649 | 649 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
650 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
650 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
651 | 651 | // to check ip is pass from proxy |
652 | 652 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
653 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
653 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
654 | 654 | $ip = $_SERVER['REMOTE_ADDR']; |
655 | 655 | } |
656 | 656 | |
657 | - return apply_filters( 'give_get_ip', $ip ); |
|
657 | + return apply_filters('give_get_ip', $ip); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -669,9 +669,9 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @uses Give()->session->set() |
671 | 671 | */ |
672 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
673 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
674 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
672 | +function give_set_purchase_session($purchase_data = array()) { |
|
673 | + Give()->session->set('give_purchase', $purchase_data); |
|
674 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @return mixed array | false |
686 | 686 | */ |
687 | 687 | function give_get_purchase_session() { |
688 | - return Give()->session->get( 'give_purchase' ); |
|
688 | + return Give()->session->get('give_purchase'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -697,33 +697,33 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @return string |
699 | 699 | */ |
700 | -function give_payment_gateway_item_title( $payment_data ) { |
|
701 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
700 | +function give_payment_gateway_item_title($payment_data) { |
|
701 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
702 | 702 | $item_name = $payment_data['post_data']['give-form-title']; |
703 | - $is_custom_amount = give_is_setting_enabled( give_get_meta( $form_id, '_give_custom_amount', true ) ); |
|
703 | + $is_custom_amount = give_is_setting_enabled(give_get_meta($form_id, '_give_custom_amount', true)); |
|
704 | 704 | |
705 | 705 | // Verify has variable prices. |
706 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
706 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
707 | 707 | |
708 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
709 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
708 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
709 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
710 | 710 | |
711 | 711 | // Donation given doesn't match selected level (must be a custom amount). |
712 | - if ( $price_level_amount !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
713 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
712 | + if ($price_level_amount !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
713 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
714 | 714 | |
715 | 715 | // user custom amount text if any, fallback to default if not. |
716 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
716 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
717 | 717 | |
718 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
718 | + } elseif ( ! empty($item_price_level_text)) { |
|
719 | 719 | // Matches a donation level - append level text. |
720 | - $item_name .= ' - ' . $item_price_level_text; |
|
720 | + $item_name .= ' - '.$item_price_level_text; |
|
721 | 721 | } |
722 | 722 | } // End if(). |
723 | - elseif ( $is_custom_amount && give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
724 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
723 | + elseif ($is_custom_amount && give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
724 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
725 | 725 | // user custom amount text if any, fallback to default if not. |
726 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
726 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return string |
739 | 739 | */ |
740 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); |
|
740 | + return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -753,36 +753,36 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return string |
755 | 755 | */ |
756 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
757 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
756 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
757 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
758 | 758 | |
759 | 759 | // Form title. |
760 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); |
|
760 | + $summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); |
|
761 | 761 | |
762 | 762 | // Form multilevel if applicable. |
763 | - if ( isset( $donation_data['post_data']['give-price-id'] ) ) { |
|
764 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
763 | + if (isset($donation_data['post_data']['give-price-id'])) { |
|
764 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | // Add Donor's name + email if requested. |
768 | - if ( $name_and_email ) { |
|
768 | + if ($name_and_email) { |
|
769 | 769 | |
770 | 770 | // First name |
771 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
772 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
771 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
772 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
773 | 773 | } |
774 | 774 | |
775 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
776 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
775 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
776 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
777 | 777 | } |
778 | 778 | |
779 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
779 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | // Cut the length |
783 | - $summary = substr( $summary, 0, $length ); |
|
783 | + $summary = substr($summary, 0, $length); |
|
784 | 784 | |
785 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
785 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -797,31 +797,31 @@ discard block |
||
797 | 797 | function give_get_host() { |
798 | 798 | $host = false; |
799 | 799 | |
800 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
800 | + if (defined('WPE_APIKEY')) { |
|
801 | 801 | $host = 'WP Engine'; |
802 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
802 | + } elseif (defined('PAGELYBIN')) { |
|
803 | 803 | $host = 'Pagely'; |
804 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
804 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
805 | 805 | $host = 'ICDSoft'; |
806 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
806 | + } elseif (DB_HOST == 'mysqlv5') { |
|
807 | 807 | $host = 'NetworkSolutions'; |
808 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
808 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
809 | 809 | $host = 'iPage'; |
810 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
810 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
811 | 811 | $host = 'IPower'; |
812 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
812 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
813 | 813 | $host = 'MediaTemple Grid'; |
814 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
814 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
815 | 815 | $host = 'pair Networks'; |
816 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
816 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
817 | 817 | $host = 'Rackspace Cloud'; |
818 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
818 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
819 | 819 | $host = 'SysFix.eu Power Hosting'; |
820 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
820 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
821 | 821 | $host = 'Flywheel'; |
822 | 822 | } else { |
823 | 823 | // Adding a general fallback for data gathering |
824 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
824 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | return $host; |
@@ -837,67 +837,67 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return bool true if host matches, false if not |
839 | 839 | */ |
840 | -function give_is_host( $host = false ) { |
|
840 | +function give_is_host($host = false) { |
|
841 | 841 | |
842 | 842 | $return = false; |
843 | 843 | |
844 | - if ( $host ) { |
|
845 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
844 | + if ($host) { |
|
845 | + $host = str_replace(' ', '', strtolower($host)); |
|
846 | 846 | |
847 | - switch ( $host ) { |
|
847 | + switch ($host) { |
|
848 | 848 | case 'wpengine': |
849 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
849 | + if (defined('WPE_APIKEY')) { |
|
850 | 850 | $return = true; |
851 | 851 | } |
852 | 852 | break; |
853 | 853 | case 'pagely': |
854 | - if ( defined( 'PAGELYBIN' ) ) { |
|
854 | + if (defined('PAGELYBIN')) { |
|
855 | 855 | $return = true; |
856 | 856 | } |
857 | 857 | break; |
858 | 858 | case 'icdsoft': |
859 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
859 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
860 | 860 | $return = true; |
861 | 861 | } |
862 | 862 | break; |
863 | 863 | case 'networksolutions': |
864 | - if ( DB_HOST == 'mysqlv5' ) { |
|
864 | + if (DB_HOST == 'mysqlv5') { |
|
865 | 865 | $return = true; |
866 | 866 | } |
867 | 867 | break; |
868 | 868 | case 'ipage': |
869 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
869 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
870 | 870 | $return = true; |
871 | 871 | } |
872 | 872 | break; |
873 | 873 | case 'ipower': |
874 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
874 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
875 | 875 | $return = true; |
876 | 876 | } |
877 | 877 | break; |
878 | 878 | case 'mediatemplegrid': |
879 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
879 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
880 | 880 | $return = true; |
881 | 881 | } |
882 | 882 | break; |
883 | 883 | case 'pairnetworks': |
884 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
884 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
885 | 885 | $return = true; |
886 | 886 | } |
887 | 887 | break; |
888 | 888 | case 'rackspacecloud': |
889 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
889 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
890 | 890 | $return = true; |
891 | 891 | } |
892 | 892 | break; |
893 | 893 | case 'sysfix.eu': |
894 | 894 | case 'sysfix.eupowerhosting': |
895 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
895 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
896 | 896 | $return = true; |
897 | 897 | } |
898 | 898 | break; |
899 | 899 | case 'flywheel': |
900 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
900 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
901 | 901 | $return = true; |
902 | 902 | } |
903 | 903 | break; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * @param string $replacement Optional. The function that should have been called. |
931 | 931 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
932 | 932 | */ |
933 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
933 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
934 | 934 | |
935 | 935 | /** |
936 | 936 | * Fires while give deprecated function call occurs. |
@@ -943,19 +943,19 @@ discard block |
||
943 | 943 | * @param string $replacement Optional. The function that should have been called. |
944 | 944 | * @param string $version The plugin version that deprecated the function. |
945 | 945 | */ |
946 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
946 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
947 | 947 | |
948 | - $show_errors = current_user_can( 'manage_options' ); |
|
948 | + $show_errors = current_user_can('manage_options'); |
|
949 | 949 | |
950 | 950 | // Allow plugin to filter the output error trigger. |
951 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
952 | - if ( ! is_null( $replacement ) ) { |
|
953 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
954 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
951 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
952 | + if ( ! is_null($replacement)) { |
|
953 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
954 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
955 | 955 | // Alternatively we could dump this to a file. |
956 | 956 | } else { |
957 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
958 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
957 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
958 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
959 | 959 | // Alternatively we could dump this to a file. |
960 | 960 | } |
961 | 961 | } |
@@ -969,8 +969,8 @@ discard block |
||
969 | 969 | * @return string $post_id |
970 | 970 | */ |
971 | 971 | function give_get_admin_post_id() { |
972 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
973 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
972 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
973 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
974 | 974 | $post_id = $_POST['post_id']; |
975 | 975 | } |
976 | 976 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return string Arg separator output |
985 | 985 | */ |
986 | 986 | function give_get_php_arg_separator_output() { |
987 | - return ini_get( 'arg_separator.output' ); |
|
987 | + return ini_get('arg_separator.output'); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
@@ -999,10 +999,10 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return string Short month name |
1001 | 1001 | */ |
1002 | -function give_month_num_to_name( $n ) { |
|
1003 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
1002 | +function give_month_num_to_name($n) { |
|
1003 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
1004 | 1004 | |
1005 | - return date_i18n( 'M', $timestamp ); |
|
1005 | + return date_i18n('M', $timestamp); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | |
@@ -1015,10 +1015,10 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return bool Whether or not function is disabled. |
1017 | 1017 | */ |
1018 | -function give_is_func_disabled( $function ) { |
|
1019 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
1018 | +function give_is_func_disabled($function) { |
|
1019 | + $disabled = explode(',', ini_get('disable_functions')); |
|
1020 | 1020 | |
1021 | - return in_array( $function, $disabled ); |
|
1021 | + return in_array($function, $disabled); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | function give_get_newsletter() { |
1030 | 1030 | ?> |
1031 | 1031 | |
1032 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
1032 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
1033 | 1033 | |
1034 | 1034 | <div class="give-newsletter-form-wrap"> |
1035 | 1035 | |
@@ -1037,33 +1037,33 @@ discard block |
||
1037 | 1037 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
1038 | 1038 | target="_blank" novalidate> |
1039 | 1039 | <div class="give-newsletter-confirmation"> |
1040 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
1040 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
1041 | 1041 | </div> |
1042 | 1042 | |
1043 | 1043 | <table class="form-table give-newsletter-form"> |
1044 | 1044 | <tr valign="middle"> |
1045 | 1045 | <td> |
1046 | 1046 | <label for="mce-EMAIL" |
1047 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
1047 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
1048 | 1048 | <input type="email" name="EMAIL" id="mce-EMAIL" |
1049 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
1049 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
1050 | 1050 | class="required email" value=""> |
1051 | 1051 | </td> |
1052 | 1052 | <td> |
1053 | 1053 | <label for="mce-FNAME" |
1054 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
1054 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
1055 | 1055 | <input type="text" name="FNAME" id="mce-FNAME" |
1056 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
1056 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
1057 | 1057 | </td> |
1058 | 1058 | <td> |
1059 | 1059 | <label for="mce-LNAME" |
1060 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
1060 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
1061 | 1061 | <input type="text" name="LNAME" id="mce-LNAME" |
1062 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
1062 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
1063 | 1063 | </td> |
1064 | 1064 | <td> |
1065 | 1065 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
1066 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
1066 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
1067 | 1067 | </td> |
1068 | 1068 | </tr> |
1069 | 1069 | </table> |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string |
1118 | 1118 | */ |
1119 | -function give_svg_icons( $icon ) { |
|
1119 | +function give_svg_icons($icon) { |
|
1120 | 1120 | |
1121 | 1121 | // Store your SVGs in an associative array |
1122 | 1122 | $svgs = array( |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | ); |
1129 | 1129 | |
1130 | 1130 | // Return the chosen icon's SVG string |
1131 | - return $svgs[ $icon ]; |
|
1131 | + return $svgs[$icon]; |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | /** |
@@ -1140,15 +1140,15 @@ discard block |
||
1140 | 1140 | * |
1141 | 1141 | * @return mixed |
1142 | 1142 | */ |
1143 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
1144 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
1145 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
1143 | +function modify_nav_menu_meta_box_object($post_type) { |
|
1144 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
1145 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | return $post_type; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
1151 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
1152 | 1152 | |
1153 | 1153 | /** |
1154 | 1154 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. |
@@ -1167,35 +1167,35 @@ discard block |
||
1167 | 1167 | // Proceed, if current screen is navigation menus. |
1168 | 1168 | if ( |
1169 | 1169 | 'nav-menus' === $screen->id && |
1170 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && |
|
1171 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) |
|
1170 | + give_is_setting_enabled(give_get_option('forms_singular')) && |
|
1171 | + ! get_user_option('give_is_donation_forms_menu_updated') |
|
1172 | 1172 | ) { |
1173 | 1173 | |
1174 | 1174 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
1175 | 1175 | if ( |
1176 | 1176 | ! is_admin() || |
1177 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) |
|
1177 | + ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) |
|
1178 | 1178 | ) { |
1179 | 1179 | return false; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
1183 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
1183 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
1184 | 1184 | return false; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | // Exclude 'Donation Form' value from hidden meta box's list. |
1188 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
1188 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
1189 | 1189 | |
1190 | 1190 | // Get current user ID. |
1191 | 1191 | $user = wp_get_current_user(); |
1192 | 1192 | |
1193 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
1194 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); |
|
1193 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
1194 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
1198 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); |
|
1198 | +add_action('current_screen', 'give_donation_metabox_menu'); |
|
1199 | 1199 | |
1200 | 1200 | /** |
1201 | 1201 | * Array_column backup usage |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | * @license https://opensource.org/licenses/MIT MIT |
1209 | 1209 | */ |
1210 | 1210 | |
1211 | -if ( ! function_exists( 'array_column' ) ) { |
|
1211 | +if ( ! function_exists('array_column')) { |
|
1212 | 1212 | /** |
1213 | 1213 | * Returns the values from a single column of the input array, identified by |
1214 | 1214 | * the $columnKey. |
@@ -1227,53 +1227,53 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return array |
1229 | 1229 | */ |
1230 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
1230 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
1231 | 1231 | // Using func_get_args() in order to check for proper number of |
1232 | 1232 | // parameters and trigger errors exactly as the built-in array_column() |
1233 | 1233 | // does in PHP 5.5. |
1234 | 1234 | $argc = func_num_args(); |
1235 | 1235 | $params = func_get_args(); |
1236 | 1236 | |
1237 | - if ( $argc < 2 ) { |
|
1238 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
1237 | + if ($argc < 2) { |
|
1238 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
1239 | 1239 | |
1240 | 1240 | return null; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - if ( ! is_array( $params[0] ) ) { |
|
1244 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
1243 | + if ( ! is_array($params[0])) { |
|
1244 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
1245 | 1245 | |
1246 | 1246 | return null; |
1247 | 1247 | } |
1248 | 1248 | |
1249 | - if ( ! is_int( $params[1] ) |
|
1250 | - && ! is_float( $params[1] ) |
|
1251 | - && ! is_string( $params[1] ) |
|
1249 | + if ( ! is_int($params[1]) |
|
1250 | + && ! is_float($params[1]) |
|
1251 | + && ! is_string($params[1]) |
|
1252 | 1252 | && $params[1] !== null |
1253 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
1253 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
1254 | 1254 | ) { |
1255 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
1255 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
1256 | 1256 | |
1257 | 1257 | return false; |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - if ( isset( $params[2] ) |
|
1261 | - && ! is_int( $params[2] ) |
|
1262 | - && ! is_float( $params[2] ) |
|
1263 | - && ! is_string( $params[2] ) |
|
1264 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
1260 | + if (isset($params[2]) |
|
1261 | + && ! is_int($params[2]) |
|
1262 | + && ! is_float($params[2]) |
|
1263 | + && ! is_string($params[2]) |
|
1264 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
1265 | 1265 | ) { |
1266 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
1266 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
1267 | 1267 | |
1268 | 1268 | return false; |
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | $paramsInput = $params[0]; |
1272 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
1272 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
1273 | 1273 | |
1274 | 1274 | $paramsIndexKey = null; |
1275 | - if ( isset( $params[2] ) ) { |
|
1276 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
1275 | + if (isset($params[2])) { |
|
1276 | + if (is_float($params[2]) || is_int($params[2])) { |
|
1277 | 1277 | $paramsIndexKey = (int) $params[2]; |
1278 | 1278 | } else { |
1279 | 1279 | $paramsIndexKey = (string) $params[2]; |
@@ -1282,26 +1282,26 @@ discard block |
||
1282 | 1282 | |
1283 | 1283 | $resultArray = array(); |
1284 | 1284 | |
1285 | - foreach ( $paramsInput as $row ) { |
|
1285 | + foreach ($paramsInput as $row) { |
|
1286 | 1286 | $key = $value = null; |
1287 | 1287 | $keySet = $valueSet = false; |
1288 | 1288 | |
1289 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
1289 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
1290 | 1290 | $keySet = true; |
1291 | - $key = (string) $row[ $paramsIndexKey ]; |
|
1291 | + $key = (string) $row[$paramsIndexKey]; |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | - if ( $paramsColumnKey === null ) { |
|
1294 | + if ($paramsColumnKey === null) { |
|
1295 | 1295 | $valueSet = true; |
1296 | 1296 | $value = $row; |
1297 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
1297 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
1298 | 1298 | $valueSet = true; |
1299 | - $value = $row[ $paramsColumnKey ]; |
|
1299 | + $value = $row[$paramsColumnKey]; |
|
1300 | 1300 | } |
1301 | 1301 | |
1302 | - if ( $valueSet ) { |
|
1303 | - if ( $keySet ) { |
|
1304 | - $resultArray[ $key ] = $value; |
|
1302 | + if ($valueSet) { |
|
1303 | + if ($keySet) { |
|
1304 | + $resultArray[$key] = $value; |
|
1305 | 1305 | } else { |
1306 | 1306 | $resultArray[] = $value; |
1307 | 1307 | } |
@@ -1321,40 +1321,40 @@ discard block |
||
1321 | 1321 | * |
1322 | 1322 | * @return bool Whether the receipt is visible or not. |
1323 | 1323 | */ |
1324 | -function give_can_view_receipt( $payment_key = '' ) { |
|
1324 | +function give_can_view_receipt($payment_key = '') { |
|
1325 | 1325 | |
1326 | 1326 | $return = false; |
1327 | 1327 | |
1328 | - if ( empty( $payment_key ) ) { |
|
1328 | + if (empty($payment_key)) { |
|
1329 | 1329 | return $return; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | global $give_receipt_args; |
1333 | 1333 | |
1334 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
1334 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
1335 | 1335 | |
1336 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
1336 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
1337 | 1337 | |
1338 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
1338 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
1339 | 1339 | |
1340 | - if ( is_user_logged_in() ) { |
|
1341 | - if ( $user_id === (int) get_current_user_id() ) { |
|
1340 | + if (is_user_logged_in()) { |
|
1341 | + if ($user_id === (int) get_current_user_id()) { |
|
1342 | 1342 | $return = true; |
1343 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
1343 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
1344 | 1344 | $return = true; |
1345 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
1345 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
1346 | 1346 | $return = true; |
1347 | 1347 | } |
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | $session = give_get_purchase_session(); |
1351 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1352 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
1351 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
1352 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
1353 | 1353 | $return = true; |
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
1357 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
1358 | 1358 | |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
1365 | 1365 | */ |
1366 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
1366 | +if ( ! function_exists('cal_days_in_month')) { |
|
1367 | 1367 | /** |
1368 | 1368 | * cal_days_in_month |
1369 | 1369 | * |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * |
1374 | 1374 | * @return bool|string |
1375 | 1375 | */ |
1376 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
1377 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
1376 | + function cal_days_in_month($calendar, $month, $year) { |
|
1377 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | |
@@ -1393,42 +1393,42 @@ discard block |
||
1393 | 1393 | */ |
1394 | 1394 | function give_get_plugins() { |
1395 | 1395 | $plugins = get_plugins(); |
1396 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
1396 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
1397 | 1397 | |
1398 | - if ( is_multisite() ) { |
|
1399 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
1400 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
1398 | + if (is_multisite()) { |
|
1399 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
1400 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
1403 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
1404 | 1404 | // Is plugin active? |
1405 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
1406 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
1405 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
1406 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
1407 | 1407 | } else { |
1408 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
1408 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
1411 | + $dirname = strtolower(dirname($plugin_path)); |
|
1412 | 1412 | |
1413 | 1413 | // Is plugin a Give add-on by WordImpress? |
1414 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
1414 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
1415 | 1415 | // Plugin is a Give-addon. |
1416 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
1416 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
1417 | 1417 | |
1418 | 1418 | // Get license info from database. |
1419 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
1420 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
1421 | - $license_active = get_option( $db_option ); |
|
1419 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
1420 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
1421 | + $license_active = get_option($db_option); |
|
1422 | 1422 | |
1423 | 1423 | // Does a valid license exist? |
1424 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
1425 | - $plugins[ $plugin_path ]['License'] = true; |
|
1424 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
1425 | + $plugins[$plugin_path]['License'] = true; |
|
1426 | 1426 | } else { |
1427 | - $plugins[ $plugin_path ]['License'] = false; |
|
1427 | + $plugins[$plugin_path]['License'] = false; |
|
1428 | 1428 | } |
1429 | 1429 | } else { |
1430 | 1430 | // Plugin is not a Give add-on. |
1431 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
1431 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1432 | 1432 | } |
1433 | 1433 | } |
1434 | 1434 | |
@@ -1445,16 +1445,16 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @return bool |
1447 | 1447 | */ |
1448 | -function give_is_terms_enabled( $form_id ) { |
|
1449 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1448 | +function give_is_terms_enabled($form_id) { |
|
1449 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1450 | 1450 | |
1451 | 1451 | if ( |
1452 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1453 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1452 | + give_is_setting_enabled($form_option, 'global') |
|
1453 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1454 | 1454 | ) { |
1455 | 1455 | return true; |
1456 | 1456 | |
1457 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1457 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1458 | 1458 | return true; |
1459 | 1459 | |
1460 | 1460 | } else { |
@@ -1478,9 +1478,9 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @return WP_Error|bool |
1480 | 1480 | */ |
1481 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1481 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1482 | 1482 | // Delete all cache. |
1483 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1483 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1484 | 1484 | |
1485 | 1485 | /** |
1486 | 1486 | * Fire the action when donation stats delete. |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | * @param string|array $date_range |
1491 | 1491 | * @param array $args |
1492 | 1492 | */ |
1493 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1493 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1494 | 1494 | |
1495 | 1495 | return $status; |
1496 | 1496 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | * |
1509 | 1509 | * @return mixed |
1510 | 1510 | */ |
1511 | -function give_get_meta( $id, $meta_key, $single = false, $default = false ) { |
|
1511 | +function give_get_meta($id, $meta_key, $single = false, $default = false) { |
|
1512 | 1512 | /** |
1513 | 1513 | * Filter the meta value |
1514 | 1514 | * |
@@ -1516,14 +1516,14 @@ discard block |
||
1516 | 1516 | */ |
1517 | 1517 | $meta_value = apply_filters( |
1518 | 1518 | 'give_get_meta', |
1519 | - get_post_meta( $id, $meta_key, $single ), |
|
1519 | + get_post_meta($id, $meta_key, $single), |
|
1520 | 1520 | $id, |
1521 | 1521 | $meta_key, |
1522 | 1522 | $default |
1523 | 1523 | ); |
1524 | 1524 | |
1525 | 1525 | if ( |
1526 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1526 | + (empty($meta_key) || empty($meta_value)) |
|
1527 | 1527 | && $default |
1528 | 1528 | ) { |
1529 | 1529 | $meta_value = $default; |
@@ -1544,15 +1544,15 @@ discard block |
||
1544 | 1544 | * |
1545 | 1545 | * @return mixed |
1546 | 1546 | */ |
1547 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1548 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1547 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1548 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1549 | 1549 | |
1550 | 1550 | /** |
1551 | 1551 | * Filter the meta value update status |
1552 | 1552 | * |
1553 | 1553 | * @since 1.8.8 |
1554 | 1554 | */ |
1555 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1555 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | /** |
@@ -1566,15 +1566,15 @@ discard block |
||
1566 | 1566 | * |
1567 | 1567 | * @return mixed |
1568 | 1568 | */ |
1569 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1570 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1569 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1570 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1571 | 1571 | |
1572 | 1572 | /** |
1573 | 1573 | * Filter the meta value delete status |
1574 | 1574 | * |
1575 | 1575 | * @since 1.8.8 |
1576 | 1576 | */ |
1577 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1577 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | /** |
@@ -1586,15 +1586,15 @@ discard block |
||
1586 | 1586 | * |
1587 | 1587 | * @return bool If the action has been added to the completed actions array |
1588 | 1588 | */ |
1589 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1589 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1590 | 1590 | |
1591 | - if ( empty( $upgrade_action ) ) { |
|
1591 | + if (empty($upgrade_action)) { |
|
1592 | 1592 | return false; |
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | $completed_upgrades = give_get_completed_upgrades(); |
1596 | 1596 | |
1597 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1597 | + return in_array($upgrade_action, $completed_upgrades); |
|
1598 | 1598 | |
1599 | 1599 | } |
1600 | 1600 | |
@@ -1606,8 +1606,8 @@ discard block |
||
1606 | 1606 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1607 | 1607 | */ |
1608 | 1608 | function give_maybe_resume_upgrade() { |
1609 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1610 | - if ( empty( $doing_upgrade ) ) { |
|
1609 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1610 | + if (empty($doing_upgrade)) { |
|
1611 | 1611 | return false; |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1623,9 +1623,9 @@ discard block |
||
1623 | 1623 | * |
1624 | 1624 | * @return bool If the function was successfully added |
1625 | 1625 | */ |
1626 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1626 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1627 | 1627 | |
1628 | - if ( empty( $upgrade_action ) ) { |
|
1628 | + if (empty($upgrade_action)) { |
|
1629 | 1629 | return false; |
1630 | 1630 | } |
1631 | 1631 | |
@@ -1633,16 +1633,16 @@ discard block |
||
1633 | 1633 | $completed_upgrades[] = $upgrade_action; |
1634 | 1634 | |
1635 | 1635 | // Remove any blanks, and only show uniques. |
1636 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1636 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1637 | 1637 | |
1638 | 1638 | /** |
1639 | 1639 | * Fire the action when any upgrade set to complete. |
1640 | 1640 | * |
1641 | 1641 | * @since 1.8.12 |
1642 | 1642 | */ |
1643 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1643 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1644 | 1644 | |
1645 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
1645 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | * @return array The array of completed upgrades |
1653 | 1653 | */ |
1654 | 1654 | function give_get_completed_upgrades() { |
1655 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1655 | + return (array) get_option('give_completed_upgrades'); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | /** |
@@ -1662,21 +1662,21 @@ discard block |
||
1662 | 1662 | * |
1663 | 1663 | * @param \WP_Query |
1664 | 1664 | */ |
1665 | -function give_remove_pages_from_search( $query ) { |
|
1666 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1667 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1668 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1665 | +function give_remove_pages_from_search($query) { |
|
1666 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1667 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1668 | + $success_page = give_get_option('success_page', 0); |
|
1669 | 1669 | $args = apply_filters( |
1670 | 1670 | 'give_remove_pages_from_search', array( |
1671 | 1671 | $transaction_failed, |
1672 | 1672 | $success_page, |
1673 | 1673 | ), $query |
1674 | 1674 | ); |
1675 | - $query->set( 'post__not_in', $args ); |
|
1675 | + $query->set('post__not_in', $args); |
|
1676 | 1676 | } |
1677 | 1677 | } |
1678 | 1678 | |
1679 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1679 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1680 | 1680 | |
1681 | 1681 | /** |
1682 | 1682 | * Inserts a new key/value before a key in the array. |
@@ -1692,14 +1692,14 @@ discard block |
||
1692 | 1692 | * |
1693 | 1693 | * @see array_insert_before() |
1694 | 1694 | */ |
1695 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
1696 | - if ( array_key_exists( $key, $array ) ) { |
|
1695 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
1696 | + if (array_key_exists($key, $array)) { |
|
1697 | 1697 | $new = array(); |
1698 | - foreach ( $array as $k => $value ) { |
|
1699 | - if ( $k === $key ) { |
|
1700 | - $new[ $new_key ] = $new_value; |
|
1698 | + foreach ($array as $k => $value) { |
|
1699 | + if ($k === $key) { |
|
1700 | + $new[$new_key] = $new_value; |
|
1701 | 1701 | } |
1702 | - $new[ $k ] = $value; |
|
1702 | + $new[$k] = $value; |
|
1703 | 1703 | } |
1704 | 1704 | |
1705 | 1705 | return $new; |
@@ -1722,13 +1722,13 @@ discard block |
||
1722 | 1722 | * |
1723 | 1723 | * @see array_insert_before() |
1724 | 1724 | */ |
1725 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
1726 | - if ( array_key_exists( $key, $array ) ) { |
|
1725 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
1726 | + if (array_key_exists($key, $array)) { |
|
1727 | 1727 | $new = array(); |
1728 | - foreach ( $array as $k => $value ) { |
|
1729 | - $new[ $k ] = $value; |
|
1730 | - if ( $k === $key ) { |
|
1731 | - $new[ $new_key ] = $new_value; |
|
1728 | + foreach ($array as $k => $value) { |
|
1729 | + $new[$k] = $value; |
|
1730 | + if ($k === $key) { |
|
1731 | + $new[$new_key] = $new_value; |
|
1732 | 1732 | } |
1733 | 1733 | } |
1734 | 1734 | |
@@ -1755,21 +1755,21 @@ discard block |
||
1755 | 1755 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
1756 | 1756 | * `$list` will be preserved in the results. |
1757 | 1757 | */ |
1758 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
1758 | +function give_list_pluck($list, $field, $index_key = null) { |
|
1759 | 1759 | |
1760 | - if ( ! $index_key ) { |
|
1760 | + if ( ! $index_key) { |
|
1761 | 1761 | /* |
1762 | 1762 | * This is simple. Could at some point wrap array_column() |
1763 | 1763 | * if we knew we had an array of arrays. |
1764 | 1764 | */ |
1765 | - foreach ( $list as $key => $value ) { |
|
1766 | - if ( is_object( $value ) ) { |
|
1767 | - if ( isset( $value->$field ) ) { |
|
1768 | - $list[ $key ] = $value->$field; |
|
1765 | + foreach ($list as $key => $value) { |
|
1766 | + if (is_object($value)) { |
|
1767 | + if (isset($value->$field)) { |
|
1768 | + $list[$key] = $value->$field; |
|
1769 | 1769 | } |
1770 | 1770 | } else { |
1771 | - if ( isset( $value[ $field ] ) ) { |
|
1772 | - $list[ $key ] = $value[ $field ]; |
|
1771 | + if (isset($value[$field])) { |
|
1772 | + $list[$key] = $value[$field]; |
|
1773 | 1773 | } |
1774 | 1774 | } |
1775 | 1775 | } |
@@ -1782,18 +1782,18 @@ discard block |
||
1782 | 1782 | * to the end of the stack. This is how array_column() behaves. |
1783 | 1783 | */ |
1784 | 1784 | $newlist = array(); |
1785 | - foreach ( $list as $value ) { |
|
1786 | - if ( is_object( $value ) ) { |
|
1787 | - if ( isset( $value->$index_key ) ) { |
|
1788 | - $newlist[ $value->$index_key ] = $value->$field; |
|
1785 | + foreach ($list as $value) { |
|
1786 | + if (is_object($value)) { |
|
1787 | + if (isset($value->$index_key)) { |
|
1788 | + $newlist[$value->$index_key] = $value->$field; |
|
1789 | 1789 | } else { |
1790 | 1790 | $newlist[] = $value->$field; |
1791 | 1791 | } |
1792 | 1792 | } else { |
1793 | - if ( isset( $value[ $index_key ] ) ) { |
|
1794 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
1793 | + if (isset($value[$index_key])) { |
|
1794 | + $newlist[$value[$index_key]] = $value[$field]; |
|
1795 | 1795 | } else { |
1796 | - $newlist[] = $value[ $field ]; |
|
1796 | + $newlist[] = $value[$field]; |
|
1797 | 1797 | } |
1798 | 1798 | } |
1799 | 1799 | } |
@@ -1816,8 +1816,8 @@ discard block |
||
1816 | 1816 | * |
1817 | 1817 | * @return int|false Meta ID on success, false on failure. |
1818 | 1818 | */ |
1819 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
1820 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
1819 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
1820 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | /** |
@@ -1835,8 +1835,8 @@ discard block |
||
1835 | 1835 | * |
1836 | 1836 | * @return bool True on success, false on failure. |
1837 | 1837 | */ |
1838 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
1839 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
1838 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
1839 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | /** |
@@ -1851,8 +1851,8 @@ discard block |
||
1851 | 1851 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
1852 | 1852 | * is true. |
1853 | 1853 | */ |
1854 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
1855 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
1854 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
1855 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
1856 | 1856 | } |
1857 | 1857 | |
1858 | 1858 | /** |
@@ -1869,8 +1869,8 @@ discard block |
||
1869 | 1869 | * |
1870 | 1870 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
1871 | 1871 | */ |
1872 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1873 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
1872 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
1873 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
1874 | 1874 | } |
1875 | 1875 | |
1876 | 1876 | /* |
@@ -1880,15 +1880,15 @@ discard block |
||
1880 | 1880 | * |
1881 | 1881 | * @param int $form_id Form id of which recalculation needs to be done. |
1882 | 1882 | */ |
1883 | -function give_recount_form_income_donation( $form_id = false ) { |
|
1883 | +function give_recount_form_income_donation($form_id = false) { |
|
1884 | 1884 | // Check if form id is not empty. |
1885 | - if ( ! empty( $form_id ) ) { |
|
1885 | + if ( ! empty($form_id)) { |
|
1886 | 1886 | /** |
1887 | 1887 | * Filter to modify payment status. |
1888 | 1888 | * |
1889 | 1889 | * @since 1.8.13 |
1890 | 1890 | */ |
1891 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
1891 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
1892 | 1892 | |
1893 | 1893 | /** |
1894 | 1894 | * Filter to modify args of payment query before recalculating the form total |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | 'give_recount_form_stats_args', array( |
1900 | 1900 | 'give_forms' => $form_id, |
1901 | 1901 | 'status' => $accepted_statuses, |
1902 | - 'posts_per_page' => - 1, |
|
1902 | + 'posts_per_page' => -1, |
|
1903 | 1903 | 'fields' => 'ids', |
1904 | 1904 | ) |
1905 | 1905 | ); |
@@ -1909,28 +1909,28 @@ discard block |
||
1909 | 1909 | 'earnings' => 0, |
1910 | 1910 | ); |
1911 | 1911 | |
1912 | - $payments = new Give_Payments_Query( $args ); |
|
1912 | + $payments = new Give_Payments_Query($args); |
|
1913 | 1913 | $payments = $payments->get_payments(); |
1914 | 1914 | |
1915 | - if ( $payments ) { |
|
1916 | - foreach ( $payments as $payment ) { |
|
1915 | + if ($payments) { |
|
1916 | + foreach ($payments as $payment) { |
|
1917 | 1917 | // Ensure acceptible status only |
1918 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
1918 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
1919 | 1919 | continue; |
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | // Ensure only payments for this form are counted |
1923 | - if ( $payment->form_id != $form_id ) { |
|
1923 | + if ($payment->form_id != $form_id) { |
|
1924 | 1924 | continue; |
1925 | 1925 | } |
1926 | 1926 | |
1927 | - $totals['sales'] ++; |
|
1927 | + $totals['sales']++; |
|
1928 | 1928 | $totals['earnings'] += $payment->total; |
1929 | 1929 | |
1930 | 1930 | } |
1931 | 1931 | } |
1932 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
1933 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
1932 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
1933 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
1934 | 1934 | }// End if(). |
1935 | 1935 | } |
1936 | 1936 | |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | * |
1946 | 1946 | * @return bool |
1947 | 1947 | */ |
1948 | -function give_is_zero_based_currency( $currency = '' ) { |
|
1948 | +function give_is_zero_based_currency($currency = '') { |
|
1949 | 1949 | $zero_based_currency = array( |
1950 | 1950 | 'PYG', // Paraguayan Guarani. |
1951 | 1951 | 'GNF', // Guinean Franc. |
@@ -1965,12 +1965,12 @@ discard block |
||
1965 | 1965 | ); |
1966 | 1966 | |
1967 | 1967 | // Set default currency. |
1968 | - if( empty( $currency ) ) { |
|
1968 | + if (empty($currency)) { |
|
1969 | 1969 | $currency = give_get_currency(); |
1970 | 1970 | } |
1971 | 1971 | |
1972 | 1972 | // Check for Zero Based Currency. |
1973 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1973 | + if (in_array($currency, $zero_based_currency)) { |
|
1974 | 1974 | return true; |
1975 | 1975 | } |
1976 | 1976 |
@@ -166,7 +166,8 @@ discard block |
||
166 | 166 | __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »' |
167 | 167 | ); |
168 | 168 | |
169 | - else : |
|
169 | + else { |
|
170 | + : |
|
170 | 171 | echo sprintf( |
171 | 172 | '<a href="%1$s">%2$s</a>', |
172 | 173 | esc_url( |
@@ -178,6 +179,7 @@ discard block |
||
178 | 179 | ), |
179 | 180 | __( 'View Receipt »', 'give' ) |
180 | 181 | ); |
182 | + } |
|
181 | 183 | |
182 | 184 | endif; |
183 | 185 | ?> |
@@ -210,6 +212,9 @@ discard block |
||
210 | 212 | ?> |
211 | 213 | </div> |
212 | 214 | <?php wp_reset_postdata(); ?> |
213 | -<?php else : ?> |
|
214 | - <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
215 | +<?php else { |
|
216 | + : ?> |
|
217 | + <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); |
|
218 | +} |
|
219 | +?> |
|
215 | 220 | <?php endif; |
@@ -3,33 +3,33 @@ discard block |
||
3 | 3 | * This template is used to display the donation history of the current user. |
4 | 4 | */ |
5 | 5 | |
6 | -$donation_history_args = Give()->session->get( 'give_donation_history_args' ); |
|
6 | +$donation_history_args = Give()->session->get('give_donation_history_args'); |
|
7 | 7 | |
8 | 8 | $donations = array(); |
9 | 9 | |
10 | 10 | // User's Donations. |
11 | -if ( is_user_logged_in() ) { |
|
12 | - $donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' ); |
|
13 | -} elseif ( Give()->email_access->token_exists ) { |
|
11 | +if (is_user_logged_in()) { |
|
12 | + $donations = give_get_users_donations(get_current_user_id(), 20, true, 'any'); |
|
13 | +} elseif (Give()->email_access->token_exists) { |
|
14 | 14 | // Email Access Token? |
15 | - $donations = give_get_users_donations( 0, 20, true, 'any' ); |
|
16 | -} elseif ( Give()->session->get_session_expiration() !== false ) { |
|
15 | + $donations = give_get_users_donations(0, 20, true, 'any'); |
|
16 | +} elseif (Give()->session->get_session_expiration() !== false) { |
|
17 | 17 | // Session active? |
18 | - $email = Give()->session->get( 'give_email' ); |
|
19 | - $donations = give_get_users_donations( $email, 20, true, 'any' ); |
|
18 | + $email = Give()->session->get('give_email'); |
|
19 | + $donations = give_get_users_donations($email, 20, true, 'any'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | -if ( $donations ) : ?> |
|
23 | +if ($donations) : ?> |
|
24 | 24 | <?php |
25 | 25 | $table_headings = array( |
26 | - 'id' => __( 'ID', 'give' ), |
|
27 | - 'date' => __( 'Date', 'give' ), |
|
28 | - 'donor' => __( 'Donor', 'give' ), |
|
29 | - 'amount' => __( 'Amount', 'give' ), |
|
30 | - 'status' => __( 'Status', 'give' ), |
|
31 | - 'payment_method' => __( 'Payment Method', 'give' ), |
|
32 | - 'details' => __( 'Details', 'give' ), |
|
26 | + 'id' => __('ID', 'give'), |
|
27 | + 'date' => __('Date', 'give'), |
|
28 | + 'donor' => __('Donor', 'give'), |
|
29 | + 'amount' => __('Amount', 'give'), |
|
30 | + 'status' => __('Status', 'give'), |
|
31 | + 'payment_method' => __('Payment Method', 'give'), |
|
32 | + 'details' => __('Details', 'give'), |
|
33 | 33 | ); |
34 | 34 | ?> |
35 | 35 | <table id="give_user_history" class="give-table"> |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @since 1.7 |
45 | 45 | */ |
46 | - do_action( 'give_donation_history_header_before' ); |
|
46 | + do_action('give_donation_history_header_before'); |
|
47 | 47 | |
48 | - foreach ( $donation_history_args as $index => $value ) { |
|
49 | - if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) : |
|
48 | + foreach ($donation_history_args as $index => $value) { |
|
49 | + if (filter_var($donation_history_args[$index], FILTER_VALIDATE_BOOLEAN)) : |
|
50 | 50 | echo sprintf( |
51 | 51 | '<th scope="col" class="give-donation-%1$s>">%2$s</th>', |
52 | 52 | $index, |
53 | - $table_headings[ $index ] |
|
53 | + $table_headings[$index] |
|
54 | 54 | ); |
55 | 55 | endif; |
56 | 56 | } |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.7 |
64 | 64 | */ |
65 | - do_action( 'give_donation_history_header_after' ); |
|
65 | + do_action('give_donation_history_header_after'); |
|
66 | 66 | ?> |
67 | 67 | </tr> |
68 | 68 | </thead> |
69 | - <?php foreach ( $donations as $post ) : |
|
70 | - setup_postdata( $post ); |
|
71 | - $donation_data = give_get_payment_meta( $post->ID ); ?> |
|
69 | + <?php foreach ($donations as $post) : |
|
70 | + setup_postdata($post); |
|
71 | + $donation_data = give_get_payment_meta($post->ID); ?> |
|
72 | 72 | <tr class="give-donation-row"> |
73 | 73 | <?php |
74 | 74 | /** |
@@ -81,37 +81,37 @@ discard block |
||
81 | 81 | * @param int $post_id The ID of the post. |
82 | 82 | * @param mixed $donation_data Payment meta data. |
83 | 83 | */ |
84 | - do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
|
84 | + do_action('give_donation_history_row_start', $post->ID, $donation_data); |
|
85 | 85 | |
86 | - if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
86 | + if (filter_var($donation_history_args['id'], FILTER_VALIDATE_BOOLEAN)) : |
|
87 | 87 | echo sprintf( |
88 | 88 | '<td class="give-donation-id">#%1$s</td>', |
89 | - give_get_payment_number( $post->ID ) |
|
89 | + give_get_payment_number($post->ID) |
|
90 | 90 | ); |
91 | 91 | endif; |
92 | 92 | |
93 | - if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
93 | + if (filter_var($donation_history_args['date'], FILTER_VALIDATE_BOOLEAN)) : |
|
94 | 94 | echo sprintf( |
95 | 95 | '<td class="give-donation-date">%1$s</td>', |
96 | - date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ) |
|
96 | + date_i18n(give_date_format(), strtotime(get_post_field('post_date', $post->ID))) |
|
97 | 97 | ); |
98 | 98 | endif; |
99 | 99 | |
100 | - if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
100 | + if (filter_var($donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN)) : |
|
101 | 101 | echo sprintf( |
102 | 102 | '<td class="give-donation-donor">%1$s</td>', |
103 | - give_get_donor_name_by( $post->ID ) |
|
103 | + give_get_donor_name_by($post->ID) |
|
104 | 104 | ); |
105 | 105 | endif; |
106 | 106 | ?> |
107 | 107 | |
108 | - <?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
108 | + <?php if (filter_var($donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
109 | 109 | <td class="give-donation-amount"> |
110 | 110 | <span class="give-donation-amount"> |
111 | 111 | <?php |
112 | - $currency_code = give_get_payment_currency_code( $post->ID ); |
|
112 | + $currency_code = give_get_payment_currency_code($post->ID); |
|
113 | 113 | $donation_amount = give_currency_filter( |
114 | - give_format_amount( give_get_payment_amount( $post->ID ), array( |
|
114 | + give_format_amount(give_get_payment_amount($post->ID), array( |
|
115 | 115 | 'sanitize' => false, |
116 | 116 | 'currency' => $currency_code, |
117 | 117 | )), |
@@ -128,42 +128,42 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return int |
130 | 130 | */ |
131 | - echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID ); |
|
131 | + echo apply_filters('give_donation_history_row_amount', $donation_amount, $post->ID); |
|
132 | 132 | ?> |
133 | 133 | </span> |
134 | 134 | </td> |
135 | 135 | <?php endif; ?> |
136 | 136 | |
137 | 137 | <?php |
138 | - if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
138 | + if (filter_var($donation_history_args['status'], FILTER_VALIDATE_BOOLEAN)) : |
|
139 | 139 | echo sprintf( |
140 | 140 | '<td class="give-donation-status">%1$s</td>', |
141 | - give_get_payment_status( $post, true ) |
|
141 | + give_get_payment_status($post, true) |
|
142 | 142 | ); |
143 | 143 | endif; |
144 | 144 | |
145 | - if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
145 | + if (filter_var($donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN)) : |
|
146 | 146 | echo sprintf( |
147 | 147 | '<td class="give-donation-payment-method">%1$s</td>', |
148 | - give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) ) |
|
148 | + give_get_gateway_checkout_label(give_get_payment_gateway($post->ID)) |
|
149 | 149 | ); |
150 | 150 | endif; |
151 | 151 | ?> |
152 | 152 | <td class="give-donation-details"> |
153 | 153 | <?php |
154 | 154 | // Display View Receipt or. |
155 | - if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) : |
|
155 | + if ('publish' !== $post->post_status && 'subscription' !== $post->post_status) : |
|
156 | 156 | echo sprintf( |
157 | 157 | '<a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>', |
158 | 158 | esc_url( |
159 | 159 | add_query_arg( |
160 | 160 | 'payment_key', |
161 | - give_get_payment_key( $post->ID ), |
|
161 | + give_get_payment_key($post->ID), |
|
162 | 162 | give_get_history_page_uri() |
163 | 163 | ) |
164 | 164 | ), |
165 | 165 | $post->post_status, |
166 | - __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »' |
|
166 | + __('View', 'give').' '.give_get_payment_status($post, true).' »' |
|
167 | 167 | ); |
168 | 168 | |
169 | 169 | else : |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | esc_url( |
173 | 173 | add_query_arg( |
174 | 174 | 'payment_key', |
175 | - give_get_payment_key( $post->ID ), |
|
175 | + give_get_payment_key($post->ID), |
|
176 | 176 | give_get_history_page_uri() |
177 | 177 | ) |
178 | 178 | ), |
179 | - __( 'View Receipt »', 'give' ) |
|
179 | + __('View Receipt »', 'give') |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | endif; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param int $post_id The ID of the post. |
194 | 194 | * @param mixed $donation_data Payment meta data. |
195 | 195 | */ |
196 | - do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
|
196 | + do_action('give_donation_history_row_end', $post->ID, $donation_data); |
|
197 | 197 | ?> |
198 | 198 | </tr> |
199 | 199 | <?php endforeach; ?> |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
202 | 202 | <?php |
203 | 203 | $big = 999999; |
204 | - echo paginate_links( array( |
|
205 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
204 | + echo paginate_links(array( |
|
205 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
206 | 206 | 'format' => '?paged=%#%', |
207 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
208 | - 'total' => ceil( give_count_donations_of_donor() / 20 ) // 20 items per page |
|
209 | - ) ); |
|
207 | + 'current' => max(1, get_query_var('paged')), |
|
208 | + 'total' => ceil(give_count_donations_of_donor() / 20) // 20 items per page |
|
209 | + )); |
|
210 | 210 | ?> |
211 | 211 | </div> |
212 | 212 | <?php wp_reset_postdata(); ?> |
213 | 213 | <?php else : ?> |
214 | - <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
|
214 | + <?php Give()->notices->print_frontend_notice(__('It looks like you haven\'t made any donations.', 'give'), true, 'success'); ?> |
|
215 | 215 | <?php endif; |
@@ -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,33 +23,33 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | -function give_donation_history( $atts ) { |
|
26 | +function give_donation_history($atts) { |
|
27 | 27 | |
28 | - $donation_history_args = shortcode_atts( array( |
|
28 | + $donation_history_args = shortcode_atts(array( |
|
29 | 29 | 'id' => true, |
30 | 30 | 'date' => true, |
31 | 31 | 'donor' => false, |
32 | 32 | 'amount' => true, |
33 | 33 | 'status' => false, |
34 | 34 | 'payment_method' => false, |
35 | - ), $atts, 'donation_history' ); |
|
35 | + ), $atts, 'donation_history'); |
|
36 | 36 | |
37 | 37 | // Always show receipt link. |
38 | 38 | $donation_history_args['details'] = true; |
39 | 39 | |
40 | 40 | // Set Donation History Shortcode Arguments in session variable. |
41 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
41 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
42 | 42 | |
43 | 43 | // If payment_key query arg exists, return receipt instead of donation history. |
44 | - if ( isset( $_GET['payment_key'] ) ) { |
|
44 | + if (isset($_GET['payment_key'])) { |
|
45 | 45 | ob_start(); |
46 | - echo give_receipt_shortcode( array() ); |
|
47 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . __( 'Return to All Donations', 'give' ) . '</a>'; |
|
46 | + echo give_receipt_shortcode(array()); |
|
47 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.__('Return to All Donations', 'give').'</a>'; |
|
48 | 48 | |
49 | 49 | return ob_get_clean(); |
50 | 50 | } |
51 | 51 | |
52 | - $email_access = give_get_option( 'email_access' ); |
|
52 | + $email_access = give_get_option('email_access'); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Determine access |
@@ -59,30 +59,30 @@ discard block |
||
59 | 59 | */ |
60 | 60 | if ( |
61 | 61 | is_user_logged_in() || false !== Give()->session->get_session_expiration() |
62 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
62 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
63 | 63 | ) { |
64 | 64 | ob_start(); |
65 | - give_get_template_part( 'history', 'donations' ); |
|
65 | + give_get_template_part('history', 'donations'); |
|
66 | 66 | |
67 | 67 | return ob_get_clean(); |
68 | 68 | |
69 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
69 | + } elseif (give_is_setting_enabled($email_access)) { |
|
70 | 70 | // Is Email-based access enabled? |
71 | 71 | ob_start(); |
72 | - give_get_template_part( 'email', 'login-form' ); |
|
72 | + give_get_template_part('email', 'login-form'); |
|
73 | 73 | |
74 | 74 | return ob_get_clean(); |
75 | 75 | |
76 | 76 | } else { |
77 | 77 | |
78 | - $output = 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 ) ); |
|
79 | - $output .= do_shortcode( '[give_login]' ); |
|
78 | + $output = 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)); |
|
79 | + $output .= do_shortcode('[give_login]'); |
|
80 | 80 | |
81 | 81 | return $output; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
85 | +add_shortcode('donation_history', 'give_donation_history'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Donation Form Shortcode |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string |
97 | 97 | */ |
98 | -function give_form_shortcode( $atts ) { |
|
99 | - $atts = shortcode_atts( array( |
|
98 | +function give_form_shortcode($atts) { |
|
99 | + $atts = shortcode_atts(array( |
|
100 | 100 | 'id' => '', |
101 | 101 | 'show_title' => true, |
102 | 102 | 'show_goal' => true, |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | 'float_labels' => '', |
105 | 105 | 'display_style' => '', |
106 | 106 | 'continue_button_title' => '', |
107 | - ), $atts, 'give_form' ); |
|
107 | + ), $atts, 'give_form'); |
|
108 | 108 | |
109 | 109 | // Convert string to bool. |
110 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
111 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
110 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
111 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
112 | 112 | |
113 | 113 | //get the Give Form |
114 | 114 | ob_start(); |
115 | - give_get_donation_form( $atts ); |
|
115 | + give_get_donation_form($atts); |
|
116 | 116 | $final_output = ob_get_clean(); |
117 | 117 | |
118 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
118 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
119 | 119 | } |
120 | 120 | |
121 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
121 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Donation Form Goal Shortcode. |
@@ -131,37 +131,37 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string |
133 | 133 | */ |
134 | -function give_goal_shortcode( $atts ) { |
|
135 | - $atts = shortcode_atts( array( |
|
134 | +function give_goal_shortcode($atts) { |
|
135 | + $atts = shortcode_atts(array( |
|
136 | 136 | 'id' => '', |
137 | 137 | 'show_text' => true, |
138 | 138 | 'show_bar' => true, |
139 | - ), $atts, 'give_goal' ); |
|
139 | + ), $atts, 'give_goal'); |
|
140 | 140 | |
141 | 141 | |
142 | 142 | //get the Give Form. |
143 | 143 | ob_start(); |
144 | 144 | |
145 | 145 | //Sanity check 1: ensure there is an ID Provided. |
146 | - if ( empty( $atts['id'] ) ) { |
|
147 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
146 | + if (empty($atts['id'])) { |
|
147 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | //Sanity check 2: Check the form even has Goals enabled. |
151 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
151 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
152 | 152 | |
153 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
153 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
154 | 154 | } else { |
155 | 155 | //Passed all sanity checks: output Goal. |
156 | - give_show_goal_progress( $atts['id'], $atts ); |
|
156 | + give_show_goal_progress($atts['id'], $atts); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $final_output = ob_get_clean(); |
160 | 160 | |
161 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
161 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
162 | 162 | } |
163 | 163 | |
164 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
164 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
165 | 165 | |
166 | 166 | |
167 | 167 | /** |
@@ -178,22 +178,22 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return string |
180 | 180 | */ |
181 | -function give_login_form_shortcode( $atts ) { |
|
182 | - $atts = shortcode_atts( array( |
|
181 | +function give_login_form_shortcode($atts) { |
|
182 | + $atts = shortcode_atts(array( |
|
183 | 183 | // Add backward compatibility for redirect attribute. |
184 | 184 | 'redirect' => '', |
185 | 185 | |
186 | 186 | 'login-redirect' => '', |
187 | 187 | 'logout-redirect' => '', |
188 | - ), $atts, 'give_login' ); |
|
188 | + ), $atts, 'give_login'); |
|
189 | 189 | |
190 | 190 | // 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. |
191 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
191 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
192 | 192 | |
193 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
193 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
194 | 194 | } |
195 | 195 | |
196 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
196 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Register Shortcode. |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return string |
210 | 210 | */ |
211 | -function give_register_form_shortcode( $atts ) { |
|
212 | - $atts = shortcode_atts( array( |
|
211 | +function give_register_form_shortcode($atts) { |
|
212 | + $atts = shortcode_atts(array( |
|
213 | 213 | 'redirect' => '', |
214 | - ), $atts, 'give_register' ); |
|
214 | + ), $atts, 'give_register'); |
|
215 | 215 | |
216 | - return give_register_form( $atts['redirect'] ); |
|
216 | + return give_register_form($atts['redirect']); |
|
217 | 217 | } |
218 | 218 | |
219 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
219 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Receipt Shortcode. |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string |
231 | 231 | */ |
232 | -function give_receipt_shortcode( $atts ) { |
|
232 | +function give_receipt_shortcode($atts) { |
|
233 | 233 | |
234 | 234 | global $give_receipt_args, $payment; |
235 | 235 | |
236 | - $give_receipt_args = shortcode_atts( array( |
|
237 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
236 | + $give_receipt_args = shortcode_atts(array( |
|
237 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
238 | 238 | 'price' => true, |
239 | 239 | 'donor' => true, |
240 | 240 | 'date' => true, |
@@ -243,50 +243,50 @@ discard block |
||
243 | 243 | 'payment_id' => true, |
244 | 244 | 'payment_status' => false, |
245 | 245 | 'status_notice' => true, |
246 | - ), $atts, 'give_receipt' ); |
|
246 | + ), $atts, 'give_receipt'); |
|
247 | 247 | |
248 | 248 | //set $session var |
249 | 249 | $session = give_get_purchase_session(); |
250 | 250 | |
251 | 251 | //set payment key var |
252 | - if ( isset( $_GET['payment_key'] ) ) { |
|
253 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
254 | - } elseif ( $session ) { |
|
252 | + if (isset($_GET['payment_key'])) { |
|
253 | + $payment_key = urldecode($_GET['payment_key']); |
|
254 | + } elseif ($session) { |
|
255 | 255 | $payment_key = $session['purchase_key']; |
256 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
256 | + } elseif ($give_receipt_args['payment_key']) { |
|
257 | 257 | $payment_key = $give_receipt_args['payment_key']; |
258 | 258 | } |
259 | 259 | |
260 | - $email_access = give_get_option( 'email_access' ); |
|
260 | + $email_access = give_get_option('email_access'); |
|
261 | 261 | |
262 | 262 | // No payment_key found & Email Access is Turned on: |
263 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
263 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
264 | 264 | |
265 | 265 | ob_start(); |
266 | 266 | |
267 | - give_get_template_part( 'email-login-form' ); |
|
267 | + give_get_template_part('email-login-form'); |
|
268 | 268 | |
269 | 269 | return ob_get_clean(); |
270 | 270 | |
271 | - } elseif ( ! isset( $payment_key ) ) { |
|
271 | + } elseif ( ! isset($payment_key)) { |
|
272 | 272 | |
273 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
273 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
274 | 274 | |
275 | 275 | } |
276 | 276 | |
277 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
278 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
277 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
278 | + $user_can_view = give_can_view_receipt($payment_key); |
|
279 | 279 | |
280 | 280 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
281 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
281 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
282 | 282 | |
283 | 283 | ob_start(); |
284 | 284 | |
285 | - give_get_template_part( 'email-login-form' ); |
|
285 | + give_get_template_part('email-login-form'); |
|
286 | 286 | |
287 | 287 | return ob_get_clean(); |
288 | 288 | |
289 | - } elseif ( ! $user_can_view ) { |
|
289 | + } elseif ( ! $user_can_view) { |
|
290 | 290 | |
291 | 291 | global $give_login_redirect; |
292 | 292 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | ob_start(); |
296 | 296 | |
297 | - 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' ) ) ); |
|
297 | + 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'))); |
|
298 | 298 | |
299 | - give_get_template_part( 'shortcode', 'login' ); |
|
299 | + give_get_template_part('shortcode', 'login'); |
|
300 | 300 | |
301 | 301 | $login_form = ob_get_clean(); |
302 | 302 | |
@@ -310,20 +310,20 @@ discard block |
||
310 | 310 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
311 | 311 | * or if user is logged in and the user can view sensitive shop data. |
312 | 312 | */ |
313 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
314 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
313 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
314 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | ob_start(); |
318 | 318 | |
319 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
319 | + give_get_template_part('shortcode', 'receipt'); |
|
320 | 320 | |
321 | 321 | $display = ob_get_clean(); |
322 | 322 | |
323 | 323 | return $display; |
324 | 324 | } |
325 | 325 | |
326 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
326 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Profile Editor Shortcode. |
@@ -342,25 +342,25 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return string Output generated from the profile editor |
344 | 344 | */ |
345 | -function give_profile_editor_shortcode( $atts ) { |
|
345 | +function give_profile_editor_shortcode($atts) { |
|
346 | 346 | |
347 | 347 | ob_start(); |
348 | 348 | |
349 | 349 | // Restrict access to donor profile, if donor and user are disconnected. |
350 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
351 | - if( is_user_logged_in() && $is_donor_disconnected ) { |
|
352 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
350 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
351 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
352 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | |
356 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
356 | + give_get_template_part('shortcode', 'profile-editor'); |
|
357 | 357 | |
358 | 358 | $display = ob_get_clean(); |
359 | 359 | |
360 | 360 | return $display; |
361 | 361 | } |
362 | 362 | |
363 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
363 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Process Profile Updater Form. |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool |
375 | 375 | */ |
376 | -function give_process_profile_editor_updates( $data ) { |
|
376 | +function give_process_profile_editor_updates($data) { |
|
377 | 377 | // Profile field change request |
378 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
378 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
379 | 379 | return false; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Nonce security |
383 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
383 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
384 | 384 | return false; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $user_id = get_current_user_id(); |
388 | - $old_user_data = get_userdata( $user_id ); |
|
389 | - |
|
390 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
391 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
392 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
393 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
394 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
395 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
396 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
397 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
398 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
399 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
388 | + $old_user_data = get_userdata($user_id); |
|
389 | + |
|
390 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
391 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
392 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
393 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
394 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
395 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
396 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
397 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
398 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
399 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
400 | 400 | |
401 | 401 | $userdata = array( |
402 | 402 | 'ID' => $user_id, |
@@ -424,40 +424,40 @@ discard block |
||
424 | 424 | * @param int $user_id The ID of the user. |
425 | 425 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
426 | 426 | */ |
427 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
427 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
428 | 428 | |
429 | 429 | // Make sure to validate passwords for existing Donors |
430 | - give_validate_user_password( $data['give_new_user_pass1'], $data['give_new_user_pass2'] ); |
|
430 | + give_validate_user_password($data['give_new_user_pass1'], $data['give_new_user_pass2']); |
|
431 | 431 | |
432 | - if ( empty( $email ) ) { |
|
432 | + if (empty($email)) { |
|
433 | 433 | // Make sure email should not be empty. |
434 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
434 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
435 | 435 | |
436 | - } else if ( ! is_email( $email ) ) { |
|
436 | + } else if ( ! is_email($email)) { |
|
437 | 437 | // Make sure email should be valid. |
438 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
438 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
439 | 439 | |
440 | - } else if ( $email != $old_user_data->user_email ) { |
|
440 | + } else if ($email != $old_user_data->user_email) { |
|
441 | 441 | // Make sure the new email doesn't belong to another user |
442 | - if ( email_exists( $email ) ) { |
|
443 | - give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
442 | + if (email_exists($email)) { |
|
443 | + give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | 447 | // Check for errors |
448 | 448 | $errors = give_get_errors(); |
449 | 449 | |
450 | - if ( $errors ) { |
|
450 | + if ($errors) { |
|
451 | 451 | // Send back to the profile editor if there are errors |
452 | - wp_redirect( $data['give_redirect'] ); |
|
452 | + wp_redirect($data['give_redirect']); |
|
453 | 453 | give_die(); |
454 | 454 | } |
455 | 455 | |
456 | 456 | // Update the user |
457 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
458 | - $updated = wp_update_user( $userdata ); |
|
457 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
458 | + $updated = wp_update_user($userdata); |
|
459 | 459 | |
460 | - if ( $updated ) { |
|
460 | + if ($updated) { |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Fires after updating user profile. |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | * @param int $user_id The ID of the user. |
468 | 468 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
469 | 469 | */ |
470 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
471 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
470 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
471 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
472 | 472 | give_die(); |
473 | 473 | } |
474 | 474 | |
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
478 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the donation data and uses the Manual Payment gateway to record |
@@ -32,44 +32,44 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
49 | 49 | 'purchase_key' => $purchase_data['purchase_key'], |
50 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
50 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
51 | 51 | 'user_info' => $purchase_data['user_info'], |
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the donation page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,39 +109,39 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | |
118 | - $args = wp_parse_args( $args, $defaults ); |
|
118 | + $args = wp_parse_args($args, $defaults); |
|
119 | 119 | |
120 | - $forms = get_posts( array( |
|
120 | + $forms = get_posts(array( |
|
121 | 121 | 'post_type' => 'give_forms', |
122 | 122 | 'orderby' => 'title', |
123 | 123 | 'order' => 'ASC', |
124 | 124 | 'posts_per_page' => $args['number'], |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $options = array(); |
128 | 128 | |
129 | 129 | // Ensure the selected. |
130 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
131 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
130 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
131 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( $forms ) { |
|
134 | + if ($forms) { |
|
135 | 135 | $options[0] = $args['placeholder']; |
136 | - foreach ( $forms as $form ) { |
|
137 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
138 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
136 | + foreach ($forms as $form) { |
|
137 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
138 | + $options[absint($form->ID)] = esc_html($form_title); |
|
139 | 139 | } |
140 | 140 | } else { |
141 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
141 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
142 | 142 | } |
143 | 143 | |
144 | - $output = $this->select( array( |
|
144 | + $output = $this->select(array( |
|
145 | 145 | 'name' => $args['name'], |
146 | 146 | 'selected' => $args['selected'], |
147 | 147 | 'id' => $args['id'], |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'show_option_all' => false, |
154 | 154 | 'show_option_none' => false, |
155 | 155 | 'data' => $args['data'], |
156 | - ) ); |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | return $output; |
159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string Donors dropdown. |
172 | 172 | */ |
173 | - public function donor_dropdown( $args = array() ) { |
|
173 | + public function donor_dropdown($args = array()) { |
|
174 | 174 | |
175 | 175 | $defaults = array( |
176 | 176 | 'name' => 'donors', |
@@ -179,57 +179,57 @@ discard block |
||
179 | 179 | 'multiple' => false, |
180 | 180 | 'selected' => 0, |
181 | 181 | 'chosen' => true, |
182 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
182 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
183 | 183 | 'number' => 30, |
184 | 184 | 'data' => array( |
185 | 185 | 'search-type' => 'donor', |
186 | 186 | ), |
187 | 187 | ); |
188 | 188 | |
189 | - $args = wp_parse_args( $args, $defaults ); |
|
189 | + $args = wp_parse_args($args, $defaults); |
|
190 | 190 | |
191 | - $donors = Give()->donors->get_donors( array( |
|
191 | + $donors = Give()->donors->get_donors(array( |
|
192 | 192 | 'number' => $args['number'] |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | 195 | $options = array(); |
196 | 196 | |
197 | - if ( $donors ) { |
|
198 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
199 | - foreach ( $donors as $donor ) { |
|
200 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
197 | + if ($donors) { |
|
198 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
199 | + foreach ($donors as $donor) { |
|
200 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
201 | 201 | } |
202 | 202 | } else { |
203 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
203 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
204 | 204 | } |
205 | 205 | |
206 | - if ( ! empty( $args['selected'] ) ) { |
|
206 | + if ( ! empty($args['selected'])) { |
|
207 | 207 | |
208 | 208 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
209 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
209 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
210 | 210 | |
211 | - $donor = new Give_Donor( $args['selected'] ); |
|
211 | + $donor = new Give_Donor($args['selected']); |
|
212 | 212 | |
213 | - if ( $donor ) { |
|
213 | + if ($donor) { |
|
214 | 214 | |
215 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
215 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - $output = $this->select( array( |
|
221 | + $output = $this->select(array( |
|
222 | 222 | 'name' => $args['name'], |
223 | 223 | 'selected' => $args['selected'], |
224 | 224 | 'id' => $args['id'], |
225 | - 'class' => $args['class'] . ' give-customer-select', |
|
225 | + 'class' => $args['class'].' give-customer-select', |
|
226 | 226 | 'options' => $options, |
227 | 227 | 'multiple' => $args['multiple'], |
228 | 228 | 'chosen' => $args['chosen'], |
229 | 229 | 'show_option_all' => false, |
230 | 230 | 'show_option_none' => false, |
231 | 231 | 'data' => $args['data'], |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | |
234 | 234 | return $output; |
235 | 235 | } |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string Categories dropdown. |
250 | 250 | */ |
251 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
252 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
251 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
252 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
253 | 253 | $options = array(); |
254 | 254 | |
255 | - foreach ( $categories as $category ) { |
|
256 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
255 | + foreach ($categories as $category) { |
|
256 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
257 | 257 | } |
258 | 258 | |
259 | - $output = $this->select( wp_parse_args( $args, array( |
|
259 | + $output = $this->select(wp_parse_args($args, array( |
|
260 | 260 | 'name' => $name, |
261 | 261 | 'selected' => $selected, |
262 | 262 | 'options' => $options, |
263 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
263 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
264 | 264 | 'show_option_none' => false, |
265 | - ) ) ); |
|
265 | + ))); |
|
266 | 266 | |
267 | 267 | return $output; |
268 | 268 | } |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string Tags dropdown. |
283 | 283 | */ |
284 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
285 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
284 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
285 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
286 | 286 | $options = array(); |
287 | 287 | |
288 | - foreach ( $tags as $tag ) { |
|
289 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
288 | + foreach ($tags as $tag) { |
|
289 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
290 | 290 | } |
291 | 291 | |
292 | - $output = $this->select( wp_parse_args( $args, array( |
|
292 | + $output = $this->select(wp_parse_args($args, array( |
|
293 | 293 | 'name' => $name, |
294 | 294 | 'selected' => $selected, |
295 | 295 | 'options' => $options, |
296 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
296 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
297 | 297 | 'show_option_none' => false, |
298 | - ) ) ); |
|
298 | + ))); |
|
299 | 299 | |
300 | 300 | return $output; |
301 | 301 | } |
@@ -315,25 +315,25 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return string Years dropdown. |
317 | 317 | */ |
318 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
319 | - $current = date( 'Y' ); |
|
320 | - $start_year = $current - absint( $years_before ); |
|
321 | - $end_year = $current + absint( $years_after ); |
|
322 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
318 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
319 | + $current = date('Y'); |
|
320 | + $start_year = $current - absint($years_before); |
|
321 | + $end_year = $current + absint($years_after); |
|
322 | + $selected = empty($selected) ? date('Y') : $selected; |
|
323 | 323 | $options = array(); |
324 | 324 | |
325 | - while ( $start_year <= $end_year ) { |
|
326 | - $options[ absint( $start_year ) ] = $start_year; |
|
327 | - $start_year ++; |
|
325 | + while ($start_year <= $end_year) { |
|
326 | + $options[absint($start_year)] = $start_year; |
|
327 | + $start_year++; |
|
328 | 328 | } |
329 | 329 | |
330 | - $output = $this->select( array( |
|
330 | + $output = $this->select(array( |
|
331 | 331 | 'name' => $name, |
332 | 332 | 'selected' => $selected, |
333 | 333 | 'options' => $options, |
334 | 334 | 'show_option_all' => false, |
335 | 335 | 'show_option_none' => false, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | |
338 | 338 | return $output; |
339 | 339 | } |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return string Months dropdown. |
353 | 353 | */ |
354 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
354 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
355 | 355 | $month = 1; |
356 | 356 | $options = array(); |
357 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
357 | + $selected = empty($selected) ? date('n') : $selected; |
|
358 | 358 | |
359 | - while ( $month <= 12 ) { |
|
360 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
361 | - $month ++; |
|
359 | + while ($month <= 12) { |
|
360 | + $options[absint($month)] = give_month_num_to_name($month); |
|
361 | + $month++; |
|
362 | 362 | } |
363 | 363 | |
364 | - $output = $this->select( array( |
|
364 | + $output = $this->select(array( |
|
365 | 365 | 'name' => $name, |
366 | 366 | 'selected' => $selected, |
367 | 367 | 'options' => $options, |
368 | 368 | 'show_option_all' => false, |
369 | 369 | 'show_option_none' => false, |
370 | - ) ); |
|
370 | + )); |
|
371 | 371 | |
372 | 372 | return $output; |
373 | 373 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return string The dropdown. |
386 | 386 | */ |
387 | - public function select( $args = array() ) { |
|
387 | + public function select($args = array()) { |
|
388 | 388 | $defaults = array( |
389 | 389 | 'options' => array(), |
390 | 390 | 'name' => null, |
@@ -395,67 +395,67 @@ discard block |
||
395 | 395 | 'placeholder' => null, |
396 | 396 | 'multiple' => false, |
397 | 397 | 'select_atts' => false, |
398 | - 'show_option_all' => __( 'All', 'give' ), |
|
399 | - 'show_option_none' => __( 'None', 'give' ), |
|
398 | + 'show_option_all' => __('All', 'give'), |
|
399 | + 'show_option_none' => __('None', 'give'), |
|
400 | 400 | 'data' => array(), |
401 | 401 | 'readonly' => false, |
402 | 402 | 'disabled' => false, |
403 | 403 | ); |
404 | 404 | |
405 | - $args = wp_parse_args( $args, $defaults ); |
|
405 | + $args = wp_parse_args($args, $defaults); |
|
406 | 406 | |
407 | 407 | $data_elements = ''; |
408 | - foreach ( $args['data'] as $key => $value ) { |
|
409 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
408 | + foreach ($args['data'] as $key => $value) { |
|
409 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
410 | 410 | } |
411 | 411 | |
412 | - if ( $args['multiple'] ) { |
|
412 | + if ($args['multiple']) { |
|
413 | 413 | $multiple = ' MULTIPLE'; |
414 | 414 | } else { |
415 | 415 | $multiple = ''; |
416 | 416 | } |
417 | 417 | |
418 | - if ( $args['chosen'] ) { |
|
418 | + if ($args['chosen']) { |
|
419 | 419 | $args['class'] .= ' give-select-chosen'; |
420 | 420 | } |
421 | 421 | |
422 | - if ( $args['placeholder'] ) { |
|
422 | + if ($args['placeholder']) { |
|
423 | 423 | $placeholder = $args['placeholder']; |
424 | 424 | } else { |
425 | 425 | $placeholder = ''; |
426 | 426 | } |
427 | 427 | |
428 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
428 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'"'.$data_elements.'>'; |
|
429 | 429 | |
430 | - if ( $args['show_option_all'] ) { |
|
431 | - if ( $args['multiple'] ) { |
|
432 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
430 | + if ($args['show_option_all']) { |
|
431 | + if ($args['multiple']) { |
|
432 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
433 | 433 | } else { |
434 | - $selected = selected( $args['selected'], 0, false ); |
|
434 | + $selected = selected($args['selected'], 0, false); |
|
435 | 435 | } |
436 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
436 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - if ( ! empty( $args['options'] ) ) { |
|
439 | + if ( ! empty($args['options'])) { |
|
440 | 440 | |
441 | - if ( $args['show_option_none'] ) { |
|
442 | - if ( $args['multiple'] ) { |
|
443 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
441 | + if ($args['show_option_none']) { |
|
442 | + if ($args['multiple']) { |
|
443 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
444 | 444 | } else { |
445 | - $selected = selected( $args['selected'], - 1, false ); |
|
445 | + $selected = selected($args['selected'], - 1, false); |
|
446 | 446 | } |
447 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
447 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
448 | 448 | } |
449 | 449 | |
450 | - foreach ( $args['options'] as $key => $option ) { |
|
450 | + foreach ($args['options'] as $key => $option) { |
|
451 | 451 | |
452 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
453 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
452 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
453 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
454 | 454 | } else { |
455 | - $selected = selected( $args['selected'], $key, false ); |
|
455 | + $selected = selected($args['selected'], $key, false); |
|
456 | 456 | } |
457 | 457 | |
458 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
458 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return string The checkbox. |
478 | 478 | */ |
479 | - public function checkbox( $args = array() ) { |
|
479 | + public function checkbox($args = array()) { |
|
480 | 480 | $defaults = array( |
481 | 481 | 'name' => null, |
482 | 482 | 'current' => null, |
@@ -487,16 +487,16 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ); |
489 | 489 | |
490 | - $args = wp_parse_args( $args, $defaults ); |
|
490 | + $args = wp_parse_args($args, $defaults); |
|
491 | 491 | |
492 | 492 | $options = ''; |
493 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
493 | + if ( ! empty($args['options']['disabled'])) { |
|
494 | 494 | $options .= ' disabled="disabled"'; |
495 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
495 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
496 | 496 | $options .= ' readonly'; |
497 | 497 | } |
498 | 498 | |
499 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
499 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
500 | 500 | |
501 | 501 | return $output; |
502 | 502 | } |
@@ -513,22 +513,22 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @return string The text field. |
515 | 515 | */ |
516 | - public function text( $args = array() ) { |
|
516 | + public function text($args = array()) { |
|
517 | 517 | // Backwards compatibility. |
518 | - if ( func_num_args() > 1 ) { |
|
518 | + if (func_num_args() > 1) { |
|
519 | 519 | $args = func_get_args(); |
520 | 520 | |
521 | 521 | $name = $args[0]; |
522 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
523 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
524 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
522 | + $value = isset($args[1]) ? $args[1] : ''; |
|
523 | + $label = isset($args[2]) ? $args[2] : ''; |
|
524 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $defaults = array( |
528 | - 'name' => isset( $name ) ? $name : 'text', |
|
529 | - 'value' => isset( $value ) ? $value : null, |
|
530 | - 'label' => isset( $label ) ? $label : null, |
|
531 | - 'desc' => isset( $desc ) ? $desc : null, |
|
528 | + 'name' => isset($name) ? $name : 'text', |
|
529 | + 'value' => isset($value) ? $value : null, |
|
530 | + 'label' => isset($label) ? $label : null, |
|
531 | + 'desc' => isset($desc) ? $desc : null, |
|
532 | 532 | 'placeholder' => '', |
533 | 533 | 'class' => 'regular-text', |
534 | 534 | 'disabled' => false, |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | 'data' => false, |
537 | 537 | ); |
538 | 538 | |
539 | - $args = wp_parse_args( $args, $defaults ); |
|
539 | + $args = wp_parse_args($args, $defaults); |
|
540 | 540 | |
541 | 541 | $disabled = ''; |
542 | - if ( $args['disabled'] ) { |
|
542 | + if ($args['disabled']) { |
|
543 | 543 | $disabled = ' disabled="disabled"'; |
544 | 544 | } |
545 | 545 | |
546 | 546 | $data = ''; |
547 | - if ( ! empty( $args['data'] ) ) { |
|
548 | - foreach ( $args['data'] as $key => $value ) { |
|
549 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
547 | + if ( ! empty($args['data'])) { |
|
548 | + foreach ($args['data'] as $key => $value) { |
|
549 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
553 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
554 | 554 | |
555 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
555 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
556 | 556 | |
557 | - if ( ! empty( $args['desc'] ) ) { |
|
558 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
557 | + if ( ! empty($args['desc'])) { |
|
558 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
559 | 559 | } |
560 | 560 | |
561 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
561 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
562 | 562 | |
563 | 563 | $output .= '</span>'; |
564 | 564 | |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @return string The date picker. |
579 | 579 | */ |
580 | - public function date_field( $args = array() ) { |
|
580 | + public function date_field($args = array()) { |
|
581 | 581 | |
582 | - if ( empty( $args['class'] ) ) { |
|
582 | + if (empty($args['class'])) { |
|
583 | 583 | $args['class'] = 'give_datepicker'; |
584 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
584 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
585 | 585 | $args['class'] .= ' give_datepicker'; |
586 | 586 | } |
587 | 587 | |
588 | - return $this->text( $args ); |
|
588 | + return $this->text($args); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * |
601 | 601 | * @return string The textarea. |
602 | 602 | */ |
603 | - public function textarea( $args = array() ) { |
|
603 | + public function textarea($args = array()) { |
|
604 | 604 | $defaults = array( |
605 | 605 | 'name' => 'textarea', |
606 | 606 | 'value' => null, |
@@ -610,21 +610,21 @@ discard block |
||
610 | 610 | 'disabled' => false, |
611 | 611 | ); |
612 | 612 | |
613 | - $args = wp_parse_args( $args, $defaults ); |
|
613 | + $args = wp_parse_args($args, $defaults); |
|
614 | 614 | |
615 | 615 | $disabled = ''; |
616 | - if ( $args['disabled'] ) { |
|
616 | + if ($args['disabled']) { |
|
617 | 617 | $disabled = ' disabled="disabled"'; |
618 | 618 | } |
619 | 619 | |
620 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
621 | 621 | |
622 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
622 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
623 | 623 | |
624 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
624 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
625 | 625 | |
626 | - if ( ! empty( $args['desc'] ) ) { |
|
627 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
626 | + if ( ! empty($args['desc'])) { |
|
627 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | $output .= '</span>'; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @return string The text field with ajax search. |
646 | 646 | */ |
647 | - public function ajax_user_search( $args = array() ) { |
|
647 | + public function ajax_user_search($args = array()) { |
|
648 | 648 | |
649 | 649 | $defaults = array( |
650 | 650 | 'name' => 'users', |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | 'chosen' => true, |
656 | 656 | 'number' => 30, |
657 | 657 | 'select_atts' => '', |
658 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
658 | + 'placeholder' => __('Select a user', 'give'), |
|
659 | 659 | 'data' => array( |
660 | 660 | 'search-type' => 'user', |
661 | 661 | ), |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | 666 | // Set initial args. |
667 | 667 | $get_users_args = array( |
@@ -670,31 +670,31 @@ discard block |
||
670 | 670 | |
671 | 671 | // Ensure selected user is not included in initial query. |
672 | 672 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
673 | - if ( ! empty( $args['selected'] ) ) { |
|
673 | + if ( ! empty($args['selected'])) { |
|
674 | 674 | $get_users_args['exclude'] = $args['selected']; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Initial users array. |
678 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
678 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
679 | 679 | |
680 | 680 | // Now add the selected user to the $users array if the arg is present. |
681 | - if ( ! empty( $args['selected'] ) ) { |
|
682 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
683 | - $users = array_merge( $users, $selected_user ); |
|
681 | + if ( ! empty($args['selected'])) { |
|
682 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
683 | + $users = array_merge($users, $selected_user); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | $options = array(); |
687 | 687 | |
688 | - if ( $users ) { |
|
688 | + if ($users) { |
|
689 | 689 | $options[0] = $args['placeholder']; |
690 | - foreach ( $users as $user ) { |
|
691 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
690 | + foreach ($users as $user) { |
|
691 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
692 | 692 | } |
693 | 693 | } else { |
694 | - $options[0] = __( 'No users found.', 'give' ); |
|
694 | + $options[0] = __('No users found.', 'give'); |
|
695 | 695 | } |
696 | 696 | |
697 | - $output = $this->select( array( |
|
697 | + $output = $this->select(array( |
|
698 | 698 | 'name' => $args['name'], |
699 | 699 | 'selected' => $args['selected'], |
700 | 700 | 'id' => $args['id'], |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | 'show_option_all' => false, |
708 | 708 | 'show_option_none' => false, |
709 | 709 | 'data' => $args['data'], |
710 | - ) ); |
|
710 | + )); |
|
711 | 711 | |
712 | 712 | return $output; |
713 | 713 |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded. |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | public function __construct() { |
135 | 135 | |
136 | 136 | // Set parent defaults. |
137 | - parent::__construct( array( |
|
138 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
139 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
140 | - 'ajax' => false, // Does this table support ajax? |
|
141 | - ) ); |
|
137 | + parent::__construct(array( |
|
138 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
139 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
140 | + 'ajax' => false, // Does this table support ajax? |
|
141 | + )); |
|
142 | 142 | |
143 | 143 | $this->process_bulk_action(); |
144 | 144 | $this->get_payment_counts(); |
145 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
145 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,55 +151,55 @@ discard block |
||
151 | 151 | * @return void |
152 | 152 | */ |
153 | 153 | public function advanced_filters() { |
154 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
155 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null; |
|
156 | - $status = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : ''; |
|
157 | - $donor = isset( $_GET['donor'] ) ? sanitize_text_field( $_GET['donor'] ) : ''; |
|
158 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
159 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; |
|
154 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
155 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null; |
|
156 | + $status = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : ''; |
|
157 | + $donor = isset($_GET['donor']) ? sanitize_text_field($_GET['donor']) : ''; |
|
158 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
159 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0; |
|
160 | 160 | ?> |
161 | 161 | <div id="give-payment-filters" class="give-filters"> |
162 | - <?php $this->search_box( esc_html__( 'Search', 'give' ), 'give-payments' ); ?> |
|
162 | + <?php $this->search_box(esc_html__('Search', 'give'), 'give-payments'); ?> |
|
163 | 163 | <div id="give-payment-date-filters"> |
164 | 164 | <div class="give-filter give-filter-half"> |
165 | 165 | <label for="start-date" |
166 | - class="give-start-date-label"><?php esc_html_e( 'Start Date', 'give' ); ?></label> |
|
166 | + class="give-start-date-label"><?php esc_html_e('Start Date', 'give'); ?></label> |
|
167 | 167 | <input type="text" id="start-date" name="start-date" class="give_datepicker" |
168 | 168 | value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy" /> |
169 | 169 | </div> |
170 | 170 | <div class="give-filter give-filter-half"> |
171 | - <label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date', 'give' ); ?></label> |
|
171 | + <label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date', 'give'); ?></label> |
|
172 | 172 | <input type="text" id="end-date" name="end-date" class="give_datepicker" |
173 | 173 | value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy" /> |
174 | 174 | </div> |
175 | 175 | </div> |
176 | 176 | <div id="give-payment-form-filter" class="give-filter"> |
177 | 177 | <label for="give-donation-forms-filter" |
178 | - class="give-donation-forms-filter-label"><?php esc_html_e( 'Form', 'give' ); ?></label> |
|
178 | + class="give-donation-forms-filter-label"><?php esc_html_e('Form', 'give'); ?></label> |
|
179 | 179 | <?php |
180 | 180 | // Filter Donations by Donation Forms. |
181 | - echo Give()->html->forms_dropdown( array( |
|
181 | + echo Give()->html->forms_dropdown(array( |
|
182 | 182 | 'name' => 'form_id', |
183 | 183 | 'id' => 'give-donation-forms-filter', |
184 | 184 | 'class' => 'give-donation-forms-filter', |
185 | 185 | 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection. |
186 | 186 | 'chosen' => true, |
187 | - 'number' => - 1, |
|
188 | - ) ); |
|
187 | + 'number' => -1, |
|
188 | + )); |
|
189 | 189 | ?> |
190 | 190 | </div> |
191 | 191 | |
192 | - <?php if ( ! empty( $status ) ) : ?> |
|
193 | - <input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>" /> |
|
192 | + <?php if ( ! empty($status)) : ?> |
|
193 | + <input type="hidden" name="status" value="<?php echo esc_attr($status); ?>" /> |
|
194 | 194 | <?php endif; ?> |
195 | 195 | |
196 | 196 | <div class="give-filter"> |
197 | - <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?> |
|
197 | + <?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?> |
|
198 | 198 | <?php |
199 | 199 | // Clear active filters button. |
200 | - if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : ?> |
|
201 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" |
|
202 | - class="button give-clear-filters-button"><?php esc_html_e( 'Clear Filters', 'give' ); ?></a> |
|
200 | + if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : ?> |
|
201 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" |
|
202 | + class="button give-clear-filters-button"><?php esc_html_e('Clear Filters', 'give'); ?></a> |
|
203 | 203 | <?php endif; ?> |
204 | 204 | </div> |
205 | 205 | </div> |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | - public function search_box( $text, $input_id ) { |
|
222 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
221 | + public function search_box($text, $input_id) { |
|
222 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - $input_id = $input_id . '-search-input'; |
|
226 | + $input_id = $input_id.'-search-input'; |
|
227 | 227 | |
228 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
229 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
228 | + if ( ! empty($_REQUEST['orderby'])) { |
|
229 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
230 | 230 | } |
231 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
232 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
231 | + if ( ! empty($_REQUEST['order'])) { |
|
232 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
233 | 233 | } |
234 | 234 | ?> |
235 | 235 | <div class="give-filter give-filter-search" role="search"> |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @since 1.7 |
243 | 243 | */ |
244 | - do_action( 'give_payment_history_search' ); |
|
244 | + do_action('give_payment_history_search'); |
|
245 | 245 | ?> |
246 | 246 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
247 | 247 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
248 | - <?php submit_button( $text, 'button', false, false, array( |
|
248 | + <?php submit_button($text, 'button', false, false, array( |
|
249 | 249 | 'ID' => 'search-submit', |
250 | - ) ); ?><br /> |
|
250 | + )); ?><br /> |
|
251 | 251 | </div> |
252 | 252 | <?php |
253 | 253 | } |
@@ -261,52 +261,52 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function get_views() { |
263 | 263 | |
264 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
264 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
265 | 265 | $views = array(); |
266 | 266 | $tabs = array( |
267 | 267 | 'all' => array( |
268 | 268 | 'total_count', |
269 | - esc_html__( 'All', 'give' ), |
|
269 | + esc_html__('All', 'give'), |
|
270 | 270 | ), |
271 | 271 | 'publish' => array( |
272 | 272 | 'complete_count', |
273 | - esc_html__( 'Completed', 'give' ), |
|
273 | + esc_html__('Completed', 'give'), |
|
274 | 274 | ), |
275 | 275 | 'pending' => array( |
276 | 276 | 'pending_count', |
277 | - esc_html__( 'Pending', 'give' ), |
|
277 | + esc_html__('Pending', 'give'), |
|
278 | 278 | ), |
279 | 279 | 'processing' => array( |
280 | 280 | 'processing_count', |
281 | - esc_html__( 'Processing', 'give' ), |
|
281 | + esc_html__('Processing', 'give'), |
|
282 | 282 | ), |
283 | 283 | 'refunded' => array( |
284 | 284 | 'refunded_count', |
285 | - esc_html__( 'Refunded', 'give' ), |
|
285 | + esc_html__('Refunded', 'give'), |
|
286 | 286 | ), |
287 | 287 | 'revoked' => array( |
288 | 288 | 'revoked_count', |
289 | - esc_html__( 'Revoked', 'give' ), |
|
289 | + esc_html__('Revoked', 'give'), |
|
290 | 290 | ), |
291 | 291 | 'failed' => array( |
292 | 292 | 'failed_count', |
293 | - esc_html__( 'Failed', 'give' ), |
|
293 | + esc_html__('Failed', 'give'), |
|
294 | 294 | ), |
295 | 295 | 'cancelled' => array( |
296 | 296 | 'cancelled_count', |
297 | - esc_html__( 'Cancelled', 'give' ), |
|
297 | + esc_html__('Cancelled', 'give'), |
|
298 | 298 | ), |
299 | 299 | 'abandoned' => array( |
300 | 300 | 'abandoned_count', |
301 | - esc_html__( 'Abandoned', 'give' ), |
|
301 | + esc_html__('Abandoned', 'give'), |
|
302 | 302 | ), |
303 | 303 | 'preapproval' => array( |
304 | 304 | 'preapproval_count', |
305 | - esc_html__( 'Preapproval Pending', 'give' ), |
|
305 | + esc_html__('Preapproval Pending', 'give'), |
|
306 | 306 | ), |
307 | 307 | ); |
308 | 308 | |
309 | - foreach ( $tabs as $key => $tab ) { |
|
309 | + foreach ($tabs as $key => $tab) { |
|
310 | 310 | $count_key = $tab[0]; |
311 | 311 | $name = $tab[1]; |
312 | 312 | $count = $this->$count_key; |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * @param string $key Current view tab value. |
322 | 322 | * @param int $count Number of donation inside the tab. |
323 | 323 | */ |
324 | - if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) { |
|
324 | + if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) { |
|
325 | 325 | |
326 | - $views[ $key ] = sprintf( |
|
326 | + $views[$key] = sprintf( |
|
327 | 327 | '<a href="%s" %s >%s <span class="count">(%s)</span></a>', |
328 | - esc_url( ( 'all' === (string) $key ) ? remove_query_arg( array( 'status', 'paged' ) ) : add_query_arg( array( 'status' => $key, 'paged' => false ), admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ) ) ), |
|
329 | - ( ( 'all' === $key && empty( $current ) ) ) ? 'class="current"' : ( $current == $key ) ? 'class="current"' : '', |
|
328 | + esc_url(('all' === (string) $key) ? remove_query_arg(array('status', 'paged')) : add_query_arg(array('status' => $key, 'paged' => false), admin_url('edit.php?post_type=give_forms&page=give-payment-history'))), |
|
329 | + (('all' === $key && empty($current))) ? 'class="current"' : ($current == $key) ? 'class="current"' : '', |
|
330 | 330 | $name, |
331 | 331 | $count |
332 | 332 | ); |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - return apply_filters( 'give_payments_table_views', $views ); |
|
336 | + return apply_filters('give_payments_table_views', $views); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | public function get_columns() { |
347 | 347 | $columns = array( |
348 | 348 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
349 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
350 | - 'donation_form' => esc_html__( 'Donation Form', 'give' ), |
|
351 | - 'status' => esc_html__( 'Status', 'give' ), |
|
352 | - 'date' => esc_html__( 'Date', 'give' ), |
|
353 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
354 | - 'details' => esc_html__( 'Details', 'give' ), |
|
349 | + 'donation' => esc_html__('Donation', 'give'), |
|
350 | + 'donation_form' => esc_html__('Donation Form', 'give'), |
|
351 | + 'status' => esc_html__('Status', 'give'), |
|
352 | + 'date' => esc_html__('Date', 'give'), |
|
353 | + 'amount' => esc_html__('Amount', 'give'), |
|
354 | + 'details' => esc_html__('Details', 'give'), |
|
355 | 355 | ); |
356 | 356 | |
357 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
357 | + return apply_filters('give_payments_table_columns', $columns); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function get_sortable_columns() { |
368 | 368 | $columns = array( |
369 | - 'donation' => array( 'ID', true ), |
|
370 | - 'donation_form' => array( 'donation_form', false ), |
|
371 | - 'status' => array( 'status', false ), |
|
372 | - 'amount' => array( 'amount', false ), |
|
373 | - 'date' => array( 'date', false ), |
|
369 | + 'donation' => array('ID', true), |
|
370 | + 'donation_form' => array('donation_form', false), |
|
371 | + 'status' => array('status', false), |
|
372 | + 'amount' => array('amount', false), |
|
373 | + 'date' => array('date', false), |
|
374 | 374 | ); |
375 | 375 | |
376 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
376 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -399,55 +399,55 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string Column Name |
401 | 401 | */ |
402 | - public function column_default( $payment, $column_name ) { |
|
402 | + public function column_default($payment, $column_name) { |
|
403 | 403 | |
404 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) ); |
|
405 | - $row_actions = $this->get_row_actions( $payment ); |
|
404 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details'))); |
|
405 | + $row_actions = $this->get_row_actions($payment); |
|
406 | 406 | |
407 | - switch ( $column_name ) { |
|
407 | + switch ($column_name) { |
|
408 | 408 | case 'donation' : |
409 | - $value = sprintf( '<a href="%1$s" data-tooltip="%2$s">#%3$s</a> %4$s %5$s<br>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ), $payment->ID, esc_html__( 'by', 'give' ), $this->get_donor( $payment ) ); |
|
410 | - $value .= $this->get_donor_email( $payment ); |
|
411 | - $value .= $this->row_actions( $row_actions ); |
|
409 | + $value = sprintf('<a href="%1$s" data-tooltip="%2$s">#%3$s</a> %4$s %5$s<br>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID), $payment->ID, esc_html__('by', 'give'), $this->get_donor($payment)); |
|
410 | + $value .= $this->get_donor_email($payment); |
|
411 | + $value .= $this->row_actions($row_actions); |
|
412 | 412 | break; |
413 | 413 | |
414 | 414 | case 'amount' : |
415 | - $amount = ! empty( $payment->total ) ? $payment->total : 0; |
|
416 | - $value = give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false, 'donation_id' => $payment->ID ) ), give_get_payment_currency_code( $payment->ID ) ); |
|
417 | - $value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) ); |
|
415 | + $amount = ! empty($payment->total) ? $payment->total : 0; |
|
416 | + $value = give_currency_filter(give_format_amount($amount, array('sanitize' => false, 'donation_id' => $payment->ID)), give_get_payment_currency_code($payment->ID)); |
|
417 | + $value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway)); |
|
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'donation_form' : |
421 | - $form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title; |
|
422 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>'; |
|
423 | - $level = give_get_payment_form_title( $payment->meta, true ); |
|
421 | + $form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title; |
|
422 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>'; |
|
423 | + $level = give_get_payment_form_title($payment->meta, true); |
|
424 | 424 | |
425 | - if ( ! empty( $level ) ) { |
|
425 | + if ( ! empty($level)) { |
|
426 | 426 | $value .= $level; |
427 | 427 | } |
428 | 428 | |
429 | 429 | break; |
430 | 430 | |
431 | 431 | case 'date' : |
432 | - $date = strtotime( $payment->date ); |
|
433 | - $value = date_i18n( give_date_format(), $date ); |
|
432 | + $date = strtotime($payment->date); |
|
433 | + $value = date_i18n(give_date_format(), $date); |
|
434 | 434 | break; |
435 | 435 | |
436 | 436 | case 'status' : |
437 | - $value = $this->get_payment_status( $payment ); |
|
437 | + $value = $this->get_payment_status($payment); |
|
438 | 438 | break; |
439 | 439 | |
440 | 440 | case 'details' : |
441 | - $value = sprintf( '<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ) ); |
|
441 | + $value = sprintf('<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID)); |
|
442 | 442 | break; |
443 | 443 | |
444 | 444 | default: |
445 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
445 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
446 | 446 | break; |
447 | 447 | |
448 | 448 | }// End switch(). |
449 | 449 | |
450 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
450 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return string Data shown in the Email column |
462 | 462 | */ |
463 | - public function get_donor_email( $payment ) { |
|
463 | + public function get_donor_email($payment) { |
|
464 | 464 | |
465 | - $email = give_get_payment_user_email( $payment->ID ); |
|
465 | + $email = give_get_payment_user_email($payment->ID); |
|
466 | 466 | |
467 | - if ( empty( $email ) ) { |
|
468 | - $email = esc_html__( '(unknown)', 'give' ); |
|
467 | + if (empty($email)) { |
|
468 | + $email = esc_html__('(unknown)', 'give'); |
|
469 | 469 | } |
470 | 470 | |
471 | - $value = '<a href="mailto:' . $email . '" data-tooltip="' . esc_attr__( 'Email donor', 'give' ) . '">' . $email . '</a>'; |
|
471 | + $value = '<a href="mailto:'.$email.'" data-tooltip="'.esc_attr__('Email donor', 'give').'">'.$email.'</a>'; |
|
472 | 472 | |
473 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
473 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -482,32 +482,32 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @return array $actions |
484 | 484 | */ |
485 | - function get_row_actions( $payment ) { |
|
485 | + function get_row_actions($payment) { |
|
486 | 486 | |
487 | 487 | $actions = array(); |
488 | - $email = give_get_payment_user_email( $payment->ID ); |
|
488 | + $email = give_get_payment_user_email($payment->ID); |
|
489 | 489 | |
490 | 490 | // Add search term string back to base URL. |
491 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
492 | - if ( ! empty( $search_terms ) ) { |
|
493 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
491 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
492 | + if ( ! empty($search_terms)) { |
|
493 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
494 | 494 | } |
495 | 495 | |
496 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
496 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
497 | 497 | |
498 | - $actions['email_links'] = sprintf( '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array( |
|
498 | + $actions['email_links'] = sprintf('<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array( |
|
499 | 499 | 'give-action' => 'email_links', |
500 | 500 | 'purchase_id' => $payment->ID, |
501 | - ), $this->base_url ), 'give_payment_nonce' ), sprintf( esc_attr__( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), esc_html__( 'Resend Receipt', 'give' ) ); |
|
501 | + ), $this->base_url), 'give_payment_nonce'), sprintf(esc_attr__('Resend Donation %s Receipt', 'give'), $payment->ID), esc_html__('Resend Receipt', 'give')); |
|
502 | 502 | |
503 | 503 | } |
504 | 504 | |
505 | - $actions['delete'] = sprintf( '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array( |
|
505 | + $actions['delete'] = sprintf('<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array( |
|
506 | 506 | 'give-action' => 'delete_payment', |
507 | 507 | 'purchase_id' => $payment->ID, |
508 | - ), $this->base_url ), 'give_donation_nonce' ), sprintf( esc_attr__( 'Delete Donation %s', 'give' ), $payment->ID ), esc_html__( 'Delete', 'give' ) ); |
|
508 | + ), $this->base_url), 'give_donation_nonce'), sprintf(esc_attr__('Delete Donation %s', 'give'), $payment->ID), esc_html__('Delete', 'give')); |
|
509 | 509 | |
510 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
510 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string Data shown in the Email column |
523 | 523 | */ |
524 | - function get_payment_status( $payment ) { |
|
525 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
526 | - if ( $payment->mode == 'test' ) { |
|
527 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
524 | + function get_payment_status($payment) { |
|
525 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
526 | + if ($payment->mode == 'test') { |
|
527 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
528 | 528 | } |
529 | 529 | |
530 | - if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) { |
|
531 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was imported.', 'give' ) . '">' . esc_html__( 'Import', 'give' ) . '</span>'; |
|
530 | + if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) { |
|
531 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was imported.', 'give').'">'.esc_html__('Import', 'give').'</span>'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | return $value; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return string Displays a checkbox. |
546 | 546 | */ |
547 | - public function column_cb( $payment ) { |
|
548 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID ); |
|
547 | + public function column_cb($payment) { |
|
548 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string Displays a checkbox. |
560 | 560 | */ |
561 | - public function get_payment_id( $payment ) { |
|
562 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
561 | + public function get_payment_id($payment) { |
|
562 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -572,32 +572,32 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return string Data shown in the User column |
574 | 574 | */ |
575 | - public function get_donor( $payment ) { |
|
575 | + public function get_donor($payment) { |
|
576 | 576 | |
577 | - $donor_id = give_get_payment_donor_id( $payment->ID ); |
|
578 | - $donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' ); |
|
579 | - $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
|
577 | + $donor_id = give_get_payment_donor_id($payment->ID); |
|
578 | + $donor_billing_name = give_get_donor_name_by($payment->ID, 'donation'); |
|
579 | + $donor_name = give_get_donor_name_by($donor_id, 'donor'); |
|
580 | 580 | |
581 | 581 | $value = ''; |
582 | - if ( ! empty( $donor_id ) ) { |
|
582 | + if ( ! empty($donor_id)) { |
|
583 | 583 | |
584 | 584 | // Check whether the donor name and WP_User name is same or not. |
585 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
586 | - $value .= $donor_billing_name . ' ('; |
|
585 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
586 | + $value .= $donor_billing_name.' ('; |
|
587 | 587 | } |
588 | 588 | |
589 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>'; |
|
589 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>'; |
|
590 | 590 | |
591 | 591 | // Check whether the donor name and WP_User name is same or not. |
592 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
592 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
593 | 593 | $value .= ')'; |
594 | 594 | } |
595 | 595 | } else { |
596 | - $email = give_get_payment_user_email( $payment->ID ); |
|
597 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html__( '(donor missing)', 'give' ) . '</a>'; |
|
596 | + $email = give_get_payment_user_email($payment->ID); |
|
597 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html__('(donor missing)', 'give').'</a>'; |
|
598 | 598 | } |
599 | 599 | |
600 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
600 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -609,20 +609,20 @@ discard block |
||
609 | 609 | */ |
610 | 610 | public function get_bulk_actions() { |
611 | 611 | $actions = array( |
612 | - 'delete' => __( 'Delete', 'give' ), |
|
613 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
614 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
615 | - 'set-status-processing' => __( 'Set To Processing', 'give' ), |
|
616 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
617 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
618 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
619 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
620 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
621 | - 'set-status-preapproval' => __( 'Set To Preapproval', 'give' ), |
|
622 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ), |
|
612 | + 'delete' => __('Delete', 'give'), |
|
613 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
614 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
615 | + 'set-status-processing' => __('Set To Processing', 'give'), |
|
616 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
617 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
618 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
619 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
620 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
621 | + 'set-status-preapproval' => __('Set To Preapproval', 'give'), |
|
622 | + 'resend-receipt' => __('Resend Email Receipts', 'give'), |
|
623 | 623 | ); |
624 | 624 | |
625 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
625 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -633,63 +633,63 @@ discard block |
||
633 | 633 | * @return void |
634 | 634 | */ |
635 | 635 | public function process_bulk_action() { |
636 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
636 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
637 | 637 | $action = $this->current_action(); |
638 | 638 | |
639 | - if ( ! is_array( $ids ) ) { |
|
640 | - $ids = array( $ids ); |
|
639 | + if ( ! is_array($ids)) { |
|
640 | + $ids = array($ids); |
|
641 | 641 | } |
642 | 642 | |
643 | - if ( empty( $action ) ) { |
|
643 | + if (empty($action)) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
647 | - foreach ( $ids as $id ) { |
|
647 | + foreach ($ids as $id) { |
|
648 | 648 | |
649 | 649 | // Detect when a bulk action is being triggered. |
650 | - switch ( $this->current_action() ) { |
|
650 | + switch ($this->current_action()) { |
|
651 | 651 | |
652 | 652 | case'delete': |
653 | - give_delete_donation( $id ); |
|
653 | + give_delete_donation($id); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'set-status-publish': |
657 | - give_update_payment_status( $id, 'publish' ); |
|
657 | + give_update_payment_status($id, 'publish'); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'set-status-pending': |
661 | - give_update_payment_status( $id, 'pending' ); |
|
661 | + give_update_payment_status($id, 'pending'); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'set-status-processing': |
665 | - give_update_payment_status( $id, 'processing' ); |
|
665 | + give_update_payment_status($id, 'processing'); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'set-status-refunded': |
669 | - give_update_payment_status( $id, 'refunded' ); |
|
669 | + give_update_payment_status($id, 'refunded'); |
|
670 | 670 | break; |
671 | 671 | case 'set-status-revoked': |
672 | - give_update_payment_status( $id, 'revoked' ); |
|
672 | + give_update_payment_status($id, 'revoked'); |
|
673 | 673 | break; |
674 | 674 | |
675 | 675 | case 'set-status-failed': |
676 | - give_update_payment_status( $id, 'failed' ); |
|
676 | + give_update_payment_status($id, 'failed'); |
|
677 | 677 | break; |
678 | 678 | |
679 | 679 | case 'set-status-cancelled': |
680 | - give_update_payment_status( $id, 'cancelled' ); |
|
680 | + give_update_payment_status($id, 'cancelled'); |
|
681 | 681 | break; |
682 | 682 | |
683 | 683 | case 'set-status-abandoned': |
684 | - give_update_payment_status( $id, 'abandoned' ); |
|
684 | + give_update_payment_status($id, 'abandoned'); |
|
685 | 685 | break; |
686 | 686 | |
687 | 687 | case 'set-status-preapproval': |
688 | - give_update_payment_status( $id, 'preapproval' ); |
|
688 | + give_update_payment_status($id, 'preapproval'); |
|
689 | 689 | break; |
690 | 690 | |
691 | 691 | case 'resend-receipt': |
692 | - give_email_donation_receipt( $id, false ); |
|
692 | + give_email_donation_receipt($id, false); |
|
693 | 693 | break; |
694 | 694 | }// End switch(). |
695 | 695 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param int $id The ID of the payment. |
702 | 702 | * @param string $current_action The action that is being triggered. |
703 | 703 | */ |
704 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
704 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
705 | 705 | }// End foreach(). |
706 | 706 | |
707 | 707 | } |
@@ -717,31 +717,31 @@ discard block |
||
717 | 717 | |
718 | 718 | $args = array(); |
719 | 719 | |
720 | - if ( isset( $_GET['user'] ) ) { |
|
721 | - $args['user'] = urldecode( $_GET['user'] ); |
|
722 | - } elseif ( isset( $_GET['donor'] ) ) { |
|
723 | - $args['donor'] = absint( $_GET['donor'] ); |
|
724 | - } elseif ( isset( $_GET['s'] ) ) { |
|
725 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
726 | - if ( $is_user ) { |
|
727 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
728 | - unset( $args['s'] ); |
|
720 | + if (isset($_GET['user'])) { |
|
721 | + $args['user'] = urldecode($_GET['user']); |
|
722 | + } elseif (isset($_GET['donor'])) { |
|
723 | + $args['donor'] = absint($_GET['donor']); |
|
724 | + } elseif (isset($_GET['s'])) { |
|
725 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
726 | + if ($is_user) { |
|
727 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
728 | + unset($args['s']); |
|
729 | 729 | } else { |
730 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
730 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
735 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
734 | + if ( ! empty($_GET['start-date'])) { |
|
735 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
736 | 736 | } |
737 | 737 | |
738 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
739 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
738 | + if ( ! empty($_GET['end-date'])) { |
|
739 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
740 | 740 | } |
741 | 741 | |
742 | - $args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
742 | + $args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
743 | 743 | |
744 | - $payment_count = give_count_payments( $args ); |
|
744 | + $payment_count = give_count_payments($args); |
|
745 | 745 | $this->complete_count = $payment_count->publish; |
746 | 746 | $this->pending_count = $payment_count->pending; |
747 | 747 | $this->processing_count = $payment_count->processing; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $this->abandoned_count = $payment_count->abandoned; |
753 | 753 | $this->preapproval_count = $payment_count->preapproval; |
754 | 754 | |
755 | - foreach ( $payment_count as $count ) { |
|
755 | + foreach ($payment_count as $count) { |
|
756 | 756 | $this->total_count += $count; |
757 | 757 | } |
758 | 758 | } |
@@ -767,28 +767,28 @@ discard block |
||
767 | 767 | public function payments_data() { |
768 | 768 | |
769 | 769 | $per_page = $this->per_page; |
770 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
771 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
772 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
773 | - $donor = isset( $_GET['donor'] ) ? $_GET['donor'] : null; |
|
774 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
775 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
776 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
777 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
778 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
779 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
780 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
781 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
782 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
783 | - |
|
784 | - if ( ! empty( $search ) ) { |
|
770 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
771 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
772 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
773 | + $donor = isset($_GET['donor']) ? $_GET['donor'] : null; |
|
774 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
775 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
776 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
777 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
778 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
779 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
780 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
781 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
782 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
783 | + |
|
784 | + if ( ! empty($search)) { |
|
785 | 785 | $status = 'any'; // Force all payment statuses when searching. |
786 | 786 | } |
787 | 787 | |
788 | 788 | $args = array( |
789 | 789 | 'output' => 'payments', |
790 | 790 | 'number' => $per_page, |
791 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
791 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
792 | 792 | 'orderby' => $orderby, |
793 | 793 | 'order' => $order, |
794 | 794 | 'user' => $user, |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | 'give_forms' => $form_id, |
805 | 805 | ); |
806 | 806 | |
807 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
807 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
808 | 808 | $args['search_in_notes'] = true; |
809 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
809 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
810 | 810 | } |
811 | 811 | |
812 | - $p_query = new Give_Payments_Query( $args ); |
|
812 | + $p_query = new Give_Payments_Query($args); |
|
813 | 813 | |
814 | 814 | return $p_query->get_payments(); |
815 | 815 | |
@@ -829,17 +829,17 @@ discard block |
||
829 | 829 | */ |
830 | 830 | public function prepare_items() { |
831 | 831 | |
832 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
832 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
833 | 833 | |
834 | 834 | $columns = $this->get_columns(); |
835 | 835 | $hidden = array(); // No hidden columns. |
836 | 836 | $sortable = $this->get_sortable_columns(); |
837 | 837 | $data = $this->payments_data(); |
838 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
838 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
839 | 839 | |
840 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
840 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
841 | 841 | |
842 | - switch ( $status ) { |
|
842 | + switch ($status) { |
|
843 | 843 | case 'publish': |
844 | 844 | $total_items = $this->complete_count; |
845 | 845 | break; |
@@ -872,20 +872,20 @@ discard block |
||
872 | 872 | break; |
873 | 873 | default: |
874 | 874 | // Retrieve the count of the non-default-Give status. |
875 | - $count = wp_count_posts( 'give_payment' ); |
|
876 | - $total_items = isset( $count->{$status} ) ? $count->{$status} : 0; |
|
875 | + $count = wp_count_posts('give_payment'); |
|
876 | + $total_items = isset($count->{$status} ) ? $count->{$status} : 0; |
|
877 | 877 | break; |
878 | 878 | } |
879 | 879 | |
880 | 880 | $this->items = $data; |
881 | 881 | |
882 | - $this->set_pagination_args( array( |
|
882 | + $this->set_pagination_args(array( |
|
883 | 883 | 'total_items' => $total_items, |
884 | 884 | // We have to calculate the total number of items. |
885 | 885 | 'per_page' => $this->per_page, |
886 | 886 | // We have to determine how many items to show on a page. |
887 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
887 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
888 | 888 | // We have to calculate the total number of pages. |
889 | - ) ); |
|
889 | + )); |
|
890 | 890 | } |
891 | 891 | } |