@@ -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 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | 'start_date' => $this->start_date, |
58 | 58 | 'end_date' => $this->end_date, |
59 | 59 | 'fields' => 'ids', |
60 | - 'number' => - 1, |
|
60 | + 'number' => -1, |
|
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $form_id ) ) { |
|
63 | + if ( ! empty($form_id)) { |
|
64 | 64 | $args['give_forms'] = $form_id; |
65 | 65 | } |
66 | 66 | |
67 | 67 | /* @var Give_Payments_Query $payments */ |
68 | - $payments = new Give_Payments_Query( $args ); |
|
68 | + $payments = new Give_Payments_Query($args); |
|
69 | 69 | $payments = $payments->get_payments(); |
70 | 70 | |
71 | - return count( $payments ); |
|
71 | + return count($payments); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return float|int Total amount of donations based on the passed arguments. |
87 | 87 | */ |
88 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
89 | - $this->setup_dates( $start_date, $end_date ); |
|
88 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
89 | + $this->setup_dates($start_date, $end_date); |
|
90 | 90 | |
91 | 91 | // Make sure start date is valid |
92 | - if ( is_wp_error( $this->start_date ) ) { |
|
92 | + if (is_wp_error($this->start_date)) { |
|
93 | 93 | return $this->start_date; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Make sure end date is valid |
97 | - if ( is_wp_error( $this->end_date ) ) { |
|
97 | + if (is_wp_error($this->end_date)) { |
|
98 | 98 | return $this->end_date; |
99 | 99 | } |
100 | 100 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | 'start_date' => $this->start_date, |
105 | 105 | 'end_date' => $this->end_date, |
106 | 106 | 'fields' => 'ids', |
107 | - 'number' => - 1, |
|
107 | + 'number' => -1, |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | |
111 | 111 | // Filter by Gateway ID meta_key |
112 | - if ( $gateway_id ) { |
|
112 | + if ($gateway_id) { |
|
113 | 113 | $args['meta_query'][] = array( |
114 | 114 | 'key' => '_give_payment_gateway', |
115 | 115 | 'value' => $gateway_id, |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Filter by Gateway ID meta_key |
120 | - if ( $form_id ) { |
|
120 | + if ($form_id) { |
|
121 | 121 | $args['meta_query'][] = array( |
122 | 122 | 'key' => '_give_payment_form_id', |
123 | 123 | 'value' => $form_id, |
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
127 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
128 | 128 | $args['meta_query']['relation'] = 'AND'; |
129 | 129 | } |
130 | 130 | |
131 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
132 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
131 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
132 | + $key = Give_Cache::get_key('give_stats', $args); |
|
133 | 133 | |
134 | 134 | // Set transient for faster stats. |
135 | - $earnings = Give_Cache::get( $key ); |
|
135 | + $earnings = Give_Cache::get($key); |
|
136 | 136 | |
137 | - if ( false === $earnings ) { |
|
137 | + if (false === $earnings) { |
|
138 | 138 | |
139 | 139 | $this->timestamp = false; |
140 | - $payments = new Give_Payments_Query( $args ); |
|
140 | + $payments = new Give_Payments_Query($args); |
|
141 | 141 | $payments = $payments->get_payments(); |
142 | 142 | $earnings = 0; |
143 | 143 | |
144 | - if ( ! empty( $payments ) ) { |
|
145 | - foreach ( $payments as $payment ) { |
|
146 | - $earnings += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
144 | + if ( ! empty($payments)) { |
|
145 | + foreach ($payments as $payment) { |
|
146 | + $earnings += (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Cache the results for one hour. |
152 | - Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 ); |
|
152 | + Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * @param string|bool $end_date Earning end date. |
164 | 164 | * @param string|bool $gateway_id Payment gateway id. |
165 | 165 | */ |
166 | - $earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id ); |
|
166 | + $earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id); |
|
167 | 167 | |
168 | 168 | //return earnings |
169 | - return round( $earnings, give_get_price_decimals( $form_id ) ); |
|
169 | + return round($earnings, give_get_price_decimals($form_id)); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return float|int Total amount of donations based on the passed arguments. |
185 | 185 | */ |
186 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
186 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
187 | 187 | |
188 | - $this->setup_dates( $start_date, $end_date ); |
|
188 | + $this->setup_dates($start_date, $end_date); |
|
189 | 189 | |
190 | 190 | // Make sure start date is valid |
191 | - if ( is_wp_error( $this->start_date ) ) { |
|
191 | + if (is_wp_error($this->start_date)) { |
|
192 | 192 | return $this->start_date; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Make sure end date is valid |
196 | - if ( is_wp_error( $this->end_date ) ) { |
|
196 | + if (is_wp_error($this->end_date)) { |
|
197 | 197 | return $this->end_date; |
198 | 198 | } |
199 | 199 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | 'start_date' => $this->start_date, |
204 | 204 | 'end_date' => $this->end_date, |
205 | 205 | 'fields' => 'ids', |
206 | - 'number' => - 1, |
|
206 | + 'number' => -1, |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | |
210 | 210 | // Filter by Gateway ID meta_key |
211 | - if ( $gateway_id ) { |
|
211 | + if ($gateway_id) { |
|
212 | 212 | $args['meta_query'][] = array( |
213 | 213 | 'key' => '_give_payment_gateway', |
214 | 214 | 'value' => $gateway_id, |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | // Filter by Gateway ID meta_key |
219 | - if ( $form_id ) { |
|
219 | + if ($form_id) { |
|
220 | 220 | $args['meta_query'][] = array( |
221 | 221 | 'key' => '_give_payment_form_id', |
222 | 222 | 'value' => $form_id, |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) { |
|
226 | + if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) { |
|
227 | 227 | $args['meta_query']['relation'] = 'AND'; |
228 | 228 | } |
229 | 229 | |
230 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
231 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
230 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
231 | + $key = Give_Cache::get_key('give_stats', $args); |
|
232 | 232 | |
233 | 233 | //return earnings |
234 | 234 | return $key; |
@@ -245,16 +245,16 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return array Best selling forms |
247 | 247 | */ |
248 | - public function get_best_selling( $number = 10 ) { |
|
248 | + public function get_best_selling($number = 10) { |
|
249 | 249 | |
250 | 250 | global $wpdb; |
251 | 251 | |
252 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
252 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
253 | 253 | "SELECT post_id as form_id, max(meta_value) as sales |
254 | 254 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
255 | 255 | GROUP BY meta_value+0 |
256 | 256 | DESC LIMIT %d;", $number |
257 | - ) ); |
|
257 | + )); |
|
258 | 258 | |
259 | 259 | return $give_forms; |
260 | 260 | } |
@@ -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 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
68 | 68 | */ |
69 | - public function __construct( $args = array() ) { |
|
69 | + public function __construct($args = array()) { |
|
70 | 70 | $defaults = array( |
71 | 71 | 'output' => 'payments', |
72 | - 'post_type' => array( 'give_payment' ), |
|
72 | + 'post_type' => array('give_payment'), |
|
73 | 73 | 'start_date' => false, |
74 | 74 | 'end_date' => false, |
75 | 75 | 'number' => 20, |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'count' => false, |
97 | 97 | ); |
98 | 98 | |
99 | - $this->args = $this->_args = wp_parse_args( $args, $defaults ); |
|
99 | + $this->args = $this->_args = wp_parse_args($args, $defaults); |
|
100 | 100 | |
101 | 101 | $this->init(); |
102 | 102 | } |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | * @param $query_var |
111 | 111 | * @param $value |
112 | 112 | */ |
113 | - public function __set( $query_var, $value ) { |
|
114 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
115 | - $this->args[ $query_var ][] = $value; |
|
113 | + public function __set($query_var, $value) { |
|
114 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
115 | + $this->args[$query_var][] = $value; |
|
116 | 116 | } else { |
117 | - $this->args[ $query_var ] = $value; |
|
117 | + $this->args[$query_var] = $value; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param $query_var |
128 | 128 | */ |
129 | - public function __unset( $query_var ) { |
|
130 | - unset( $this->args[ $query_var ] ); |
|
129 | + public function __unset($query_var) { |
|
130 | + unset($this->args[$query_var]); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $this->give_forms(); |
168 | 168 | $this->gateway_filter(); |
169 | 169 | |
170 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
170 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Fires after setup filters. |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param Give_Payments_Query $this Payments query object. |
178 | 178 | */ |
179 | - do_action( 'give_pre_get_payments', $this ); |
|
179 | + do_action('give_pre_get_payments', $this); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @access private |
187 | 187 | */ |
188 | 188 | private function unset_filters() { |
189 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
189 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Fires after retrieving payments. |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @param Give_Payments_Query $this Payments query object. |
197 | 197 | */ |
198 | - do_action( 'give_post_get_payments', $this ); |
|
198 | + do_action('give_post_get_payments', $this); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | // Modify the query/query arguments before we retrieve payments. |
216 | 216 | $this->set_filters(); |
217 | 217 | |
218 | - $query = new WP_Query( $this->args ); |
|
218 | + $query = new WP_Query($this->args); |
|
219 | 219 | $this->payments = array(); |
220 | 220 | |
221 | 221 | $custom_output = array( |
@@ -223,18 +223,18 @@ discard block |
||
223 | 223 | 'give_payments', |
224 | 224 | ); |
225 | 225 | |
226 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
226 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
227 | 227 | return $query->posts; |
228 | 228 | } |
229 | 229 | |
230 | - if ( $query->have_posts() ) { |
|
231 | - while ( $query->have_posts() ) { |
|
230 | + if ($query->have_posts()) { |
|
231 | + while ($query->have_posts()) { |
|
232 | 232 | $query->the_post(); |
233 | 233 | |
234 | 234 | $payment_id = get_post()->ID; |
235 | - $payment = new Give_Payment( $payment_id ); |
|
235 | + $payment = new Give_Payment($payment_id); |
|
236 | 236 | |
237 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
237 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | wp_reset_postdata(); |
@@ -257,31 +257,31 @@ discard block |
||
257 | 257 | public function get_payment_by_group() { |
258 | 258 | global $wpdb; |
259 | 259 | |
260 | - $allowed_groups = array( 'post_status' ); |
|
260 | + $allowed_groups = array('post_status'); |
|
261 | 261 | $result = array(); |
262 | 262 | |
263 | 263 | |
264 | - if ( in_array( $this->args['group_by'], $allowed_groups ) ) { |
|
264 | + if (in_array($this->args['group_by'], $allowed_groups)) { |
|
265 | 265 | // Set only count in result. |
266 | - if ( $this->args['count'] ) { |
|
266 | + if ($this->args['count']) { |
|
267 | 267 | |
268 | 268 | $this->set_filters(); |
269 | 269 | |
270 | - $new_results = $wpdb->get_results( $this->get_sql(), ARRAY_N ); |
|
270 | + $new_results = $wpdb->get_results($this->get_sql(), ARRAY_N); |
|
271 | 271 | |
272 | 272 | $this->unset_filters(); |
273 | 273 | |
274 | - foreach ( $new_results as $results ) { |
|
275 | - $result[ $results[0] ] = $results[1]; |
|
274 | + foreach ($new_results as $results) { |
|
275 | + $result[$results[0]] = $results[1]; |
|
276 | 276 | } |
277 | 277 | |
278 | - switch ( $this->args['group_by'] ) { |
|
278 | + switch ($this->args['group_by']) { |
|
279 | 279 | case 'post_status': |
280 | 280 | |
281 | 281 | /* @var Give_Payment $donation */ |
282 | - foreach ( give_get_payment_status_keys() as $status ) { |
|
283 | - if ( ! isset( $result[ $status ] ) ) { |
|
284 | - $result[ $status ] = 0; |
|
282 | + foreach (give_get_payment_status_keys() as $status) { |
|
283 | + if ( ! isset($result[$status])) { |
|
284 | + $result[$status] = 0; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | $donations = $this->get_payments(); |
292 | 292 | |
293 | 293 | /* @var $donation Give_Payment */ |
294 | - foreach ( $donations as $donation ) { |
|
295 | - $result[ $donation->{$this->args['group_by']} ][] = $donation; |
|
294 | + foreach ($donations as $donation) { |
|
295 | + $result[$donation->{$this->args['group_by']}][] = $donation; |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @since 1.8.17 |
305 | 305 | */ |
306 | - return apply_filters( 'give_get_payment_by_group', $result, $this ); |
|
306 | + return apply_filters('give_get_payment_by_group', $result, $this); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -315,26 +315,26 @@ discard block |
||
315 | 315 | * @return void |
316 | 316 | */ |
317 | 317 | public function date_filter_pre() { |
318 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
318 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
323 | - $is_start_date = property_exists( __CLASS__, 'start_date' ); |
|
324 | - $is_end_date = property_exists( __CLASS__, 'end_date' ); |
|
322 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
323 | + $is_start_date = property_exists(__CLASS__, 'start_date'); |
|
324 | + $is_end_date = property_exists(__CLASS__, 'end_date'); |
|
325 | 325 | |
326 | - if ( $is_start_date || $is_end_date ) { |
|
326 | + if ($is_start_date || $is_end_date) { |
|
327 | 327 | $date_query = array(); |
328 | 328 | |
329 | - if ( $is_start_date && ! is_wp_error( $this->start_date ) ) { |
|
330 | - $date_query['after'] = date( 'Y-m-d H:i:s', $this->start_date ); |
|
329 | + if ($is_start_date && ! is_wp_error($this->start_date)) { |
|
330 | + $date_query['after'] = date('Y-m-d H:i:s', $this->start_date); |
|
331 | 331 | } |
332 | 332 | |
333 | - if ( $is_end_date && ! is_wp_error( $this->end_date ) ) { |
|
334 | - $date_query['before'] = date( 'Y-m-d H:i:s', $this->end_date ); |
|
333 | + if ($is_end_date && ! is_wp_error($this->end_date)) { |
|
334 | + $date_query['before'] = date('Y-m-d H:i:s', $this->end_date); |
|
335 | 335 | } |
336 | 336 | |
337 | - $this->__set( 'date_query', $date_query ); |
|
337 | + $this->__set('date_query', $date_query); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * @return void |
350 | 350 | */ |
351 | 351 | public function status() { |
352 | - if ( ! isset( $this->args['status'] ) ) { |
|
352 | + if ( ! isset($this->args['status'])) { |
|
353 | 353 | return; |
354 | 354 | } |
355 | 355 | |
356 | - $this->__set( 'post_status', $this->args['status'] ); |
|
357 | - $this->__unset( 'status' ); |
|
356 | + $this->__set('post_status', $this->args['status']); |
|
357 | + $this->__unset('status'); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -366,12 +366,12 @@ discard block |
||
366 | 366 | * @return void |
367 | 367 | */ |
368 | 368 | public function page() { |
369 | - if ( ! isset( $this->args['page'] ) ) { |
|
369 | + if ( ! isset($this->args['page'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - $this->__set( 'paged', $this->args['page'] ); |
|
374 | - $this->__unset( 'page' ); |
|
373 | + $this->__set('paged', $this->args['page']); |
|
374 | + $this->__unset('page'); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function per_page() { |
386 | 386 | |
387 | - if ( ! isset( $this->args['number'] ) ) { |
|
387 | + if ( ! isset($this->args['number'])) { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | - if ( $this->args['number'] == - 1 ) { |
|
392 | - $this->__set( 'nopaging', true ); |
|
391 | + if ($this->args['number'] == - 1) { |
|
392 | + $this->__set('nopaging', true); |
|
393 | 393 | } else { |
394 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
394 | + $this->__set('posts_per_page', $this->args['number']); |
|
395 | 395 | } |
396 | 396 | |
397 | - $this->__unset( 'number' ); |
|
397 | + $this->__unset('number'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | * @return void |
407 | 407 | */ |
408 | 408 | public function month() { |
409 | - if ( ! isset( $this->args['month'] ) ) { |
|
409 | + if ( ! isset($this->args['month'])) { |
|
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
413 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
414 | - $this->__unset( 'month' ); |
|
413 | + $this->__set('monthnum', $this->args['month']); |
|
414 | + $this->__unset('month'); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -423,23 +423,23 @@ discard block |
||
423 | 423 | * @return void |
424 | 424 | */ |
425 | 425 | public function orderby() { |
426 | - switch ( $this->args['orderby'] ) { |
|
426 | + switch ($this->args['orderby']) { |
|
427 | 427 | case 'amount': |
428 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
429 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
428 | + $this->__set('orderby', 'meta_value_num'); |
|
429 | + $this->__set('meta_key', '_give_payment_total'); |
|
430 | 430 | break; |
431 | 431 | |
432 | 432 | case 'status': |
433 | - $this->__set( 'orderby', 'post_status' ); |
|
433 | + $this->__set('orderby', 'post_status'); |
|
434 | 434 | break; |
435 | 435 | |
436 | 436 | case 'donation_form': |
437 | - $this->__set( 'orderby', 'meta_value' ); |
|
438 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
437 | + $this->__set('orderby', 'meta_value'); |
|
438 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
439 | 439 | break; |
440 | 440 | |
441 | 441 | default: |
442 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
442 | + $this->__set('orderby', $this->args['orderby']); |
|
443 | 443 | break; |
444 | 444 | } |
445 | 445 | } |
@@ -456,19 +456,19 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return mixed |
458 | 458 | */ |
459 | - public function custom_orderby( $order, $query ) { |
|
459 | + public function custom_orderby($order, $query) { |
|
460 | 460 | |
461 | - if ( ! empty( $query->query['post_type'] ) ) { |
|
462 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
461 | + if ( ! empty($query->query['post_type'])) { |
|
462 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
463 | 463 | |
464 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
464 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
465 | 465 | return $order; |
466 | 466 | } |
467 | 467 | |
468 | 468 | global $wpdb; |
469 | - switch ( $query->query['orderby'] ) { |
|
469 | + switch ($query->query['orderby']) { |
|
470 | 470 | case 'post_status': |
471 | - $order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] ); |
|
471 | + $order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']); |
|
472 | 472 | break; |
473 | 473 | } |
474 | 474 | } |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | * @return void |
486 | 486 | */ |
487 | 487 | public function user() { |
488 | - if ( is_null( $this->args['user'] ) ) { |
|
488 | + if (is_null($this->args['user'])) { |
|
489 | 489 | return; |
490 | 490 | } |
491 | 491 | |
492 | - if ( is_numeric( $this->args['user'] ) ) { |
|
492 | + if (is_numeric($this->args['user'])) { |
|
493 | 493 | $user_key = '_give_payment_user_id'; |
494 | 494 | } else { |
495 | 495 | $user_key = '_give_payment_user_email'; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @return void |
512 | 512 | */ |
513 | 513 | public function donor() { |
514 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
514 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
515 | 515 | return; |
516 | 516 | } |
517 | 517 | |
@@ -533,33 +533,33 @@ discard block |
||
533 | 533 | */ |
534 | 534 | public function search() { |
535 | 535 | |
536 | - if ( ! isset( $this->args['s'] ) ) { |
|
536 | + if ( ! isset($this->args['s'])) { |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | |
540 | - $search = trim( $this->args['s'] ); |
|
540 | + $search = trim($this->args['s']); |
|
541 | 541 | |
542 | - if ( empty( $search ) ) { |
|
542 | + if (empty($search)) { |
|
543 | 543 | return; |
544 | 544 | } |
545 | 545 | |
546 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
547 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
546 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
547 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
548 | 548 | |
549 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
549 | + if ( ! empty($this->args['search_in_notes'])) { |
|
550 | 550 | |
551 | - $notes = give_get_payment_notes( 0, $search ); |
|
551 | + $notes = give_get_payment_notes(0, $search); |
|
552 | 552 | |
553 | - if ( ! empty( $notes ) ) { |
|
553 | + if ( ! empty($notes)) { |
|
554 | 554 | |
555 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
555 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
556 | 556 | |
557 | - $this->__set( 'post__in', $payment_ids ); |
|
557 | + $this->__set('post__in', $payment_ids); |
|
558 | 558 | } |
559 | 559 | |
560 | - $this->__unset( 's' ); |
|
560 | + $this->__unset('s'); |
|
561 | 561 | |
562 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
562 | + } elseif ($is_email || strlen($search) == 32) { |
|
563 | 563 | |
564 | 564 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
565 | 565 | $search_meta = array( |
@@ -568,19 +568,19 @@ discard block |
||
568 | 568 | 'compare' => 'LIKE', |
569 | 569 | ); |
570 | 570 | |
571 | - $this->__set( 'meta_query', $search_meta ); |
|
572 | - $this->__unset( 's' ); |
|
571 | + $this->__set('meta_query', $search_meta); |
|
572 | + $this->__unset('s'); |
|
573 | 573 | |
574 | - } elseif ( $is_user ) { |
|
574 | + } elseif ($is_user) { |
|
575 | 575 | |
576 | 576 | $search_meta = array( |
577 | 577 | 'key' => '_give_payment_user_id', |
578 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
578 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
579 | 579 | ); |
580 | 580 | |
581 | - $this->__set( 'meta_query', $search_meta ); |
|
581 | + $this->__set('meta_query', $search_meta); |
|
582 | 582 | |
583 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
583 | + if (give_get_option('enable_sequential')) { |
|
584 | 584 | |
585 | 585 | $search_meta = array( |
586 | 586 | 'key' => '_give_payment_number', |
@@ -588,19 +588,19 @@ discard block |
||
588 | 588 | 'compare' => 'LIKE', |
589 | 589 | ); |
590 | 590 | |
591 | - $this->__set( 'meta_query', $search_meta ); |
|
591 | + $this->__set('meta_query', $search_meta); |
|
592 | 592 | |
593 | 593 | $this->args['meta_query']['relation'] = 'OR'; |
594 | 594 | |
595 | 595 | } |
596 | 596 | |
597 | - $this->__unset( 's' ); |
|
597 | + $this->__unset('s'); |
|
598 | 598 | |
599 | 599 | } elseif ( |
600 | - give_get_option( 'enable_sequential' ) && |
|
600 | + give_get_option('enable_sequential') && |
|
601 | 601 | ( |
602 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
603 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
602 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
603 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
604 | 604 | ) |
605 | 605 | ) { |
606 | 606 | |
@@ -610,29 +610,29 @@ discard block |
||
610 | 610 | 'compare' => 'LIKE', |
611 | 611 | ); |
612 | 612 | |
613 | - $this->__set( 'meta_query', $search_meta ); |
|
614 | - $this->__unset( 's' ); |
|
613 | + $this->__set('meta_query', $search_meta); |
|
614 | + $this->__unset('s'); |
|
615 | 615 | |
616 | - } elseif ( is_numeric( $search ) ) { |
|
616 | + } elseif (is_numeric($search)) { |
|
617 | 617 | |
618 | - $post = get_post( $search ); |
|
618 | + $post = get_post($search); |
|
619 | 619 | |
620 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
620 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
621 | 621 | |
622 | 622 | $arr = array(); |
623 | 623 | $arr[] = $search; |
624 | - $this->__set( 'post__in', $arr ); |
|
625 | - $this->__unset( 's' ); |
|
624 | + $this->__set('post__in', $arr); |
|
625 | + $this->__unset('s'); |
|
626 | 626 | } |
627 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
627 | + } elseif ('#' == substr($search, 0, 1)) { |
|
628 | 628 | |
629 | - $search = str_replace( '#:', '', $search ); |
|
630 | - $search = str_replace( '#', '', $search ); |
|
631 | - $this->__set( 'give_forms', $search ); |
|
632 | - $this->__unset( 's' ); |
|
629 | + $search = str_replace('#:', '', $search); |
|
630 | + $search = str_replace('#', '', $search); |
|
631 | + $this->__set('give_forms', $search); |
|
632 | + $this->__unset('s'); |
|
633 | 633 | |
634 | 634 | } else { |
635 | - $this->__set( 's', $search ); |
|
635 | + $this->__set('s', $search); |
|
636 | 636 | |
637 | 637 | } |
638 | 638 | |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * @return void |
648 | 648 | */ |
649 | 649 | public function mode() { |
650 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
651 | - $this->__unset( 'mode' ); |
|
650 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
651 | + $this->__unset('mode'); |
|
652 | 652 | |
653 | 653 | return; |
654 | 654 | } |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | * @return void |
671 | 671 | */ |
672 | 672 | public function children() { |
673 | - if ( empty( $this->args['children'] ) ) { |
|
674 | - $this->__set( 'post_parent', 0 ); |
|
673 | + if (empty($this->args['children'])) { |
|
674 | + $this->__set('post_parent', 0); |
|
675 | 675 | } |
676 | - $this->__unset( 'children' ); |
|
676 | + $this->__unset('children'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -686,13 +686,13 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function give_forms() { |
688 | 688 | |
689 | - if ( empty( $this->args['give_forms'] ) ) { |
|
689 | + if (empty($this->args['give_forms'])) { |
|
690 | 690 | return; |
691 | 691 | } |
692 | 692 | |
693 | 693 | $compare = '='; |
694 | 694 | |
695 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
695 | + if (is_array($this->args['give_forms'])) { |
|
696 | 696 | $compare = 'IN'; |
697 | 697 | } |
698 | 698 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | ) |
707 | 707 | ); |
708 | 708 | |
709 | - $this->__unset( 'give_forms' ); |
|
709 | + $this->__unset('give_forms'); |
|
710 | 710 | |
711 | 711 | } |
712 | 712 | |
@@ -720,13 +720,13 @@ discard block |
||
720 | 720 | */ |
721 | 721 | public function gateway_filter() { |
722 | 722 | |
723 | - if ( empty( $this->args['gateway'] ) ) { |
|
723 | + if (empty($this->args['gateway'])) { |
|
724 | 724 | return; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $compare = '='; |
728 | 728 | |
729 | - if ( is_array( $this->args['gateway'] ) ) { |
|
729 | + if (is_array($this->args['gateway'])) { |
|
730 | 730 | $compare = 'IN'; |
731 | 731 | } |
732 | 732 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | ) |
741 | 741 | ); |
742 | 742 | |
743 | - $this->__unset( 'gateway' ); |
|
743 | + $this->__unset('gateway'); |
|
744 | 744 | |
745 | 745 | } |
746 | 746 | |
@@ -760,9 +760,9 @@ discard block |
||
760 | 760 | global $wpdb; |
761 | 761 | |
762 | 762 | $where = "WHERE {$wpdb->posts}.post_type = 'give_payment'"; |
763 | - $where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')"; |
|
763 | + $where .= " AND {$wpdb->posts}.post_status IN ('".implode("','", $this->args['post_status'])."')"; |
|
764 | 764 | |
765 | - if( is_numeric( $this->args['post_parent'] ) ) { |
|
765 | + if (is_numeric($this->args['post_parent'])) { |
|
766 | 766 | $where .= " AND {$wpdb->posts}.post_parent={$this->args['post_parent']}"; |
767 | 767 | } |
768 | 768 | |
@@ -771,42 +771,42 @@ discard block |
||
771 | 771 | $group_by = ''; |
772 | 772 | |
773 | 773 | // Set group by. |
774 | - if ( ! empty( $this->args['group_by'] ) ) { |
|
774 | + if ( ! empty($this->args['group_by'])) { |
|
775 | 775 | $group_by = "GROUP BY {$wpdb->posts}.{$this->args['group_by']}"; |
776 | 776 | } |
777 | 777 | |
778 | 778 | // Set offset. |
779 | 779 | if ( |
780 | - empty( $this->args['nopaging'] ) && |
|
781 | - empty( $this->args['offset'] ) && |
|
782 | - ( ! empty( $this->args['page'] ) && 0 < $this->args['page'] ) |
|
780 | + empty($this->args['nopaging']) && |
|
781 | + empty($this->args['offset']) && |
|
782 | + ( ! empty($this->args['page']) && 0 < $this->args['page']) |
|
783 | 783 | ) { |
784 | - $this->args['offset'] = $this->args['posts_per_page'] * ( $this->args['page'] - 1 ); |
|
784 | + $this->args['offset'] = $this->args['posts_per_page'] * ($this->args['page'] - 1); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | // Set fields. |
788 | 788 | $fields = "{$wpdb->posts}.*"; |
789 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
790 | - if ( is_string( $this->args['fields'] ) ) { |
|
789 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
790 | + if (is_string($this->args['fields'])) { |
|
791 | 791 | $fields = "{$wpdb->posts}.{$this->args['fields']}"; |
792 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
793 | - $fields = "{$wpdb->posts}." . implode( " , {$wpdb->posts}.", $this->args['fields'] ); |
|
792 | + } elseif (is_array($this->args['fields'])) { |
|
793 | + $fields = "{$wpdb->posts}.".implode(" , {$wpdb->posts}.", $this->args['fields']); |
|
794 | 794 | } |
795 | 795 | } |
796 | 796 | |
797 | 797 | // Set count. |
798 | - if ( ! empty( $this->args['count'] ) ) { |
|
798 | + if ( ! empty($this->args['count'])) { |
|
799 | 799 | $fields = "COUNT({$wpdb->posts}.ID)"; |
800 | 800 | |
801 | - if ( ! empty( $this->args['group_by'] ) ) { |
|
801 | + if ( ! empty($this->args['group_by'])) { |
|
802 | 802 | $fields = "{$wpdb->posts}.{$this->args['group_by']}, {$fields}"; |
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
806 | 806 | // Date query. |
807 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
808 | - $date_query_obj = new WP_Date_Query( $this->args['date_query'] ); |
|
809 | - $where .= str_replace( |
|
807 | + if ( ! empty($this->args['date_query'])) { |
|
808 | + $date_query_obj = new WP_Date_Query($this->args['date_query']); |
|
809 | + $where .= str_replace( |
|
810 | 810 | array( |
811 | 811 | "\n", |
812 | 812 | '( (', |
@@ -822,21 +822,21 @@ discard block |
||
822 | 822 | } |
823 | 823 | |
824 | 824 | // Meta query. |
825 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
826 | - $meta_query_obj = new WP_Meta_Query( $this->args['meta_query'] ); |
|
827 | - $where = implode( ' ', $meta_query_obj->get_sql( 'post', $wpdb->posts, 'ID' ) ) . " {$where}"; |
|
825 | + if ( ! empty($this->args['meta_query'])) { |
|
826 | + $meta_query_obj = new WP_Meta_Query($this->args['meta_query']); |
|
827 | + $where = implode(' ', $meta_query_obj->get_sql('post', $wpdb->posts, 'ID'))." {$where}"; |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | // Set sql query. |
831 | 831 | $sql = $wpdb->prepare( |
832 | 832 | "SELECT {$fields} FROM {$wpdb->posts} LIMIT %d,%d;", |
833 | - absint( $this->args['offset'] ), |
|
834 | - ( empty( $this->args['nopaging'] ) ? absint( $this->args['posts_per_page'] ) : 999999999999999 ) |
|
833 | + absint($this->args['offset']), |
|
834 | + (empty($this->args['nopaging']) ? absint($this->args['posts_per_page']) : 999999999999999) |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
838 | 838 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
839 | - $sql = str_replace( 'LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql ); |
|
839 | + $sql = str_replace('LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql); |
|
840 | 840 | |
841 | 841 | return $sql; |
842 | 842 | } |
@@ -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 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * @param bool $_id Post id. Default is false. |
338 | 338 | * @param array $_args Arguments passed. |
339 | 339 | */ |
340 | - public function __construct( $_id = false, $_args = array() ) { |
|
340 | + public function __construct($_id = false, $_args = array()) { |
|
341 | 341 | |
342 | - $donation_form = WP_Post::get_instance( $_id ); |
|
342 | + $donation_form = WP_Post::get_instance($_id); |
|
343 | 343 | |
344 | - return $this->setup_donation_form( $donation_form ); |
|
344 | + return $this->setup_donation_form($donation_form); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -354,23 +354,23 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return bool If the setup was successful or not. |
356 | 356 | */ |
357 | - private function setup_donation_form( $donation_form ) { |
|
357 | + private function setup_donation_form($donation_form) { |
|
358 | 358 | |
359 | - if ( ! is_object( $donation_form ) ) { |
|
359 | + if ( ! is_object($donation_form)) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
363 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
364 | 364 | return false; |
365 | 365 | } |
366 | 366 | |
367 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
367 | + if ('give_forms' !== $donation_form->post_type) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | - foreach ( $donation_form as $key => $value ) { |
|
371 | + foreach ($donation_form as $key => $value) { |
|
372 | 372 | |
373 | - switch ( $key ) { |
|
373 | + switch ($key) { |
|
374 | 374 | |
375 | 375 | default: |
376 | 376 | $this->$key = $value; |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return mixed |
396 | 396 | */ |
397 | - public function __get( $key ) { |
|
397 | + public function __get($key) { |
|
398 | 398 | |
399 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
399 | + if (method_exists($this, 'get_'.$key)) { |
|
400 | 400 | |
401 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
401 | + return call_user_func(array($this, 'get_'.$key)); |
|
402 | 402 | |
403 | 403 | } else { |
404 | 404 | |
405 | 405 | /* translators: %s: property key */ |
406 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
406 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool|int False if data isn't passed and class not instantiated for creation, or New Form ID. |
421 | 421 | */ |
422 | - public function create( $data = array() ) { |
|
422 | + public function create($data = array()) { |
|
423 | 423 | |
424 | - if ( $this->id != 0 ) { |
|
424 | + if ($this->id != 0) { |
|
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
428 | 428 | $defaults = array( |
429 | 429 | 'post_type' => 'give_forms', |
430 | 430 | 'post_status' => 'draft', |
431 | - 'post_title' => __( 'New Donation Form', 'give' ), |
|
431 | + 'post_title' => __('New Donation Form', 'give'), |
|
432 | 432 | ); |
433 | 433 | |
434 | - $args = wp_parse_args( $data, $defaults ); |
|
434 | + $args = wp_parse_args($data, $defaults); |
|
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Fired before a donation form is created |
438 | 438 | * |
439 | 439 | * @param array $args The post object arguments used for creation. |
440 | 440 | */ |
441 | - do_action( 'give_form_pre_create', $args ); |
|
441 | + do_action('give_form_pre_create', $args); |
|
442 | 442 | |
443 | - $id = wp_insert_post( $args, true ); |
|
443 | + $id = wp_insert_post($args, true); |
|
444 | 444 | |
445 | - $donation_form = WP_Post::get_instance( $id ); |
|
445 | + $donation_form = WP_Post::get_instance($id); |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Fired after a donation form is created |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | * @param int $id The post ID of the created item. |
451 | 451 | * @param array $args The post object arguments used for creation. |
452 | 452 | */ |
453 | - do_action( 'give_form_post_create', $id, $args ); |
|
453 | + do_action('give_form_post_create', $id, $args); |
|
454 | 454 | |
455 | - return $this->setup_donation_form( $donation_form ); |
|
455 | + return $this->setup_donation_form($donation_form); |
|
456 | 456 | |
457 | 457 | } |
458 | 458 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return string Donation form name. |
478 | 478 | */ |
479 | 479 | public function get_name() { |
480 | - return get_the_title( $this->ID ); |
|
480 | + return get_the_title($this->ID); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function get_price() { |
492 | 492 | |
493 | - if ( ! isset( $this->price ) ) { |
|
493 | + if ( ! isset($this->price)) { |
|
494 | 494 | |
495 | 495 | $this->price = give_maybe_sanitize_amount( |
496 | 496 | give_get_meta( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | |
503 | - if ( ! $this->price ) { |
|
503 | + if ( ! $this->price) { |
|
504 | 504 | $this->price = 0; |
505 | 505 | } |
506 | 506 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param string $price The donation form price. |
515 | 515 | * @param string|int $id The form ID. |
516 | 516 | */ |
517 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
517 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | */ |
528 | 528 | public function get_minimum_price() { |
529 | 529 | |
530 | - if ( ! isset( $this->minimum_price ) ) { |
|
530 | + if ( ! isset($this->minimum_price)) { |
|
531 | 531 | |
532 | - $this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
532 | + $this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true); |
|
533 | 533 | |
534 | - if ( ! $this->is_custom_price_mode() ) { |
|
534 | + if ( ! $this->is_custom_price_mode()) { |
|
535 | 535 | $this->minimum_price = 0; |
536 | 536 | } |
537 | 537 | |
538 | 538 | } |
539 | 539 | |
540 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
540 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | */ |
551 | 551 | public function get_prices() { |
552 | 552 | |
553 | - if ( ! isset( $this->prices ) ) { |
|
553 | + if ( ! isset($this->prices)) { |
|
554 | 554 | |
555 | - $this->prices = give_get_meta( $this->ID, '_give_donation_levels', true ); |
|
555 | + $this->prices = give_get_meta($this->ID, '_give_donation_levels', true); |
|
556 | 556 | |
557 | 557 | } |
558 | 558 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * @param array $prices The array of mulit-level prices. |
565 | 565 | * @param int|string $ID The ID of the form. |
566 | 566 | */ |
567 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
567 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
568 | 568 | |
569 | 569 | } |
570 | 570 | |
@@ -578,17 +578,17 @@ discard block |
||
578 | 578 | */ |
579 | 579 | public function get_goal() { |
580 | 580 | |
581 | - if ( ! isset( $this->goal ) ) { |
|
581 | + if ( ! isset($this->goal)) { |
|
582 | 582 | |
583 | - $this->goal = give_get_meta( $this->ID, '_give_set_goal', true ); |
|
583 | + $this->goal = give_get_meta($this->ID, '_give_set_goal', true); |
|
584 | 584 | |
585 | - if ( ! $this->goal ) { |
|
585 | + if ( ! $this->goal) { |
|
586 | 586 | $this->goal = 0; |
587 | 587 | } |
588 | 588 | |
589 | 589 | } |
590 | 590 | |
591 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
591 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | |
@@ -602,10 +602,10 @@ discard block |
||
602 | 602 | */ |
603 | 603 | public function is_single_price_mode() { |
604 | 604 | |
605 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
605 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
606 | 606 | $ret = 0; |
607 | 607 | |
608 | - if ( empty( $option ) || $option === 'set' ) { |
|
608 | + if (empty($option) || $option === 'set') { |
|
609 | 609 | $ret = 1; |
610 | 610 | } |
611 | 611 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * @param bool $ret Is donation form in single price mode? |
618 | 618 | * @param int|string $ID The ID of the donation form. |
619 | 619 | */ |
620 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
620 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
621 | 621 | |
622 | 622 | } |
623 | 623 | |
@@ -631,10 +631,10 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function is_custom_price_mode() { |
633 | 633 | |
634 | - $option = give_get_meta( $this->ID, '_give_custom_amount', true ); |
|
634 | + $option = give_get_meta($this->ID, '_give_custom_amount', true); |
|
635 | 635 | $ret = 0; |
636 | 636 | |
637 | - if ( give_is_setting_enabled( $option ) ) { |
|
637 | + if (give_is_setting_enabled($option)) { |
|
638 | 638 | $ret = 1; |
639 | 639 | } |
640 | 640 | |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @param bool $ret Is donation form in custom price mode? |
647 | 647 | * @param int|string $ID The ID of the donation form. |
648 | 648 | */ |
649 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
649 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
650 | 650 | |
651 | 651 | } |
652 | 652 | |
@@ -660,20 +660,20 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @return bool |
662 | 662 | */ |
663 | - public function is_custom_price( $amount ) { |
|
663 | + public function is_custom_price($amount) { |
|
664 | 664 | $result = false; |
665 | - $amount = give_maybe_sanitize_amount( $amount ); |
|
665 | + $amount = give_maybe_sanitize_amount($amount); |
|
666 | 666 | |
667 | - if ( $this->is_custom_price_mode() ) { |
|
667 | + if ($this->is_custom_price_mode()) { |
|
668 | 668 | |
669 | - if ( 'set' === $this->get_type() ) { |
|
670 | - if ( $amount !== $this->get_price() ) { |
|
669 | + if ('set' === $this->get_type()) { |
|
670 | + if ($amount !== $this->get_price()) { |
|
671 | 671 | $result = true; |
672 | 672 | } |
673 | 673 | |
674 | - } elseif ( 'multi' === $this->get_type() ) { |
|
675 | - $level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) ); |
|
676 | - $result = ! in_array( $amount, $level_amounts ); |
|
674 | + } elseif ('multi' === $this->get_type()) { |
|
675 | + $level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount')); |
|
676 | + $result = ! in_array($amount, $level_amounts); |
|
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * |
687 | 687 | * @since 1.8.18 |
688 | 688 | */ |
689 | - return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID ); |
|
689 | + return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -701,10 +701,10 @@ discard block |
||
701 | 701 | */ |
702 | 702 | public function has_variable_prices() { |
703 | 703 | |
704 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
704 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
705 | 705 | $ret = 0; |
706 | 706 | |
707 | - if ( $option === 'multi' ) { |
|
707 | + if ($option === 'multi') { |
|
708 | 708 | $ret = 1; |
709 | 709 | } |
710 | 710 | |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param bool $ret Does donation form have variable prices? |
715 | 715 | * @param int|string $ID The ID of the donation form. |
716 | 716 | */ |
717 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
717 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
718 | 718 | |
719 | 719 | } |
720 | 720 | |
@@ -728,17 +728,17 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function get_type() { |
730 | 730 | |
731 | - if ( ! isset( $this->type ) ) { |
|
731 | + if ( ! isset($this->type)) { |
|
732 | 732 | |
733 | - $this->type = give_get_meta( $this->ID, '_give_price_option', true ); |
|
733 | + $this->type = give_get_meta($this->ID, '_give_price_option', true); |
|
734 | 734 | |
735 | - if ( empty( $this->type ) ) { |
|
735 | + if (empty($this->type)) { |
|
736 | 736 | $this->type = 'set'; |
737 | 737 | } |
738 | 738 | |
739 | 739 | } |
740 | 740 | |
741 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
741 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
742 | 742 | |
743 | 743 | } |
744 | 744 | |
@@ -754,23 +754,23 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return string |
756 | 756 | */ |
757 | - public function get_form_classes( $args ) { |
|
757 | + public function get_form_classes($args) { |
|
758 | 758 | |
759 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
759 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
760 | 760 | ? 'float-labels-enabled' |
761 | 761 | : ''; |
762 | 762 | |
763 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
763 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
764 | 764 | 'give-form', |
765 | - 'give-form-' . $this->ID, |
|
766 | - 'give-form-type-' . $this->get_type(), |
|
765 | + 'give-form-'.$this->ID, |
|
766 | + 'give-form-type-'.$this->get_type(), |
|
767 | 767 | $float_labels_option, |
768 | - ), $this->ID, $args ); |
|
768 | + ), $this->ID, $args); |
|
769 | 769 | |
770 | 770 | // Remove empty class names. |
771 | - $form_classes_array = array_filter( $form_classes_array ); |
|
771 | + $form_classes_array = array_filter($form_classes_array); |
|
772 | 772 | |
773 | - return implode( ' ', $form_classes_array ); |
|
773 | + return implode(' ', $form_classes_array); |
|
774 | 774 | |
775 | 775 | } |
776 | 776 | |
@@ -785,22 +785,22 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @return string |
787 | 787 | */ |
788 | - public function get_form_wrap_classes( $args ) { |
|
788 | + public function get_form_wrap_classes($args) { |
|
789 | 789 | $custom_class = array( |
790 | 790 | 'give-form-wrap', |
791 | 791 | ); |
792 | 792 | |
793 | - if ( $this->is_close_donation_form() ) { |
|
793 | + if ($this->is_close_donation_form()) { |
|
794 | 794 | $custom_class[] = 'give-form-closed'; |
795 | - } else{ |
|
796 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
795 | + } else { |
|
796 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
797 | 797 | ? $args['display_style'] |
798 | - : give_get_meta( $this->ID, '_give_payment_display', true ); |
|
798 | + : give_get_meta($this->ID, '_give_payment_display', true); |
|
799 | 799 | |
800 | 800 | $custom_class[] = "give-display-{$display_option}"; |
801 | 801 | |
802 | 802 | // If admin want to show only button for form then user inbuilt modal functionality. |
803 | - if ( 'button' === $display_option ) { |
|
803 | + if ('button' === $display_option) { |
|
804 | 804 | $custom_class[] = 'give-display-button-only'; |
805 | 805 | } |
806 | 806 | } |
@@ -811,10 +811,10 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @since 1.0 |
813 | 813 | */ |
814 | - $form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args ); |
|
814 | + $form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args); |
|
815 | 815 | |
816 | 816 | |
817 | - return implode( ' ', $form_wrap_classes_array ); |
|
817 | + return implode(' ', $form_wrap_classes_array); |
|
818 | 818 | |
819 | 819 | } |
820 | 820 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | public function is_set_type_donation_form() { |
830 | 830 | $form_type = $this->get_type(); |
831 | 831 | |
832 | - return ( 'set' === $form_type ? true : false ); |
|
832 | + return ('set' === $form_type ? true : false); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | public function is_multi_type_donation_form() { |
844 | 844 | $form_type = $this->get_type(); |
845 | 845 | |
846 | - return ( 'multi' === $form_type ? true : false ); |
|
846 | + return ('multi' === $form_type ? true : false); |
|
847 | 847 | |
848 | 848 | } |
849 | 849 | |
@@ -857,15 +857,15 @@ discard block |
||
857 | 857 | */ |
858 | 858 | public function get_sales() { |
859 | 859 | |
860 | - if ( ! isset( $this->sales ) ) { |
|
860 | + if ( ! isset($this->sales)) { |
|
861 | 861 | |
862 | - if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) { |
|
863 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
862 | + if ('' == give_get_meta($this->ID, '_give_form_sales', true)) { |
|
863 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
864 | 864 | } // End if |
865 | 865 | |
866 | - $this->sales = give_get_meta( $this->ID, '_give_form_sales', true ); |
|
866 | + $this->sales = give_get_meta($this->ID, '_give_form_sales', true); |
|
867 | 867 | |
868 | - if ( $this->sales < 0 ) { |
|
868 | + if ($this->sales < 0) { |
|
869 | 869 | // Never let sales be less than zero. |
870 | 870 | $this->sales = 0; |
871 | 871 | } |
@@ -886,13 +886,13 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return int|false New number of total sales. |
888 | 888 | */ |
889 | - public function increase_sales( $quantity = 1 ) { |
|
889 | + public function increase_sales($quantity = 1) { |
|
890 | 890 | |
891 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
892 | - $quantity = absint( $quantity ); |
|
891 | + $sales = give_get_form_sales_stats($this->ID); |
|
892 | + $quantity = absint($quantity); |
|
893 | 893 | $total_sales = $sales + $quantity; |
894 | 894 | |
895 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
895 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
896 | 896 | |
897 | 897 | $this->sales = $total_sales; |
898 | 898 | |
@@ -913,17 +913,17 @@ discard block |
||
913 | 913 | * |
914 | 914 | * @return int|false New number of total sales. |
915 | 915 | */ |
916 | - public function decrease_sales( $quantity = 1 ) { |
|
916 | + public function decrease_sales($quantity = 1) { |
|
917 | 917 | |
918 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
918 | + $sales = give_get_form_sales_stats($this->ID); |
|
919 | 919 | |
920 | 920 | // Only decrease if not already zero |
921 | - if ( $sales > 0 ) { |
|
921 | + if ($sales > 0) { |
|
922 | 922 | |
923 | - $quantity = absint( $quantity ); |
|
923 | + $quantity = absint($quantity); |
|
924 | 924 | $total_sales = $sales - $quantity; |
925 | 925 | |
926 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
926 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
927 | 927 | |
928 | 928 | $this->sales = $sales; |
929 | 929 | |
@@ -947,15 +947,15 @@ discard block |
||
947 | 947 | */ |
948 | 948 | public function get_earnings() { |
949 | 949 | |
950 | - if ( ! isset( $this->earnings ) ) { |
|
950 | + if ( ! isset($this->earnings)) { |
|
951 | 951 | |
952 | - if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
953 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
952 | + if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) { |
|
953 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
954 | 954 | } |
955 | 955 | |
956 | - $this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true ); |
|
956 | + $this->earnings = give_get_meta($this->ID, '_give_form_earnings', true); |
|
957 | 957 | |
958 | - if ( $this->earnings < 0 ) { |
|
958 | + if ($this->earnings < 0) { |
|
959 | 959 | // Never let earnings be less than zero |
960 | 960 | $this->earnings = 0; |
961 | 961 | } |
@@ -976,12 +976,12 @@ discard block |
||
976 | 976 | * |
977 | 977 | * @return float|false |
978 | 978 | */ |
979 | - public function increase_earnings( $amount = 0 ) { |
|
979 | + public function increase_earnings($amount = 0) { |
|
980 | 980 | |
981 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
981 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
982 | 982 | $new_amount = $earnings + (float) $amount; |
983 | 983 | |
984 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
984 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
985 | 985 | |
986 | 986 | $this->earnings = $new_amount; |
987 | 987 | |
@@ -1003,16 +1003,16 @@ discard block |
||
1003 | 1003 | * |
1004 | 1004 | * @return float|false |
1005 | 1005 | */ |
1006 | - public function decrease_earnings( $amount ) { |
|
1006 | + public function decrease_earnings($amount) { |
|
1007 | 1007 | |
1008 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
1008 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
1009 | 1009 | |
1010 | - if ( $earnings > 0 ) { |
|
1010 | + if ($earnings > 0) { |
|
1011 | 1011 | // Only decrease if greater than zero |
1012 | 1012 | $new_amount = $earnings - (float) $amount; |
1013 | 1013 | |
1014 | 1014 | |
1015 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
1015 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
1016 | 1016 | |
1017 | 1017 | $this->earnings = $new_amount; |
1018 | 1018 | |
@@ -1036,22 +1036,22 @@ discard block |
||
1036 | 1036 | * |
1037 | 1037 | * @return bool |
1038 | 1038 | */ |
1039 | - public function is_free( $price_id = false ) { |
|
1039 | + public function is_free($price_id = false) { |
|
1040 | 1040 | |
1041 | 1041 | $is_free = false; |
1042 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
1042 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
1043 | 1043 | |
1044 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
1045 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
1046 | - } elseif ( ! $variable_pricing ) { |
|
1047 | - $price = give_get_meta( $this->ID, '_give_set_price', true ); |
|
1044 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
1045 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
1046 | + } elseif ( ! $variable_pricing) { |
|
1047 | + $price = give_get_meta($this->ID, '_give_set_price', true); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
1050 | + if (isset($price) && (float) $price == 0) { |
|
1051 | 1051 | $is_free = true; |
1052 | 1052 | } |
1053 | 1053 | |
1054 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
1054 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
1055 | 1055 | |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | $is_close_form = apply_filters( |
1079 | 1079 | 'give_is_close_donation_form', |
1080 | 1080 | ( |
1081 | - give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) ) |
|
1082 | - && give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1083 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1081 | + give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) ) |
|
1082 | + && give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true)) |
|
1083 | + && ($this->get_goal() <= $this->get_earnings() |
|
1084 | 1084 | ), |
1085 | 1085 | $this->ID |
1086 | 1086 | ); |
@@ -1099,29 +1099,29 @@ discard block |
||
1099 | 1099 | * |
1100 | 1100 | * @return bool The result of the update query. |
1101 | 1101 | */ |
1102 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
1102 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
1103 | 1103 | |
1104 | 1104 | /* @var WPDB $wpdb */ |
1105 | 1105 | global $wpdb; |
1106 | 1106 | |
1107 | - if ( empty( $meta_key ) ) { |
|
1107 | + if (empty($meta_key)) { |
|
1108 | 1108 | return false; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // Make sure if it needs to be serialized, we do |
1112 | - $meta_value = maybe_serialize( $meta_value ); |
|
1112 | + $meta_value = maybe_serialize($meta_value); |
|
1113 | 1113 | |
1114 | - if ( is_numeric( $meta_value ) ) { |
|
1115 | - $value_type = is_float( $meta_value ) ? '%f' : '%d'; |
|
1114 | + if (is_numeric($meta_value)) { |
|
1115 | + $value_type = is_float($meta_value) ? '%f' : '%d'; |
|
1116 | 1116 | } else { |
1117 | 1117 | $value_type = "'%s'"; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - $sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key ); |
|
1120 | + $sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key); |
|
1121 | 1121 | |
1122 | - if ( $wpdb->query( $sql ) ) { |
|
1122 | + if ($wpdb->query($sql)) { |
|
1123 | 1123 | |
1124 | - clean_post_cache( $this->ID ); |
|
1124 | + clean_post_cache($this->ID); |
|
1125 | 1125 | |
1126 | 1126 | return true; |
1127 | 1127 |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return string The currency code |
22 | 22 | */ |
23 | -function give_get_currency( $donation_or_form_id = null, $args = array() ) { |
|
23 | +function give_get_currency($donation_or_form_id = null, $args = array()) { |
|
24 | 24 | |
25 | 25 | // Get currency from donation |
26 | - if ( is_numeric( $donation_or_form_id ) && 'give_payment' === get_post_type( $donation_or_form_id ) ) { |
|
27 | - $donation_meta = give_get_meta( $donation_or_form_id, '_give_payment_meta', true ); |
|
26 | + if (is_numeric($donation_or_form_id) && 'give_payment' === get_post_type($donation_or_form_id)) { |
|
27 | + $donation_meta = give_get_meta($donation_or_form_id, '_give_payment_meta', true); |
|
28 | 28 | |
29 | - if ( ! empty( $donation_meta['currency'] ) ) { |
|
29 | + if ( ! empty($donation_meta['currency'])) { |
|
30 | 30 | $currency = $donation_meta['currency']; |
31 | 31 | } else { |
32 | - $currency = give_get_option( 'currency', 'USD' ); |
|
32 | + $currency = give_get_option('currency', 'USD'); |
|
33 | 33 | } |
34 | 34 | } else { |
35 | - $currency = give_get_option( 'currency', 'USD' ); |
|
35 | + $currency = give_get_option('currency', 'USD'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.0 |
42 | 42 | */ |
43 | - return apply_filters( 'give_currency', $currency, $donation_or_form_id, $args ); |
|
43 | + return apply_filters('give_currency', $currency, $donation_or_form_id, $args); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function give_get_currency_position() { |
54 | 54 | |
55 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
55 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
56 | 56 | |
57 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
57 | + return apply_filters('give_currency_position', $currency_pos); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | function give_get_currencies_list() { |
68 | 68 | $currencies = array( |
69 | 69 | 'USD' => array( |
70 | - 'admin_label' => __( 'US Dollars ($)', 'give' ), |
|
70 | + 'admin_label' => __('US Dollars ($)', 'give'), |
|
71 | 71 | 'symbol' => '$', |
72 | 72 | 'setting' => array( |
73 | 73 | 'currency_position' => 'before', |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | 'EUR' => array( |
80 | - 'admin_label' => __( 'Euros (€)', 'give' ), |
|
80 | + 'admin_label' => __('Euros (€)', 'give'), |
|
81 | 81 | 'symbol' => '€', |
82 | 82 | 'setting' => array( |
83 | 83 | 'currency_position' => 'before', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | ), |
89 | 89 | 'GBP' => array( |
90 | - 'admin_label' => __( 'Pounds Sterling (£)', 'give' ), |
|
90 | + 'admin_label' => __('Pounds Sterling (£)', 'give'), |
|
91 | 91 | 'symbol' => '£', |
92 | 92 | 'setting' => array( |
93 | 93 | 'currency_position' => 'before', |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ), |
98 | 98 | ), |
99 | 99 | 'AUD' => array( |
100 | - 'admin_label' => __( 'Australian Dollars ($)', 'give' ), |
|
100 | + 'admin_label' => __('Australian Dollars ($)', 'give'), |
|
101 | 101 | 'symbol' => '$', |
102 | 102 | 'setting' => array( |
103 | 103 | 'currency_position' => 'before', |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | 'BRL' => array( |
110 | - 'admin_label' => __( 'Brazilian Real (R$)', 'give' ), |
|
110 | + 'admin_label' => __('Brazilian Real (R$)', 'give'), |
|
111 | 111 | 'symbol' => 'R$', |
112 | 112 | 'setting' => array( |
113 | 113 | 'currency_position' => 'before', |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ), |
118 | 118 | ), |
119 | 119 | 'CAD' => array( |
120 | - 'admin_label' => __( 'Canadian Dollars ($)', 'give' ), |
|
120 | + 'admin_label' => __('Canadian Dollars ($)', 'give'), |
|
121 | 121 | 'symbol' => '$', |
122 | 122 | 'setting' => array( |
123 | 123 | 'currency_position' => 'before', |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | ), |
128 | 128 | ), |
129 | 129 | 'CZK' => array( |
130 | - 'admin_label' => __( 'Czech Koruna (Kč)', 'give' ), |
|
130 | + 'admin_label' => __('Czech Koruna (Kč)', 'give'), |
|
131 | 131 | 'symbol' => 'Kč', |
132 | 132 | 'setting' => array( |
133 | 133 | 'currency_position' => 'after', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ), |
138 | 138 | ), |
139 | 139 | 'DKK' => array( |
140 | - 'admin_label' => __( 'Danish Krone (kr.)', 'give' ), |
|
140 | + 'admin_label' => __('Danish Krone (kr.)', 'give'), |
|
141 | 141 | 'symbol' => ' kr. ', |
142 | 142 | 'setting' => array( |
143 | 143 | 'currency_position' => 'before', |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | ), |
148 | 148 | ), |
149 | 149 | 'HKD' => array( |
150 | - 'admin_label' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
150 | + 'admin_label' => __('Hong Kong Dollar ($)', 'give'), |
|
151 | 151 | 'symbol' => '$', |
152 | 152 | 'setting' => array( |
153 | 153 | 'currency_position' => 'before', |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ), |
158 | 158 | ), |
159 | 159 | 'HUF' => array( |
160 | - 'admin_label' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
160 | + 'admin_label' => __('Hungarian Forint (Ft)', 'give'), |
|
161 | 161 | 'symbol' => 'Ft', |
162 | 162 | 'setting' => array( |
163 | 163 | 'currency_position' => 'after', |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | 'ILS' => array( |
170 | - 'admin_label' => __( 'Israeli Shekel (₪)', 'give' ), |
|
170 | + 'admin_label' => __('Israeli Shekel (₪)', 'give'), |
|
171 | 171 | 'symbol' => '₪', |
172 | 172 | 'setting' => array( |
173 | 173 | 'currency_position' => 'after', |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ), |
178 | 178 | ), |
179 | 179 | 'JPY' => array( |
180 | - 'admin_label' => __( 'Japanese Yen (¥)', 'give' ), |
|
180 | + 'admin_label' => __('Japanese Yen (¥)', 'give'), |
|
181 | 181 | 'symbol' => '¥', |
182 | 182 | 'setting' => array( |
183 | 183 | 'currency_position' => 'before', |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ), |
188 | 188 | ), |
189 | 189 | 'MYR' => array( |
190 | - 'admin_label' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
190 | + 'admin_label' => __('Malaysian Ringgits (RM)', 'give'), |
|
191 | 191 | 'symbol' => 'RM', |
192 | 192 | 'setting' => array( |
193 | 193 | 'currency_position' => 'before', |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | ), |
198 | 198 | ), |
199 | 199 | 'MXN' => array( |
200 | - 'admin_label' => __( 'Mexican Peso ($)', 'give' ), |
|
200 | + 'admin_label' => __('Mexican Peso ($)', 'give'), |
|
201 | 201 | 'symbol' => '$', |
202 | 202 | 'setting' => array( |
203 | 203 | 'currency_position' => 'before', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ), |
208 | 208 | ), |
209 | 209 | 'MAD' => array( |
210 | - 'admin_label' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
210 | + 'admin_label' => __('Moroccan Dirham (.د.م)', 'give'), |
|
211 | 211 | 'symbol' => '.د.م', |
212 | 212 | 'setting' => array( |
213 | 213 | 'currency_position' => 'before', |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ), |
218 | 218 | ), |
219 | 219 | 'NZD' => array( |
220 | - 'admin_label' => __( 'New Zealand Dollar ($)', 'give' ), |
|
220 | + 'admin_label' => __('New Zealand Dollar ($)', 'give'), |
|
221 | 221 | 'symbol' => '$', |
222 | 222 | 'setting' => array( |
223 | 223 | 'currency_position' => 'before', |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ), |
228 | 228 | ), |
229 | 229 | 'NOK' => array( |
230 | - 'admin_label' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
230 | + 'admin_label' => __('Norwegian Krone (Kr.)', 'give'), |
|
231 | 231 | 'symbol' => 'kr.', |
232 | 232 | 'setting' => array( |
233 | 233 | 'currency_position' => 'before', |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | ), |
238 | 238 | ), |
239 | 239 | 'PHP' => array( |
240 | - 'admin_label' => __( 'Philippine Pesos (₱)', 'give' ), |
|
240 | + 'admin_label' => __('Philippine Pesos (₱)', 'give'), |
|
241 | 241 | 'symbol' => '₱', |
242 | 242 | 'setting' => array( |
243 | 243 | 'currency_position' => 'before', |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ), |
248 | 248 | ), |
249 | 249 | 'PLN' => array( |
250 | - 'admin_label' => __( 'Polish Zloty (zł)', 'give' ), |
|
250 | + 'admin_label' => __('Polish Zloty (zł)', 'give'), |
|
251 | 251 | 'symbol' => 'zł', |
252 | 252 | 'setting' => array( |
253 | 253 | 'currency_position' => 'after', |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | ), |
258 | 258 | ), |
259 | 259 | 'SGD' => array( |
260 | - 'admin_label' => __( 'Singapore Dollar ($)', 'give' ), |
|
260 | + 'admin_label' => __('Singapore Dollar ($)', 'give'), |
|
261 | 261 | 'symbol' => '$', |
262 | 262 | 'setting' => array( |
263 | 263 | 'currency_position' => 'before', |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | ), |
268 | 268 | ), |
269 | 269 | 'KRW' => array( |
270 | - 'admin_label' => __( 'South Korean Won (₩)', 'give' ), |
|
270 | + 'admin_label' => __('South Korean Won (₩)', 'give'), |
|
271 | 271 | 'symbol' => '₩', |
272 | 272 | 'setting' => array( |
273 | 273 | 'currency_position' => 'before', |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ), |
278 | 278 | ), |
279 | 279 | 'ZAR' => array( |
280 | - 'admin_label' => __( 'South African Rand (R)', 'give' ), |
|
280 | + 'admin_label' => __('South African Rand (R)', 'give'), |
|
281 | 281 | 'symbol' => 'R', |
282 | 282 | 'setting' => array( |
283 | 283 | 'currency_position' => 'before', |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | ), |
288 | 288 | ), |
289 | 289 | 'SEK' => array( |
290 | - 'admin_label' => __( 'Swedish Krona (kr)', 'give' ), |
|
290 | + 'admin_label' => __('Swedish Krona (kr)', 'give'), |
|
291 | 291 | 'symbol' => ' kr. ', |
292 | 292 | 'setting' => array( |
293 | 293 | 'currency_position' => 'before', |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | ), |
298 | 298 | ), |
299 | 299 | 'CHF' => array( |
300 | - 'admin_label' => __( 'Swiss Franc (Fr)', 'give' ), |
|
300 | + 'admin_label' => __('Swiss Franc (Fr)', 'give'), |
|
301 | 301 | 'symbol' => 'Fr', |
302 | 302 | 'setting' => array( |
303 | 303 | 'currency_position' => 'before', |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | ), |
308 | 308 | ), |
309 | 309 | 'TWD' => array( |
310 | - 'admin_label' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
310 | + 'admin_label' => __('Taiwan New Dollars (NT$)', 'give'), |
|
311 | 311 | 'symbol' => 'NT$', |
312 | 312 | 'setting' => array( |
313 | 313 | 'currency_position' => 'before', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | ), |
318 | 318 | ), |
319 | 319 | 'THB' => array( |
320 | - 'admin_label' => __( 'Thai Baht (฿)', 'give' ), |
|
320 | + 'admin_label' => __('Thai Baht (฿)', 'give'), |
|
321 | 321 | 'symbol' => '฿', |
322 | 322 | 'setting' => array( |
323 | 323 | 'currency_position' => 'before', |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | ), |
328 | 328 | ), |
329 | 329 | 'INR' => array( |
330 | - 'admin_label' => __( 'Indian Rupee (₹)', 'give' ), |
|
330 | + 'admin_label' => __('Indian Rupee (₹)', 'give'), |
|
331 | 331 | 'symbol' => '₹', |
332 | 332 | 'setting' => array( |
333 | 333 | 'currency_position' => 'before', |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | ), |
338 | 338 | ), |
339 | 339 | 'TRY' => array( |
340 | - 'admin_label' => __( 'Turkish Lira (₺)', 'give' ), |
|
340 | + 'admin_label' => __('Turkish Lira (₺)', 'give'), |
|
341 | 341 | 'symbol' => '₺', |
342 | 342 | 'setting' => array( |
343 | 343 | 'currency_position' => 'after', |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | ), |
348 | 348 | ), |
349 | 349 | 'IRR' => array( |
350 | - 'admin_label' => __( 'Iranian Rial (﷼)', 'give' ), |
|
350 | + 'admin_label' => __('Iranian Rial (﷼)', 'give'), |
|
351 | 351 | 'symbol' => '﷼', |
352 | 352 | 'setting' => array( |
353 | 353 | 'currency_position' => 'after', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | ), |
358 | 358 | ), |
359 | 359 | 'RUB' => array( |
360 | - 'admin_label' => __( 'Russian Rubles (руб)', 'give' ), |
|
360 | + 'admin_label' => __('Russian Rubles (руб)', 'give'), |
|
361 | 361 | 'symbol' => '₽', |
362 | 362 | 'setting' => array( |
363 | 363 | 'currency_position' => 'before', |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ), |
368 | 368 | ), |
369 | 369 | 'AED' => array( |
370 | - 'admin_label' => __( 'United Arab Emirates dirham (د.إ)', 'give' ), |
|
370 | + 'admin_label' => __('United Arab Emirates dirham (د.إ)', 'give'), |
|
371 | 371 | 'symbol' => 'د.إ', |
372 | 372 | 'setting' => array( |
373 | 373 | 'currency_position' => 'before', |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ), |
378 | 378 | ), |
379 | 379 | 'AMD' => array( |
380 | - 'admin_label' => __( 'Armenian dram (AMD)', 'give' ), |
|
380 | + 'admin_label' => __('Armenian dram (AMD)', 'give'), |
|
381 | 381 | 'symbol' => 'AMD', // Add backward compatibility. Using AMD in place of ֏ |
382 | 382 | 'setting' => array( |
383 | 383 | 'currency_position' => 'before', |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | ), |
388 | 388 | ), |
389 | 389 | 'ANG' => array( |
390 | - 'admin_label' => __( 'Netherlands Antillean guilder (ƒ)', 'give' ), |
|
390 | + 'admin_label' => __('Netherlands Antillean guilder (ƒ)', 'give'), |
|
391 | 391 | 'symbol' => 'ƒ', |
392 | 392 | 'setting' => array( |
393 | 393 | 'currency_position' => 'before', |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | ), |
398 | 398 | ), |
399 | 399 | 'ARS' => array( |
400 | - 'admin_label' => __( 'Argentine peso ($)', 'give' ), |
|
400 | + 'admin_label' => __('Argentine peso ($)', 'give'), |
|
401 | 401 | 'symbol' => '$', |
402 | 402 | 'setting' => array( |
403 | 403 | 'currency_position' => 'before', |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | ), |
408 | 408 | ), |
409 | 409 | 'AWG' => array( |
410 | - 'admin_label' => __( 'Aruban florin (ƒ)', 'give' ), |
|
410 | + 'admin_label' => __('Aruban florin (ƒ)', 'give'), |
|
411 | 411 | 'symbol' => 'ƒ', |
412 | 412 | 'setting' => array( |
413 | 413 | 'currency_position' => 'before', |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | ), |
418 | 418 | ), |
419 | 419 | 'BAM' => array( |
420 | - 'admin_label' => __( 'Bosnia and Herzegovina convertible mark (KM)', 'give' ), |
|
420 | + 'admin_label' => __('Bosnia and Herzegovina convertible mark (KM)', 'give'), |
|
421 | 421 | 'symbol' => 'KM', |
422 | 422 | 'setting' => array( |
423 | 423 | 'currency_position' => 'before', |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | ), |
428 | 428 | ), |
429 | 429 | 'BDT' => array( |
430 | - 'admin_label' => __( 'Bangladeshi taka (৳)', 'give' ), |
|
430 | + 'admin_label' => __('Bangladeshi taka (৳)', 'give'), |
|
431 | 431 | 'symbol' => '৳', |
432 | 432 | 'setting' => array( |
433 | 433 | 'currency_position' => 'before', |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | ), |
438 | 438 | ), |
439 | 439 | 'BHD' => array( |
440 | - 'admin_label' => __( 'Bahraini dinar (.د.ب)', 'give' ), |
|
440 | + 'admin_label' => __('Bahraini dinar (.د.ب)', 'give'), |
|
441 | 441 | 'symbol' => '.د.ب', |
442 | 442 | 'setting' => array( |
443 | 443 | 'currency_position' => 'before', |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | ), |
448 | 448 | ), |
449 | 449 | 'BMD' => array( |
450 | - 'admin_label' => __( 'Bermudian dollar (BD$)', 'give' ), |
|
450 | + 'admin_label' => __('Bermudian dollar (BD$)', 'give'), |
|
451 | 451 | 'symbol' => 'BD$', |
452 | 452 | 'setting' => array( |
453 | 453 | 'currency_position' => 'before', |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | ), |
458 | 458 | ), |
459 | 459 | 'BND' => array( |
460 | - 'admin_label' => __( 'Brunei dollar (B$)', 'give' ), |
|
460 | + 'admin_label' => __('Brunei dollar (B$)', 'give'), |
|
461 | 461 | 'symbol' => 'B$', |
462 | 462 | 'setting' => array( |
463 | 463 | 'currency_position' => 'before', |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | ), |
468 | 468 | ), |
469 | 469 | 'BOB' => array( |
470 | - 'admin_label' => __( 'Bolivian boliviano (Bs.)', 'give' ), |
|
470 | + 'admin_label' => __('Bolivian boliviano (Bs.)', 'give'), |
|
471 | 471 | 'symbol' => 'Bs.', |
472 | 472 | 'setting' => array( |
473 | 473 | 'currency_position' => 'before', |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | ), |
478 | 478 | ), |
479 | 479 | 'BSD' => array( |
480 | - 'admin_label' => __( 'Bahamian dollar (B$)', 'give' ), |
|
480 | + 'admin_label' => __('Bahamian dollar (B$)', 'give'), |
|
481 | 481 | 'symbol' => 'B$', |
482 | 482 | 'setting' => array( |
483 | 483 | 'currency_position' => 'before', |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ), |
489 | 489 | 'BWP' => array( |
490 | - 'admin_label' => __( 'Botswana pula (P)', 'give' ), |
|
490 | + 'admin_label' => __('Botswana pula (P)', 'give'), |
|
491 | 491 | 'symbol' => 'P', |
492 | 492 | 'setting' => array( |
493 | 493 | 'currency_position' => 'before', |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | ), |
498 | 498 | ), |
499 | 499 | 'BZD' => array( |
500 | - 'admin_label' => __( 'Belizean dollar (BZ$)', 'give' ), |
|
500 | + 'admin_label' => __('Belizean dollar (BZ$)', 'give'), |
|
501 | 501 | 'symbol' => 'BZ$', |
502 | 502 | 'setting' => array( |
503 | 503 | 'currency_position' => 'before', |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | ), |
508 | 508 | ), |
509 | 509 | 'CLP' => array( |
510 | - 'admin_label' => __( 'Chilean peso ($)', 'give' ), |
|
510 | + 'admin_label' => __('Chilean peso ($)', 'give'), |
|
511 | 511 | 'symbol' => '$', |
512 | 512 | 'setting' => array( |
513 | 513 | 'currency_position' => 'before', |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ), |
518 | 518 | ), |
519 | 519 | 'CNY' => array( |
520 | - 'admin_label' => __( 'Chinese yuan (¥)', 'give' ), |
|
520 | + 'admin_label' => __('Chinese yuan (¥)', 'give'), |
|
521 | 521 | 'symbol' => '¥', |
522 | 522 | 'setting' => array( |
523 | 523 | 'currency_position' => 'before', |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ), |
528 | 528 | ), |
529 | 529 | 'COP' => array( |
530 | - 'admin_label' => __( 'Colombian peso ($)', 'give' ), |
|
530 | + 'admin_label' => __('Colombian peso ($)', 'give'), |
|
531 | 531 | 'symbol' => '$', |
532 | 532 | 'setting' => array( |
533 | 533 | 'currency_position' => 'before', |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | ), |
538 | 538 | ), |
539 | 539 | 'CRC' => array( |
540 | - 'admin_label' => __( 'Costa Rican colón (₡)', 'give' ), |
|
540 | + 'admin_label' => __('Costa Rican colón (₡)', 'give'), |
|
541 | 541 | 'symbol' => '₡', |
542 | 542 | 'setting' => array( |
543 | 543 | 'currency_position' => 'before', |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | ), |
548 | 548 | ), |
549 | 549 | 'CUC' => array( |
550 | - 'admin_label' => __( 'Cuban convertible peso (₱)', 'give' ), |
|
550 | + 'admin_label' => __('Cuban convertible peso (₱)', 'give'), |
|
551 | 551 | 'symbol' => '₱', |
552 | 552 | 'setting' => array( |
553 | 553 | 'currency_position' => 'before', |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | ), |
558 | 558 | ), |
559 | 559 | 'CUP' => array( |
560 | - 'admin_label' => __( 'Cuban convertible peso (₱)', 'give' ), |
|
560 | + 'admin_label' => __('Cuban convertible peso (₱)', 'give'), |
|
561 | 561 | 'symbol' => '₱', |
562 | 562 | 'setting' => array( |
563 | 563 | 'currency_position' => 'before', |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | ), |
568 | 568 | ), |
569 | 569 | 'DOP' => array( |
570 | - 'admin_label' => __( 'Dominican peso (RD$)', 'give' ), |
|
570 | + 'admin_label' => __('Dominican peso (RD$)', 'give'), |
|
571 | 571 | 'symbol' => 'RD$', |
572 | 572 | 'setting' => array( |
573 | 573 | 'currency_position' => 'before', |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | ), |
578 | 578 | ), |
579 | 579 | 'EGP' => array( |
580 | - 'admin_label' => __( 'Egyptian pound (E£)', 'give' ), |
|
580 | + 'admin_label' => __('Egyptian pound (E£)', 'give'), |
|
581 | 581 | 'symbol' => 'E£', |
582 | 582 | 'setting' => array( |
583 | 583 | 'currency_position' => 'before', |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | ), |
588 | 588 | ), |
589 | 589 | 'GIP' => array( |
590 | - 'admin_label' => __( 'Gibraltar pound (£)', 'give' ), |
|
590 | + 'admin_label' => __('Gibraltar pound (£)', 'give'), |
|
591 | 591 | 'symbol' => '£', |
592 | 592 | 'setting' => array( |
593 | 593 | 'currency_position' => 'before', |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | ), |
598 | 598 | ), |
599 | 599 | 'GTQ' => array( |
600 | - 'admin_label' => __( 'Guatemalan quetzal (Q)', 'give' ), |
|
600 | + 'admin_label' => __('Guatemalan quetzal (Q)', 'give'), |
|
601 | 601 | 'symbol' => 'Q', |
602 | 602 | 'setting' => array( |
603 | 603 | 'currency_position' => 'before', |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | ), |
608 | 608 | ), |
609 | 609 | 'HNL' => array( |
610 | - 'admin_label' => __( 'Honduran lempira (L)', 'give' ), |
|
610 | + 'admin_label' => __('Honduran lempira (L)', 'give'), |
|
611 | 611 | 'symbol' => 'L', |
612 | 612 | 'setting' => array( |
613 | 613 | 'currency_position' => 'before', |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ), |
618 | 618 | ), |
619 | 619 | 'HRK' => array( |
620 | - 'admin_label' => __( 'Croatian kuna (kn)', 'give' ), |
|
620 | + 'admin_label' => __('Croatian kuna (kn)', 'give'), |
|
621 | 621 | 'symbol' => 'kn', |
622 | 622 | 'setting' => array( |
623 | 623 | 'currency_position' => 'after', |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | ), |
628 | 628 | ), |
629 | 629 | 'IDR' => array( |
630 | - 'admin_label' => __( 'Indonesian rupiah (Rp)', 'give' ), |
|
630 | + 'admin_label' => __('Indonesian rupiah (Rp)', 'give'), |
|
631 | 631 | 'symbol' => 'Rp', |
632 | 632 | 'setting' => array( |
633 | 633 | 'currency_position' => 'before', |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | ), |
638 | 638 | ), |
639 | 639 | 'ISK' => array( |
640 | - 'admin_label' => __( 'Icelandic króna (kr)', 'give' ), |
|
640 | + 'admin_label' => __('Icelandic króna (kr)', 'give'), |
|
641 | 641 | 'symbol' => 'kr', |
642 | 642 | 'setting' => array( |
643 | 643 | 'currency_position' => 'after', |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | ), |
648 | 648 | ), |
649 | 649 | 'JMD' => array( |
650 | - 'admin_label' => __( 'Jamaican dollar (J$)', 'give' ), |
|
650 | + 'admin_label' => __('Jamaican dollar (J$)', 'give'), |
|
651 | 651 | 'symbol' => 'j$', |
652 | 652 | 'setting' => array( |
653 | 653 | 'currency_position' => 'before', |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | ), |
658 | 658 | ), |
659 | 659 | 'JOD' => array( |
660 | - 'admin_label' => __( 'Jordanian dinar (د.ا)', 'give' ), |
|
660 | + 'admin_label' => __('Jordanian dinar (د.ا)', 'give'), |
|
661 | 661 | 'symbol' => 'د.ا', |
662 | 662 | 'setting' => array( |
663 | 663 | 'currency_position' => 'before', |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | ), |
668 | 668 | ), |
669 | 669 | 'KES' => array( |
670 | - 'admin_label' => __( 'Kenyan shilling (KSh)', 'give' ), |
|
670 | + 'admin_label' => __('Kenyan shilling (KSh)', 'give'), |
|
671 | 671 | 'symbol' => 'KSh', |
672 | 672 | 'setting' => array( |
673 | 673 | 'currency_position' => 'before', |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | ), |
678 | 678 | ), |
679 | 679 | 'KWD' => array( |
680 | - 'admin_label' => __( 'Kuwaiti dinar (د.ك)', 'give' ), |
|
680 | + 'admin_label' => __('Kuwaiti dinar (د.ك)', 'give'), |
|
681 | 681 | 'symbol' => 'د.ك', |
682 | 682 | 'setting' => array( |
683 | 683 | 'currency_position' => 'before', |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | ), |
688 | 688 | ), |
689 | 689 | 'KYD' => array( |
690 | - 'admin_label' => __( 'Cayman Islands dollar (KY$)', 'give' ), |
|
690 | + 'admin_label' => __('Cayman Islands dollar (KY$)', 'give'), |
|
691 | 691 | 'symbol' => 'KY$', |
692 | 692 | 'setting' => array( |
693 | 693 | 'currency_position' => 'before', |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ), |
698 | 698 | ), |
699 | 699 | 'MKD' => array( |
700 | - 'admin_label' => __( 'Macedonian denar (ден)', 'give' ), |
|
700 | + 'admin_label' => __('Macedonian denar (ден)', 'give'), |
|
701 | 701 | 'symbol' => 'ден', |
702 | 702 | 'setting' => array( |
703 | 703 | 'currency_position' => 'before', |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | ), |
708 | 708 | ), |
709 | 709 | 'NPR' => array( |
710 | - 'admin_label' => __( 'Nepalese rupee (NɌs)', 'give' ), |
|
710 | + 'admin_label' => __('Nepalese rupee (NɌs)', 'give'), |
|
711 | 711 | 'symbol' => '₨', |
712 | 712 | 'setting' => array( |
713 | 713 | 'currency_position' => 'before', |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | ), |
718 | 718 | ), |
719 | 719 | 'OMR' => array( |
720 | - 'admin_label' => __( 'Omani rial (ر.ع.)', 'give' ), |
|
720 | + 'admin_label' => __('Omani rial (ر.ع.)', 'give'), |
|
721 | 721 | 'symbol' => 'ر.ع.', |
722 | 722 | 'setting' => array( |
723 | 723 | 'currency_position' => 'before', |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | ), |
728 | 728 | ), |
729 | 729 | 'PEN' => array( |
730 | - 'admin_label' => __( 'Peruvian nuevo sol (S/.)', 'give' ), |
|
730 | + 'admin_label' => __('Peruvian nuevo sol (S/.)', 'give'), |
|
731 | 731 | 'symbol' => 'S/.', |
732 | 732 | 'setting' => array( |
733 | 733 | 'currency_position' => 'before', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | ), |
738 | 738 | ), |
739 | 739 | 'PKR' => array( |
740 | - 'admin_label' => __( 'Pakistani rupee (Ɍs)', 'give' ), |
|
740 | + 'admin_label' => __('Pakistani rupee (Ɍs)', 'give'), |
|
741 | 741 | 'symbol' => '₨', |
742 | 742 | 'setting' => array( |
743 | 743 | 'currency_position' => 'before', |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | ), |
748 | 748 | ), |
749 | 749 | 'RON' => array( |
750 | - 'admin_label' => __( 'Romanian leu (L)', 'give' ), |
|
750 | + 'admin_label' => __('Romanian leu (L)', 'give'), |
|
751 | 751 | 'symbol' => 'L', |
752 | 752 | 'setting' => array( |
753 | 753 | 'currency_position' => 'after', |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | ), |
758 | 758 | ), |
759 | 759 | 'SAR' => array( |
760 | - 'admin_label' => __( 'Saudi riyal (ر.س)', 'give' ), |
|
760 | + 'admin_label' => __('Saudi riyal (ر.س)', 'give'), |
|
761 | 761 | 'symbol' => 'ر.س', |
762 | 762 | 'setting' => array( |
763 | 763 | 'currency_position' => 'before', |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | ), |
768 | 768 | ), |
769 | 769 | 'SZL' => array( |
770 | - 'admin_label' => __( 'Swazi lilangeni (L)', 'give' ), |
|
770 | + 'admin_label' => __('Swazi lilangeni (L)', 'give'), |
|
771 | 771 | 'symbol' => 'L', |
772 | 772 | 'setting' => array( |
773 | 773 | 'currency_position' => 'before', |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | ), |
778 | 778 | ), |
779 | 779 | 'TOP' => array( |
780 | - 'admin_label' => __( 'Tongan paʻanga (T$)', 'give' ), |
|
780 | + 'admin_label' => __('Tongan paʻanga (T$)', 'give'), |
|
781 | 781 | 'symbol' => 'T$', |
782 | 782 | 'setting' => array( |
783 | 783 | 'currency_position' => 'before', |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | ), |
788 | 788 | ), |
789 | 789 | 'TZS' => array( |
790 | - 'admin_label' => __( 'Tanzanian shilling (TSh)', 'give' ), |
|
790 | + 'admin_label' => __('Tanzanian shilling (TSh)', 'give'), |
|
791 | 791 | 'symbol' => 'TSh', |
792 | 792 | 'setting' => array( |
793 | 793 | 'currency_position' => 'before', |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | ), |
798 | 798 | ), |
799 | 799 | 'UAH' => array( |
800 | - 'admin_label' => __( 'Ukrainian hryvnia (₴)', 'give' ), |
|
800 | + 'admin_label' => __('Ukrainian hryvnia (₴)', 'give'), |
|
801 | 801 | 'symbol' => '₴', |
802 | 802 | 'setting' => array( |
803 | 803 | 'currency_position' => 'before', |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | ), |
808 | 808 | ), |
809 | 809 | 'UYU' => array( |
810 | - 'admin_label' => __( 'Uruguayan peso ($U)', 'give' ), |
|
810 | + 'admin_label' => __('Uruguayan peso ($U)', 'give'), |
|
811 | 811 | 'symbol' => '$U', |
812 | 812 | 'setting' => array( |
813 | 813 | 'currency_position' => 'before', |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | ), |
818 | 818 | ), |
819 | 819 | 'VEF' => array( |
820 | - 'admin_label' => __( 'Venezuelan bolívar (Bs)', 'give' ), |
|
820 | + 'admin_label' => __('Venezuelan bolívar (Bs)', 'give'), |
|
821 | 821 | 'symbol' => 'Bs', |
822 | 822 | 'setting' => array( |
823 | 823 | 'currency_position' => 'before', |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | ), |
828 | 828 | ), |
829 | 829 | 'XCD' => array( |
830 | - 'admin_label' => __( 'East Caribbean dollar (EC$)', 'give' ), |
|
830 | + 'admin_label' => __('East Caribbean dollar (EC$)', 'give'), |
|
831 | 831 | 'symbol' => 'EC$', |
832 | 832 | 'setting' => array( |
833 | 833 | 'currency_position' => 'before', |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | * |
853 | 853 | * @param array $currencies |
854 | 854 | */ |
855 | - return (array) apply_filters( 'give_currencies', $currencies ); |
|
855 | + return (array) apply_filters('give_currencies', $currencies); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -864,22 +864,22 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return array $currencies A list of the available currencies |
866 | 866 | */ |
867 | -function give_get_currencies( $info = 'admin_label' ) { |
|
867 | +function give_get_currencies($info = 'admin_label') { |
|
868 | 868 | |
869 | 869 | $currencies = give_get_currencies_list(); |
870 | 870 | |
871 | 871 | // Backward compatibility: handle old way of currency registration. |
872 | 872 | // Backward compatibility: Return desired result. |
873 | - if ( ! empty( $currencies ) ) { |
|
874 | - foreach ( $currencies as $currency_code => $currency_setting ) { |
|
875 | - if ( is_string( $currency_setting ) ) { |
|
876 | - $currencies[ $currency_code ] = array( |
|
873 | + if ( ! empty($currencies)) { |
|
874 | + foreach ($currencies as $currency_code => $currency_setting) { |
|
875 | + if (is_string($currency_setting)) { |
|
876 | + $currencies[$currency_code] = array( |
|
877 | 877 | 'admin_label' => $currency_setting, |
878 | 878 | ); |
879 | 879 | } |
880 | 880 | |
881 | - $currencies[ $currency_code ] = wp_parse_args( |
|
882 | - $currencies[ $currency_code ], |
|
881 | + $currencies[$currency_code] = wp_parse_args( |
|
882 | + $currencies[$currency_code], |
|
883 | 883 | array( |
884 | 884 | 'admin_label' => '', |
885 | 885 | 'symbol' => $currency_code, |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | ); |
889 | 889 | } |
890 | 890 | |
891 | - if ( ! empty( $info ) && is_string( $info ) && 'all' !== $info ) { |
|
892 | - $currencies = wp_list_pluck( $currencies, $info ); |
|
891 | + if ( ! empty($info) && is_string($info) && 'all' !== $info) { |
|
892 | + $currencies = wp_list_pluck($currencies, $info); |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | * |
907 | 907 | * @return array |
908 | 908 | */ |
909 | -function give_currency_symbols( $decode_currencies = false ) { |
|
910 | - $currencies = give_get_currencies( 'symbol' ); |
|
909 | +function give_currency_symbols($decode_currencies = false) { |
|
910 | + $currencies = give_get_currencies('symbol'); |
|
911 | 911 | |
912 | - if ( $decode_currencies ) { |
|
913 | - array_walk( $currencies, function ( &$currency_symbol ) { |
|
914 | - $currency_symbol = html_entity_decode( $currency_symbol, ENT_COMPAT, 'UTF-8' ); |
|
912 | + if ($decode_currencies) { |
|
913 | + array_walk($currencies, function(&$currency_symbol) { |
|
914 | + $currency_symbol = html_entity_decode($currency_symbol, ENT_COMPAT, 'UTF-8'); |
|
915 | 915 | } ); |
916 | 916 | } |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @param array $currencies |
924 | 924 | */ |
925 | - return apply_filters( 'give_currency_symbols', $currencies ); |
|
925 | + return apply_filters('give_currency_symbols', $currencies); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -939,14 +939,14 @@ discard block |
||
939 | 939 | * |
940 | 940 | * @return string The symbol to use for the currency |
941 | 941 | */ |
942 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
942 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
943 | 943 | |
944 | - if ( empty( $currency ) ) { |
|
944 | + if (empty($currency)) { |
|
945 | 945 | $currency = give_get_currency(); |
946 | 946 | } |
947 | 947 | |
948 | - $currencies = give_currency_symbols( $decode_currency ); |
|
949 | - $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency; |
|
948 | + $currencies = give_currency_symbols($decode_currency); |
|
949 | + $symbol = array_key_exists($currency, $currencies) ? $currencies[$currency] : $currency; |
|
950 | 950 | |
951 | 951 | /** |
952 | 952 | * Filter the currency symbol |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * @param string $symbol |
957 | 957 | * @param string $currency |
958 | 958 | */ |
959 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
959 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | |
@@ -969,13 +969,13 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return string |
971 | 971 | */ |
972 | -function give_get_currency_name( $currency_code ) { |
|
972 | +function give_get_currency_name($currency_code) { |
|
973 | 973 | $currency_name = ''; |
974 | 974 | $currency_names = give_get_currencies(); |
975 | 975 | |
976 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
977 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
978 | - $currency_name = trim( current( $currency_name ) ); |
|
976 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
977 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
978 | + $currency_name = trim(current($currency_name)); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | * @param string $currency_name |
987 | 987 | * @param string $currency_code |
988 | 988 | */ |
989 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
989 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | /** |
@@ -999,20 +999,20 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return mixed|string |
1001 | 1001 | */ |
1002 | -function give_currency_filter( $price = '', $args = array() ) { |
|
1002 | +function give_currency_filter($price = '', $args = array()) { |
|
1003 | 1003 | |
1004 | 1004 | // Get functions arguments. |
1005 | 1005 | $func_args = func_get_args(); |
1006 | 1006 | |
1007 | 1007 | // Backward compatibility: modify second param to array |
1008 | - if ( isset( $func_args[1] ) && is_string( $func_args[1] ) ) { |
|
1008 | + if (isset($func_args[1]) && is_string($func_args[1])) { |
|
1009 | 1009 | $args = array( |
1010 | - 'currency_code' => isset( $func_args[1] ) ? $func_args[1] : '', |
|
1011 | - 'decode_currency' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
1012 | - 'form_id' => isset( $func_args[3] ) ? $func_args[3] : '', |
|
1010 | + 'currency_code' => isset($func_args[1]) ? $func_args[1] : '', |
|
1011 | + 'decode_currency' => isset($func_args[2]) ? $func_args[2] : false, |
|
1012 | + 'form_id' => isset($func_args[3]) ? $func_args[3] : '', |
|
1013 | 1013 | ); |
1014 | 1014 | |
1015 | - give_doing_it_wrong( __FUNCTION__, 'Pass second argument as Array.', GIVE_VERSION ); |
|
1015 | + give_doing_it_wrong(__FUNCTION__, 'Pass second argument as Array.', GIVE_VERSION); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | // Set default values. |
@@ -1025,22 +1025,22 @@ discard block |
||
1025 | 1025 | ) |
1026 | 1026 | ); |
1027 | 1027 | |
1028 | - if ( empty( $args['currency_code'] ) || ! array_key_exists( (string) $args['currency_code'], give_get_currencies() ) ) { |
|
1029 | - $args['currency_code'] = give_get_currency( $args['form_id'] ); |
|
1028 | + if (empty($args['currency_code']) || ! array_key_exists((string) $args['currency_code'], give_get_currencies())) { |
|
1029 | + $args['currency_code'] = give_get_currency($args['form_id']); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | - $args['position'] = give_get_option( 'currency_position', 'before' ); |
|
1032 | + $args['position'] = give_get_option('currency_position', 'before'); |
|
1033 | 1033 | |
1034 | 1034 | $negative = $price < 0; |
1035 | 1035 | |
1036 | - if ( $negative ) { |
|
1036 | + if ($negative) { |
|
1037 | 1037 | // Remove proceeding "-". |
1038 | - $price = substr( $price, 1 ); |
|
1038 | + $price = substr($price, 1); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | - $args['symbol'] = give_currency_symbol( $args['currency_code'], $args['decode_currency'] ); |
|
1041 | + $args['symbol'] = give_currency_symbol($args['currency_code'], $args['decode_currency']); |
|
1042 | 1042 | |
1043 | - switch ( $args['currency_code'] ) : |
|
1043 | + switch ($args['currency_code']) : |
|
1044 | 1044 | case 'GBP' : |
1045 | 1045 | case 'BRL' : |
1046 | 1046 | case 'EUR' : |
@@ -1070,13 +1070,13 @@ discard block |
||
1070 | 1070 | case 'MAD' : |
1071 | 1071 | case 'KRW' : |
1072 | 1072 | case 'ZAR' : |
1073 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . $price : $price . $args['symbol'] ); |
|
1073 | + $formatted = ('before' === $args['position'] ? $args['symbol'].$price : $price.$args['symbol']); |
|
1074 | 1074 | break; |
1075 | 1075 | case 'NOK': |
1076 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] ); |
|
1076 | + $formatted = ('before' === $args['position'] ? $args['symbol'].' '.$price : $price.' '.$args['symbol']); |
|
1077 | 1077 | break; |
1078 | 1078 | default: |
1079 | - $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] ); |
|
1079 | + $formatted = ('before' === $args['position'] ? $args['symbol'].' '.$price : $price.' '.$args['symbol']); |
|
1080 | 1080 | break; |
1081 | 1081 | endswitch; |
1082 | 1082 | |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | * |
1086 | 1086 | * @since 1.8.17 |
1087 | 1087 | */ |
1088 | - $formatted = apply_filters( 'give_currency_filter', $formatted, $args, $price ); |
|
1088 | + $formatted = apply_filters('give_currency_filter', $formatted, $args, $price); |
|
1089 | 1089 | |
1090 | 1090 | /** |
1091 | 1091 | * Filter formatted amount with currency |
@@ -1099,16 +1099,16 @@ discard block |
||
1099 | 1099 | * filter name will be give_usd_currency_filter_after |
1100 | 1100 | */ |
1101 | 1101 | $formatted = apply_filters( |
1102 | - 'give_' . strtolower( $args['currency_code'] ) . "_currency_filter_{$args['position']}", |
|
1102 | + 'give_'.strtolower($args['currency_code'])."_currency_filter_{$args['position']}", |
|
1103 | 1103 | $formatted, |
1104 | 1104 | $args['currency_code'], |
1105 | 1105 | $price, |
1106 | 1106 | $args |
1107 | 1107 | ); |
1108 | 1108 | |
1109 | - if ( $negative ) { |
|
1109 | + if ($negative) { |
|
1110 | 1110 | // Prepend the minus sign before the currency sign. |
1111 | - $formatted = '-' . $formatted; |
|
1111 | + $formatted = '-'.$formatted; |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | return $formatted; |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | * |
1126 | 1126 | * @return bool |
1127 | 1127 | */ |
1128 | -function give_is_zero_based_currency( $currency = '' ) { |
|
1128 | +function give_is_zero_based_currency($currency = '') { |
|
1129 | 1129 | $zero_based_currency = array( |
1130 | 1130 | 'PYG', // Paraguayan Guarani. |
1131 | 1131 | 'GNF', // Guinean Franc. |
@@ -1145,12 +1145,12 @@ discard block |
||
1145 | 1145 | ); |
1146 | 1146 | |
1147 | 1147 | // Set default currency. |
1148 | - if ( empty( $currency ) ) { |
|
1148 | + if (empty($currency)) { |
|
1149 | 1149 | $currency = give_get_currency(); |
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | // Check for Zero Based Currency. |
1153 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1153 | + if (in_array($currency, $zero_based_currency)) { |
|
1154 | 1154 | return true; |
1155 | 1155 | } |
1156 | 1156 | |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | * |
1166 | 1166 | * @return bool |
1167 | 1167 | */ |
1168 | -function give_is_right_to_left_supported_currency( $currency = '' ) { |
|
1168 | +function give_is_right_to_left_supported_currency($currency = '') { |
|
1169 | 1169 | $zero_based_currency = apply_filters( |
1170 | 1170 | 'give_right_to_left_supported_currency', |
1171 | 1171 | array( |
@@ -1181,12 +1181,12 @@ discard block |
||
1181 | 1181 | ); |
1182 | 1182 | |
1183 | 1183 | // Set default currency. |
1184 | - if ( empty( $currency ) ) { |
|
1184 | + if (empty($currency)) { |
|
1185 | 1185 | $currency = give_get_currency(); |
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | // Check for Zero Based Currency. |
1189 | - if ( in_array( $currency, $zero_based_currency ) ) { |
|
1189 | + if (in_array($currency, $zero_based_currency)) { |
|
1190 | 1190 | return true; |
1191 | 1191 | } |
1192 | 1192 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param string $description Email tag description text |
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | */ |
58 | - public function add( $tag, $description, $func ) { |
|
59 | - if ( is_callable( $func ) ) { |
|
60 | - $this->tags[ $tag ] = array( |
|
58 | + public function add($tag, $description, $func) { |
|
59 | + if (is_callable($func)) { |
|
60 | + $this->tags[$tag] = array( |
|
61 | 61 | 'tag' => $tag, |
62 | 62 | 'description' => $description, |
63 | 63 | 'func' => $func, |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param string $tag Email tag to remove hook from |
74 | 74 | */ |
75 | - public function remove( $tag ) { |
|
76 | - unset( $this->tags[ $tag ] ); |
|
75 | + public function remove($tag) { |
|
76 | + unset($this->tags[$tag]); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - public function email_tag_exists( $tag ) { |
|
89 | - return array_key_exists( $tag, $this->tags ); |
|
88 | + public function email_tag_exists($tag) { |
|
89 | + return array_key_exists($tag, $this->tags); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Content with email tags filtered out. |
112 | 112 | */ |
113 | - public function do_tags( $content, $payment_id ) { |
|
113 | + public function do_tags($content, $payment_id) { |
|
114 | 114 | |
115 | 115 | // Check if there is at least one tag added. |
116 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
116 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
117 | 117 | return $content; |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->payment_id = $payment_id; |
121 | 121 | |
122 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
122 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
123 | 123 | |
124 | 124 | $this->payment_id = null; |
125 | 125 | |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public function do_tag( $m ) { |
|
138 | + public function do_tag($m) { |
|
139 | 139 | |
140 | 140 | // Get tag |
141 | 141 | $tag = $m[1]; |
142 | 142 | |
143 | 143 | // Return tag if tag not set |
144 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
144 | + if ( ! $this->email_tag_exists($tag)) { |
|
145 | 145 | return $m[0]; |
146 | 146 | } |
147 | 147 | |
148 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
148 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @param string $description Description of the email tag added |
160 | 160 | * @param callable $func Hook to run when email tag is found |
161 | 161 | */ |
162 | -function give_add_email_tag( $tag, $description, $func ) { |
|
163 | - Give()->email_tags->add( $tag, $description, $func ); |
|
162 | +function give_add_email_tag($tag, $description, $func) { |
|
163 | + Give()->email_tags->add($tag, $description, $func); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param string $tag Email tag to remove hook from |
172 | 172 | */ |
173 | -function give_remove_email_tag( $tag ) { |
|
174 | - Give()->email_tags->remove( $tag ); |
|
173 | +function give_remove_email_tag($tag) { |
|
174 | + Give()->email_tags->remove($tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return bool |
185 | 185 | */ |
186 | -function give_email_tag_exists( $tag ) { |
|
187 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
186 | +function give_email_tag_exists($tag) { |
|
187 | + return Give()->email_tags->email_tag_exists($tag); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | $email_tags = give_get_email_tags(); |
212 | 212 | |
213 | 213 | ob_start(); |
214 | - if ( count( $email_tags ) > 0 ) : ?> |
|
214 | + if (count($email_tags) > 0) : ?> |
|
215 | 215 | <div class="give-email-tags-wrap"> |
216 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
216 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
217 | 217 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
218 | 218 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
219 | 219 | </span> |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return string Content with email tags filtered out. |
237 | 237 | */ |
238 | -function give_do_email_tags( $content, $payment_id ) { |
|
238 | +function give_do_email_tags($content, $payment_id) { |
|
239 | 239 | |
240 | 240 | // Replace all tags |
241 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
241 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
242 | 242 | |
243 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
243 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
244 | 244 | |
245 | 245 | // Return content |
246 | 246 | return $content; |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @since 1.0 |
261 | 261 | */ |
262 | - do_action( 'give_add_email_tags' ); |
|
262 | + do_action('give_add_email_tags'); |
|
263 | 263 | } |
264 | 264 | |
265 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
265 | +add_action('init', 'give_load_email_tags', - 999); |
|
266 | 266 | |
267 | 267 | |
268 | 268 | /** |
@@ -276,97 +276,97 @@ discard block |
||
276 | 276 | $email_tags = array( |
277 | 277 | array( |
278 | 278 | 'tag' => 'donation', |
279 | - 'description' => __( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
279 | + 'description' => __('The donation form name, and the donation level (if applicable).', 'give'), |
|
280 | 280 | 'function' => 'give_email_tag_donation', |
281 | 281 | ), |
282 | 282 | array( |
283 | 283 | 'tag' => 'form_title', |
284 | - 'description' => __( 'The donation form name.', 'give' ), |
|
284 | + 'description' => __('The donation form name.', 'give'), |
|
285 | 285 | 'function' => 'give_email_tag_form_title', |
286 | 286 | ), |
287 | 287 | array( |
288 | 288 | 'tag' => 'amount', |
289 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
289 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
290 | 290 | 'function' => 'give_email_tag_amount', |
291 | 291 | ), |
292 | 292 | array( |
293 | 293 | 'tag' => 'price', |
294 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
294 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
295 | 295 | 'function' => 'give_email_tag_price', |
296 | 296 | ), |
297 | 297 | array( |
298 | 298 | 'tag' => 'name', |
299 | - 'description' => __( 'The donor\'s first name.', 'give' ), |
|
299 | + 'description' => __('The donor\'s first name.', 'give'), |
|
300 | 300 | 'function' => 'give_email_tag_first_name', |
301 | 301 | ), |
302 | 302 | array( |
303 | 303 | 'tag' => 'fullname', |
304 | - 'description' => __( 'The donor\'s full name, first and last.', 'give' ), |
|
304 | + 'description' => __('The donor\'s full name, first and last.', 'give'), |
|
305 | 305 | 'function' => 'give_email_tag_fullname', |
306 | 306 | ), |
307 | 307 | array( |
308 | 308 | 'tag' => 'username', |
309 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
309 | + 'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
310 | 310 | 'function' => 'give_email_tag_username', |
311 | 311 | ), |
312 | 312 | array( |
313 | 313 | 'tag' => 'user_email', |
314 | - 'description' => __( 'The donor\'s email address.', 'give' ), |
|
314 | + 'description' => __('The donor\'s email address.', 'give'), |
|
315 | 315 | 'function' => 'give_email_tag_user_email', |
316 | 316 | ), |
317 | 317 | array( |
318 | 318 | 'tag' => 'billing_address', |
319 | - 'description' => __( 'The donor\'s billing address.', 'give' ), |
|
319 | + 'description' => __('The donor\'s billing address.', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_billing_address', |
321 | 321 | ), |
322 | 322 | array( |
323 | 323 | 'tag' => 'date', |
324 | - 'description' => __( 'The date of the donation.', 'give' ), |
|
324 | + 'description' => __('The date of the donation.', 'give'), |
|
325 | 325 | 'function' => 'give_email_tag_date', |
326 | 326 | ), |
327 | 327 | array( |
328 | 328 | 'tag' => 'payment_id', |
329 | - 'description' => __( 'The unique ID number for this donation.', 'give' ), |
|
329 | + 'description' => __('The unique ID number for this donation.', 'give'), |
|
330 | 330 | 'function' => 'give_email_tag_payment_id', |
331 | 331 | ), |
332 | 332 | array( |
333 | 333 | 'tag' => 'receipt_id', |
334 | - 'description' => __( 'The unique ID number for this donation receipt.', 'give' ), |
|
334 | + 'description' => __('The unique ID number for this donation receipt.', 'give'), |
|
335 | 335 | 'function' => 'give_email_tag_receipt_id', |
336 | 336 | ), |
337 | 337 | array( |
338 | 338 | 'tag' => 'payment_method', |
339 | - 'description' => __( 'The method of payment used for this donation.', 'give' ), |
|
339 | + 'description' => __('The method of payment used for this donation.', 'give'), |
|
340 | 340 | 'function' => 'give_email_tag_payment_method', |
341 | 341 | ), |
342 | 342 | array( |
343 | 343 | 'tag' => 'sitename', |
344 | - 'description' => __( 'The name of your site.', 'give' ), |
|
344 | + 'description' => __('The name of your site.', 'give'), |
|
345 | 345 | 'function' => 'give_email_tag_sitename', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'receipt_link', |
349 | - 'description' => __( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
349 | + 'description' => __('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_receipt_link', |
351 | 351 | ), |
352 | 352 | array( |
353 | 353 | 'tag' => 'receipt_link_url', |
354 | - 'description' => __( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
354 | + 'description' => __('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
355 | 355 | 'function' => 'give_email_tag_receipt_link_url', |
356 | 356 | ), |
357 | 357 | ); |
358 | 358 | |
359 | 359 | // Apply give_email_tags filter |
360 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
360 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
361 | 361 | |
362 | 362 | // Add email tags |
363 | - foreach ( $email_tags as $email_tag ) { |
|
364 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
363 | + foreach ($email_tags as $email_tag) { |
|
364 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
369 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
370 | 370 | |
371 | 371 | |
372 | 372 | /** |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return string name |
380 | 380 | */ |
381 | -function give_email_tag_first_name( $payment_id ) { |
|
382 | - $payment = new Give_Payment( $payment_id ); |
|
381 | +function give_email_tag_first_name($payment_id) { |
|
382 | + $payment = new Give_Payment($payment_id); |
|
383 | 383 | $user_info = $payment->user_info; |
384 | 384 | |
385 | - if ( empty( $user_info ) ) { |
|
385 | + if (empty($user_info)) { |
|
386 | 386 | return ''; |
387 | 387 | } |
388 | 388 | |
389 | - $email_name = give_get_email_names( $user_info ); |
|
389 | + $email_name = give_get_email_names($user_info); |
|
390 | 390 | |
391 | 391 | return $email_name['name']; |
392 | 392 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string fullname |
402 | 402 | */ |
403 | -function give_email_tag_fullname( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_fullname($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['fullname']; |
414 | 414 | } |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @return string username. |
424 | 424 | */ |
425 | -function give_email_tag_username( $payment_id ) { |
|
426 | - $payment = new Give_Payment( $payment_id ); |
|
425 | +function give_email_tag_username($payment_id) { |
|
426 | + $payment = new Give_Payment($payment_id); |
|
427 | 427 | $user_info = $payment->user_info; |
428 | 428 | |
429 | - if ( empty( $user_info ) ) { |
|
429 | + if (empty($user_info)) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | - $email_name = give_get_email_names( $user_info ); |
|
433 | + $email_name = give_get_email_names($user_info); |
|
434 | 434 | |
435 | 435 | return $email_name['username']; |
436 | 436 | } |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string user_email |
446 | 446 | */ |
447 | -function give_email_tag_user_email( $payment_id ) { |
|
448 | - $payment = new Give_Payment( $payment_id ); |
|
447 | +function give_email_tag_user_email($payment_id) { |
|
448 | + $payment = new Give_Payment($payment_id); |
|
449 | 449 | |
450 | 450 | return $payment->email; |
451 | 451 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return string billing_address |
461 | 461 | */ |
462 | -function give_email_tag_billing_address( $payment_id ) { |
|
463 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
464 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
462 | +function give_email_tag_billing_address($payment_id) { |
|
463 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
464 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
465 | 465 | 'line1' => '', |
466 | 466 | 'line2' => '', |
467 | 467 | 'city' => '', |
@@ -471,24 +471,24 @@ discard block |
||
471 | 471 | ); |
472 | 472 | |
473 | 473 | $return = $user_address['line1']; |
474 | - if ( ! empty( $user_address['line2'] ) ) { |
|
475 | - $return .= ', ' . $user_address['line2']; |
|
474 | + if ( ! empty($user_address['line2'])) { |
|
475 | + $return .= ', '.$user_address['line2']; |
|
476 | 476 | } |
477 | - if ( ! empty( $user_address['city'] ) ) { |
|
478 | - $return .= "\n" . $user_address['city']; |
|
477 | + if ( ! empty($user_address['city'])) { |
|
478 | + $return .= "\n".$user_address['city']; |
|
479 | 479 | } |
480 | - if ( ! empty( $user_address['state'] ) ) { |
|
481 | - $return .= ', ' . $user_address['state']; |
|
480 | + if ( ! empty($user_address['state'])) { |
|
481 | + $return .= ', '.$user_address['state']; |
|
482 | 482 | } |
483 | - if ( ! empty( $user_address['zip'] ) ) { |
|
484 | - $return .= ' ' . $user_address['zip']; |
|
483 | + if ( ! empty($user_address['zip'])) { |
|
484 | + $return .= ' '.$user_address['zip']; |
|
485 | 485 | } |
486 | - if ( ! empty( $user_address['country'] ) ) { |
|
487 | - $return .= "\n" . give_get_country_name_by_key( $user_address['country'] ); |
|
486 | + if ( ! empty($user_address['country'])) { |
|
487 | + $return .= "\n".give_get_country_name_by_key($user_address['country']); |
|
488 | 488 | } |
489 | 489 | |
490 | - if ( empty( $return ) ) { |
|
491 | - $return = __( 'None provided', 'give' ); |
|
490 | + if (empty($return)) { |
|
491 | + $return = __('None provided', 'give'); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return apply_filters('give_email_tag_billing_address', $return, $payment_id); |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @return string date |
506 | 506 | */ |
507 | -function give_email_tag_date( $payment_id ) { |
|
508 | - $payment = new Give_Payment( $payment_id ); |
|
507 | +function give_email_tag_date($payment_id) { |
|
508 | + $payment = new Give_Payment($payment_id); |
|
509 | 509 | |
510 | - return date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
510 | + return date_i18n(give_date_format(), strtotime($payment->date)); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string amount |
521 | 521 | */ |
522 | -function give_email_tag_amount( $payment_id ) { |
|
523 | - $payment = new Give_Payment( $payment_id ); |
|
524 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) ); |
|
522 | +function give_email_tag_amount($payment_id) { |
|
523 | + $payment = new Give_Payment($payment_id); |
|
524 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency)); |
|
525 | 525 | |
526 | - return html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
526 | + return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @return string price |
537 | 537 | */ |
538 | -function give_email_tag_price( $payment_id ) { |
|
539 | - return give_email_tag_amount( $payment_id ); |
|
538 | +function give_email_tag_price($payment_id) { |
|
539 | + return give_email_tag_amount($payment_id); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return int payment_id |
550 | 550 | */ |
551 | -function give_email_tag_payment_id( $payment_id ) { |
|
552 | - $payment = new Give_Payment( $payment_id ); |
|
551 | +function give_email_tag_payment_id($payment_id) { |
|
552 | + $payment = new Give_Payment($payment_id); |
|
553 | 553 | |
554 | 554 | return $payment->number; |
555 | 555 | } |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string receipt_id |
565 | 565 | */ |
566 | -function give_email_tag_receipt_id( $payment_id ) { |
|
567 | - $payment = new Give_Payment( $payment_id ); |
|
566 | +function give_email_tag_receipt_id($payment_id) { |
|
567 | + $payment = new Give_Payment($payment_id); |
|
568 | 568 | |
569 | 569 | return $payment->key; |
570 | 570 | } |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return string $form_title |
580 | 580 | */ |
581 | -function give_email_tag_donation( $payment_id ) { |
|
582 | - $payment = new Give_Payment( $payment_id ); |
|
581 | +function give_email_tag_donation($payment_id) { |
|
582 | + $payment = new Give_Payment($payment_id); |
|
583 | 583 | $payment_meta = $payment->payment_meta; |
584 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
584 | + $level_title = give_has_variable_prices($payment->form_id); |
|
585 | 585 | $separator = $level_title ? '-' : ''; |
586 | - $form_title = strip_tags( give_get_payment_form_title( $payment_meta, false, $separator ) ); |
|
586 | + $form_title = strip_tags(give_get_payment_form_title($payment_meta, false, $separator)); |
|
587 | 587 | |
588 | - return ! empty( $form_title ) ? $form_title : ''; |
|
588 | + return ! empty($form_title) ? $form_title : ''; |
|
589 | 589 | |
590 | 590 | } |
591 | 591 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @return string $form_title |
600 | 600 | */ |
601 | -function give_email_tag_form_title( $payment_id ) { |
|
602 | - $payment = new Give_Payment( $payment_id ); |
|
601 | +function give_email_tag_form_title($payment_id) { |
|
602 | + $payment = new Give_Payment($payment_id); |
|
603 | 603 | $payment_meta = $payment->payment_meta; |
604 | 604 | |
605 | - return isset( $payment_meta['form_title'] ) ? strip_tags( $payment_meta['form_title'] ) : ''; |
|
605 | + return isset($payment_meta['form_title']) ? strip_tags($payment_meta['form_title']) : ''; |
|
606 | 606 | |
607 | 607 | } |
608 | 608 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return string gateway |
617 | 617 | */ |
618 | -function give_email_tag_payment_method( $payment_id ) { |
|
619 | - $payment = new Give_Payment( $payment_id ); |
|
618 | +function give_email_tag_payment_method($payment_id) { |
|
619 | + $payment = new Give_Payment($payment_id); |
|
620 | 620 | |
621 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
621 | + return give_get_gateway_checkout_label($payment->gateway); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return string sitename |
632 | 632 | */ |
633 | -function give_email_tag_sitename( $payment_id ) { |
|
634 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
633 | +function give_email_tag_sitename($payment_id) { |
|
634 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return string receipt_link |
645 | 645 | */ |
646 | -function give_email_tag_receipt_link( $payment_id ) { |
|
646 | +function give_email_tag_receipt_link($payment_id) { |
|
647 | 647 | |
648 | - $receipt_url = esc_url( add_query_arg( array( |
|
649 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
650 | - ), give_get_history_page_uri() ) ); |
|
648 | + $receipt_url = esc_url(add_query_arg(array( |
|
649 | + 'payment_key' => give_get_payment_key($payment_id), |
|
650 | + ), give_get_history_page_uri())); |
|
651 | 651 | $formatted = sprintf( |
652 | 652 | '<a href="%1$s">%2$s</a>', |
653 | 653 | $receipt_url, |
654 | - __( 'View it in your browser »', 'give' ) |
|
654 | + __('View it in your browser »', 'give') |
|
655 | 655 | ); |
656 | 656 | |
657 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
657 | + if (give_get_option('email_template') !== 'none') { |
|
658 | 658 | return $formatted; |
659 | 659 | } else { |
660 | 660 | return $receipt_url; |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return string receipt_url |
675 | 675 | */ |
676 | -function give_email_tag_receipt_link_url( $payment_id ) { |
|
676 | +function give_email_tag_receipt_link_url($payment_id) { |
|
677 | 677 | |
678 | - $receipt_url = esc_url( add_query_arg( array( |
|
679 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
680 | - ), give_get_history_page_uri() ) ); |
|
678 | + $receipt_url = esc_url(add_query_arg(array( |
|
679 | + 'payment_key' => give_get_payment_key($payment_id), |
|
680 | + ), give_get_history_page_uri())); |
|
681 | 681 | |
682 | 682 | return $receipt_url; |
683 | 683 |
@@ -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 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,45 +56,45 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false))); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
68 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri())); |
|
69 | 69 | |
70 | 70 | $receipt_link = sprintf( |
71 | 71 | '<a href="%1$s">%2$s</a>', |
72 | 72 | $receipt_link_url, |
73 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
73 | + esc_html__('View the receipt in your browser »', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | // Set user. |
77 | 77 | $user = wp_get_current_user(); |
78 | 78 | |
79 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
81 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
82 | - $message = str_replace( '{user_email}', $user->user_email, $message ); |
|
83 | - $message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message ); |
|
84 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
85 | - $message = str_replace( '{amount}', $price, $message ); |
|
86 | - $message = str_replace( '{price}', $price, $message ); |
|
87 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
88 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
89 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
90 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
91 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
92 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
93 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
94 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
95 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
96 | - |
|
97 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
79 | + $message = str_replace('{name}', $user->display_name, $message); |
|
80 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
81 | + $message = str_replace('{username}', $user->user_login, $message); |
|
82 | + $message = str_replace('{user_email}', $user->user_email, $message); |
|
83 | + $message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message); |
|
84 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
85 | + $message = str_replace('{amount}', $price, $message); |
|
86 | + $message = str_replace('{price}', $price, $message); |
|
87 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
88 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
89 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
90 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
91 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
92 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
93 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
94 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
95 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
96 | + |
|
97 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -106,23 +106,23 @@ discard block |
||
106 | 106 | * @since 1.0 |
107 | 107 | * @return array|bool |
108 | 108 | */ |
109 | -function give_email_template_preview( $array ) { |
|
109 | +function give_email_template_preview($array) { |
|
110 | 110 | |
111 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
111 | + if ( ! current_user_can('manage_give_settings')) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | $custom_field = array( |
115 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
116 | - 'desc' => esc_html__( 'Click the buttons to preview or send test emails.', 'give' ), |
|
115 | + 'name' => esc_html__('Preview Email', 'give'), |
|
116 | + 'desc' => esc_html__('Click the buttons to preview or send test emails.', 'give'), |
|
117 | 117 | 'id' => 'give_email_preview_buttons', |
118 | 118 | 'type' => 'email_preview_buttons', |
119 | 119 | ); |
120 | 120 | |
121 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
121 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
125 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Output Email Template Preview Buttons. |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | function give_email_preview_buttons_callback() { |
135 | 135 | ob_start(); |
136 | 136 | ?> |
137 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" |
|
138 | - target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
139 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
137 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" |
|
138 | + target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
139 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
140 | 140 | 'give_action' => 'send_test_email', |
141 | 141 | 'give-message' => 'sent-test-email', |
142 | 142 | 'tag' => 'emails', |
143 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" |
|
144 | - class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
143 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" |
|
144 | + class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
145 | 145 | <?php |
146 | 146 | echo ob_get_clean(); |
147 | 147 | } |
@@ -154,46 +154,46 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function give_display_email_template_preview() { |
156 | 156 | |
157 | - if ( empty( $_GET['give_action'] ) ) { |
|
157 | + if (empty($_GET['give_action'])) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
161 | + if ('preview_email' !== $_GET['give_action']) { |
|
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
165 | + if ( ! current_user_can('manage_give_settings')) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | 169 | |
170 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
170 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
171 | 171 | |
172 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
172 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
173 | 173 | |
174 | 174 | echo give_get_preview_email_header(); |
175 | 175 | |
176 | 176 | //Are we previewing an actual payment? |
177 | - if ( ! empty( $payment_id ) ) { |
|
177 | + if ( ! empty($payment_id)) { |
|
178 | 178 | |
179 | - $content = give_get_email_body_content( $payment_id ); |
|
179 | + $content = give_get_email_body_content($payment_id); |
|
180 | 180 | |
181 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
181 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
182 | 182 | |
183 | 183 | } else { |
184 | 184 | |
185 | 185 | //No payment ID, use sample preview content |
186 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
186 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
190 | - echo Give()->emails->build_email( $preview_content ); |
|
190 | + echo Give()->emails->build_email($preview_content); |
|
191 | 191 | |
192 | 192 | exit; |
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
196 | +add_action('init', 'give_display_email_template_preview'); |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Email Template Body. |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return string $email_body Body of the email |
207 | 207 | */ |
208 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
208 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
209 | 209 | |
210 | 210 | $default_email_body = give_get_default_donation_receipt_email(); |
211 | 211 | |
212 | - $email_content = give_get_option( 'donation_receipt' ); |
|
213 | - $email_content = ( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
212 | + $email_content = give_get_option('donation_receipt'); |
|
213 | + $email_content = ($email_content) ? stripslashes($email_content) : $default_email_body; |
|
214 | 214 | |
215 | - $email_body = wpautop( $email_content ); |
|
215 | + $email_body = wpautop($email_content); |
|
216 | 216 | |
217 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
217 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
218 | 218 | |
219 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
219 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -229,35 +229,35 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string $email_body Body of the email |
231 | 231 | */ |
232 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
232 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
233 | 233 | |
234 | - $payment = new Give_Payment( $payment_id ); |
|
234 | + $payment = new Give_Payment($payment_id); |
|
235 | 235 | |
236 | - if ( $payment->user_id > 0 ) { |
|
237 | - $user_data = get_userdata( $payment->user_id ); |
|
236 | + if ($payment->user_id > 0) { |
|
237 | + $user_data = get_userdata($payment->user_id); |
|
238 | 238 | $name = $user_data->display_name; |
239 | - } elseif ( ! empty( $payment->first_name ) && ! empty( $payment->last_name ) ) { |
|
240 | - $name = $payment->first_name . ' ' . $payment->last_name; |
|
239 | + } elseif ( ! empty($payment->first_name) && ! empty($payment->last_name)) { |
|
240 | + $name = $payment->first_name.' '.$payment->last_name; |
|
241 | 241 | } else { |
242 | 242 | $name = $payment->email; |
243 | 243 | } |
244 | 244 | |
245 | - $gateway = give_get_gateway_admin_label( $payment->gateway ); |
|
245 | + $gateway = give_get_gateway_admin_label($payment->gateway); |
|
246 | 246 | |
247 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
248 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
250 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
251 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
252 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
253 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
247 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
248 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
250 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
251 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount($payment->total, array('sanitize' => false))), ENT_COMPAT, 'UTF-8')."\n"; |
|
252 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
253 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
254 | 254 | |
255 | - $message = give_get_option( 'donation_notification' ); |
|
256 | - $message = isset( $message ) ? stripslashes( $message ) : $default_email_body; |
|
255 | + $message = give_get_option('donation_notification'); |
|
256 | + $message = isset($message) ? stripslashes($message) : $default_email_body; |
|
257 | 257 | |
258 | - $email_body = give_do_email_tags( $message, $payment_id ); |
|
258 | + $email_body = give_do_email_tags($message, $payment_id); |
|
259 | 259 | |
260 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
260 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -272,29 +272,29 @@ discard block |
||
272 | 272 | |
273 | 273 | //Payment receipt switcher |
274 | 274 | $payment_count = give_count_payments()->publish; |
275 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
275 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
276 | 276 | |
277 | - if ( $payment_count <= 0 ) { |
|
277 | + if ($payment_count <= 0) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | 281 | //Get payments. |
282 | - $payments = new Give_Payments_Query( array( |
|
282 | + $payments = new Give_Payments_Query(array( |
|
283 | 283 | 'number' => 100, |
284 | - ) ); |
|
284 | + )); |
|
285 | 285 | $payments = $payments->get_payments(); |
286 | 286 | $options = array(); |
287 | 287 | |
288 | 288 | //Provide nice human readable options. |
289 | - if ( $payments ) { |
|
290 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
291 | - foreach ( $payments as $payment ) { |
|
289 | + if ($payments) { |
|
290 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
291 | + foreach ($payments as $payment) { |
|
292 | 292 | |
293 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
293 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
294 | 294 | |
295 | 295 | } |
296 | 296 | } else { |
297 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
297 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | //Start constructing HTML output. |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | var selected_trans = transactions.options[transactions.selectedIndex]; |
308 | 308 | console.log(selected_trans); |
309 | 309 | if (selected_trans){ |
310 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
310 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
311 | 311 | window.location = url_string; |
312 | 312 | } |
313 | 313 | } |
314 | 314 | </script>'; |
315 | 315 | |
316 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
316 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
317 | 317 | |
318 | 318 | //The select field with 100 latest transactions |
319 | - $transaction_header .= Give()->html->select( array( |
|
319 | + $transaction_header .= Give()->html->select(array( |
|
320 | 320 | 'name' => 'preview_email_payment_id', |
321 | 321 | 'selected' => $payment_id, |
322 | 322 | 'id' => 'give_preview_email_payment_id', |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | 'select_atts' => 'onchange="change_preview()">', |
327 | 327 | 'show_option_all' => false, |
328 | 328 | 'show_option_none' => false, |
329 | - ) ); |
|
329 | + )); |
|
330 | 330 | |
331 | 331 | //Closing tag |
332 | 332 | $transaction_header .= '</div>'; |
333 | 333 | |
334 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
334 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
335 | 335 | |
336 | 336 | } |
337 | 337 | \ No newline at end of file |
@@ -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 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct() { |
89 | 89 | |
90 | - if ( 'none' === $this->get_template() ) { |
|
90 | + if ('none' === $this->get_template()) { |
|
91 | 91 | $this->html = false; |
92 | 92 | } |
93 | 93 | |
94 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
95 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
94 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
95 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param $key |
105 | 105 | * @param $value |
106 | 106 | */ |
107 | - public function __set( $key, $value ) { |
|
107 | + public function __set($key, $value) { |
|
108 | 108 | $this->$key = $value; |
109 | 109 | } |
110 | 110 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | 116 | public function get_from_name() { |
117 | - if ( ! $this->from_name ) { |
|
118 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
117 | + if ( ! $this->from_name) { |
|
118 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
119 | 119 | } |
120 | 120 | |
121 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
121 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | 129 | public function get_from_address() { |
130 | - if ( ! $this->from_address ) { |
|
131 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
130 | + if ( ! $this->from_address) { |
|
131 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
134 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | * @since 1.0 |
141 | 141 | */ |
142 | 142 | public function get_content_type() { |
143 | - if ( ! $this->content_type && $this->html ) { |
|
144 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
145 | - } else if ( ! $this->html ) { |
|
143 | + if ( ! $this->content_type && $this->html) { |
|
144 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
145 | + } else if ( ! $this->html) { |
|
146 | 146 | $this->content_type = 'text/plain'; |
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
149 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_headers() { |
158 | - if ( ! $this->headers ) { |
|
158 | + if ( ! $this->headers) { |
|
159 | 159 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
160 | 160 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
161 | 161 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
164 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function get_templates() { |
173 | 173 | $templates = array( |
174 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
175 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
174 | + 'default' => esc_html__('Default Template', 'give'), |
|
175 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
176 | 176 | ); |
177 | 177 | |
178 | - return apply_filters( 'give_email_templates', $templates ); |
|
178 | + return apply_filters('give_email_templates', $templates); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @since 1.0 |
185 | 185 | */ |
186 | 186 | public function get_template() { |
187 | - if ( ! $this->template ) { |
|
188 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
187 | + if ( ! $this->template) { |
|
188 | + $this->template = give_get_option('email_template', 'default'); |
|
189 | 189 | } |
190 | 190 | |
191 | - return apply_filters( 'give_email_template', $this->template ); |
|
191 | + return apply_filters('give_email_template', $this->template); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | 199 | public function get_heading() { |
200 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
200 | + return apply_filters('give_email_heading', $this->heading); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function parse_tags( $content ) { |
|
210 | + public function parse_tags($content) { |
|
211 | 211 | return $content; |
212 | 212 | } |
213 | 213 | |
@@ -220,33 +220,33 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function build_email( $message ) { |
|
223 | + public function build_email($message) { |
|
224 | 224 | |
225 | - if ( false === $this->html ) { |
|
225 | + if (false === $this->html) { |
|
226 | 226 | |
227 | 227 | // Added Replacement check to simply behaviour of anchor tags. |
228 | 228 | $pattern = '/<a.+?href\=(?:["|\'])(.+?)(?:["|\']).*?>(.+?)<\/a>/i'; |
229 | 229 | $message = preg_replace_callback( |
230 | 230 | $pattern, |
231 | - function( $return ) { |
|
232 | - if ( $return[1] !== $return[2] ) { |
|
231 | + function($return) { |
|
232 | + if ($return[1] !== $return[2]) { |
|
233 | 233 | return "{$return[2]} ( {$return[1]} )"; |
234 | 234 | } |
235 | - return trailingslashit( $return[1] ); |
|
235 | + return trailingslashit($return[1]); |
|
236 | 236 | }, |
237 | 237 | $message |
238 | 238 | ); |
239 | 239 | |
240 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
240 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
241 | 241 | } |
242 | 242 | |
243 | - $message = $this->text_to_html( $message ); |
|
243 | + $message = $this->text_to_html($message); |
|
244 | 244 | |
245 | 245 | $template = $this->get_template(); |
246 | 246 | |
247 | 247 | ob_start(); |
248 | 248 | |
249 | - give_get_template_part( 'emails/header', $template, true ); |
|
249 | + give_get_template_part('emails/header', $template, true); |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Fires in the email head. |
@@ -255,17 +255,17 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @param Give_Emails $this The email object. |
257 | 257 | */ |
258 | - do_action( 'give_email_header', $this ); |
|
258 | + do_action('give_email_header', $this); |
|
259 | 259 | |
260 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
260 | + if (has_action('give_email_template_'.$template)) { |
|
261 | 261 | /** |
262 | 262 | * Fires in a specific email template. |
263 | 263 | * |
264 | 264 | * @since 1.0 |
265 | 265 | */ |
266 | - do_action( "give_email_template_{$template}" ); |
|
266 | + do_action("give_email_template_{$template}"); |
|
267 | 267 | } else { |
268 | - give_get_template_part( 'emails/body', $template, true ); |
|
268 | + give_get_template_part('emails/body', $template, true); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param Give_Emails $this The email object. |
277 | 277 | */ |
278 | - do_action( 'give_email_body', $this ); |
|
278 | + do_action('give_email_body', $this); |
|
279 | 279 | |
280 | - give_get_template_part( 'emails/footer', $template, true ); |
|
280 | + give_get_template_part('emails/footer', $template, true); |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * Fires in the email footer. |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param Give_Emails $this The email object. |
288 | 288 | */ |
289 | - do_action( 'give_email_footer', $this ); |
|
289 | + do_action('give_email_footer', $this); |
|
290 | 290 | |
291 | 291 | $body = ob_get_clean(); |
292 | - $message = str_replace( '{email}', $message, $body ); |
|
292 | + $message = str_replace('{email}', $message, $body); |
|
293 | 293 | |
294 | - return apply_filters( 'give_email_message', $message, $this ); |
|
294 | + return apply_filters('give_email_message', $message, $this); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool |
306 | 306 | */ |
307 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
307 | + public function send($to, $subject, $message, $attachments = '') { |
|
308 | 308 | |
309 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
310 | - give_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
309 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
310 | + give_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
311 | 311 | |
312 | 312 | return false; |
313 | 313 | } |
@@ -319,16 +319,16 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @param Give_Emails $this The email object. |
321 | 321 | */ |
322 | - do_action( 'give_email_send_before', $this ); |
|
322 | + do_action('give_email_send_before', $this); |
|
323 | 323 | |
324 | - $subject = $this->parse_tags( $subject ); |
|
325 | - $message = $this->parse_tags( $message ); |
|
324 | + $subject = $this->parse_tags($subject); |
|
325 | + $message = $this->parse_tags($message); |
|
326 | 326 | |
327 | - $message = $this->build_email( $message ); |
|
327 | + $message = $this->build_email($message); |
|
328 | 328 | |
329 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
329 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
330 | 330 | |
331 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
331 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
332 | 332 | |
333 | 333 | /** |
334 | 334 | * Fires after sending an email. |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @param Give_Emails $this The email object. |
339 | 339 | */ |
340 | - do_action( 'give_email_send_after', $this ); |
|
340 | + do_action('give_email_send_after', $this); |
|
341 | 341 | |
342 | 342 | return $sent; |
343 | 343 | |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | * @since 1.0 |
350 | 350 | */ |
351 | 351 | public function send_before() { |
352 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
353 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
354 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
352 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
353 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
354 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * @since 1.0 |
361 | 361 | */ |
362 | 362 | public function send_after() { |
363 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
364 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
365 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
363 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
364 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
365 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
366 | 366 | |
367 | 367 | // Reset heading to an empty string |
368 | 368 | $this->heading = ''; |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @since 1.0 |
375 | 375 | */ |
376 | - public function text_to_html( $message ) { |
|
376 | + public function text_to_html($message) { |
|
377 | 377 | |
378 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
379 | - $message = wpautop( $message ); |
|
378 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
379 | + $message = wpautop($message); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | return $message; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | 52 | |
53 | - $payment_id = give_create_payment( $payment_data ); |
|
53 | + $payment_id = give_create_payment($payment_data); |
|
54 | 54 | |
55 | 55 | // Check payment. |
56 | - if ( empty( $payment_id ) ) { |
|
56 | + if (empty($payment_id)) { |
|
57 | 57 | // Record the error. |
58 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
59 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
58 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
59 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
60 | 60 | // Problems? Send back. |
61 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
61 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // Redirect to PayPal. |
65 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
65 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
69 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | function give_listen_for_paypal_ipn() { |
78 | 78 | |
79 | 79 | // Regular PayPal IPN. |
80 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
80 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
81 | 81 | /** |
82 | 82 | * Fires while verifying PayPal IPN |
83 | 83 | * |
84 | 84 | * @since 1.0 |
85 | 85 | */ |
86 | - do_action( 'give_verify_paypal_ipn' ); |
|
86 | + do_action('give_verify_paypal_ipn'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
90 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Process PayPal IPN |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function give_process_paypal_ipn() { |
99 | 99 | |
100 | 100 | // Check the request method is POST. |
101 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
101 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $post_data = ''; |
107 | 107 | |
108 | 108 | // Fallback just in case post_max_size is lower than needed. |
109 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
110 | - $post_data = file_get_contents( 'php://input' ); |
|
109 | + if (ini_get('allow_url_fopen')) { |
|
110 | + $post_data = file_get_contents('php://input'); |
|
111 | 111 | } else { |
112 | 112 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
113 | - ini_set( 'post_max_size', '12M' ); |
|
113 | + ini_set('post_max_size', '12M'); |
|
114 | 114 | } |
115 | 115 | // Start the encoded data collection with notification command. |
116 | 116 | $encoded_data = 'cmd=_notify-validate'; |
@@ -119,41 +119,41 @@ discard block |
||
119 | 119 | $arg_separator = give_get_php_arg_separator_output(); |
120 | 120 | |
121 | 121 | // Verify there is a post_data. |
122 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
122 | + if ($post_data || strlen($post_data) > 0) { |
|
123 | 123 | // Append the data. |
124 | - $encoded_data .= $arg_separator . $post_data; |
|
124 | + $encoded_data .= $arg_separator.$post_data; |
|
125 | 125 | } else { |
126 | 126 | // Check if POST is empty. |
127 | - if ( empty( $_POST ) ) { |
|
127 | + if (empty($_POST)) { |
|
128 | 128 | // Nothing to do. |
129 | 129 | return; |
130 | 130 | } else { |
131 | 131 | // Loop through each POST. |
132 | - foreach ( $_POST as $key => $value ) { |
|
132 | + foreach ($_POST as $key => $value) { |
|
133 | 133 | // Encode the value and append the data. |
134 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
134 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Convert collected post data to an array. |
140 | - parse_str( $encoded_data, $encoded_data_array ); |
|
140 | + parse_str($encoded_data, $encoded_data_array); |
|
141 | 141 | |
142 | - foreach ( $encoded_data_array as $key => $value ) { |
|
142 | + foreach ($encoded_data_array as $key => $value) { |
|
143 | 143 | |
144 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
145 | - $new_key = str_replace( '&', '&', $key ); |
|
146 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
144 | + if (false !== strpos($key, 'amp;')) { |
|
145 | + $new_key = str_replace('&', '&', $key); |
|
146 | + $new_key = str_replace('amp;', '&', $new_key); |
|
147 | 147 | |
148 | - unset( $encoded_data_array[ $key ] ); |
|
149 | - $encoded_data_array[ $new_key ] = $value; |
|
148 | + unset($encoded_data_array[$key]); |
|
149 | + $encoded_data_array[$new_key] = $value; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $api_response = false; |
154 | 154 | |
155 | 155 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
156 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
156 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
157 | 157 | |
158 | 158 | $remote_post_vars = array( |
159 | 159 | 'method' => 'POST', |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | ); |
174 | 174 | |
175 | 175 | // Validate the IPN. |
176 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
176 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
177 | 177 | |
178 | - if ( is_wp_error( $api_response ) ) { |
|
179 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
178 | + if (is_wp_error($api_response)) { |
|
179 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
181 | 181 | |
182 | 182 | return; // Something went wrong. |
183 | 183 | } |
184 | 184 | |
185 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
186 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
185 | + if ('VERIFIED' !== $api_response['body']) { |
|
186 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
188 | 188 | |
189 | 189 | return; // Response not okay. |
190 | 190 | } |
191 | 191 | }// End if(). |
192 | 192 | |
193 | 193 | // Check if $post_data_array has been populated. |
194 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
194 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
@@ -200,28 +200,28 @@ discard block |
||
200 | 200 | 'payment_status' => '', |
201 | 201 | ); |
202 | 202 | |
203 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
203 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
204 | 204 | |
205 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
205 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
206 | 206 | $txn_type = $encoded_data_array['txn_type']; |
207 | 207 | |
208 | 208 | // Check for PayPal IPN Notifications and update data based on it. |
209 | - $current_timestamp = current_time( 'timestamp' ); |
|
209 | + $current_timestamp = current_time('timestamp'); |
|
210 | 210 | $paypal_ipn_vars = array( |
211 | - 'auth_status' => isset( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
212 | - 'transaction_id' => isset( $encoded_data_array['txn_id'] ) ? $encoded_data_array['txn_id'] : 'N/A', |
|
211 | + 'auth_status' => isset($api_response['body']) ? $api_response['body'] : 'N/A', |
|
212 | + 'transaction_id' => isset($encoded_data_array['txn_id']) ? $encoded_data_array['txn_id'] : 'N/A', |
|
213 | 213 | 'payment_id' => $payment_id, |
214 | 214 | ); |
215 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
216 | - give_insert_payment_note( $payment_id, sprintf( |
|
217 | - __( 'IPN received on %s at %s', 'give' ), |
|
218 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
219 | - date_i18n( 'H:i', $current_timestamp ) |
|
215 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
216 | + give_insert_payment_note($payment_id, sprintf( |
|
217 | + __('IPN received on %s at %s', 'give'), |
|
218 | + date_i18n('m/d/Y', $current_timestamp), |
|
219 | + date_i18n('H:i', $current_timestamp) |
|
220 | 220 | ) |
221 | 221 | ); |
222 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
222 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
223 | 223 | |
224 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
224 | + if (has_action('give_paypal_'.$txn_type)) { |
|
225 | 225 | /** |
226 | 226 | * Fires while processing PayPal IPN $txn_type. |
227 | 227 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param array $encoded_data_array Encoded data. |
233 | 233 | * @param int $payment_id Payment id. |
234 | 234 | */ |
235 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
235 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
236 | 236 | } else { |
237 | 237 | /** |
238 | 238 | * Fires while process PayPal IPN. |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * @param array $encoded_data_array Encoded data. |
245 | 245 | * @param int $payment_id Payment id. |
246 | 246 | */ |
247 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
247 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
248 | 248 | } |
249 | 249 | exit; |
250 | 250 | } |
251 | 251 | |
252 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
252 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Process web accept (one time) payment IPNs. |
@@ -261,99 +261,99 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return void |
263 | 263 | */ |
264 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
264 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
265 | 265 | |
266 | 266 | // Only allow through these transaction types. |
267 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
267 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Need $payment_id to continue. |
272 | - if ( empty( $payment_id ) ) { |
|
272 | + if (empty($payment_id)) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Collect donation payment details. |
277 | 277 | $paypal_amount = $data['mc_gross']; |
278 | - $payment_status = strtolower( $data['payment_status'] ); |
|
279 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
280 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
281 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
278 | + $payment_status = strtolower($data['payment_status']); |
|
279 | + $currency_code = strtolower($data['mc_currency']); |
|
280 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
281 | + $payment_meta = give_get_payment_meta($payment_id); |
|
282 | 282 | |
283 | 283 | // Must be a PayPal standard IPN. |
284 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
284 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Verify payment recipient. |
289 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
289 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
290 | 290 | |
291 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
293 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
291 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
293 | + give_update_payment_status($payment_id, 'failed'); |
|
294 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
295 | 295 | |
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Verify payment currency. |
300 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
300 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
301 | 301 | |
302 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
304 | - give_update_payment_status( $payment_id, 'failed' ); |
|
305 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
302 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
304 | + give_update_payment_status($payment_id, 'failed'); |
|
305 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
306 | 306 | |
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Process refunds & reversed. |
311 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
312 | - give_process_paypal_refund( $data, $payment_id ); |
|
311 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
312 | + give_process_paypal_refund($data, $payment_id); |
|
313 | 313 | |
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Only complete payments once. |
318 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
318 | + if ('publish' === get_post_status($payment_id)) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Retrieve the total donation amount (before PayPal). |
323 | - $payment_amount = give_donation_amount( $payment_id ); |
|
323 | + $payment_amount = give_donation_amount($payment_id); |
|
324 | 324 | |
325 | 325 | // Check that the donation PP and local db amounts match. |
326 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
326 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
327 | 327 | // The prices don't match |
328 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
330 | - give_update_payment_status( $payment_id, 'failed' ); |
|
331 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
328 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
330 | + give_update_payment_status($payment_id, 'failed'); |
|
331 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
332 | 332 | |
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Process completed donations. |
337 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
337 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
338 | 338 | |
339 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
341 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
342 | - give_update_payment_status( $payment_id, 'publish' ); |
|
339 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
341 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
342 | + give_update_payment_status($payment_id, 'publish'); |
|
343 | 343 | |
344 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
344 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
345 | 345 | |
346 | 346 | // Look for possible pending reasons, such as an echeck. |
347 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
347 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
348 | 348 | |
349 | - if ( ! empty( $note ) ) { |
|
350 | - give_insert_payment_note( $payment_id, $note ); |
|
349 | + if ( ! empty($note)) { |
|
350 | + give_insert_payment_note($payment_id, $note); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
356 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Process PayPal IPN Refunds |
@@ -365,35 +365,35 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return void |
367 | 367 | */ |
368 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
368 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
369 | 369 | |
370 | 370 | // Collect payment details. |
371 | - if ( empty( $payment_id ) ) { |
|
371 | + if (empty($payment_id)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // Only refund payments once. |
376 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
376 | + if ('refunded' === get_post_status($payment_id)) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | - $payment_amount = give_donation_amount( $payment_id ); |
|
380 | + $payment_amount = give_donation_amount($payment_id); |
|
381 | 381 | $refund_amount = $data['payment_gross'] * - 1; |
382 | 382 | |
383 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
383 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
384 | 384 | |
385 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
385 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
387 | 387 | |
388 | 388 | return; // This is a partial refund |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
394 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
396 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
392 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
394 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
396 | + give_update_payment_status($payment_id, 'refunded'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -405,24 +405,24 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return string |
407 | 407 | */ |
408 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
408 | +function give_get_paypal_redirect($ssl_check = false) { |
|
409 | 409 | |
410 | - if ( is_ssl() || ! $ssl_check ) { |
|
410 | + if (is_ssl() || ! $ssl_check) { |
|
411 | 411 | $protocol = 'https://'; |
412 | 412 | } else { |
413 | 413 | $protocol = 'http://'; |
414 | 414 | } |
415 | 415 | |
416 | 416 | // Check the current payment mode |
417 | - if ( give_is_test_mode() ) { |
|
417 | + if (give_is_test_mode()) { |
|
418 | 418 | // Test mode |
419 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
419 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
420 | 420 | } else { |
421 | 421 | // Live mode |
422 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
422 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
423 | 423 | } |
424 | 424 | |
425 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
425 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | * @return string |
433 | 433 | */ |
434 | 434 | function give_get_paypal_page_style() { |
435 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
435 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
436 | 436 | |
437 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
437 | + return apply_filters('give_paypal_page_style', $page_style); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -448,26 +448,26 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return string |
450 | 450 | */ |
451 | -function give_paypal_success_page_content( $content ) { |
|
451 | +function give_paypal_success_page_content($content) { |
|
452 | 452 | |
453 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
453 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
454 | 454 | return $content; |
455 | 455 | } |
456 | 456 | |
457 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
457 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
458 | 458 | |
459 | - if ( ! $payment_id ) { |
|
459 | + if ( ! $payment_id) { |
|
460 | 460 | $session = give_get_purchase_session(); |
461 | - $payment_id = give_get_donation_id_by_key( $session['purchase_key'] ); |
|
461 | + $payment_id = give_get_donation_id_by_key($session['purchase_key']); |
|
462 | 462 | } |
463 | 463 | |
464 | - $payment = get_post( $payment_id ); |
|
465 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
464 | + $payment = get_post($payment_id); |
|
465 | + if ($payment && 'pending' === $payment->post_status) { |
|
466 | 466 | |
467 | 467 | // Payment is still pending so show processing indicator to fix the race condition. |
468 | 468 | ob_start(); |
469 | 469 | |
470 | - give_get_template_part( 'payment', 'processing' ); |
|
470 | + give_get_template_part('payment', 'processing'); |
|
471 | 471 | |
472 | 472 | $content = ob_get_clean(); |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
480 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -489,16 +489,16 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return string A link to the PayPal transaction details |
491 | 491 | */ |
492 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
492 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
493 | 493 | |
494 | 494 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
495 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
495 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
496 | 496 | |
497 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
497 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
498 | 498 | |
499 | 499 | } |
500 | 500 | |
501 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
501 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
502 | 502 | |
503 | 503 | |
504 | 504 | /** |
@@ -510,64 +510,64 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
513 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
514 | 514 | |
515 | 515 | $note = ''; |
516 | 516 | |
517 | - switch ( $pending_reason ) { |
|
517 | + switch ($pending_reason) { |
|
518 | 518 | |
519 | 519 | case 'echeck' : |
520 | 520 | |
521 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
521 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
522 | 522 | |
523 | 523 | break; |
524 | 524 | |
525 | 525 | case 'address' : |
526 | 526 | |
527 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
527 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | 531 | case 'intl' : |
532 | 532 | |
533 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
533 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
534 | 534 | |
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'multi-currency' : |
538 | 538 | |
539 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
539 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
540 | 540 | |
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'paymentreview' : |
544 | 544 | case 'regulatory_review' : |
545 | 545 | |
546 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
546 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
547 | 547 | |
548 | 548 | break; |
549 | 549 | |
550 | 550 | case 'unilateral' : |
551 | 551 | |
552 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
552 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
553 | 553 | |
554 | 554 | break; |
555 | 555 | |
556 | 556 | case 'upgrade' : |
557 | 557 | |
558 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
558 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
559 | 559 | |
560 | 560 | break; |
561 | 561 | |
562 | 562 | case 'verify' : |
563 | 563 | |
564 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
564 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
565 | 565 | |
566 | 566 | break; |
567 | 567 | |
568 | 568 | case 'other' : |
569 | 569 | |
570 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
570 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
@@ -585,49 +585,49 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return mixed|string |
587 | 587 | */ |
588 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
588 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
589 | 589 | // Only send to PayPal if the pending payment is created successfully. |
590 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
590 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
591 | 591 | |
592 | 592 | // Get the success url. |
593 | - $return_url = add_query_arg( array( |
|
593 | + $return_url = add_query_arg(array( |
|
594 | 594 | 'payment-confirmation' => 'paypal', |
595 | 595 | 'payment-id' => $payment_id, |
596 | 596 | |
597 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
597 | + ), get_permalink(give_get_option('success_page'))); |
|
598 | 598 | |
599 | 599 | // Get the PayPal redirect uri. |
600 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
600 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
601 | 601 | |
602 | 602 | // Item name. |
603 | - $item_name = give_payment_gateway_item_title( $payment_data ); |
|
603 | + $item_name = give_payment_gateway_item_title($payment_data); |
|
604 | 604 | |
605 | 605 | // Setup PayPal API params. |
606 | 606 | $paypal_args = array( |
607 | - 'business' => give_get_option( 'paypal_email', false ), |
|
607 | + 'business' => give_get_option('paypal_email', false), |
|
608 | 608 | 'first_name' => $payment_data['user_info']['first_name'], |
609 | 609 | 'last_name' => $payment_data['user_info']['last_name'], |
610 | 610 | 'email' => $payment_data['user_email'], |
611 | 611 | 'invoice' => $payment_data['purchase_key'], |
612 | 612 | 'amount' => $payment_data['price'], |
613 | - 'item_name' => stripslashes( $item_name ), |
|
613 | + 'item_name' => stripslashes($item_name), |
|
614 | 614 | 'no_shipping' => '1', |
615 | 615 | 'shipping' => '0', |
616 | 616 | 'no_note' => '1', |
617 | - 'currency_code' => give_get_currency( $payment_id, $payment_data ), |
|
618 | - 'charset' => get_bloginfo( 'charset' ), |
|
617 | + 'currency_code' => give_get_currency($payment_id, $payment_data), |
|
618 | + 'charset' => get_bloginfo('charset'), |
|
619 | 619 | 'custom' => $payment_id, |
620 | 620 | 'rm' => '2', |
621 | 621 | 'return' => $return_url, |
622 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
622 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
623 | 623 | 'notify_url' => $listener_url, |
624 | 624 | 'page_style' => give_get_paypal_page_style(), |
625 | - 'cbt' => get_bloginfo( 'name' ), |
|
625 | + 'cbt' => get_bloginfo('name'), |
|
626 | 626 | 'bn' => 'givewp_SP', |
627 | 627 | ); |
628 | 628 | |
629 | 629 | // Add user address if present. |
630 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
630 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
631 | 631 | $default_address = array( |
632 | 632 | 'line1' => '', |
633 | 633 | 'line2' => '', |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | 'country' => '', |
638 | 638 | ); |
639 | 639 | |
640 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
640 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
641 | 641 | |
642 | 642 | $paypal_args['address1'] = $address['line1']; |
643 | 643 | $paypal_args['address2'] = $address['line2']; |
@@ -658,13 +658,13 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @since 1.8 |
660 | 660 | */ |
661 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
661 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
662 | 662 | |
663 | 663 | // Build query. |
664 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
664 | + $paypal_redirect .= http_build_query($paypal_args); |
|
665 | 665 | |
666 | 666 | // Fix for some sites that encode the entities. |
667 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
667 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
668 | 668 | |
669 | 669 | return $paypal_redirect; |
670 | 670 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | function give_get_paypal_button_type() { |
680 | 680 | // paypal_button_type can be donation or standard. |
681 | 681 | $paypal_button_type = '_donations'; |
682 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
682 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
683 | 683 | $paypal_button_type = '_xclick'; |
684 | 684 | } |
685 | 685 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return Give |
203 | 203 | */ |
204 | 204 | public static function instance() { |
205 | - if ( is_null( self::$_instance ) ) { |
|
205 | + if (is_null(self::$_instance)) { |
|
206 | 206 | self::$_instance = new self(); |
207 | 207 | } |
208 | 208 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function __construct() { |
216 | 216 | // PHP version |
217 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { |
|
218 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); |
|
217 | + if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) { |
|
218 | + define('GIVE_REQUIRED_PHP_VERSION', '5.3'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // Bailout: Need minimum php version to load plugin. |
222 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
223 | - add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) ); |
|
222 | + if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { |
|
223 | + add_action('admin_notices', array($this, 'minmum_phpversion_notice')); |
|
224 | 224 | |
225 | 225 | return; |
226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->includes(); |
231 | 231 | $this->init_hooks(); |
232 | 232 | |
233 | - do_action( 'give_loaded' ); |
|
233 | + do_action('give_loaded'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @since 1.8.9 |
240 | 240 | */ |
241 | 241 | private function init_hooks() { |
242 | - register_activation_hook( __FILE__, 'give_install' ); |
|
243 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
|
242 | + register_activation_hook(__FILE__, 'give_install'); |
|
243 | + add_action('plugins_loaded', array($this, 'init'), 0); |
|
244 | 244 | } |
245 | 245 | /** |
246 | 246 | * Init Give when WordPress Initializes. |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @since 1.8.9 |
256 | 256 | */ |
257 | - do_action( 'before_give_init' ); |
|
257 | + do_action('before_give_init'); |
|
258 | 258 | |
259 | 259 | // Set up localization. |
260 | 260 | $this->load_textdomain(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @since 1.8.7 |
281 | 281 | */ |
282 | - do_action( 'give_init', $this ); |
|
282 | + do_action('give_init', $this); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function __clone() { |
298 | 298 | // Cloning instances of the class is forbidden. |
299 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
299 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function __wakeup() { |
311 | 311 | // Unserializing instances of the class is forbidden. |
312 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
312 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -323,33 +323,33 @@ discard block |
||
323 | 323 | private function setup_constants() { |
324 | 324 | |
325 | 325 | // Plugin version |
326 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
327 | - define( 'GIVE_VERSION', '1.8.18' ); |
|
326 | + if ( ! defined('GIVE_VERSION')) { |
|
327 | + define('GIVE_VERSION', '1.8.18'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // Plugin Folder Path |
331 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
332 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
331 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
332 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // Plugin Folder URL |
336 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
337 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
336 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
337 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Plugin Basename aka: "give/give.php" |
341 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
342 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
341 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
342 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Plugin Root File |
346 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
347 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
346 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
347 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Make sure CAL_GREGORIAN is defined |
351 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
352 | - define( 'CAL_GREGORIAN', 1 ); |
|
351 | + if ( ! defined('CAL_GREGORIAN')) { |
|
352 | + define('CAL_GREGORIAN', 1); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -364,133 +364,133 @@ discard block |
||
364 | 364 | private function includes() { |
365 | 365 | global $give_options; |
366 | 366 | |
367 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
368 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
368 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
369 | 369 | $give_options = give_get_settings(); |
370 | 370 | |
371 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; |
|
381 | - |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
383 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
386 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
393 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
395 | - |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
401 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
411 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
412 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
414 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
415 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
416 | - |
|
417 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
418 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
419 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
420 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
421 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
422 | - |
|
423 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
424 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
425 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
426 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
427 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
428 | - |
|
429 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
430 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
431 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
432 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
433 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
434 | - |
|
435 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php'; |
|
436 | - |
|
437 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
438 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
371 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/class-notices.php'; |
|
381 | + |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
383 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
386 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php'; |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
393 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
395 | + |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/import-functions.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
401 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
411 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
412 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php'; |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
414 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
415 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
416 | + |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
418 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
419 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
420 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
421 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
422 | + |
|
423 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
424 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
425 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
426 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
427 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
428 | + |
|
429 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
430 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
431 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
432 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
433 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
434 | + |
|
435 | + require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php'; |
|
436 | + |
|
437 | + if (defined('WP_CLI') && WP_CLI) { |
|
438 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
439 | 439 | } |
440 | 440 | |
441 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
441 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
442 | 442 | |
443 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
444 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
445 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
446 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
447 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
448 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
449 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
450 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
451 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
452 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
453 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php'; |
|
443 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
444 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
445 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
446 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
447 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
448 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
449 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
450 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
451 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
452 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
453 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php'; |
|
454 | 454 | |
455 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
456 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
455 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
456 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
457 | 457 | |
458 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; |
|
459 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; |
|
460 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; |
|
458 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php'; |
|
459 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php'; |
|
460 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php'; |
|
461 | 461 | |
462 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
463 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
464 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
462 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
463 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
464 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
465 | 465 | |
466 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; |
|
467 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; |
|
468 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; |
|
469 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; |
|
466 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php'; |
|
467 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php'; |
|
468 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php'; |
|
469 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php'; |
|
470 | 470 | |
471 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php'; |
|
472 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php'; |
|
473 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php'; |
|
471 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php'; |
|
472 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php'; |
|
473 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php'; |
|
474 | 474 | |
475 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
475 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
476 | 476 | |
477 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; |
|
477 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php'; |
|
478 | 478 | |
479 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
480 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
481 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
482 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
483 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
484 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
485 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
486 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
487 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
479 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
480 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
481 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
482 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
483 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
484 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
485 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
486 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
487 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
488 | 488 | |
489 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php'; |
|
489 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php'; |
|
490 | 490 | |
491 | 491 | }// End if(). |
492 | 492 | |
493 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
493 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
@@ -505,16 +505,16 @@ discard block |
||
505 | 505 | public function load_textdomain() { |
506 | 506 | |
507 | 507 | // Set filter for Give's languages directory |
508 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
509 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
508 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
509 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
510 | 510 | |
511 | 511 | // Traditional WordPress plugin locale filter. |
512 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
513 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); |
|
512 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
513 | + $locale = apply_filters('plugin_locale', $locale, 'give'); |
|
514 | 514 | |
515 | - unload_textdomain( 'give' ); |
|
516 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); |
|
517 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
515 | + unload_textdomain('give'); |
|
516 | + load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo'); |
|
517 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
518 | 518 | |
519 | 519 | } |
520 | 520 | |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | */ |
528 | 528 | public function minmum_phpversion_notice() { |
529 | 529 | // Bailout. |
530 | - if ( ! is_admin() ) { |
|
530 | + if ( ! is_admin()) { |
|
531 | 531 | return; |
532 | 532 | } |
533 | 533 | |
534 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
535 | - $notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
536 | - $notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
537 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
538 | - $notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
539 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
540 | - $notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
534 | + $notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>'; |
|
535 | + $notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>'; |
|
536 | + $notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>'; |
|
537 | + $notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>'; |
|
538 | + $notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>'; |
|
539 | + $notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>'; |
|
540 | + $notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>'; |
|
541 | 541 | |
542 | 542 | echo sprintf( |
543 | 543 | '<div class="notice notice-error">%1$s</div>', |