@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
61 | + do_action('give_pre_complete_purchase', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_purchase_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_purchase_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $customer = new Give_Customer( $customer_id ); |
|
89 | + $customer = new Give_Customer($customer_id); |
|
90 | 90 | $customer->increase_purchase_count(); |
91 | - $customer->increase_value( $amount ); |
|
91 | + $customer->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | 136 | $status_change = sprintf( |
137 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
137 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
138 | 138 | $old_status, |
139 | 139 | $new_status |
140 | 140 | ); |
141 | 141 | |
142 | - give_insert_payment_note( $payment_id, $status_change ); |
|
142 | + give_insert_payment_note($payment_id, $status_change); |
|
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
145 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** |
@@ -158,25 +158,25 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return void |
160 | 160 | */ |
161 | -function give_update_old_payments_with_totals( $data ) { |
|
162 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
161 | +function give_update_old_payments_with_totals($data) { |
|
162 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
166 | + if (get_option('give_payment_totals_upgraded')) { |
|
167 | 167 | return; |
168 | 168 | } |
169 | 169 | |
170 | - $payments = give_get_payments( array( |
|
170 | + $payments = give_get_payments(array( |
|
171 | 171 | 'offset' => 0, |
172 | - 'number' => - 1, |
|
172 | + 'number' => -1, |
|
173 | 173 | 'mode' => 'all', |
174 | - ) ); |
|
174 | + )); |
|
175 | 175 | |
176 | - if ( $payments ) { |
|
177 | - foreach ( $payments as $payment ) { |
|
176 | + if ($payments) { |
|
177 | + foreach ($payments as $payment) { |
|
178 | 178 | |
179 | - $payment = new Give_Payment( $payment->ID ); |
|
179 | + $payment = new Give_Payment($payment->ID); |
|
180 | 180 | $meta = $payment->get_meta(); |
181 | 181 | |
182 | 182 | $payment->total = $meta['amount']; |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
188 | + add_option('give_payment_totals_upgraded', 1); |
|
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
191 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Mark Abandoned Donations |
@@ -202,17 +202,17 @@ discard block |
||
202 | 202 | function give_mark_abandoned_donations() { |
203 | 203 | $args = array( |
204 | 204 | 'status' => 'pending', |
205 | - 'number' => - 1, |
|
205 | + 'number' => -1, |
|
206 | 206 | 'output' => 'give_payments', |
207 | 207 | ); |
208 | 208 | |
209 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - $payments = give_get_payments( $args ); |
|
211 | + $payments = give_get_payments($args); |
|
212 | 212 | |
213 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
213 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
214 | 214 | |
215 | - if ( $payments ) { |
|
215 | + if ($payments) { |
|
216 | 216 | /** |
217 | 217 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
218 | 218 | * |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param array $skip_payment_gateways Array of payment gateways |
222 | 222 | */ |
223 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
223 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
224 | 224 | |
225 | - foreach ( $payments as $payment ) { |
|
226 | - $gateway = give_get_payment_gateway( $payment ); |
|
225 | + foreach ($payments as $payment) { |
|
226 | + $gateway = give_get_payment_gateway($payment); |
|
227 | 227 | |
228 | 228 | // Skip payment gateways. |
229 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
229 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
239 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
240 | 240 | |
241 | 241 | |
242 | 242 | /** |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return void |
250 | 250 | */ |
251 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
251 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
252 | 252 | // Monthly stats. |
253 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
253 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
254 | 254 | |
255 | 255 | // @todo: Refresh only range related stat cache |
256 | 256 | give_delete_donation_stats(); |
257 | 257 | } |
258 | 258 | |
259 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
259 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option('thousands_separator', ','); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option('decimal_separator', '.'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -61,67 +61,67 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string $amount Newly sanitized amount |
63 | 63 | */ |
64 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
64 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
65 | 65 | |
66 | 66 | // Bailout. |
67 | - if ( empty( $number ) ) { |
|
67 | + if (empty($number)) { |
|
68 | 68 | return $number; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Remove slash from amount. |
72 | 72 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
73 | 73 | // To prevent notices and warning remove slash from amount/number. |
74 | - $number = wp_unslash( $number ); |
|
74 | + $number = wp_unslash($number); |
|
75 | 75 | |
76 | 76 | $thousand_separator = give_get_price_thousand_separator(); |
77 | 77 | |
78 | 78 | $locale = localeconv(); |
79 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
79 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
80 | 80 | |
81 | 81 | // Remove locale from string |
82 | - if ( ! is_float( $number ) ) { |
|
83 | - $number = str_replace( $decimals, '.', $number ); |
|
82 | + if ( ! is_float($number)) { |
|
83 | + $number = str_replace($decimals, '.', $number); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Remove thousand amount formatting if amount has. |
87 | 87 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
88 | 88 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
89 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
90 | - $number = str_replace( $thousand_separator, '', $number ); |
|
91 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
92 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
89 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
90 | + $number = str_replace($thousand_separator, '', $number); |
|
91 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
92 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Remove non numeric entity before decimal separator. |
96 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
96 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
97 | 97 | $default_dp = give_get_price_decimals(); |
98 | 98 | |
99 | 99 | // Reset negative amount to zero. |
100 | - if ( 0 > $number ) { |
|
101 | - $number = number_format( 0, $default_dp, '.' ); |
|
100 | + if (0 > $number) { |
|
101 | + $number = number_format(0, $default_dp, '.'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // If number does not have decimal then add number of decimals to it. |
105 | 105 | if ( |
106 | - false === strpos( $number, '.' ) |
|
107 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
106 | + false === strpos($number, '.') |
|
107 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
108 | 108 | ) { |
109 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
109 | + $number = number_format($number, $default_dp, '.', ''); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Format number by custom number of decimals. |
113 | - if ( false !== $dp ) { |
|
114 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
115 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
116 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
113 | + if (false !== $dp) { |
|
114 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
115 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
116 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Trim zeros. |
120 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
121 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
120 | + if ($trim_zeros && strstr($number, '.')) { |
|
121 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
124 | + return apply_filters('give_sanitize_amount', $number); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return string $amount Newly formatted amount or Price Not Available |
136 | 136 | */ |
137 | -function give_format_amount( $amount, $decimals = true ) { |
|
138 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
139 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
137 | +function give_format_amount($amount, $decimals = true) { |
|
138 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
139 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
140 | 140 | |
141 | - if ( empty( $amount ) ) { |
|
141 | + if (empty($amount)) { |
|
142 | 142 | $amount = 0; |
143 | 143 | } else { |
144 | 144 | // Sanitize amount before formatting. |
145 | - $amount = give_sanitize_amount( $amount ); |
|
145 | + $amount = give_sanitize_amount($amount); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $decimals = $decimals ? give_get_price_decimals() : 0; |
149 | 149 | |
150 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
150 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
151 | 151 | |
152 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
152 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -166,33 +166,33 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return float|string formatted amount number with large number names. |
168 | 168 | */ |
169 | -function give_human_format_large_amount( $amount ) { |
|
169 | +function give_human_format_large_amount($amount) { |
|
170 | 170 | |
171 | 171 | // Get thousand separator. |
172 | 172 | $thousands_sep = give_get_price_thousand_separator(); |
173 | 173 | |
174 | 174 | // Sanitize amount. |
175 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
175 | + $sanitize_amount = give_sanitize_amount($amount); |
|
176 | 176 | |
177 | 177 | // Explode amount to calculate name of large numbers. |
178 | - $amount_array = explode( $thousands_sep, $amount ); |
|
178 | + $amount_array = explode($thousands_sep, $amount); |
|
179 | 179 | |
180 | 180 | // Calculate amount parts count. |
181 | - $amount_count_parts = count( $amount_array ); |
|
181 | + $amount_count_parts = count($amount_array); |
|
182 | 182 | |
183 | 183 | // Human format amount (default). |
184 | 184 | $human_format_amount = $amount; |
185 | 185 | |
186 | 186 | // Calculate large number formatted amount. |
187 | - if ( 4 < $amount_count_parts ) { |
|
188 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
189 | - } elseif ( 3 < $amount_count_parts ) { |
|
190 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
191 | - } elseif ( 2 < $amount_count_parts ) { |
|
192 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
187 | + if (4 < $amount_count_parts) { |
|
188 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
189 | + } elseif (3 < $amount_count_parts) { |
|
190 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
191 | + } elseif (2 < $amount_count_parts) { |
|
192 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
193 | 193 | } |
194 | 194 | |
195 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
195 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return string $amount Newly formatted amount or Price Not Available |
207 | 207 | */ |
208 | -function give_format_decimal( $amount, $dp = false ) { |
|
208 | +function give_format_decimal($amount, $dp = false) { |
|
209 | 209 | $decimal_separator = give_get_price_decimal_separator(); |
210 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
210 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
211 | 211 | |
212 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
213 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
212 | + if (false !== strpos($formatted_amount, '.')) { |
|
213 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
214 | 214 | } |
215 | 215 | |
216 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
216 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return mixed|string |
228 | 228 | */ |
229 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
229 | +function give_currency_filter($price = '', $currency = '') { |
|
230 | 230 | |
231 | - if ( empty( $currency ) ) { |
|
231 | + if (empty($currency)) { |
|
232 | 232 | $currency = give_get_currency(); |
233 | 233 | } |
234 | 234 | |
235 | - $position = give_get_option( 'currency_position', 'before' ); |
|
235 | + $position = give_get_option('currency_position', 'before'); |
|
236 | 236 | |
237 | 237 | $negative = $price < 0; |
238 | 238 | |
239 | - if ( $negative ) { |
|
239 | + if ($negative) { |
|
240 | 240 | // Remove proceeding "-". |
241 | - $price = substr( $price, 1 ); |
|
241 | + $price = substr($price, 1); |
|
242 | 242 | } |
243 | 243 | |
244 | - $symbol = give_currency_symbol( $currency ); |
|
244 | + $symbol = give_currency_symbol($currency); |
|
245 | 245 | |
246 | - switch ( $currency ) : |
|
246 | + switch ($currency) : |
|
247 | 247 | case 'GBP' : |
248 | 248 | case 'BRL' : |
249 | 249 | case 'EUR' : |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | case 'MAD' : |
273 | 273 | case 'KRW' : |
274 | 274 | case 'ZAR' : |
275 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
275 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
276 | 276 | break; |
277 | 277 | case 'NOK' : |
278 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
278 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
279 | 279 | break; |
280 | 280 | default : |
281 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
281 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
282 | 282 | break; |
283 | 283 | endswitch; |
284 | 284 | |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * and if currency is USD and currency position is after then |
294 | 294 | * filter name will be give_usd_currency_filter_after |
295 | 295 | */ |
296 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
296 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
297 | 297 | |
298 | - if ( $negative ) { |
|
298 | + if ($negative) { |
|
299 | 299 | // Prepend the minus sign before the currency sign. |
300 | - $formatted = '-' . $formatted; |
|
300 | + $formatted = '-'.$formatted; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return $formatted; |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function give_currency_decimal_filter() { |
315 | 315 | |
316 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
316 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
317 | 317 | |
318 | 318 | // Set default number of decimals. |
319 | 319 | $decimals = give_get_price_decimals(); |
320 | 320 | |
321 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
321 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
322 | 322 | |
323 | 323 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
324 | - if ( 1 <= func_num_args() ) { |
|
325 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
324 | + if (1 <= func_num_args()) { |
|
325 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $currency = give_get_currency(); |
329 | 329 | |
330 | - switch ( $currency ) { |
|
330 | + switch ($currency) { |
|
331 | 331 | case 'RIAL' : |
332 | 332 | case 'JPY' : |
333 | 333 | case 'TWD' : |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | break; |
338 | 338 | } |
339 | 339 | |
340 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
340 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
341 | 341 | } |
342 | 342 | |
343 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
344 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
343 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
344 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
345 | 345 | |
346 | 346 | |
347 | 347 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string Date format string |
355 | 355 | */ |
356 | -function give_date_format( $date_context = '' ) { |
|
356 | +function give_date_format($date_context = '') { |
|
357 | 357 | /** |
358 | 358 | * Filter the date context |
359 | 359 | * |
@@ -374,19 +374,19 @@ discard block |
||
374 | 374 | * |
375 | 375 | * } |
376 | 376 | */ |
377 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
377 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
378 | 378 | |
379 | 379 | // Set date format to default date format. |
380 | - $date_format = get_option( 'date_format' ); |
|
380 | + $date_format = get_option('date_format'); |
|
381 | 381 | |
382 | 382 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
383 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
384 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
385 | - ? $date_format_contexts[ $date_context ] |
|
383 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
384 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
385 | + ? $date_format_contexts[$date_context] |
|
386 | 386 | : $date_format; |
387 | 387 | } |
388 | 388 | |
389 | - return apply_filters( 'give_date_format', $date_format ); |
|
389 | + return apply_filters('give_date_format', $date_format); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string |
402 | 402 | */ |
403 | -function give_get_cache_key( $action, $query_args ) { |
|
404 | - return Give_Cache::get_key( $action, $query_args ); |
|
403 | +function give_get_cache_key($action, $query_args) { |
|
404 | + return Give_Cache::get_key($action, $query_args); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return string|array |
416 | 416 | */ |
417 | -function give_clean( $var ) { |
|
418 | - if ( is_array( $var ) ) { |
|
419 | - return array_map( 'give_clean', $var ); |
|
417 | +function give_clean($var) { |
|
418 | + if (is_array($var)) { |
|
419 | + return array_map('give_clean', $var); |
|
420 | 420 | } else { |
421 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
421 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @return int |
433 | 433 | */ |
434 | -function give_let_to_num( $size ) { |
|
435 | - $l = substr( $size, - 1 ); |
|
436 | - $ret = substr( $size, 0, - 1 ); |
|
437 | - switch ( strtoupper( $l ) ) { |
|
434 | +function give_let_to_num($size) { |
|
435 | + $l = substr($size, - 1); |
|
436 | + $ret = substr($size, 0, - 1); |
|
437 | + switch (strtoupper($l)) { |
|
438 | 438 | case 'P': |
439 | 439 | $ret *= 1024; |
440 | 440 | case 'T': |
@@ -459,17 +459,17 @@ discard block |
||
459 | 459 | * @param int $action |
460 | 460 | * @param array $wp_die_args |
461 | 461 | */ |
462 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
462 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
463 | 463 | |
464 | 464 | $default_wp_die_args = array( |
465 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
466 | - 'title' => esc_html__( 'Error', 'give' ), |
|
467 | - 'args' => array( 'response' => 403 ), |
|
465 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
466 | + 'title' => esc_html__('Error', 'give'), |
|
467 | + 'args' => array('response' => 403), |
|
468 | 468 | ); |
469 | 469 | |
470 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
470 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
471 | 471 | |
472 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
472 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
473 | 473 | wp_die( |
474 | 474 | $wp_die_args['message'], |
475 | 475 | $wp_die_args['title'], |
@@ -491,23 +491,23 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return mixed |
493 | 493 | */ |
494 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
494 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
495 | 495 | |
496 | - switch ( $conditional ) { |
|
496 | + switch ($conditional) { |
|
497 | 497 | case 'isset_empty': |
498 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
498 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
499 | 499 | break; |
500 | 500 | |
501 | 501 | case 'empty': |
502 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
502 | + $variable = ! empty($variable) ? $variable : $default; |
|
503 | 503 | break; |
504 | 504 | |
505 | 505 | case 'null': |
506 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
506 | + $variable = ! is_null($variable) ? $variable : $default; |
|
507 | 507 | break; |
508 | 508 | |
509 | 509 | default: |
510 | - $variable = isset( $variable ) ? $variable : $default; |
|
510 | + $variable = isset($variable) ? $variable : $default; |
|
511 | 511 | |
512 | 512 | } |
513 | 513 |
@@ -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,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
31 | - if( empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function give_post_actions() { |
60 | 60 | |
61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | // Add backward compatibility to give-action param ( $_POST ) |
65 | - if( empty( $_post_action ) ) { |
|
66 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
65 | + if (empty($_post_action)) { |
|
66 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( isset( $_post_action ) ) { |
|
69 | + if (isset($_post_action)) { |
|
70 | 70 | /** |
71 | 71 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
72 | 72 | * |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array $_POST Array of HTTP POST variables. |
76 | 76 | */ |
77 | - do_action( "give_{$_post_action}", $_POST ); |
|
77 | + do_action("give_{$_post_action}", $_POST); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | -add_action( 'init', 'give_post_actions' ); |
|
82 | +add_action('init', 'give_post_actions'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Connect WordPress user with Donor. |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | * @param array $user_data User Data |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
92 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
93 | 93 | /* @var Give_Customer $donor */ |
94 | - $donor = new Give_Customer( $user_data['user_email'] ); |
|
94 | + $donor = new Give_Customer($user_data['user_email']); |
|
95 | 95 | |
96 | 96 | // Validate donor id and check if do nor is already connect to wp user or not. |
97 | - if( $donor->id && ! $donor->user_id ) { |
|
97 | + if ($donor->id && ! $donor->user_id) { |
|
98 | 98 | |
99 | 99 | // Update donor user_id. |
100 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
101 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
102 | - $donor->add_note( $donor_note ); |
|
100 | + if ($donor->update(array('user_id' => $user_id))) { |
|
101 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
102 | + $donor->add_note($donor_note); |
|
103 | 103 | |
104 | 104 | // Update user_id meta in payments. |
105 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
106 | - foreach ( $donations as $donation ) { |
|
107 | - update_post_meta( $donation, '_give_payment_user_id', $user_id ); |
|
105 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
106 | + foreach ($donations as $donation) { |
|
107 | + update_post_meta($donation, '_give_payment_user_id', $user_id); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
113 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | function give_validate_license_when_site_migrated() { |
125 | 125 | // Store current site address if not already stored. |
126 | 126 | $homeurl = home_url(); |
127 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
127 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
128 | 128 | // Update site address. |
129 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
129 | + update_option('give_site_address_before_migrate', $homeurl); |
|
130 | 130 | |
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
134 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
135 | 135 | // Immediately run cron. |
136 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
136 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
137 | 137 | |
138 | 138 | // Update site address. |
139 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
139 | + update_option('give_site_address_before_migrate', home_url()); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
144 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
143 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
144 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @since 1.8 |
151 | 151 | * @param $data |
152 | 152 | */ |
153 | -function give_donor_batch_export_complete( $data ) { |
|
153 | +function give_donor_batch_export_complete($data) { |
|
154 | 154 | // Remove donor ids cache. |
155 | - if( |
|
156 | - isset( $data['class'] ) |
|
155 | + if ( |
|
156 | + isset($data['class']) |
|
157 | 157 | && 'Give_Batch_Customers_Export' === $data['class'] |
158 | - && ! empty( $data['forms'] ) |
|
159 | - && isset( $data['give_export_option']['query_id'] ) |
|
158 | + && ! empty($data['forms']) |
|
159 | + && isset($data['give_export_option']['query_id']) |
|
160 | 160 | ) { |
161 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
161 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
162 | 162 | } |
163 | 163 | } |
164 | -add_action('give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
164 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } elseif ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } elseif (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
55 | + $args = apply_filters('give_get_users_donations_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date', |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
139 | - $completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : ''; |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | + $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1, |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1, |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool True if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int The total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | // Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
262 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
263 | 263 | |
264 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
264 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return float The total amount the user has spent |
276 | 276 | */ |
277 | -function give_purchase_total_of_user( $user = null ) { |
|
277 | +function give_purchase_total_of_user($user = null) { |
|
278 | 278 | |
279 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
279 | + $stats = give_get_purchase_stats_by_user($user); |
|
280 | 280 | |
281 | 281 | return $stats['total_spent']; |
282 | 282 | } |
@@ -292,40 +292,40 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | -function give_validate_username( $username, $form_id = 0 ) { |
|
295 | +function give_validate_username($username, $form_id = 0) { |
|
296 | 296 | $valid = true; |
297 | 297 | |
298 | 298 | // Validate username. |
299 | - if ( ! empty( $username ) ) { |
|
299 | + if ( ! empty($username)) { |
|
300 | 300 | |
301 | 301 | // Sanitize username. |
302 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
302 | + $sanitized_user_name = sanitize_user($username, false); |
|
303 | 303 | |
304 | 304 | // We have an user name, check if it already exists. |
305 | - if ( username_exists( $username ) ) { |
|
305 | + if (username_exists($username)) { |
|
306 | 306 | // Username already registered. |
307 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
307 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
308 | 308 | $valid = false; |
309 | 309 | |
310 | 310 | // Check if it's valid. |
311 | - } elseif ( $sanitized_user_name !== $username ) { |
|
311 | + } elseif ($sanitized_user_name !== $username) { |
|
312 | 312 | // Invalid username. |
313 | - if ( is_multisite() ) { |
|
314 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
313 | + if (is_multisite()) { |
|
314 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | } else { |
317 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
317 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
318 | 318 | $valid = false; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | } else { |
322 | 322 | // Username is empty. |
323 | - give_set_error( 'username_empty', esc_html__( 'Enter a username.', 'give' ) ); |
|
323 | + give_set_error('username_empty', esc_html__('Enter a username.', 'give')); |
|
324 | 324 | $valid = false; |
325 | 325 | |
326 | 326 | // Check if guest checkout is disable for form. |
327 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
328 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
327 | + if ($form_id && give_logged_in_only($form_id)) { |
|
328 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
329 | 329 | $valid = false; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string $username |
340 | 340 | * @param bool $form_id |
341 | 341 | */ |
342 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
342 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
343 | 343 | |
344 | 344 | return $valid; |
345 | 345 | } |
@@ -355,22 +355,22 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return bool |
357 | 357 | */ |
358 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
358 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
359 | 359 | $valid = true; |
360 | 360 | |
361 | - if ( empty( $email ) ) { |
|
361 | + if (empty($email)) { |
|
362 | 362 | // No email. |
363 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
363 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
364 | 364 | $valid = false; |
365 | 365 | |
366 | - } elseif ( ! is_email( $email ) ) { |
|
366 | + } elseif ( ! is_email($email)) { |
|
367 | 367 | // Validate email. |
368 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
368 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
369 | 369 | $valid = false; |
370 | 370 | |
371 | - } elseif ( $registering_new_user && email_exists( $email ) ) { |
|
371 | + } elseif ($registering_new_user && email_exists($email)) { |
|
372 | 372 | // Check if email exists. |
373 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
373 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
374 | 374 | $valid = false; |
375 | 375 | } |
376 | 376 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param string $email |
384 | 384 | * @param bool $registering_new_user |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | - if ( $password && $confirm_password ) { |
|
405 | + if ($password && $confirm_password) { |
|
406 | 406 | // Verify confirmation matches. |
407 | - if ( $password != $confirm_password ) { |
|
407 | + if ($password != $confirm_password) { |
|
408 | 408 | // Passwords do not match |
409 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
409 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | - } elseif ( $registering_new_user ) { |
|
412 | + } elseif ($registering_new_user) { |
|
413 | 413 | // Password or confirmation missing. |
414 | - if ( ! $password ) { |
|
414 | + if ( ! $password) { |
|
415 | 415 | // The password is invalid. |
416 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
416 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
417 | 417 | $valid = false; |
418 | - } elseif ( ! $confirm_password ) { |
|
418 | + } elseif ( ! $confirm_password) { |
|
419 | 419 | // Confirmation password is invalid. |
420 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
420 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
421 | 421 | $valid = false; |
422 | 422 | } |
423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param string $confirm_password |
433 | 433 | * @param bool $registering_new_user |
434 | 434 | */ |
435 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
435 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
436 | 436 | |
437 | 437 | return $valid; |
438 | 438 | } |
@@ -451,32 +451,32 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
454 | +function give_add_past_purchases_to_new_user($user_id) { |
|
455 | 455 | |
456 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
456 | + $email = get_the_author_meta('user_email', $user_id); |
|
457 | 457 | |
458 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
458 | + $payments = give_get_payments(array('s' => $email)); |
|
459 | 459 | |
460 | - if ( $payments ) { |
|
461 | - foreach ( $payments as $payment ) { |
|
462 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
460 | + if ($payments) { |
|
461 | + foreach ($payments as $payment) { |
|
462 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
463 | 463 | continue; |
464 | 464 | } // This payment already associated with an account |
465 | 465 | |
466 | - $meta = give_get_payment_meta( $payment->ID ); |
|
467 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
466 | + $meta = give_get_payment_meta($payment->ID); |
|
467 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
468 | 468 | $meta['user_info']['id'] = $user_id; |
469 | 469 | $meta['user_info'] = $meta['user_info']; |
470 | 470 | |
471 | 471 | // Store the updated user ID in the payment meta |
472 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
473 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
472 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
473 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
479 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
480 | 480 | |
481 | 481 | |
482 | 482 | /** |
@@ -502,34 +502,34 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array The donor's address, if any |
504 | 504 | */ |
505 | -function give_get_donor_address( $user_id = 0 ) { |
|
506 | - if ( empty( $user_id ) ) { |
|
505 | +function give_get_donor_address($user_id = 0) { |
|
506 | + if (empty($user_id)) { |
|
507 | 507 | $user_id = get_current_user_id(); |
508 | 508 | } |
509 | 509 | |
510 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
510 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
511 | 511 | |
512 | - if ( ! isset( $address['line1'] ) ) { |
|
512 | + if ( ! isset($address['line1'])) { |
|
513 | 513 | $address['line1'] = ''; |
514 | 514 | } |
515 | 515 | |
516 | - if ( ! isset( $address['line2'] ) ) { |
|
516 | + if ( ! isset($address['line2'])) { |
|
517 | 517 | $address['line2'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['city'] ) ) { |
|
520 | + if ( ! isset($address['city'])) { |
|
521 | 521 | $address['city'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['zip'] ) ) { |
|
524 | + if ( ! isset($address['zip'])) { |
|
525 | 525 | $address['zip'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['country'] ) ) { |
|
528 | + if ( ! isset($address['country'])) { |
|
529 | 529 | $address['country'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['state'] ) ) { |
|
532 | + if ( ! isset($address['state'])) { |
|
533 | 533 | $address['state'] = ''; |
534 | 534 | } |
535 | 535 | |
@@ -549,42 +549,42 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return void |
551 | 551 | */ |
552 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
552 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
553 | 553 | |
554 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
554 | + if (empty($user_id) || empty($user_data)) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
557 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
558 | 558 | |
559 | 559 | /* translators: %s: site name */ |
560 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
560 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
561 | 561 | /* translators: %s: user login */ |
562 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
562 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
563 | 563 | /* translators: %s: user email */ |
564 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
564 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
565 | 565 | |
566 | 566 | Give()->emails->send( |
567 | - get_option( 'admin_email' ), |
|
567 | + get_option('admin_email'), |
|
568 | 568 | sprintf( |
569 | 569 | /* translators: %s: site name */ |
570 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
570 | + esc_attr__('[%s] New User Registration', 'give'), |
|
571 | 571 | $blogname |
572 | 572 | ), |
573 | 573 | $message |
574 | 574 | ); |
575 | 575 | |
576 | 576 | /* translators: %s: user login */ |
577 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
577 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
578 | 578 | /* translators: %s: paswword */ |
579 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
579 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
580 | 580 | |
581 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
581 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
582 | 582 | |
583 | 583 | Give()->emails->send( |
584 | 584 | $user_data['user_email'], |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: site name */ |
587 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
587 | + esc_attr__('[%s] Your username and password', 'give'), |
|
588 | 588 | $blogname |
589 | 589 | ), |
590 | 590 | $message |
@@ -592,4 +592,4 @@ discard block |
||
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
595 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
51 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Run the Give Install process. |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | give_setup_post_types(); |
65 | 65 | |
66 | 66 | // Clear the permalinks. |
67 | - flush_rewrite_rules( false ); |
|
67 | + flush_rewrite_rules(false); |
|
68 | 68 | |
69 | 69 | // Add Upgraded From Option. |
70 | - $current_version = get_option( 'give_version' ); |
|
71 | - if ( $current_version ) { |
|
72 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
70 | + $current_version = get_option('give_version'); |
|
71 | + if ($current_version) { |
|
72 | + update_option('give_version_upgraded_from', $current_version); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Setup some default options. |
76 | 76 | $options = array(); |
77 | 77 | |
78 | 78 | // Checks if the Success Page option exists AND that the page exists. |
79 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
79 | + if ( ! get_post(give_get_option('success_page'))) { |
|
80 | 80 | |
81 | 81 | // Donation Confirmation (Success) Page |
82 | 82 | $success = wp_insert_post( |
83 | 83 | array( |
84 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
84 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
85 | 85 | 'post_content' => '[give_receipt]', |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | 'post_author' => 1, |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Checks if the Failure Page option exists AND that the page exists. |
98 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
98 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
99 | 99 | |
100 | 100 | // Failed Donation Page |
101 | 101 | $failed = wp_insert_post( |
102 | 102 | array( |
103 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
104 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
103 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
104 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
105 | 105 | 'post_status' => 'publish', |
106 | 106 | 'post_author' => 1, |
107 | 107 | 'post_type' => 'page', |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // Checks if the History Page option exists AND that the page exists. |
116 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
116 | + if ( ! get_post(give_get_option('history_page'))) { |
|
117 | 117 | // Donation History Page |
118 | 118 | $history = wp_insert_post( |
119 | 119 | array( |
120 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
120 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
121 | 121 | 'post_content' => '[donation_history]', |
122 | 122 | 'post_status' => 'publish', |
123 | 123 | 'post_author' => 1, |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
133 | - if ( empty( $current_version ) ) { |
|
134 | - $options = array_merge( $options, give_get_default_settings() ); |
|
133 | + if (empty($current_version)) { |
|
134 | + $options = array_merge($options, give_get_default_settings()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // Populate the default values. |
138 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
138 | + update_option('give_settings', array_merge($give_options, $options)); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Run plugin upgrades. |
142 | 142 | * |
143 | 143 | * @since 1.8 |
144 | 144 | */ |
145 | - do_action( 'give_upgrades' ); |
|
145 | + do_action('give_upgrades'); |
|
146 | 146 | |
147 | 147 | |
148 | - if( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
149 | - update_option( 'give_version', GIVE_VERSION ); |
|
148 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
149 | + update_option('give_version', GIVE_VERSION); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Create Give roles. |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $roles->add_caps(); |
156 | 156 | |
157 | 157 | $api = new Give_API(); |
158 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
158 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
159 | 159 | |
160 | 160 | // Create the customers databases. |
161 | 161 | @Give()->customers->create_table(); |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | Give()->session->use_php_sessions(); |
166 | 166 | |
167 | 167 | // Add a temporary option to note that Give pages have been created. |
168 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
168 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
169 | 169 | |
170 | - if ( ! $current_version ) { |
|
170 | + if ( ! $current_version) { |
|
171 | 171 | |
172 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
172 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
173 | 173 | |
174 | 174 | // When new upgrade routines are added, mark them as complete on fresh install. |
175 | 175 | $upgrade_routines = array( |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | 'v18_upgrades_form_metadata' |
181 | 181 | ); |
182 | 182 | |
183 | - foreach ( $upgrade_routines as $upgrade ) { |
|
184 | - give_set_upgrade_complete( $upgrade ); |
|
183 | + foreach ($upgrade_routines as $upgrade) { |
|
184 | + give_set_upgrade_complete($upgrade); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Bail if activating from network, or bulk. |
189 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
189 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Add the transient to redirect. |
194 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
194 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
198 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Network Activated New Site Setup. |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @param int $site_id The Site ID. |
212 | 212 | * @param array $meta Blog Meta. |
213 | 213 | */ |
214 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
214 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
215 | 215 | |
216 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
216 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
217 | 217 | |
218 | - switch_to_blog( $blog_id ); |
|
218 | + switch_to_blog($blog_id); |
|
219 | 219 | give_install(); |
220 | 220 | restore_current_blog(); |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
226 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
227 | 227 | |
228 | 228 | |
229 | 229 | /** |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return array The tables to drop. |
238 | 238 | */ |
239 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
239 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
240 | 240 | |
241 | - switch_to_blog( $blog_id ); |
|
241 | + switch_to_blog($blog_id); |
|
242 | 242 | $customers_db = new Give_DB_Customers(); |
243 | 243 | $customer_meta_db = new Give_DB_Customer_Meta(); |
244 | 244 | |
245 | - if ( $customers_db->installed() ) { |
|
245 | + if ($customers_db->installed()) { |
|
246 | 246 | $tables[] = $customers_db->table_name; |
247 | 247 | $tables[] = $customer_meta_db->table_name; |
248 | 248 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | } |
254 | 254 | |
255 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
255 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Post-installation |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function give_after_install() { |
266 | 266 | |
267 | - if ( ! is_admin() ) { |
|
267 | + if ( ! is_admin()) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
272 | - $give_table_check = get_option( '_give_table_check', false ); |
|
271 | + $give_options = Give_Cache::get('_give_installed', true); |
|
272 | + $give_table_check = get_option('_give_table_check', false); |
|
273 | 273 | |
274 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
274 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
275 | 275 | |
276 | - if ( ! @Give()->customer_meta->installed() ) { |
|
276 | + if ( ! @Give()->customer_meta->installed()) { |
|
277 | 277 | |
278 | 278 | // Create the customer meta database |
279 | 279 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | - if ( ! @Give()->customers->installed() ) { |
|
284 | + if ( ! @Give()->customers->installed()) { |
|
285 | 285 | // Create the customers database |
286 | 286 | // (this ensures it creates it on multisite instances where it is network activated). |
287 | 287 | @Give()->customers->create_table(); |
@@ -293,22 +293,22 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param array $give_options Give plugin options. |
295 | 295 | */ |
296 | - do_action( 'give_after_install', $give_options ); |
|
296 | + do_action('give_after_install', $give_options); |
|
297 | 297 | } |
298 | 298 | |
299 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
299 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
300 | 300 | |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Delete the transient |
304 | - if ( false !== $give_options ) { |
|
305 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
304 | + if (false !== $give_options) { |
|
305 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | 309 | } |
310 | 310 | |
311 | -add_action( 'admin_init', 'give_after_install' ); |
|
311 | +add_action('admin_init', 'give_after_install'); |
|
312 | 312 | |
313 | 313 | |
314 | 314 | /** |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | |
324 | 324 | global $wp_roles; |
325 | 325 | |
326 | - if ( ! is_object( $wp_roles ) ) { |
|
326 | + if ( ! is_object($wp_roles)) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
330 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
331 | 331 | |
332 | 332 | // Create Give plugin roles |
333 | 333 | $roles = new Give_Roles(); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | } |
340 | 340 | |
341 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
341 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
342 | 342 | |
343 | 343 | /** |
344 | 344 | * Default core setting values. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'paypal_verification' => 'enabled', |
379 | 379 | |
380 | 380 | // Default is manual gateway. |
381 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
381 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
382 | 382 | 'default_gateway' => 'manual', |
383 | 383 | |
384 | 384 | // Offline gateway setup. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Determine access |
@@ -44,30 +44,30 @@ discard block |
||
44 | 44 | */ |
45 | 45 | if ( |
46 | 46 | is_user_logged_in() || false !== Give()->session->get_session_expiration() |
47 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
47 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
48 | 48 | ) { |
49 | 49 | ob_start(); |
50 | - give_get_template_part( 'history', 'donations' ); |
|
50 | + give_get_template_part('history', 'donations'); |
|
51 | 51 | |
52 | 52 | return ob_get_clean(); |
53 | 53 | |
54 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
54 | + } elseif (give_is_setting_enabled($email_access)) { |
|
55 | 55 | // Is Email-based access enabled? |
56 | 56 | ob_start(); |
57 | - give_get_template_part( 'email', 'login-form' ); |
|
57 | + give_get_template_part('email', 'login-form'); |
|
58 | 58 | |
59 | 59 | return ob_get_clean(); |
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
63 | - $output = apply_filters( 'give_donation_history_nonuser_message', give_output_error( __( '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 ) ); |
|
64 | - $output .= do_shortcode( '[give_login]' ); |
|
63 | + $output = apply_filters('give_donation_history_nonuser_message', give_output_error(__('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)); |
|
64 | + $output .= do_shortcode('[give_login]'); |
|
65 | 65 | |
66 | 66 | return $output; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
70 | +add_shortcode('donation_history', 'give_donation_history'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Donation Form Shortcode |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string |
82 | 82 | */ |
83 | -function give_form_shortcode( $atts ) { |
|
84 | - $atts = shortcode_atts( array( |
|
83 | +function give_form_shortcode($atts) { |
|
84 | + $atts = shortcode_atts(array( |
|
85 | 85 | 'id' => '', |
86 | 86 | 'show_title' => true, |
87 | 87 | 'show_goal' => true, |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | 'float_labels' => '', |
90 | 90 | 'display_style' => '', |
91 | 91 | 'continue_button_title' => '', |
92 | - ), $atts, 'give_form' ); |
|
92 | + ), $atts, 'give_form'); |
|
93 | 93 | |
94 | 94 | // Convert string to bool. |
95 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
96 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
95 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
96 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
97 | 97 | |
98 | 98 | //get the Give Form |
99 | 99 | ob_start(); |
100 | - give_get_donation_form( $atts ); |
|
100 | + give_get_donation_form($atts); |
|
101 | 101 | $final_output = ob_get_clean(); |
102 | 102 | |
103 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
103 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
104 | 104 | } |
105 | 105 | |
106 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
106 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Donation Form Goal Shortcode. |
@@ -116,37 +116,37 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return string |
118 | 118 | */ |
119 | -function give_goal_shortcode( $atts ) { |
|
120 | - $atts = shortcode_atts( array( |
|
119 | +function give_goal_shortcode($atts) { |
|
120 | + $atts = shortcode_atts(array( |
|
121 | 121 | 'id' => '', |
122 | 122 | 'show_text' => true, |
123 | 123 | 'show_bar' => true, |
124 | - ), $atts, 'give_goal' ); |
|
124 | + ), $atts, 'give_goal'); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | //get the Give Form. |
128 | 128 | ob_start(); |
129 | 129 | |
130 | 130 | //Sanity check 1: ensure there is an ID Provided. |
131 | - if ( empty( $atts['id'] ) ) { |
|
132 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
131 | + if (empty($atts['id'])) { |
|
132 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | //Sanity check 2: Check the form even has Goals enabled. |
136 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
136 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
137 | 137 | |
138 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
138 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
139 | 139 | } else { |
140 | 140 | //Passed all sanity checks: output Goal. |
141 | - give_show_goal_progress( $atts['id'], $atts ); |
|
141 | + give_show_goal_progress($atts['id'], $atts); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $final_output = ob_get_clean(); |
145 | 145 | |
146 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
146 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
147 | 147 | } |
148 | 148 | |
149 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
149 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
150 | 150 | |
151 | 151 | |
152 | 152 | /** |
@@ -163,22 +163,22 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return string |
165 | 165 | */ |
166 | -function give_login_form_shortcode( $atts ) { |
|
167 | - $atts = shortcode_atts( array( |
|
166 | +function give_login_form_shortcode($atts) { |
|
167 | + $atts = shortcode_atts(array( |
|
168 | 168 | // Add backward compatibility for redirect attribute. |
169 | 169 | 'redirect' => '', |
170 | 170 | |
171 | 171 | 'login-redirect' => '', |
172 | 172 | 'logout-redirect' => '', |
173 | - ), $atts, 'give_login' ); |
|
173 | + ), $atts, 'give_login'); |
|
174 | 174 | |
175 | 175 | // 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. |
176 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
176 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
177 | 177 | |
178 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
178 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
179 | 179 | } |
180 | 180 | |
181 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
181 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Register Shortcode. |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return string |
195 | 195 | */ |
196 | -function give_register_form_shortcode( $atts ) { |
|
197 | - $atts = shortcode_atts( array( |
|
196 | +function give_register_form_shortcode($atts) { |
|
197 | + $atts = shortcode_atts(array( |
|
198 | 198 | 'redirect' => '', |
199 | - ), $atts, 'give_register' ); |
|
199 | + ), $atts, 'give_register'); |
|
200 | 200 | |
201 | - return give_register_form( $atts['redirect'] ); |
|
201 | + return give_register_form($atts['redirect']); |
|
202 | 202 | } |
203 | 203 | |
204 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
204 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Receipt Shortcode. |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return string |
216 | 216 | */ |
217 | -function give_receipt_shortcode( $atts ) { |
|
217 | +function give_receipt_shortcode($atts) { |
|
218 | 218 | |
219 | 219 | global $give_receipt_args, $payment; |
220 | 220 | |
221 | - $give_receipt_args = shortcode_atts( array( |
|
222 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
221 | + $give_receipt_args = shortcode_atts(array( |
|
222 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
223 | 223 | 'price' => true, |
224 | 224 | 'donor' => true, |
225 | 225 | 'date' => true, |
@@ -228,50 +228,50 @@ discard block |
||
228 | 228 | 'payment_id' => true, |
229 | 229 | 'payment_status' => false, |
230 | 230 | 'status_notice' => true, |
231 | - ), $atts, 'give_receipt' ); |
|
231 | + ), $atts, 'give_receipt'); |
|
232 | 232 | |
233 | 233 | //set $session var |
234 | 234 | $session = give_get_purchase_session(); |
235 | 235 | |
236 | 236 | //set payment key var |
237 | - if ( isset( $_GET['payment_key'] ) ) { |
|
238 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
239 | - } elseif ( $session ) { |
|
237 | + if (isset($_GET['payment_key'])) { |
|
238 | + $payment_key = urldecode($_GET['payment_key']); |
|
239 | + } elseif ($session) { |
|
240 | 240 | $payment_key = $session['purchase_key']; |
241 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
241 | + } elseif ($give_receipt_args['payment_key']) { |
|
242 | 242 | $payment_key = $give_receipt_args['payment_key']; |
243 | 243 | } |
244 | 244 | |
245 | - $email_access = give_get_option( 'email_access' ); |
|
245 | + $email_access = give_get_option('email_access'); |
|
246 | 246 | |
247 | 247 | // No payment_key found & Email Access is Turned on: |
248 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
248 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
249 | 249 | |
250 | 250 | ob_start(); |
251 | 251 | |
252 | - give_get_template_part( 'email-login-form' ); |
|
252 | + give_get_template_part('email-login-form'); |
|
253 | 253 | |
254 | 254 | return ob_get_clean(); |
255 | 255 | |
256 | - } elseif ( ! isset( $payment_key ) ) { |
|
256 | + } elseif ( ! isset($payment_key)) { |
|
257 | 257 | |
258 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
258 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
263 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
262 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
263 | + $user_can_view = give_can_view_receipt($payment_key); |
|
264 | 264 | |
265 | 265 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
266 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
266 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
267 | 267 | |
268 | 268 | ob_start(); |
269 | 269 | |
270 | - give_get_template_part( 'email-login-form' ); |
|
270 | + give_get_template_part('email-login-form'); |
|
271 | 271 | |
272 | 272 | return ob_get_clean(); |
273 | 273 | |
274 | - } elseif ( ! $user_can_view ) { |
|
274 | + } elseif ( ! $user_can_view) { |
|
275 | 275 | |
276 | 276 | global $give_login_redirect; |
277 | 277 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | |
280 | 280 | ob_start(); |
281 | 281 | |
282 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
282 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
283 | 283 | |
284 | - give_get_template_part( 'shortcode', 'login' ); |
|
284 | + give_get_template_part('shortcode', 'login'); |
|
285 | 285 | |
286 | 286 | $login_form = ob_get_clean(); |
287 | 287 | |
@@ -296,20 +296,20 @@ discard block |
||
296 | 296 | * or if user is logged in and the user can view sensitive shop data. |
297 | 297 | * |
298 | 298 | */ |
299 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
300 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
299 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
300 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | ob_start(); |
304 | 304 | |
305 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
305 | + give_get_template_part('shortcode', 'receipt'); |
|
306 | 306 | |
307 | 307 | $display = ob_get_clean(); |
308 | 308 | |
309 | 309 | return $display; |
310 | 310 | } |
311 | 311 | |
312 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
312 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * Profile Editor Shortcode. |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return string Output generated from the profile editor |
330 | 330 | */ |
331 | -function give_profile_editor_shortcode( $atts ) { |
|
331 | +function give_profile_editor_shortcode($atts) { |
|
332 | 332 | |
333 | 333 | ob_start(); |
334 | 334 | |
335 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
335 | + give_get_template_part('shortcode', 'profile-editor'); |
|
336 | 336 | |
337 | 337 | $display = ob_get_clean(); |
338 | 338 | |
339 | 339 | return $display; |
340 | 340 | } |
341 | 341 | |
342 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
342 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Process Profile Updater Form. |
@@ -352,30 +352,30 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return bool |
354 | 354 | */ |
355 | -function give_process_profile_editor_updates( $data ) { |
|
355 | +function give_process_profile_editor_updates($data) { |
|
356 | 356 | // Profile field change request |
357 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
357 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
358 | 358 | return false; |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Nonce security |
362 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
362 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
363 | 363 | return false; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $user_id = get_current_user_id(); |
367 | - $old_user_data = get_userdata( $user_id ); |
|
368 | - |
|
369 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
370 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
371 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
372 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
373 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
374 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
375 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
376 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
377 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
378 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
367 | + $old_user_data = get_userdata($user_id); |
|
368 | + |
|
369 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
370 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
371 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
372 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
373 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
374 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
375 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
376 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
377 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
378 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
379 | 379 | |
380 | 380 | $userdata = array( |
381 | 381 | 'ID' => $user_id, |
@@ -403,46 +403,46 @@ discard block |
||
403 | 403 | * @param int $user_id The ID of the user. |
404 | 404 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
405 | 405 | */ |
406 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
406 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
407 | 407 | |
408 | 408 | // New password |
409 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
410 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
411 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
409 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
410 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
411 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
412 | 412 | } else { |
413 | 413 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | - if ( empty( $email ) ) { |
|
417 | + if (empty($email)) { |
|
418 | 418 | // Make sure email should not be empty. |
419 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
419 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
420 | 420 | |
421 | - } else if ( ! is_email( $email ) ) { |
|
421 | + } else if ( ! is_email($email)) { |
|
422 | 422 | // Make sure email should be valid. |
423 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
423 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
424 | 424 | |
425 | - } else if ( $email != $old_user_data->user_email ) { |
|
425 | + } else if ($email != $old_user_data->user_email) { |
|
426 | 426 | // Make sure the new email doesn't belong to another user |
427 | - if ( email_exists( $email ) ) { |
|
428 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
427 | + if (email_exists($email)) { |
|
428 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | 432 | // Check for errors |
433 | 433 | $errors = give_get_errors(); |
434 | 434 | |
435 | - if ( $errors ) { |
|
435 | + if ($errors) { |
|
436 | 436 | // Send back to the profile editor if there are errors |
437 | - wp_redirect( $data['give_redirect'] ); |
|
437 | + wp_redirect($data['give_redirect']); |
|
438 | 438 | give_die(); |
439 | 439 | } |
440 | 440 | |
441 | 441 | // Update the user |
442 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
443 | - $updated = wp_update_user( $userdata ); |
|
442 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
443 | + $updated = wp_update_user($userdata); |
|
444 | 444 | |
445 | - if ( $updated ) { |
|
445 | + if ($updated) { |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Fires after updating user profile. |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | * @param int $user_id The ID of the user. |
453 | 453 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
454 | 454 | */ |
455 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
456 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
455 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
456 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
457 | 457 | give_die(); |
458 | 458 | } |
459 | 459 | |
460 | 460 | return false; |
461 | 461 | } |
462 | 462 | |
463 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
463 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |