@@ -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,42 +56,42 @@ 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 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
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 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())); |
|
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 | $user = wp_get_current_user(); |
77 | 77 | |
78 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
81 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
82 | - $message = str_replace( '{amount}', $price, $message ); |
|
83 | - $message = str_replace( '{price}', $price, $message ); |
|
84 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
85 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
86 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
87 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
88 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
89 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
90 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
91 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
92 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
93 | - |
|
94 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
78 | + $message = str_replace('{name}', $user->display_name, $message); |
|
79 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
80 | + $message = str_replace('{username}', $user->user_login, $message); |
|
81 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
82 | + $message = str_replace('{amount}', $price, $message); |
|
83 | + $message = str_replace('{price}', $price, $message); |
|
84 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
85 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
86 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
87 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
88 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
89 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
90 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
91 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
92 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
93 | + |
|
94 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return array|bool |
105 | 105 | */ |
106 | -function give_email_template_preview( $array ) { |
|
106 | +function give_email_template_preview($array) { |
|
107 | 107 | |
108 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
108 | + if ( ! current_user_can('manage_give_settings')) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $custom_field = array( |
112 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
113 | - 'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ), |
|
112 | + 'name' => esc_html__('Preview Email', 'give'), |
|
113 | + 'desc' => esc_html__('Click the buttons to preview emails.', 'give'), |
|
114 | 114 | 'id' => 'give_email_preview_buttons', |
115 | 115 | 'type' => 'email_preview_buttons' |
116 | 116 | ); |
117 | 117 | |
118 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
118 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
122 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Output Email Template Preview Buttons. |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function give_email_preview_buttons_callback() { |
132 | 132 | ob_start(); |
133 | 133 | ?> |
134 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
135 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
134 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
135 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
136 | 136 | 'give_action' => 'send_test_email', |
137 | 137 | 'give-message' => 'sent-test-email', |
138 | 138 | 'tag' => 'emails' |
139 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
139 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
140 | 140 | <?php |
141 | 141 | echo ob_get_clean(); |
142 | 142 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function give_display_email_template_preview() { |
151 | 151 | |
152 | - if ( empty( $_GET['give_action'] ) ) { |
|
152 | + if (empty($_GET['give_action'])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
156 | + if ('preview_email' !== $_GET['give_action']) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
160 | + if ( ! current_user_can('manage_give_settings')) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
165 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
166 | 166 | |
167 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
167 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
168 | 168 | |
169 | 169 | echo give_get_preview_email_header(); |
170 | 170 | |
171 | 171 | //Are we previewing an actual payment? |
172 | - if ( ! empty( $payment_id ) ) { |
|
172 | + if ( ! empty($payment_id)) { |
|
173 | 173 | |
174 | - $content = give_get_email_body_content( $payment_id ); |
|
174 | + $content = give_get_email_body_content($payment_id); |
|
175 | 175 | |
176 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
176 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
177 | 177 | |
178 | 178 | } else { |
179 | 179 | |
180 | 180 | //No payment ID, use sample preview content |
181 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
181 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - echo Give()->emails->build_email( $preview_content ); |
|
185 | + echo Give()->emails->build_email($preview_content); |
|
186 | 186 | |
187 | 187 | exit; |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
191 | +add_action('init', 'give_display_email_template_preview'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Email Template Body. |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string $email_body Body of the email |
202 | 202 | */ |
203 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
203 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
204 | 204 | |
205 | 205 | $default_email_body = give_get_default_donation_receipt_email(); |
206 | 206 | |
207 | - $email_content = give_get_option( 'donation_receipt' ); |
|
208 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
207 | + $email_content = give_get_option('donation_receipt'); |
|
208 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
209 | 209 | |
210 | - $email_body = wpautop( $email_content ); |
|
210 | + $email_body = wpautop($email_content); |
|
211 | 211 | |
212 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
212 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
213 | 213 | |
214 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
214 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string $email_body Body of the email |
226 | 226 | */ |
227 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
227 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
228 | 228 | |
229 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
230 | - $email = give_get_payment_user_email( $payment_id ); |
|
229 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
230 | + $email = give_get_payment_user_email($payment_id); |
|
231 | 231 | |
232 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
233 | - $user_data = get_userdata( $user_info['id'] ); |
|
232 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
233 | + $user_data = get_userdata($user_info['id']); |
|
234 | 234 | $name = $user_data->display_name; |
235 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
236 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
235 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
236 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
237 | 237 | } else { |
238 | 238 | $name = $email; |
239 | 239 | } |
240 | 240 | |
241 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
241 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
245 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
247 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
248 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
243 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
245 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
247 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
248 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
250 | 250 | |
251 | - $email = give_get_option( 'donation_notification' ); |
|
252 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
251 | + $email = give_get_option('donation_notification'); |
|
252 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
253 | 253 | |
254 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
254 | + $email_body = give_do_email_tags($email, $payment_id); |
|
255 | 255 | |
256 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
256 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | * @since 1.0 |
267 | 267 | */ |
268 | 268 | function give_render_receipt_in_browser() { |
269 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
270 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
269 | + if ( ! isset($_GET['payment_key'])) { |
|
270 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
271 | 271 | } |
272 | 272 | |
273 | - $key = urlencode( $_GET['payment_key'] ); |
|
273 | + $key = urlencode($_GET['payment_key']); |
|
274 | 274 | |
275 | 275 | ob_start(); |
276 | 276 | //Disallows caching of the page |
277 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
278 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
279 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
280 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
281 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
277 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
278 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
279 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
280 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
281 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
282 | 282 | ?> |
283 | 283 | <!DOCTYPE html> |
284 | 284 | <html lang="en"> |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.0 |
291 | 291 | */ |
292 | - do_action( 'give_receipt_head' ); |
|
292 | + do_action('give_receipt_head'); |
|
293 | 293 | ?> |
294 | 294 | </head> |
295 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
295 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
296 | 296 | |
297 | 297 | <div id="give_receipt_wrapper"> |
298 | 298 | <?php |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.0 |
303 | 303 | */ |
304 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
304 | + do_action('give_render_receipt_in_browser_before'); |
|
305 | 305 | |
306 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
306 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in the receipt template after the content. |
310 | 310 | * |
311 | 311 | * @since 1.0 |
312 | 312 | */ |
313 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
313 | + do_action('give_render_receipt_in_browser_after'); |
|
314 | 314 | ?> |
315 | 315 | </div> |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.0 |
322 | 322 | */ |
323 | - do_action( 'give_receipt_footer' ); |
|
323 | + do_action('give_receipt_footer'); |
|
324 | 324 | ?> |
325 | 325 | </body> |
326 | 326 | </html> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | die(); |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
332 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | //Payment receipt switcher |
346 | 346 | $payment_count = give_count_payments()->publish; |
347 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
347 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
348 | 348 | |
349 | - if ( $payment_count <= 0 ) { |
|
349 | + if ($payment_count <= 0) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | //Get payments. |
354 | - $payments = new Give_Payments_Query( array( |
|
354 | + $payments = new Give_Payments_Query(array( |
|
355 | 355 | 'number' => 100 |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | $payments = $payments->get_payments(); |
358 | 358 | $options = array(); |
359 | 359 | |
360 | 360 | //Provide nice human readable options. |
361 | - if ( $payments ) { |
|
362 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
363 | - foreach ( $payments as $payment ) { |
|
361 | + if ($payments) { |
|
362 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
363 | + foreach ($payments as $payment) { |
|
364 | 364 | |
365 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
365 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | } else { |
369 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
369 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | //Start constructing HTML output. |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | var selected_trans = transactions.options[transactions.selectedIndex]; |
380 | 380 | console.log(selected_trans); |
381 | 381 | if (selected_trans){ |
382 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
382 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
383 | 383 | window.location = url_string; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | </script>'; |
387 | 387 | |
388 | - $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>'; |
|
388 | + $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>'; |
|
389 | 389 | |
390 | 390 | //The select field with 100 latest transactions |
391 | - $transaction_header .= Give()->html->select( array( |
|
391 | + $transaction_header .= Give()->html->select(array( |
|
392 | 392 | 'name' => 'preview_email_payment_id', |
393 | 393 | 'selected' => $payment_id, |
394 | 394 | 'id' => 'give_preview_email_payment_id', |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | 'select_atts' => 'onchange="change_preview()">', |
399 | 399 | 'show_option_all' => false, |
400 | 400 | 'show_option_none' => false |
401 | - ) ); |
|
401 | + )); |
|
402 | 402 | |
403 | 403 | //Closing tag |
404 | 404 | $transaction_header .= '</div>'; |
405 | 405 | |
406 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
406 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | function give_receipt_head_content() { |
418 | 418 | |
419 | 419 | //Title. |
420 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
420 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
421 | 421 | |
422 | 422 | //Meta. |
423 | 423 | $output .= '<meta charset="utf-8"/> |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | <meta name="robots" content="noindex, nofollow"/>'; |
432 | 432 | |
433 | 433 | //CSS |
434 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
434 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
435 | 435 | |
436 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
436 | + echo apply_filters('give_receipt_head_content', $output); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
441 | 440 | \ No newline at end of file |
441 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
442 | 442 | \ No newline at end of file |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_purchase_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
163 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
164 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,45 +247,45 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
275 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
274 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
275 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
276 | 276 | give_purchase_form_validate_agree_to_terms(); |
277 | 277 | } |
278 | 278 | |
279 | - if ( is_user_logged_in() ) { |
|
279 | + if (is_user_logged_in()) { |
|
280 | 280 | // Collect logged in user data |
281 | 281 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
282 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
282 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
283 | 283 | // Set new user registration as required |
284 | 284 | $valid_data['need_new_user'] = true; |
285 | 285 | // Validate new user data |
286 | 286 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
287 | 287 | // Check if login validation is needed |
288 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
288 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
289 | 289 | // Set user login as required |
290 | 290 | $valid_data['need_user_login'] = true; |
291 | 291 | // Validate users login info |
@@ -310,40 +310,40 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function give_purchase_form_validate_gateway() { |
312 | 312 | |
313 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
314 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
315 | - $gateway = give_get_default_gateway( $form_id ); |
|
313 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
314 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
315 | + $gateway = give_get_default_gateway($form_id); |
|
316 | 316 | |
317 | 317 | // Check if a gateway value is present |
318 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
318 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
319 | 319 | |
320 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
320 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
321 | 321 | |
322 | 322 | // Is amount being donated in LIVE mode 0.00? If so, error: |
323 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
323 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
324 | 324 | |
325 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
325 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
326 | 326 | |
327 | 327 | } //Check for a minimum custom amount |
328 | - elseif ( ! give_verify_minimum_price() ) { |
|
328 | + elseif ( ! give_verify_minimum_price()) { |
|
329 | 329 | // translators: %s: minimum donation amount. |
330 | 330 | give_set_error( |
331 | 331 | 'invalid_donation_minimum', |
332 | 332 | sprintf( |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -545,90 +545,90 @@ discard block |
||
545 | 545 | function give_purchase_form_validate_new_user() { |
546 | 546 | |
547 | 547 | $registering_new_user = false; |
548 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
548 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
549 | 549 | |
550 | 550 | // Start an empty array to collect valid user data. |
551 | 551 | $valid_user_data = array( |
552 | 552 | // Assume there will be errors. |
553 | - 'user_id' => - 1, |
|
553 | + 'user_id' => -1, |
|
554 | 554 | // Get first name. |
555 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
555 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
556 | 556 | // Get last name. |
557 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
557 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
558 | 558 | ); |
559 | 559 | |
560 | 560 | // Check the new user's credentials against existing ones. |
561 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
562 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
563 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
564 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
561 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
562 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
563 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
564 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
565 | 565 | |
566 | 566 | // Loop through required fields and show error messages. |
567 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
568 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
569 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
567 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
568 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
569 | + give_set_error($value['error_id'], $value['error_message']); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
573 | 573 | // Check if we have an username to register. |
574 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
574 | + if ($user_login && strlen($user_login) > 0) { |
|
575 | 575 | $registering_new_user = true; |
576 | 576 | |
577 | 577 | // We have an user name, check if it already exists. |
578 | - if ( username_exists( $user_login ) ) { |
|
578 | + if (username_exists($user_login)) { |
|
579 | 579 | // Username already registered. |
580 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
580 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
581 | 581 | // Check if it's valid. |
582 | - } elseif ( ! give_validate_username( $user_login ) ) { |
|
582 | + } elseif ( ! give_validate_username($user_login)) { |
|
583 | 583 | // Invalid username. |
584 | - if ( is_multisite() ) { |
|
585 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
584 | + if (is_multisite()) { |
|
585 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
586 | 586 | } else { |
587 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
587 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
588 | 588 | } |
589 | 589 | } else { |
590 | 590 | // All the checks have run and it's good to go. |
591 | 591 | $valid_user_data['user_login'] = $user_login; |
592 | 592 | } |
593 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
594 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
593 | + } elseif (give_logged_in_only($form_id)) { |
|
594 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | // Check if we have an email to verify. |
598 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
598 | + if ($user_email && strlen($user_email) > 0) { |
|
599 | 599 | // Validate email. |
600 | - if ( ! is_email( $user_email ) ) { |
|
601 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
600 | + if ( ! is_email($user_email)) { |
|
601 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
602 | 602 | // Check if email exists. |
603 | - } elseif ( email_exists( $user_email ) && $registering_new_user ) { |
|
604 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
603 | + } elseif (email_exists($user_email) && $registering_new_user) { |
|
604 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
605 | 605 | } else { |
606 | 606 | // All the checks have run and it's good to go. |
607 | 607 | $valid_user_data['user_email'] = $user_email; |
608 | 608 | } |
609 | 609 | } else { |
610 | 610 | // No email. |
611 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
611 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | // Check password. |
615 | - if ( $user_pass && $pass_confirm ) { |
|
615 | + if ($user_pass && $pass_confirm) { |
|
616 | 616 | // Verify confirmation matches. |
617 | - if ( $user_pass != $pass_confirm ) { |
|
617 | + if ($user_pass != $pass_confirm) { |
|
618 | 618 | // Passwords do not match |
619 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
619 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
620 | 620 | } else { |
621 | 621 | // All is good to go. |
622 | 622 | $valid_user_data['user_pass'] = $user_pass; |
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | // Password or confirmation missing. |
626 | - if ( ! $user_pass && $registering_new_user ) { |
|
626 | + if ( ! $user_pass && $registering_new_user) { |
|
627 | 627 | // The password is invalid. |
628 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
629 | - } elseif ( ! $pass_confirm && $registering_new_user ) { |
|
628 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
629 | + } elseif ( ! $pass_confirm && $registering_new_user) { |
|
630 | 630 | // Confirmation password is invalid. |
631 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
631 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
@@ -647,36 +647,36 @@ discard block |
||
647 | 647 | // Start an array to collect valid user data. |
648 | 648 | $valid_user_data = array( |
649 | 649 | // Assume there will be errors |
650 | - 'user_id' => - 1, |
|
650 | + 'user_id' => -1, |
|
651 | 651 | ); |
652 | 652 | |
653 | 653 | // Username. |
654 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
655 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
654 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
655 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
656 | 656 | |
657 | 657 | return $valid_user_data; |
658 | 658 | } |
659 | 659 | |
660 | 660 | // Get the user by login. |
661 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
661 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
662 | 662 | |
663 | 663 | // Check if user exists. |
664 | - if ( $user_data ) { |
|
664 | + if ($user_data) { |
|
665 | 665 | // Get password. |
666 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
666 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
667 | 667 | |
668 | 668 | // Check user_pass. |
669 | - if ( $user_pass ) { |
|
669 | + if ($user_pass) { |
|
670 | 670 | // Check if password is valid. |
671 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
671 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
672 | 672 | // Incorrect password. |
673 | 673 | give_set_error( |
674 | 674 | 'password_incorrect', |
675 | 675 | sprintf( |
676 | 676 | '%1$s <a href="%2$s">%3$s</a>', |
677 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
678 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
679 | - esc_html__( 'Reset Password', 'give' ) |
|
677 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
678 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
679 | + esc_html__('Reset Password', 'give') |
|
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | // All is correct. |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | } |
694 | 694 | } else { |
695 | 695 | // Empty password. |
696 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
696 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
697 | 697 | } |
698 | 698 | } else { |
699 | 699 | // No username. |
700 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
700 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | return $valid_user_data; |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | */ |
713 | 713 | function give_purchase_form_validate_guest_user() { |
714 | 714 | |
715 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
715 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
716 | 716 | |
717 | 717 | // Start an array to collect valid user data. |
718 | 718 | $valid_user_data = array( |
@@ -721,38 +721,38 @@ discard block |
||
721 | 721 | ); |
722 | 722 | |
723 | 723 | // Show error message if user must be logged in. |
724 | - if ( give_logged_in_only( $form_id ) ) { |
|
725 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
724 | + if (give_logged_in_only($form_id)) { |
|
725 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | // Get the guest email. |
729 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
729 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
730 | 730 | |
731 | 731 | // Check email. |
732 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
732 | + if ($guest_email && strlen($guest_email) > 0) { |
|
733 | 733 | // Validate email. |
734 | - if ( ! is_email( $guest_email ) ) { |
|
734 | + if ( ! is_email($guest_email)) { |
|
735 | 735 | // Invalid email. |
736 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
736 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
737 | 737 | } else { |
738 | 738 | // All is good to go. |
739 | 739 | $valid_user_data['user_email'] = $guest_email; |
740 | 740 | |
741 | 741 | // Get user_id from donor if exist. |
742 | - $donor = new Give_Customer( $guest_email ); |
|
743 | - if ( $donor->id && $donor->user_id ) { |
|
742 | + $donor = new Give_Customer($guest_email); |
|
743 | + if ($donor->id && $donor->user_id) { |
|
744 | 744 | $valid_user_data['user_id'] = $donor->user_id; |
745 | 745 | } |
746 | 746 | } |
747 | 747 | } else { |
748 | 748 | // No email. |
749 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
749 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | // Loop through required fields and show error messages. |
753 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
754 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
755 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
753 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
754 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
755 | + give_set_error($value['error_id'], $value['error_message']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
@@ -768,36 +768,36 @@ discard block |
||
768 | 768 | * @since 1.0 |
769 | 769 | * @return integer |
770 | 770 | */ |
771 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
771 | +function give_register_and_login_new_user($user_data = array()) { |
|
772 | 772 | // Verify the array. |
773 | - if ( empty( $user_data ) ) { |
|
774 | - return - 1; |
|
773 | + if (empty($user_data)) { |
|
774 | + return -1; |
|
775 | 775 | } |
776 | 776 | |
777 | - if ( give_get_errors() ) { |
|
778 | - return - 1; |
|
777 | + if (give_get_errors()) { |
|
778 | + return -1; |
|
779 | 779 | } |
780 | 780 | |
781 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
782 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
783 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
784 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
785 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
786 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
787 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
788 | - 'role' => get_option( 'default_role' ), |
|
789 | - ), $user_data ); |
|
781 | + $user_args = apply_filters('give_insert_user_args', array( |
|
782 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
783 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
784 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
785 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
786 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
787 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
788 | + 'role' => get_option('default_role'), |
|
789 | + ), $user_data); |
|
790 | 790 | |
791 | 791 | // Insert new user. |
792 | - $user_id = wp_insert_user( $user_args ); |
|
792 | + $user_id = wp_insert_user($user_args); |
|
793 | 793 | |
794 | 794 | // Validate inserted user. |
795 | - if ( is_wp_error( $user_id ) ) { |
|
796 | - return - 1; |
|
795 | + if (is_wp_error($user_id)) { |
|
796 | + return -1; |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | // Allow themes and plugins to filter the user data. |
800 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
800 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
801 | 801 | |
802 | 802 | /** |
803 | 803 | * Fires after inserting user. |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | * @param int $user_id User id. |
808 | 808 | * @param array $user_data Array containing user data. |
809 | 809 | */ |
810 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
810 | + do_action('give_insert_user', $user_id, $user_data); |
|
811 | 811 | |
812 | 812 | // Login new user. |
813 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
813 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
814 | 814 | |
815 | 815 | // Return user id. |
816 | 816 | return $user_id; |
@@ -825,27 +825,27 @@ discard block |
||
825 | 825 | * @since 1.0 |
826 | 826 | * @return array |
827 | 827 | */ |
828 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
828 | +function give_get_purchase_form_user($valid_data = array()) { |
|
829 | 829 | |
830 | 830 | // Initialize user. |
831 | 831 | $user = false; |
832 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
832 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
833 | 833 | |
834 | - if ( $is_ajax ) { |
|
834 | + if ($is_ajax) { |
|
835 | 835 | // Do not create or login the user during the ajax submission (check for errors only). |
836 | 836 | return true; |
837 | - } elseif ( is_user_logged_in() ) { |
|
837 | + } elseif (is_user_logged_in()) { |
|
838 | 838 | // Set the valid user as the logged in collected data. |
839 | 839 | $user = $valid_data['logged_in_user']; |
840 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
840 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
841 | 841 | // New user registration. |
842 | - if ( $valid_data['need_new_user'] === true ) { |
|
842 | + if ($valid_data['need_new_user'] === true) { |
|
843 | 843 | // Set user. |
844 | 844 | $user = $valid_data['new_user_data']; |
845 | 845 | // Register and login new user. |
846 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
846 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
847 | 847 | // User login |
848 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
848 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
849 | 849 | |
850 | 850 | /* |
851 | 851 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -858,48 +858,48 @@ discard block |
||
858 | 858 | // Set user. |
859 | 859 | $user = $valid_data['login_user_data']; |
860 | 860 | // Login user. |
861 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
861 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Check guest checkout. |
866 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
866 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
867 | 867 | // Set user |
868 | 868 | $user = $valid_data['guest_user_data']; |
869 | 869 | } |
870 | 870 | |
871 | 871 | // Verify we have an user. |
872 | - if ( false === $user || empty( $user ) ) { |
|
872 | + if (false === $user || empty($user)) { |
|
873 | 873 | // Return false. |
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | |
877 | 877 | // Get user first name. |
878 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
879 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
878 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
879 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | // Get user last name. |
883 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
884 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
883 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
884 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | // Get the user's billing address details. |
888 | 888 | $user['address'] = array(); |
889 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
890 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
891 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
892 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
893 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
894 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
895 | - |
|
896 | - if ( empty( $user['address']['country'] ) ) { |
|
889 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
890 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
891 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
892 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
893 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
894 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
895 | + |
|
896 | + if (empty($user['address']['country'])) { |
|
897 | 897 | $user['address'] = false; |
898 | 898 | } // Country will always be set if address fields are present. |
899 | 899 | |
900 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
900 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
901 | 901 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
902 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
902 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // Return valid user. |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $card_data = give_get_purchase_cc_info(); |
919 | 919 | |
920 | 920 | // Validate the card zip. |
921 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
922 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
923 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
921 | + if ( ! empty($card_data['card_zip'])) { |
|
922 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
923 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | |
927 | 927 | // Ensure no spaces. |
928 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
929 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
930 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
928 | + if ( ! empty($card_data['card_number'])) { |
|
929 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
930 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | // This should validate card numbers at some point too. |
@@ -943,17 +943,17 @@ discard block |
||
943 | 943 | */ |
944 | 944 | function give_get_purchase_cc_info() { |
945 | 945 | $cc_info = array(); |
946 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
947 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
948 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
949 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
950 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
951 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
952 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
953 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
954 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
955 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
956 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
946 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
947 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
948 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
949 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
950 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
951 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
952 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
953 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
954 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
955 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
956 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
957 | 957 | |
958 | 958 | // Return cc info |
959 | 959 | return $cc_info; |
@@ -969,14 +969,14 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return bool|mixed|void |
971 | 971 | */ |
972 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
972 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
973 | 973 | $ret = false; |
974 | 974 | |
975 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
975 | + if (empty($zip) || empty($country_code)) { |
|
976 | 976 | return $ret; |
977 | 977 | } |
978 | 978 | |
979 | - $country_code = strtoupper( $country_code ); |
|
979 | + $country_code = strtoupper($country_code); |
|
980 | 980 | |
981 | 981 | $zip_regex = array( |
982 | 982 | 'AD' => 'AD\d{3}', |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | 'ZM' => '\d{5}', |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1139 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1140 | 1140 | $ret = true; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1143 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | |
@@ -1154,36 +1154,36 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return bool |
1156 | 1156 | */ |
1157 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1157 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1158 | 1158 | /* @var Give_Donate_Form $form */ |
1159 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1159 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1160 | 1160 | |
1161 | 1161 | $donation_level_matched = false; |
1162 | 1162 | |
1163 | - if ( $form->is_multi_type_donation_form() ) { |
|
1163 | + if ($form->is_multi_type_donation_form()) { |
|
1164 | 1164 | |
1165 | 1165 | // Bailout. |
1166 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1166 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1167 | 1167 | return false; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | // Sanitize donation amount. |
1171 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1171 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1172 | 1172 | |
1173 | 1173 | // Get number of decimals. |
1174 | 1174 | $default_decimals = give_get_price_decimals(); |
1175 | 1175 | |
1176 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1176 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | // Find correct donation level from all donation levels. |
1181 | - foreach ( $variable_prices as $variable_price ) { |
|
1181 | + foreach ($variable_prices as $variable_price) { |
|
1182 | 1182 | // Sanitize level amount. |
1183 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1183 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1184 | 1184 | |
1185 | 1185 | // Set first match donation level ID. |
1186 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1186 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1187 | 1187 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1188 | 1188 | $donation_level_matched = true; |
1189 | 1189 | break; |
@@ -1194,19 +1194,19 @@ discard block |
||
1194 | 1194 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1195 | 1195 | if ( |
1196 | 1196 | ! $donation_level_matched |
1197 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1197 | + && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true)) |
|
1198 | 1198 | ) { |
1199 | 1199 | // Sanitize custom minimum amount. |
1200 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1200 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1201 | 1201 | |
1202 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1202 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1203 | 1203 | $_POST['give-price-id'] = 'custom'; |
1204 | 1204 | $donation_level_matched = true; |
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - return ( $donation_level_matched ? true : false ); |
|
1209 | + return ($donation_level_matched ? true : false); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1212 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() { |
113 | 113 | |
114 | - $is_enabled = give_get_option( 'email_access' ); |
|
114 | + $is_enabled = give_get_option('email_access'); |
|
115 | 115 | |
116 | 116 | //Non-logged in users only |
117 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
117 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | //Are db columns setup? |
122 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
123 | - if ( empty( $is_setup ) ) { |
|
122 | + $is_setup = give_get_option('email_access_installed'); |
|
123 | + if (empty($is_setup)) { |
|
124 | 124 | $this->create_columns(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Timeouts |
128 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
129 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
128 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
129 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
130 | 130 | |
131 | 131 | // Setup login |
132 | 132 | $this->check_for_token(); |
133 | 133 | |
134 | - if ( $this->token_exists ) { |
|
135 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
136 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
137 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
134 | + if ($this->token_exists) { |
|
135 | + add_filter('give_can_view_receipt', '__return_true'); |
|
136 | + add_filter('give_user_pending_verification', '__return_false'); |
|
137 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function can_send_email( $customer_id ) { |
|
151 | + public function can_send_email($customer_id) { |
|
152 | 152 | /* @var WPDB $wpdb */ |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | // Prevent multiple emails within X minutes |
156 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
156 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
157 | 157 | |
158 | 158 | // Does a user row exist? |
159 | 159 | $exists = (int) $wpdb->get_var( |
160 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
160 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
161 | 161 | ); |
162 | 162 | |
163 | - if ( 0 < $exists ) { |
|
163 | + if (0 < $exists) { |
|
164 | 164 | $row_id = (int) $wpdb->get_var( |
165 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
165 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
166 | 166 | ); |
167 | 167 | |
168 | - if ( $row_id < 1 ) { |
|
169 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
168 | + if ($row_id < 1) { |
|
169 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function send_email( $customer_id, $email ) { |
|
189 | + public function send_email($customer_id, $email) { |
|
190 | 190 | |
191 | - $verify_key = wp_generate_password( 20, false ); |
|
191 | + $verify_key = wp_generate_password(20, false); |
|
192 | 192 | |
193 | 193 | // Generate a new verify key |
194 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
194 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
195 | 195 | |
196 | 196 | // Get the donation history page |
197 | - $page_id = give_get_option( 'history_page' ); |
|
197 | + $page_id = give_get_option('history_page'); |
|
198 | 198 | |
199 | - $access_url = add_query_arg( array( |
|
199 | + $access_url = add_query_arg(array( |
|
200 | 200 | 'give_nl' => $verify_key, |
201 | - ), get_permalink( $page_id ) ); |
|
201 | + ), get_permalink($page_id)); |
|
202 | 202 | |
203 | 203 | //Nice subject and message |
204 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
204 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
205 | 205 | |
206 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
207 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
206 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
207 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
208 | 208 | $message .= "\n\n"; |
209 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
210 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
209 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
210 | + $message .= get_bloginfo('name')."\n"; |
|
211 | 211 | |
212 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
212 | + $message = apply_filters('give_email_access_token_message', $message); |
|
213 | 213 | |
214 | 214 | // Send the email |
215 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
216 | - Give()->emails->send( $email, $subject, $message ); |
|
215 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
216 | + Give()->emails->send($email, $subject, $message); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function check_for_token() { |
229 | 229 | |
230 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
230 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
231 | 231 | |
232 | 232 | // Check for cookie |
233 | - if ( empty( $token ) ) { |
|
234 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
233 | + if (empty($token)) { |
|
234 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( ! empty( $token ) ) { |
|
238 | - if ( ! $this->is_valid_token( $token ) ) { |
|
239 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
237 | + if ( ! empty($token)) { |
|
238 | + if ( ! $this->is_valid_token($token)) { |
|
239 | + if ( ! $this->is_valid_verify_key($token)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->token_exists = true; |
245 | 245 | // Set cookie |
246 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
247 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
246 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
247 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public function is_valid_token( $token ) { |
|
261 | + public function is_valid_token($token) { |
|
262 | 262 | |
263 | 263 | global $wpdb; |
264 | 264 | |
265 | 265 | // Make sure token isn't expired |
266 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
266 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
267 | 267 | |
268 | 268 | $email = $wpdb->get_var( |
269 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
269 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
270 | 270 | ); |
271 | 271 | |
272 | - if ( ! empty( $email ) ) { |
|
272 | + if ( ! empty($email)) { |
|
273 | 273 | $this->token_email = $email; |
274 | 274 | $this->token = $token; |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | //Set error only if email access form isn't being submitted |
280 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
281 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
280 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
281 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give'))); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return false; |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
300 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
301 | 301 | global $wpdb; |
302 | 302 | |
303 | - $now = date( 'Y-m-d H:i:s' ); |
|
303 | + $now = date('Y-m-d H:i:s'); |
|
304 | 304 | |
305 | 305 | // Insert or update? |
306 | 306 | $row_id = (int) $wpdb->get_var( |
307 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
307 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Update |
311 | - if ( ! empty( $row_id ) ) { |
|
311 | + if ( ! empty($row_id)) { |
|
312 | 312 | $wpdb->query( |
313 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
313 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
314 | 314 | ); |
315 | 315 | } // Insert |
316 | 316 | else { |
317 | 317 | $wpdb->query( |
318 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
318 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function is_valid_verify_key( $token ) { |
|
333 | + public function is_valid_verify_key($token) { |
|
334 | 334 | /* @var WPDB $wpdb */ |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | 337 | // See if the verify_key exists |
338 | 338 | $row = $wpdb->get_row( |
339 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
339 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
340 | 340 | ); |
341 | 341 | |
342 | - $now = date( 'Y-m-d H:i:s' ); |
|
342 | + $now = date('Y-m-d H:i:s'); |
|
343 | 343 | |
344 | 344 | // Set token |
345 | - if ( ! empty( $row ) ) { |
|
345 | + if ( ! empty($row)) { |
|
346 | 346 | $wpdb->query( |
347 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
347 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->token_email = $row->email; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return mixed |
370 | 370 | */ |
371 | - public function users_donations_args( $args ) { |
|
371 | + public function users_donations_args($args) { |
|
372 | 372 | $args['user'] = $this->token_email; |
373 | 373 | |
374 | 374 | return $args; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | global $wpdb; |
390 | 390 | |
391 | 391 | //Create columns in customers table |
392 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
392 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
393 | 393 | |
394 | 394 | //Columns added properly |
395 | - if ( $query ) { |
|
396 | - give_update_option( 'email_access_installed', 1 ); |
|
395 | + if ($query) { |
|
396 | + give_update_option('email_access_installed', 1); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
109 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
109 | + return apply_filters('give_default_form_amount', $default_amount); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
127 | +function give_is_custom_price_mode($form_id = 0) { |
|
128 | 128 | |
129 | - if ( empty( $form_id ) ) { |
|
129 | + if (empty($form_id)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - $form = new Give_Donate_Form( $form_id ); |
|
133 | + $form = new Give_Donate_Form($form_id); |
|
134 | 134 | |
135 | 135 | return $form->is_custom_price_mode(); |
136 | 136 | } |
137 | 137 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => false, |
92 | 92 | 'upload_files' => true, |
93 | 93 | 'delete_posts' => false |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -110,38 +110,38 @@ discard block |
||
110 | 110 | public function add_caps() { |
111 | 111 | global $wp_roles; |
112 | 112 | |
113 | - if ( class_exists( 'WP_Roles' ) ) { |
|
114 | - if ( ! isset( $wp_roles ) ) { |
|
113 | + if (class_exists('WP_Roles')) { |
|
114 | + if ( ! isset($wp_roles)) { |
|
115 | 115 | $wp_roles = new WP_Roles(); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ( is_object( $wp_roles ) ) { |
|
120 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
121 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
122 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
123 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
119 | + if (is_object($wp_roles)) { |
|
120 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
121 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
122 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
123 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
124 | 124 | |
125 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
126 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
127 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
125 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
126 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
127 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
128 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
129 | 129 | |
130 | 130 | // Add the main post type capabilities. |
131 | 131 | $capabilities = $this->get_core_caps(); |
132 | - foreach ( $capabilities as $cap_group ) { |
|
133 | - foreach ( $cap_group as $cap ) { |
|
134 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
135 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
136 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
132 | + foreach ($capabilities as $cap_group) { |
|
133 | + foreach ($cap_group as $cap) { |
|
134 | + $wp_roles->add_cap('administrator', $cap); |
|
135 | + $wp_roles->add_cap('give_manager', $cap); |
|
136 | + $wp_roles->add_cap('give_worker', $cap); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
141 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
142 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
143 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
144 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
140 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
141 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
142 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
143 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
144 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | public function get_core_caps() { |
160 | 160 | $capabilities = array(); |
161 | 161 | |
162 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
162 | + $capability_types = array('give_form', 'give_payment'); |
|
163 | 163 | |
164 | - foreach ( $capability_types as $capability_type ) { |
|
165 | - $capabilities[ $capability_type ] = array( |
|
164 | + foreach ($capability_types as $capability_type) { |
|
165 | + $capabilities[$capability_type] = array( |
|
166 | 166 | // Post type. |
167 | 167 | "edit_{$capability_type}", |
168 | 168 | "read_{$capability_type}", |
@@ -208,22 +208,22 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return array $caps Meta capabilities. |
210 | 210 | */ |
211 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
211 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
212 | 212 | |
213 | - switch ( $cap ) { |
|
213 | + switch ($cap) { |
|
214 | 214 | |
215 | 215 | case 'view_give_form_stats' : |
216 | 216 | |
217 | - if ( empty( $args[0] ) ) { |
|
217 | + if (empty($args[0])) { |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | |
221 | - $form = get_post( $args[0] ); |
|
222 | - if ( empty( $form ) ) { |
|
221 | + $form = get_post($args[0]); |
|
222 | + if (empty($form)) { |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
226 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
226 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
227 | 227 | $caps = array(); |
228 | 228 | } |
229 | 229 | |
@@ -250,41 +250,41 @@ discard block |
||
250 | 250 | |
251 | 251 | global $wp_roles; |
252 | 252 | |
253 | - if ( class_exists( 'WP_Roles' ) ) { |
|
254 | - if ( ! isset( $wp_roles ) ) { |
|
253 | + if (class_exists('WP_Roles')) { |
|
254 | + if ( ! isset($wp_roles)) { |
|
255 | 255 | $wp_roles = new WP_Roles(); |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( is_object( $wp_roles ) ) { |
|
259 | + if (is_object($wp_roles)) { |
|
260 | 260 | // Give Manager Capabilities. |
261 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
262 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
263 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
264 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
261 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
262 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
263 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
264 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
265 | 265 | |
266 | 266 | // Site Administrator Capabilities. |
267 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
268 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
269 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
270 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
267 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
268 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
269 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
270 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
271 | 271 | |
272 | 272 | // Remove the Main Post Type Capabilities. |
273 | 273 | $capabilities = $this->get_core_caps(); |
274 | 274 | |
275 | - foreach ( $capabilities as $cap_group ) { |
|
276 | - foreach ( $cap_group as $cap ) { |
|
277 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
278 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
279 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
275 | + foreach ($capabilities as $cap_group) { |
|
276 | + foreach ($cap_group as $cap) { |
|
277 | + $wp_roles->remove_cap('give_manager', $cap); |
|
278 | + $wp_roles->remove_cap('administrator', $cap); |
|
279 | + $wp_roles->remove_cap('give_worker', $cap); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | 283 | /** Give Accountant Capabilities */ |
284 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
285 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
286 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
287 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
284 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
285 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
286 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
287 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -26,30 +26,30 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_do_automatic_upgrades() { |
28 | 28 | $did_upgrade = false; |
29 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
29 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
30 | 30 | |
31 | - if ( ! $give_version ) { |
|
31 | + if ( ! $give_version) { |
|
32 | 32 | // 1.0 is the first version to use this option so we must add it. |
33 | 33 | $give_version = '1.0'; |
34 | 34 | } |
35 | 35 | |
36 | - switch ( true ) { |
|
36 | + switch (true) { |
|
37 | 37 | |
38 | - case version_compare( $give_version, '1.6', '<' ) : |
|
38 | + case version_compare($give_version, '1.6', '<') : |
|
39 | 39 | give_v16_upgrades(); |
40 | 40 | $did_upgrade = true; |
41 | 41 | |
42 | - case version_compare( $give_version, '1.7', '<' ) : |
|
42 | + case version_compare($give_version, '1.7', '<') : |
|
43 | 43 | give_v17_upgrades(); |
44 | 44 | $did_upgrade = true; |
45 | 45 | } |
46 | 46 | |
47 | - if ( $did_upgrade ) { |
|
48 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
47 | + if ($did_upgrade) { |
|
48 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
52 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Display Upgrade Notices |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function give_show_upgrade_notices() { |
61 | 61 | |
62 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
62 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
63 | 63 | return; |
64 | 64 | } // Don't show notices on the upgrades page |
65 | 65 | |
66 | - $give_version = get_option( 'give_version' ); |
|
66 | + $give_version = get_option('give_version'); |
|
67 | 67 | |
68 | - if ( ! $give_version ) { |
|
68 | + if ( ! $give_version) { |
|
69 | 69 | // 1.0 is the first version to use this option so we must add it |
70 | 70 | $give_version = '1.0'; |
71 | 71 | } |
72 | 72 | |
73 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
73 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
74 | 74 | |
75 | 75 | /* |
76 | 76 | * NOTICE: |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | */ |
82 | 82 | |
83 | 83 | //v1.3.2 Upgrades |
84 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
84 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
85 | 85 | printf( |
86 | 86 | /* translators: %s: upgrade URL */ |
87 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
88 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
87 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
88 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
89 | 89 | ); |
90 | 90 | } |
91 | 91 | |
92 | 92 | //v1.3.4 Upgrades //ensure the user has gone through 1.3.4 |
93 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
93 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
94 | 94 | printf( |
95 | 95 | /* translators: %s: upgrade URL */ |
96 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
97 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
96 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
97 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | } |
106 | 106 | |
107 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
107 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Triggers all upgrade functions |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function give_trigger_upgrades() { |
118 | 118 | |
119 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
120 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
119 | + if ( ! current_user_can('manage_give_settings')) { |
|
120 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
121 | 121 | } |
122 | 122 | |
123 | - $give_version = get_option( 'give_version' ); |
|
123 | + $give_version = get_option('give_version'); |
|
124 | 124 | |
125 | - if ( ! $give_version ) { |
|
125 | + if ( ! $give_version) { |
|
126 | 126 | // 1.0 is the first version to use this option so we must add it |
127 | 127 | $give_version = '1.0'; |
128 | - add_option( 'give_version', $give_version ); |
|
128 | + add_option('give_version', $give_version); |
|
129 | 129 | } |
130 | 130 | |
131 | - update_option( 'give_version', GIVE_VERSION ); |
|
131 | + update_option('give_version', GIVE_VERSION); |
|
132 | 132 | |
133 | - if ( DOING_AJAX ) { |
|
134 | - die( 'complete' ); |
|
133 | + if (DOING_AJAX) { |
|
134 | + die('complete'); |
|
135 | 135 | } // Let AJAX know that the upgrade is complete |
136 | 136 | } |
137 | 137 | |
138 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
138 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Check if the upgrade routine has been run for a specific action |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool If the action has been added to the completed actions array |
148 | 148 | */ |
149 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
149 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
150 | 150 | |
151 | - if ( empty( $upgrade_action ) ) { |
|
151 | + if (empty($upgrade_action)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $completed_upgrades = give_get_completed_upgrades(); |
156 | 156 | |
157 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
157 | + return in_array($upgrade_action, $completed_upgrades); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return bool If the function was successfully added |
169 | 169 | */ |
170 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
170 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
171 | 171 | |
172 | - if ( empty( $upgrade_action ) ) { |
|
172 | + if (empty($upgrade_action)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $completed_upgrades[] = $upgrade_action; |
178 | 178 | |
179 | 179 | // Remove any blanks, and only show uniques |
180 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
180 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
181 | 181 | |
182 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
182 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | function give_get_completed_upgrades() { |
192 | 192 | |
193 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
193 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
194 | 194 | |
195 | - if ( false === $completed_upgrades ) { |
|
195 | + if (false === $completed_upgrades) { |
|
196 | 196 | $completed_upgrades = array(); |
197 | 197 | } |
198 | 198 | |
@@ -210,30 +210,30 @@ discard block |
||
210 | 210 | */ |
211 | 211 | function give_v132_upgrade_give_payment_customer_id() { |
212 | 212 | global $wpdb; |
213 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
214 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
213 | + if ( ! current_user_can('manage_give_settings')) { |
|
214 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
215 | 215 | } |
216 | 216 | |
217 | - ignore_user_abort( true ); |
|
217 | + ignore_user_abort(true); |
|
218 | 218 | |
219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
220 | - @set_time_limit( 0 ); |
|
219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
220 | + @set_time_limit(0); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | //UPDATE DB METAKEYS |
224 | 224 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
225 | - $query = $wpdb->query( $sql ); |
|
225 | + $query = $wpdb->query($sql); |
|
226 | 226 | |
227 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
228 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
229 | - delete_option( 'give_doing_upgrade' ); |
|
230 | - wp_redirect( admin_url() ); |
|
227 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
228 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
229 | + delete_option('give_doing_upgrade'); |
|
230 | + wp_redirect(admin_url()); |
|
231 | 231 | exit; |
232 | 232 | |
233 | 233 | |
234 | 234 | } |
235 | 235 | |
236 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
236 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Upgrades the Offline Status |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | |
248 | 248 | global $wpdb; |
249 | 249 | |
250 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
251 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
250 | + if ( ! current_user_can('manage_give_settings')) { |
|
251 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
252 | 252 | } |
253 | 253 | |
254 | - ignore_user_abort( true ); |
|
254 | + ignore_user_abort(true); |
|
255 | 255 | |
256 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
257 | - @set_time_limit( 0 ); |
|
256 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
257 | + @set_time_limit(0); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Get abandoned offline payments |
@@ -264,35 +264,35 @@ discard block |
||
264 | 264 | $where .= "AND ( p.post_status = 'abandoned' )"; |
265 | 265 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
266 | 266 | |
267 | - $sql = $select . $join . $where; |
|
268 | - $found_payments = $wpdb->get_col( $sql ); |
|
267 | + $sql = $select.$join.$where; |
|
268 | + $found_payments = $wpdb->get_col($sql); |
|
269 | 269 | |
270 | 270 | |
271 | - foreach ( $found_payments as $payment ) { |
|
271 | + foreach ($found_payments as $payment) { |
|
272 | 272 | |
273 | 273 | //Only change ones marked abandoned since our release last week |
274 | 274 | //because the admin may have marked some abandoned themselves |
275 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
275 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
276 | 276 | |
277 | 277 | //1450124863 = 12/10/2015 20:42:25 |
278 | - if ( $modified_time >= 1450124863 ) { |
|
278 | + if ($modified_time >= 1450124863) { |
|
279 | 279 | |
280 | - give_update_payment_status( $payment, 'pending' ); |
|
280 | + give_update_payment_status($payment, 'pending'); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | 284 | } |
285 | 285 | |
286 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
287 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
288 | - delete_option( 'give_doing_upgrade' ); |
|
289 | - wp_redirect( admin_url() ); |
|
286 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
287 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
288 | + delete_option('give_doing_upgrade'); |
|
289 | + wp_redirect(admin_url()); |
|
290 | 290 | exit; |
291 | 291 | |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
295 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
296 | 296 | |
297 | 297 | /** |
298 | 298 | * Cleanup User Roles |
@@ -303,17 +303,17 @@ discard block |
||
303 | 303 | */ |
304 | 304 | function give_v152_cleanup_users() { |
305 | 305 | |
306 | - $give_version = get_option( 'give_version' ); |
|
306 | + $give_version = get_option('give_version'); |
|
307 | 307 | |
308 | - if ( ! $give_version ) { |
|
308 | + if ( ! $give_version) { |
|
309 | 309 | // 1.0 is the first version to use this option so we must add it |
310 | 310 | $give_version = '1.0'; |
311 | 311 | } |
312 | 312 | |
313 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
313 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
314 | 314 | |
315 | 315 | //v1.5.2 Upgrades |
316 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
316 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
317 | 317 | |
318 | 318 | //Delete all caps with "ss" |
319 | 319 | //Also delete all unused "campaign" roles |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | ); |
361 | 361 | |
362 | 362 | global $wp_roles; |
363 | - foreach ( $delete_caps as $cap ) { |
|
364 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
365 | - $wp_roles->remove_cap( $role, $cap ); |
|
363 | + foreach ($delete_caps as $cap) { |
|
364 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
365 | + $wp_roles->remove_cap($role, $cap); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | $roles->add_caps(); |
373 | 373 | |
374 | 374 | //The Update Ran |
375 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
376 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
377 | - delete_option( 'give_doing_upgrade' ); |
|
375 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
376 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
377 | + delete_option('give_doing_upgrade'); |
|
378 | 378 | |
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
383 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -418,53 +418,53 @@ discard block |
||
418 | 418 | |
419 | 419 | // Get addons license key. |
420 | 420 | $addons = array(); |
421 | - foreach ( $give_options as $key => $value ) { |
|
422 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
423 | - $addons[ $key ] = $value; |
|
421 | + foreach ($give_options as $key => $value) { |
|
422 | + if (false !== strpos($key, '_license_key')) { |
|
423 | + $addons[$key] = $value; |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Bailout: We do not have any addon license data to upgrade. |
428 | - if ( empty( $addons ) ) { |
|
428 | + if (empty($addons)) { |
|
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - foreach ( $addons as $key => $addon_license ) { |
|
432 | + foreach ($addons as $key => $addon_license) { |
|
433 | 433 | |
434 | 434 | // Get addon shortname. |
435 | - $shortname = str_replace( '_license_key', '', $key ); |
|
435 | + $shortname = str_replace('_license_key', '', $key); |
|
436 | 436 | |
437 | 437 | // Addon license option name. |
438 | - $addon_license_option_name = $shortname . '_license_active'; |
|
438 | + $addon_license_option_name = $shortname.'_license_active'; |
|
439 | 439 | |
440 | 440 | // bailout if license is empty. |
441 | - if ( empty( $addon_license ) ) { |
|
442 | - delete_option( $addon_license_option_name ); |
|
441 | + if (empty($addon_license)) { |
|
442 | + delete_option($addon_license_option_name); |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Get addon name. |
447 | 447 | $addon_name = array(); |
448 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
449 | - foreach ( $addon_name_parts as $name_part ) { |
|
448 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
449 | + foreach ($addon_name_parts as $name_part) { |
|
450 | 450 | |
451 | 451 | // Fix addon name |
452 | - switch ( $name_part ) { |
|
452 | + switch ($name_part) { |
|
453 | 453 | case 'authorizenet' : |
454 | 454 | $name_part = 'authorize.net'; |
455 | 455 | break; |
456 | 456 | } |
457 | 457 | |
458 | - $addon_name[] = ucfirst( $name_part ); |
|
458 | + $addon_name[] = ucfirst($name_part); |
|
459 | 459 | } |
460 | 460 | |
461 | - $addon_name = implode( ' ', $addon_name ); |
|
461 | + $addon_name = implode(' ', $addon_name); |
|
462 | 462 | |
463 | 463 | // Data to send to the API |
464 | 464 | $api_params = array( |
465 | 465 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
466 | 466 | 'license' => $addon_license, |
467 | - 'item_name' => urlencode( $addon_name ), |
|
467 | + 'item_name' => urlencode($addon_name), |
|
468 | 468 | 'url' => home_url() |
469 | 469 | ); |
470 | 470 | |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | ); |
480 | 480 | |
481 | 481 | // Make sure there are no errors |
482 | - if ( is_wp_error( $response ) ) { |
|
483 | - delete_option( $addon_license_option_name ); |
|
482 | + if (is_wp_error($response)) { |
|
483 | + delete_option($addon_license_option_name); |
|
484 | 484 | continue; |
485 | 485 | } |
486 | 486 | |
487 | 487 | // Tell WordPress to look for updates |
488 | - set_site_transient( 'update_plugins', null ); |
|
488 | + set_site_transient('update_plugins', null); |
|
489 | 489 | |
490 | 490 | // Decode license data |
491 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
492 | - update_option( $addon_license_option_name, $license_data ); |
|
491 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
492 | + update_option($addon_license_option_name, $license_data); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
@@ -519,9 +519,9 @@ discard block |
||
519 | 519 | ); |
520 | 520 | |
521 | 521 | global $wp_roles; |
522 | - foreach ( $delete_caps as $cap ) { |
|
523 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
524 | - $wp_roles->remove_cap( $role, $cap ); |
|
522 | + foreach ($delete_caps as $cap) { |
|
523 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
524 | + $wp_roles->remove_cap($role, $cap); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } else if ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } else if (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
55 | + $args = apply_filters('give_get_users_donations_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date' |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | 139 | $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1 |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1 |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool True if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int The total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | //Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | //Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | 262 | |
263 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
263 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
264 | 264 | |
265 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
265 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return float The total amount the user has spent |
277 | 277 | */ |
278 | -function give_purchase_total_of_user( $user = null ) { |
|
278 | +function give_purchase_total_of_user($user = null) { |
|
279 | 279 | |
280 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
280 | + $stats = give_get_purchase_stats_by_user($user); |
|
281 | 281 | |
282 | 282 | return $stats['total_spent']; |
283 | 283 | } |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return bool |
295 | 295 | */ |
296 | -function give_validate_username( $username ) { |
|
297 | - $sanitized = sanitize_user( $username, false ); |
|
298 | - $valid = ( $sanitized == $username ); |
|
296 | +function give_validate_username($username) { |
|
297 | + $sanitized = sanitize_user($username, false); |
|
298 | + $valid = ($sanitized == $username); |
|
299 | 299 | |
300 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
300 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return void |
316 | 316 | */ |
317 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
317 | +function give_add_past_purchases_to_new_user($user_id) { |
|
318 | 318 | |
319 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
319 | + $email = get_the_author_meta('user_email', $user_id); |
|
320 | 320 | |
321 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
321 | + $payments = give_get_payments(array('s' => $email)); |
|
322 | 322 | |
323 | - if ( $payments ) { |
|
324 | - foreach ( $payments as $payment ) { |
|
325 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
323 | + if ($payments) { |
|
324 | + foreach ($payments as $payment) { |
|
325 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
326 | 326 | continue; |
327 | 327 | } // This payment already associated with an account |
328 | 328 | |
329 | - $meta = give_get_payment_meta( $payment->ID ); |
|
330 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
329 | + $meta = give_get_payment_meta($payment->ID); |
|
330 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
331 | 331 | $meta['user_info']['id'] = $user_id; |
332 | 332 | $meta['user_info'] = $meta['user_info']; |
333 | 333 | |
334 | 334 | // Store the updated user ID in the payment meta |
335 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
336 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
335 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
336 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
342 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | /** |
@@ -365,34 +365,34 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return array The donor's address, if any |
367 | 367 | */ |
368 | -function give_get_donor_address( $user_id = 0 ) { |
|
369 | - if ( empty( $user_id ) ) { |
|
368 | +function give_get_donor_address($user_id = 0) { |
|
369 | + if (empty($user_id)) { |
|
370 | 370 | $user_id = get_current_user_id(); |
371 | 371 | } |
372 | 372 | |
373 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
373 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
374 | 374 | |
375 | - if ( ! isset( $address['line1'] ) ) { |
|
375 | + if ( ! isset($address['line1'])) { |
|
376 | 376 | $address['line1'] = ''; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! isset( $address['line2'] ) ) { |
|
379 | + if ( ! isset($address['line2'])) { |
|
380 | 380 | $address['line2'] = ''; |
381 | 381 | } |
382 | 382 | |
383 | - if ( ! isset( $address['city'] ) ) { |
|
383 | + if ( ! isset($address['city'])) { |
|
384 | 384 | $address['city'] = ''; |
385 | 385 | } |
386 | 386 | |
387 | - if ( ! isset( $address['zip'] ) ) { |
|
387 | + if ( ! isset($address['zip'])) { |
|
388 | 388 | $address['zip'] = ''; |
389 | 389 | } |
390 | 390 | |
391 | - if ( ! isset( $address['country'] ) ) { |
|
391 | + if ( ! isset($address['country'])) { |
|
392 | 392 | $address['country'] = ''; |
393 | 393 | } |
394 | 394 | |
395 | - if ( ! isset( $address['state'] ) ) { |
|
395 | + if ( ! isset($address['state'])) { |
|
396 | 396 | $address['state'] = ''; |
397 | 397 | } |
398 | 398 | |
@@ -412,42 +412,42 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return void |
414 | 414 | */ |
415 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
415 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
416 | 416 | |
417 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
417 | + if (empty($user_id) || empty($user_data)) { |
|
418 | 418 | return; |
419 | 419 | } |
420 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
420 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
421 | 421 | |
422 | 422 | /* translators: %s: site name */ |
423 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
423 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
424 | 424 | /* translators: %s: user login */ |
425 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
425 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
426 | 426 | /* translators: %s: user email */ |
427 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
427 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
428 | 428 | |
429 | 429 | @wp_mail( |
430 | - get_option( 'admin_email' ), |
|
430 | + get_option('admin_email'), |
|
431 | 431 | sprintf( |
432 | 432 | /* translators: %s: site name */ |
433 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
433 | + esc_attr__('[%s] New User Registration', 'give'), |
|
434 | 434 | $blogname |
435 | 435 | ), |
436 | 436 | $message |
437 | 437 | ); |
438 | 438 | |
439 | 439 | /* translators: %s: user login */ |
440 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
440 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
441 | 441 | /* translators: %s: paswword */ |
442 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
442 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
443 | 443 | |
444 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
444 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
445 | 445 | |
446 | 446 | wp_mail( |
447 | 447 | $user_data['user_email'], |
448 | 448 | sprintf( |
449 | 449 | /* translators: %s: site name */ |
450 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
450 | + esc_attr__('[%s] Your username and password', 'give'), |
|
451 | 451 | $blogname |
452 | 452 | ), |
453 | 453 | $message |
@@ -455,4 +455,4 @@ discard block |
||
455 | 455 | |
456 | 456 | } |
457 | 457 | |
458 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
458 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -464,7 +464,7 @@ |
||
464 | 464 | * |
465 | 465 | * @param WP_Post $payment |
466 | 466 | * |
467 | - * @return mixed |
|
467 | + * @return false|null |
|
468 | 468 | */ |
469 | 469 | function give_offline_payment_receipt_after( $payment ) { |
470 | 470 | // Get payment object. |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,34 +66,34 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
90 | - give_default_cc_address_fields( $form_id ); |
|
91 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
92 | - give_default_cc_address_fields( $form_id ); |
|
89 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
90 | + give_default_cc_address_fields($form_id); |
|
91 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
92 | + give_default_cc_address_fields($form_id); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
96 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Process the payment |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | -function give_offline_process_payment( $purchase_data ) { |
|
107 | +function give_offline_process_payment($purchase_data) { |
|
108 | 108 | |
109 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
109 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
110 | 110 | |
111 | 111 | // setup the payment details |
112 | 112 | $payment_data = array( |
113 | 113 | 'price' => $purchase_data['price'], |
114 | 114 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
115 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
116 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
115 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
116 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
117 | 117 | 'date' => $purchase_data['date'], |
118 | 118 | 'user_email' => $purchase_data['user_email'], |
119 | 119 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | |
126 | 126 | |
127 | 127 | // record the pending payment |
128 | - $payment = give_insert_payment( $payment_data ); |
|
128 | + $payment = give_insert_payment($payment_data); |
|
129 | 129 | |
130 | - if ( $payment ) { |
|
131 | - give_offline_send_admin_notice( $payment ); |
|
132 | - give_offline_send_donor_instructions( $payment ); |
|
130 | + if ($payment) { |
|
131 | + give_offline_send_admin_notice($payment); |
|
132 | + give_offline_send_donor_instructions($payment); |
|
133 | 133 | give_send_to_success_page(); |
134 | 134 | } else { |
135 | 135 | // if errors are present, send the user back to the donation form so they can be corrected |
136 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
136 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
141 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -151,59 +151,59 @@ discard block |
||
151 | 151 | * @since 1.0 |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
154 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
155 | 155 | |
156 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
157 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
156 | + $payment_data = give_get_payment_meta($payment_id); |
|
157 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
158 | 158 | |
159 | 159 | //Customize email content depending on whether the single form has been customized |
160 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
160 | + $email_content = give_get_option('global_offline_donation_email'); |
|
161 | 161 | |
162 | - if ( $post_offline_customization_option === 'yes' ) { |
|
163 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
162 | + if ($post_offline_customization_option === 'yes') { |
|
163 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
164 | 164 | } |
165 | 165 | |
166 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
166 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Filters the from name. |
170 | 170 | * |
171 | 171 | * @since 1.7 |
172 | 172 | */ |
173 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
173 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
174 | 174 | |
175 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
175 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Filters the from email. |
179 | 179 | * |
180 | 180 | * @since 1.7 |
181 | 181 | */ |
182 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
182 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
183 | 183 | |
184 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
184 | + $to_email = give_get_payment_user_email($payment_id); |
|
185 | 185 | |
186 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
187 | - if ( $post_offline_customization_option === 'yes' ) { |
|
188 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
186 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
187 | + if ($post_offline_customization_option === 'yes') { |
|
188 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
189 | 189 | } |
190 | 190 | |
191 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
192 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
191 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
192 | + $subject = give_do_email_tags($subject, $payment_id); |
|
193 | 193 | |
194 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
195 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
194 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
195 | + $message = give_do_email_tags($email_content, $payment_id); |
|
196 | 196 | |
197 | 197 | $emails = Give()->emails; |
198 | 198 | |
199 | - $emails->__set( 'from_name', $from_name ); |
|
200 | - $emails->__set( 'from_email', $from_email ); |
|
201 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
199 | + $emails->__set('from_name', $from_name); |
|
200 | + $emails->__set('from_email', $from_email); |
|
201 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
202 | 202 | |
203 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
204 | - $emails->__set( 'headers', $headers ); |
|
203 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
204 | + $emails->__set('headers', $headers); |
|
205 | 205 | |
206 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
206 | + $emails->send($to_email, $subject, $message, $attachments); |
|
207 | 207 | |
208 | 208 | } |
209 | 209 | |
@@ -220,52 +220,52 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | * |
222 | 222 | */ |
223 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
223 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
224 | 224 | |
225 | 225 | /* Send an email notification to the admin */ |
226 | 226 | $admin_email = give_get_admin_notice_emails(); |
227 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
227 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
228 | 228 | |
229 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
230 | - $user_data = get_userdata( $user_info['id'] ); |
|
229 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
230 | + $user_data = get_userdata($user_info['id']); |
|
231 | 231 | $name = $user_data->display_name; |
232 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
233 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
232 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
233 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
234 | 234 | } else { |
235 | 235 | $name = $user_info['email']; |
236 | 236 | } |
237 | 237 | |
238 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
238 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
239 | 239 | |
240 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
240 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
241 | 241 | |
242 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
243 | - $admin_message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
244 | - $admin_message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
242 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
243 | + $admin_message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
244 | + $admin_message .= __('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
245 | 245 | |
246 | 246 | |
247 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
248 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
247 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
248 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
249 | 249 | |
250 | 250 | $admin_message .= sprintf( |
251 | 251 | '<a href="%1$s">%2$s</a>', |
252 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
253 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
254 | - ) . "\n\n"; |
|
252 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
253 | + __('Click Here to View and/or Update Donation Details', 'give') |
|
254 | + )."\n\n"; |
|
255 | 255 | |
256 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
257 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
256 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
257 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
258 | 258 | |
259 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
260 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
259 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
260 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
261 | 261 | |
262 | 262 | //Send Email |
263 | 263 | $emails = Give()->emails; |
264 | - if ( ! empty( $admin_headers ) ) { |
|
265 | - $emails->__set( 'headers', $admin_headers ); |
|
264 | + if ( ! empty($admin_headers)) { |
|
265 | + $emails->__set('headers', $admin_headers); |
|
266 | 266 | } |
267 | 267 | |
268 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
268 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return array |
279 | 279 | */ |
280 | -function give_offline_add_settings( $settings ) { |
|
280 | +function give_offline_add_settings($settings) { |
|
281 | 281 | |
282 | 282 | //Vars |
283 | 283 | $prefix = '_give_'; |
284 | 284 | |
285 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
285 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
286 | 286 | |
287 | 287 | //this gateway isn't active |
288 | - if ( ! $is_gateway_active ) { |
|
288 | + if ( ! $is_gateway_active) { |
|
289 | 289 | //return settings and bounce |
290 | 290 | return $settings; |
291 | 291 | } |
@@ -294,27 +294,27 @@ discard block |
||
294 | 294 | $check_settings = array( |
295 | 295 | |
296 | 296 | array( |
297 | - 'name' => __( 'Customize Offline Donations', 'give' ), |
|
298 | - 'desc' => __( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
299 | - 'id' => $prefix . 'customize_offline_donations', |
|
297 | + 'name' => __('Customize Offline Donations', 'give'), |
|
298 | + 'desc' => __('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
299 | + 'id' => $prefix.'customize_offline_donations', |
|
300 | 300 | 'type' => 'radio_inline', |
301 | 301 | 'default' => 'no', |
302 | 302 | 'options' => array( |
303 | - 'yes' => __( 'Yes', 'give' ), |
|
304 | - 'no' => __( 'No', 'give' ), |
|
303 | + 'yes' => __('Yes', 'give'), |
|
304 | + 'no' => __('No', 'give'), |
|
305 | 305 | ), |
306 | 306 | ), |
307 | 307 | array( |
308 | - 'name' => __( 'Request Billing Information', 'give' ), |
|
309 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
310 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
308 | + 'name' => __('Request Billing Information', 'give'), |
|
309 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
310 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
311 | 311 | 'row_classes' => 'give-subfield', |
312 | 312 | 'type' => 'checkbox' |
313 | 313 | ), |
314 | 314 | array( |
315 | - 'id' => $prefix . 'offline_checkout_notes', |
|
316 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
317 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
315 | + 'id' => $prefix.'offline_checkout_notes', |
|
316 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
317 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
318 | 318 | 'default' => give_get_default_offline_donation_content(), |
319 | 319 | 'type' => 'wysiwyg', |
320 | 320 | 'row_classes' => 'give-subfield', |
@@ -323,17 +323,17 @@ discard block |
||
323 | 323 | ) |
324 | 324 | ), |
325 | 325 | array( |
326 | - 'id' => $prefix . 'offline_donation_subject', |
|
327 | - 'name' => __( 'Offline Donation Email Instructions Subject', 'give' ), |
|
328 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
329 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
326 | + 'id' => $prefix.'offline_donation_subject', |
|
327 | + 'name' => __('Offline Donation Email Instructions Subject', 'give'), |
|
328 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
329 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
330 | 330 | 'row_classes' => 'give-subfield', |
331 | 331 | 'type' => 'text' |
332 | 332 | ), |
333 | 333 | array( |
334 | - 'id' => $prefix . 'offline_donation_email', |
|
335 | - 'name' => __( 'Offline Donation Email Instructions', 'give' ), |
|
336 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
334 | + 'id' => $prefix.'offline_donation_email', |
|
335 | + 'name' => __('Offline Donation Email Instructions', 'give'), |
|
336 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
337 | 337 | 'default' => give_get_default_offline_donation_email_content(), |
338 | 338 | 'type' => 'wysiwyg', |
339 | 339 | 'row_classes' => 'give-subfield', |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | ) |
344 | 344 | ); |
345 | 345 | |
346 | - return array_merge( $settings, $check_settings ); |
|
346 | + return array_merge($settings, $check_settings); |
|
347 | 347 | } |
348 | 348 | |
349 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
349 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
350 | 350 | |
351 | 351 | |
352 | 352 | /** |
@@ -358,32 +358,32 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function give_get_default_offline_donation_content() { |
360 | 360 | |
361 | - $sitename = get_bloginfo( 'sitename' ); |
|
361 | + $sitename = get_bloginfo('sitename'); |
|
362 | 362 | |
363 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
363 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
364 | 364 | $default_text .= '<ol>'; |
365 | 365 | $default_text .= '<li>'; |
366 | 366 | $default_text .= sprintf( |
367 | 367 | /* translators: %s: site name */ |
368 | - __( 'Make a check payable to "%s"', 'give' ), |
|
368 | + __('Make a check payable to "%s"', 'give'), |
|
369 | 369 | $sitename |
370 | 370 | ); |
371 | 371 | $default_text .= '</li>'; |
372 | 372 | $default_text .= '<li>'; |
373 | 373 | $default_text .= sprintf( |
374 | 374 | /* translators: %s: site name */ |
375 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
375 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
376 | 376 | $sitename |
377 | 377 | ); |
378 | 378 | $default_text .= '</li>'; |
379 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
379 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
380 | 380 | $default_text .= '</ol>'; |
381 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
381 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
382 | 382 | $default_text .= ' <em>123 G Street </em><br>'; |
383 | 383 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
384 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
384 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
385 | 385 | |
386 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
386 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
387 | 387 | |
388 | 388 | } |
389 | 389 | |
@@ -396,34 +396,34 @@ discard block |
||
396 | 396 | */ |
397 | 397 | function give_get_default_offline_donation_email_content() { |
398 | 398 | |
399 | - $sitename = get_bloginfo( 'sitename' ); |
|
400 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
401 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
399 | + $sitename = get_bloginfo('sitename'); |
|
400 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
401 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
402 | 402 | $default_text .= '<ol>'; |
403 | 403 | $default_text .= '<li>'; |
404 | 404 | $default_text .= sprintf( |
405 | 405 | /* translators: %s: site name */ |
406 | - __( 'Make a check payable to "%s"', 'give' ), |
|
406 | + __('Make a check payable to "%s"', 'give'), |
|
407 | 407 | $sitename |
408 | 408 | ); |
409 | 409 | $default_text .= '</li>'; |
410 | 410 | $default_text .= '<li>'; |
411 | 411 | $default_text .= sprintf( |
412 | 412 | /* translators: %s: site name */ |
413 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
413 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
414 | 414 | $sitename |
415 | 415 | ); |
416 | 416 | $default_text .= '</li>'; |
417 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
417 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
418 | 418 | $default_text .= '</ol>'; |
419 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
419 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
420 | 420 | $default_text .= ' <em>123 G Street </em><br>'; |
421 | 421 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
422 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
423 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
424 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
422 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
423 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
424 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
425 | 425 | |
426 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
426 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
427 | 427 | |
428 | 428 | } |
429 | 429 | |
@@ -437,17 +437,17 @@ discard block |
||
437 | 437 | * |
438 | 438 | * @return string |
439 | 439 | */ |
440 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
441 | - $payment = new Give_Payment( $id ); |
|
440 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
441 | + $payment = new Give_Payment($id); |
|
442 | 442 | |
443 | - if ( 'offline' !== $payment->gateway ) { |
|
443 | + if ('offline' !== $payment->gateway) { |
|
444 | 444 | return $notice; |
445 | 445 | } |
446 | 446 | |
447 | - return give_output_error( 'Payment Pending: Please follow the instructions below to complete your donation.', false, 'warning' ); |
|
447 | + return give_output_error('Payment Pending: Please follow the instructions below to complete your donation.', false, 'warning'); |
|
448 | 448 | } |
449 | 449 | |
450 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
450 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Add offline payment instruction on payment receipt. |
@@ -458,26 +458,26 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return mixed |
460 | 460 | */ |
461 | -function give_offline_payment_receipt_after( $payment ) { |
|
461 | +function give_offline_payment_receipt_after($payment) { |
|
462 | 462 | // Get payment object. |
463 | - $payment = new Give_Payment( $payment->ID ); |
|
463 | + $payment = new Give_Payment($payment->ID); |
|
464 | 464 | |
465 | 465 | // Bailout. |
466 | - if ( 'offline' !== $payment->gateway ) { |
|
466 | + if ('offline' !== $payment->gateway) { |
|
467 | 467 | return false; |
468 | 468 | } |
469 | 469 | |
470 | 470 | ?> |
471 | 471 | <tr> |
472 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
472 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
473 | 473 | <td> |
474 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
474 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
475 | 475 | </td> |
476 | 476 | </tr> |
477 | 477 | <?php |
478 | 478 | } |
479 | 479 | |
480 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
480 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Get offline payment instructions. |
@@ -489,25 +489,25 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return string |
491 | 491 | */ |
492 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
492 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
493 | 493 | // Bailout. |
494 | - if ( ! $form_id ) { |
|
494 | + if ( ! $form_id) { |
|
495 | 495 | return ''; |
496 | 496 | } |
497 | 497 | |
498 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
499 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
500 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
498 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
499 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
500 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
501 | 501 | $offline_instructions = $global_offline_instruction; |
502 | 502 | |
503 | - if ( $post_offline_customization_option == 'yes' ) { |
|
503 | + if ($post_offline_customization_option == 'yes') { |
|
504 | 504 | $offline_instructions = $post_offline_instructions; |
505 | 505 | } |
506 | 506 | |
507 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
507 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
508 | 508 | |
509 | 509 | /* translators: %s: form settings url */ |
510 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
510 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
511 | 511 | |
512 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
512 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
513 | 513 | } |
@@ -1028,10 +1028,10 @@ |
||
1028 | 1028 | */ |
1029 | 1029 | public function is_close_donation_form() { |
1030 | 1030 | return ( |
1031 | - 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1032 | - && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1033 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1034 | - ); |
|
1031 | + 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1032 | + && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1033 | + && ( $this->get_goal() <= $this->get_earnings() |
|
1034 | + ); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -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' => esc_html__( 'New Donation Form', 'give' ) |
|
431 | + 'post_title' => esc_html__('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,13 +490,13 @@ 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 | - $this->price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
495 | + $this->price = get_post_meta($this->ID, '_give_set_price', true); |
|
496 | 496 | |
497 | - if ( $this->price ) { |
|
497 | + if ($this->price) { |
|
498 | 498 | |
499 | - $this->price = give_sanitize_amount( $this->price ); |
|
499 | + $this->price = give_sanitize_amount($this->price); |
|
500 | 500 | |
501 | 501 | } else { |
502 | 502 | |
@@ -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,14 +527,14 @@ 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 | - $allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
533 | - $this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
532 | + $allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true); |
|
533 | + $this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true); |
|
534 | 534 | |
535 | - if ( $allow_custom_amount != 'no' && $this->minimum_price ) { |
|
535 | + if ($allow_custom_amount != 'no' && $this->minimum_price) { |
|
536 | 536 | |
537 | - $this->minimum_price = give_sanitize_amount( $this->minimum_price ); |
|
537 | + $this->minimum_price = give_sanitize_amount($this->minimum_price); |
|
538 | 538 | |
539 | 539 | } else { |
540 | 540 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | } |
546 | 546 | |
547 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
547 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | */ |
558 | 558 | public function get_prices() { |
559 | 559 | |
560 | - if ( ! isset( $this->prices ) ) { |
|
560 | + if ( ! isset($this->prices)) { |
|
561 | 561 | |
562 | - $this->prices = get_post_meta( $this->ID, '_give_donation_levels', true ); |
|
562 | + $this->prices = get_post_meta($this->ID, '_give_donation_levels', true); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @param array $prices The array of mulit-level prices. |
572 | 572 | * @param int|string The ID of the form. |
573 | 573 | */ |
574 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
574 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
575 | 575 | |
576 | 576 | } |
577 | 577 | |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function get_goal() { |
587 | 587 | |
588 | - if ( ! isset( $this->goal ) ) { |
|
588 | + if ( ! isset($this->goal)) { |
|
589 | 589 | |
590 | - $this->goal = get_post_meta( $this->ID, '_give_set_goal', true ); |
|
590 | + $this->goal = get_post_meta($this->ID, '_give_set_goal', true); |
|
591 | 591 | |
592 | - if ( $this->goal ) { |
|
592 | + if ($this->goal) { |
|
593 | 593 | |
594 | - $this->goal = give_sanitize_amount( $this->goal ); |
|
594 | + $this->goal = give_sanitize_amount($this->goal); |
|
595 | 595 | |
596 | 596 | } else { |
597 | 597 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | } |
603 | 603 | |
604 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
604 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
605 | 605 | |
606 | 606 | } |
607 | 607 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | */ |
616 | 616 | public function is_single_price_mode() { |
617 | 617 | |
618 | - $option = get_post_meta( $this->ID, '_give_price_options_mode', true ); |
|
618 | + $option = get_post_meta($this->ID, '_give_price_options_mode', true); |
|
619 | 619 | $ret = 0; |
620 | 620 | |
621 | - if ( empty( $option ) || $option === 'set' ) { |
|
621 | + if (empty($option) || $option === 'set') { |
|
622 | 622 | $ret = 1; |
623 | 623 | } |
624 | 624 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @param bool $ret Is donation form in single price mode? |
631 | 631 | * @param int|string The ID of the donation form. |
632 | 632 | */ |
633 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
633 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
634 | 634 | |
635 | 635 | } |
636 | 636 | |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | */ |
645 | 645 | public function is_custom_price_mode() { |
646 | 646 | |
647 | - $option = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
647 | + $option = get_post_meta($this->ID, '_give_custom_amount', true); |
|
648 | 648 | $ret = 0; |
649 | 649 | |
650 | - if ( $option === 'yes' ) { |
|
650 | + if ($option === 'yes') { |
|
651 | 651 | $ret = 1; |
652 | 652 | } |
653 | 653 | |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | * @param bool $ret Is donation form in custom price mode? |
660 | 660 | * @param int|string The ID of the donation form. |
661 | 661 | */ |
662 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
662 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
663 | 663 | |
664 | 664 | } |
665 | 665 | |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public function has_variable_prices() { |
677 | 677 | |
678 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
678 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
679 | 679 | $ret = 0; |
680 | 680 | |
681 | - if ( $option === 'multi' ) { |
|
681 | + if ($option === 'multi') { |
|
682 | 682 | $ret = 1; |
683 | 683 | } |
684 | 684 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param bool $ret Does donation form have variable prices? |
689 | 689 | * @param int|string The ID of the donation form. |
690 | 690 | */ |
691 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
691 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
692 | 692 | |
693 | 693 | } |
694 | 694 | |
@@ -702,17 +702,17 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public function get_type() { |
704 | 704 | |
705 | - if ( ! isset( $this->type ) ) { |
|
705 | + if ( ! isset($this->type)) { |
|
706 | 706 | |
707 | - $this->type = get_post_meta( $this->ID, '_give_price_option', true ); |
|
707 | + $this->type = get_post_meta($this->ID, '_give_price_option', true); |
|
708 | 708 | |
709 | - if ( empty( $this->type ) ) { |
|
709 | + if (empty($this->type)) { |
|
710 | 710 | $this->type = 'set'; |
711 | 711 | } |
712 | 712 | |
713 | 713 | } |
714 | 714 | |
715 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
715 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
716 | 716 | |
717 | 717 | } |
718 | 718 | |
@@ -728,23 +728,23 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @return string |
730 | 730 | */ |
731 | - public function get_form_classes( $args ) { |
|
731 | + public function get_form_classes($args) { |
|
732 | 732 | |
733 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
733 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
734 | 734 | ? 'float-labels-enabled' |
735 | 735 | : ''; |
736 | 736 | |
737 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
737 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
738 | 738 | 'give-form', |
739 | - 'give-form-' . $this->ID, |
|
740 | - 'give-form-type-' . $this->get_type(), |
|
739 | + 'give-form-'.$this->ID, |
|
740 | + 'give-form-type-'.$this->get_type(), |
|
741 | 741 | $float_labels_option |
742 | - ), $this->ID, $args ); |
|
742 | + ), $this->ID, $args); |
|
743 | 743 | |
744 | 744 | // Remove empty class names. |
745 | - $form_classes_array = array_filter( $form_classes_array ); |
|
745 | + $form_classes_array = array_filter($form_classes_array); |
|
746 | 746 | |
747 | - return implode( ' ', $form_classes_array ); |
|
747 | + return implode(' ', $form_classes_array); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | |
@@ -759,19 +759,19 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @return string |
761 | 761 | */ |
762 | - public function get_form_wrap_classes( $args ) { |
|
762 | + public function get_form_wrap_classes($args) { |
|
763 | 763 | |
764 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
764 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
765 | 765 | ? $args['display_style'] |
766 | - : get_post_meta( $this->ID, '_give_payment_display', true ); |
|
766 | + : get_post_meta($this->ID, '_give_payment_display', true); |
|
767 | 767 | |
768 | - $form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array( |
|
768 | + $form_wrap_classes_array = apply_filters('give_form_wrap_classes', array( |
|
769 | 769 | 'give-form-wrap', |
770 | - 'give-display-' . $display_option |
|
771 | - ), $this->ID, $args ); |
|
770 | + 'give-display-'.$display_option |
|
771 | + ), $this->ID, $args); |
|
772 | 772 | |
773 | 773 | |
774 | - return implode( ' ', $form_wrap_classes_array ); |
|
774 | + return implode(' ', $form_wrap_classes_array); |
|
775 | 775 | |
776 | 776 | } |
777 | 777 | |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | public function is_set_type_donation_form() { |
787 | 787 | $form_type = $this->get_type(); |
788 | 788 | |
789 | - return ( 'set' === $form_type ? true : false ); |
|
789 | + return ('set' === $form_type ? true : false); |
|
790 | 790 | |
791 | 791 | } |
792 | 792 | |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | public function is_multi_type_donation_form() { |
802 | 802 | $form_type = $this->get_type(); |
803 | 803 | |
804 | - return ( 'multi' === $form_type ? true : false ); |
|
804 | + return ('multi' === $form_type ? true : false); |
|
805 | 805 | |
806 | 806 | } |
807 | 807 | |
@@ -815,15 +815,15 @@ discard block |
||
815 | 815 | */ |
816 | 816 | public function get_sales() { |
817 | 817 | |
818 | - if ( ! isset( $this->sales ) ) { |
|
818 | + if ( ! isset($this->sales)) { |
|
819 | 819 | |
820 | - if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) { |
|
821 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
820 | + if ('' == get_post_meta($this->ID, '_give_form_sales', true)) { |
|
821 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
822 | 822 | } // End if |
823 | 823 | |
824 | - $this->sales = get_post_meta( $this->ID, '_give_form_sales', true ); |
|
824 | + $this->sales = get_post_meta($this->ID, '_give_form_sales', true); |
|
825 | 825 | |
826 | - if ( $this->sales < 0 ) { |
|
826 | + if ($this->sales < 0) { |
|
827 | 827 | // Never let sales be less than zero |
828 | 828 | $this->sales = 0; |
829 | 829 | } |
@@ -844,13 +844,13 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @return int|false New number of total sales. |
846 | 846 | */ |
847 | - public function increase_sales( $quantity = 1 ) { |
|
847 | + public function increase_sales($quantity = 1) { |
|
848 | 848 | |
849 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
850 | - $quantity = absint( $quantity ); |
|
849 | + $sales = give_get_form_sales_stats($this->ID); |
|
850 | + $quantity = absint($quantity); |
|
851 | 851 | $total_sales = $sales + $quantity; |
852 | 852 | |
853 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
853 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
854 | 854 | |
855 | 855 | $this->sales = $total_sales; |
856 | 856 | |
@@ -871,17 +871,17 @@ discard block |
||
871 | 871 | * |
872 | 872 | * @return int|false New number of total sales. |
873 | 873 | */ |
874 | - public function decrease_sales( $quantity = 1 ) { |
|
874 | + public function decrease_sales($quantity = 1) { |
|
875 | 875 | |
876 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
876 | + $sales = give_get_form_sales_stats($this->ID); |
|
877 | 877 | |
878 | 878 | // Only decrease if not already zero |
879 | - if ( $sales > 0 ) { |
|
879 | + if ($sales > 0) { |
|
880 | 880 | |
881 | - $quantity = absint( $quantity ); |
|
881 | + $quantity = absint($quantity); |
|
882 | 882 | $total_sales = $sales - $quantity; |
883 | 883 | |
884 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
884 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
885 | 885 | |
886 | 886 | $this->sales = $sales; |
887 | 887 | |
@@ -905,15 +905,15 @@ discard block |
||
905 | 905 | */ |
906 | 906 | public function get_earnings() { |
907 | 907 | |
908 | - if ( ! isset( $this->earnings ) ) { |
|
908 | + if ( ! isset($this->earnings)) { |
|
909 | 909 | |
910 | - if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
911 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
910 | + if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) { |
|
911 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
912 | 912 | } |
913 | 913 | |
914 | - $this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true ); |
|
914 | + $this->earnings = get_post_meta($this->ID, '_give_form_earnings', true); |
|
915 | 915 | |
916 | - if ( $this->earnings < 0 ) { |
|
916 | + if ($this->earnings < 0) { |
|
917 | 917 | // Never let earnings be less than zero |
918 | 918 | $this->earnings = 0; |
919 | 919 | } |
@@ -934,12 +934,12 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return float|false |
936 | 936 | */ |
937 | - public function increase_earnings( $amount = 0 ) { |
|
937 | + public function increase_earnings($amount = 0) { |
|
938 | 938 | |
939 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
939 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
940 | 940 | $new_amount = $earnings + (float) $amount; |
941 | 941 | |
942 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
942 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
943 | 943 | |
944 | 944 | $this->earnings = $new_amount; |
945 | 945 | |
@@ -961,16 +961,16 @@ discard block |
||
961 | 961 | * |
962 | 962 | * @return float|false |
963 | 963 | */ |
964 | - public function decrease_earnings( $amount ) { |
|
964 | + public function decrease_earnings($amount) { |
|
965 | 965 | |
966 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
966 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
967 | 967 | |
968 | - if ( $earnings > 0 ) { |
|
968 | + if ($earnings > 0) { |
|
969 | 969 | // Only decrease if greater than zero |
970 | 970 | $new_amount = $earnings - (float) $amount; |
971 | 971 | |
972 | 972 | |
973 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
973 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
974 | 974 | |
975 | 975 | $this->earnings = $new_amount; |
976 | 976 | |
@@ -994,22 +994,22 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @return bool |
996 | 996 | */ |
997 | - public function is_free( $price_id = false ) { |
|
997 | + public function is_free($price_id = false) { |
|
998 | 998 | |
999 | 999 | $is_free = false; |
1000 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
1000 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
1001 | 1001 | |
1002 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
1003 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
1004 | - } elseif ( ! $variable_pricing ) { |
|
1005 | - $price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
1002 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
1003 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
1004 | + } elseif ( ! $variable_pricing) { |
|
1005 | + $price = get_post_meta($this->ID, '_give_set_price', true); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
1008 | + if (isset($price) && (float) $price == 0) { |
|
1009 | 1009 | $is_free = true; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
1012 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
1013 | 1013 | |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1028,9 +1028,9 @@ discard block |
||
1028 | 1028 | */ |
1029 | 1029 | public function is_close_donation_form() { |
1030 | 1030 | return ( |
1031 | - 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1032 | - && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1033 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1031 | + 'yes' === get_post_meta($this->ID, '_give_goal_option', true) ) |
|
1032 | + && ('yes' === get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true)) |
|
1033 | + && ($this->get_goal() <= $this->get_earnings() |
|
1034 | 1034 | ); |
1035 | 1035 | } |
1036 | 1036 | |
@@ -1045,29 +1045,29 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * @return bool The result of the update query. |
1047 | 1047 | */ |
1048 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
1048 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
1049 | 1049 | |
1050 | 1050 | /* @var WPDB $wpdb */ |
1051 | 1051 | global $wpdb; |
1052 | 1052 | |
1053 | - if ( empty( $meta_key ) ) { |
|
1053 | + if (empty($meta_key)) { |
|
1054 | 1054 | return false; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // Make sure if it needs to be serialized, we do |
1058 | - $meta_value = maybe_serialize( $meta_value ); |
|
1058 | + $meta_value = maybe_serialize($meta_value); |
|
1059 | 1059 | |
1060 | - if ( is_numeric( $meta_value ) ) { |
|
1061 | - $value_type = is_float( $meta_value ) ? '%f' : '%d'; |
|
1060 | + if (is_numeric($meta_value)) { |
|
1061 | + $value_type = is_float($meta_value) ? '%f' : '%d'; |
|
1062 | 1062 | } else { |
1063 | 1063 | $value_type = "'%s'"; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - $sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key ); |
|
1066 | + $sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key); |
|
1067 | 1067 | |
1068 | - if ( $wpdb->query( $sql ) ) { |
|
1068 | + if ($wpdb->query($sql)) { |
|
1069 | 1069 | |
1070 | - clean_post_cache( $this->ID ); |
|
1070 | + clean_post_cache($this->ID); |
|
1071 | 1071 | |
1072 | 1072 | return true; |
1073 | 1073 |