@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | */ |
5 | 5 | $give_map_deprecated_filters = give_deprecated_filters(); |
6 | 6 | |
7 | -foreach ( $give_map_deprecated_filters as $new => $old ) { |
|
8 | - add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 ); |
|
7 | +foreach ($give_map_deprecated_filters as $new => $old) { |
|
8 | + add_filter($new, 'give_deprecated_filter_mapping', 10, 4); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | // Dynamic filters. |
61 | - switch ( true ) { |
|
62 | - case ( ! empty( $_GET['payment-confirmation'] ) ) : |
|
61 | + switch (true) { |
|
62 | + case ( ! empty($_GET['payment-confirmation'])) : |
|
63 | 63 | $give_deprecated_filters["give_donation_confirm_{$_GET['payment-confirmation']}"] = "give_payment_confirm_{$_GET['payment-confirmation']}"; |
64 | 64 | } |
65 | 65 | |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return mixed|void |
78 | 78 | */ |
79 | -function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
79 | +function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
80 | 80 | $give_map_deprecated_filters = give_deprecated_filters(); |
81 | 81 | $filter = current_filter(); |
82 | 82 | |
83 | - if ( isset( $give_map_deprecated_filters[ $filter ] ) ) { |
|
84 | - if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) { |
|
85 | - $data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 ); |
|
83 | + if (isset($give_map_deprecated_filters[$filter])) { |
|
84 | + if (has_filter($give_map_deprecated_filters[$filter])) { |
|
85 | + $data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3); |
|
86 | 86 | |
87 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
88 | - _give_deprecated_function( 'The ' . $give_map_deprecated_filters[ $filter ] . ' filter', '1.7', $filter ); |
|
87 | + if ( ! defined('DOING_AJAX')) { |
|
88 | + _give_deprecated_function('The '.$give_map_deprecated_filters[$filter].' filter', '1.7', $filter); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | */ |
5 | 5 | $give_map_deprecated_actions = give_deprecated_actions(); |
6 | 6 | |
7 | -foreach ( $give_map_deprecated_actions as $new => $old ) { |
|
8 | - add_action( $new, 'give_deprecated_action_mapping', 10, 4 ); |
|
7 | +foreach ($give_map_deprecated_actions as $new => $old) { |
|
8 | + add_action($new, 'give_deprecated_action_mapping', 10, 4); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return mixed|void |
80 | 80 | */ |
81 | -function give_deprecated_action_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
81 | +function give_deprecated_action_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
82 | 82 | $give_map_deprecated_actions = give_deprecated_actions(); |
83 | 83 | $action = current_filter(); |
84 | 84 | |
85 | - if ( isset( $give_map_deprecated_actions[ $action ] ) ) { |
|
86 | - if ( has_action( $give_map_deprecated_actions[ $action ] ) ) { |
|
87 | - do_action( $give_map_deprecated_actions[ $action ], $data, $arg_1, $arg_2, $arg_3 ); |
|
85 | + if (isset($give_map_deprecated_actions[$action])) { |
|
86 | + if (has_action($give_map_deprecated_actions[$action])) { |
|
87 | + do_action($give_map_deprecated_actions[$action], $data, $arg_1, $arg_2, $arg_3); |
|
88 | 88 | |
89 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
90 | - _give_deprecated_function( 'The ' . $give_map_deprecated_actions[ $action ] . ' action', '1.7', $action ); |
|
89 | + if ( ! defined('DOING_AJAX')) { |
|
90 | + _give_deprecated_function('The '.$give_map_deprecated_actions[$action].' action', '1.7', $action); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -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,40 +56,40 @@ 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( '{price}', $price, $message ); |
|
83 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
84 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
85 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
86 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
87 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
88 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
89 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
90 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
91 | - |
|
92 | - 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('{price}', $price, $message); |
|
83 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
84 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
85 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
86 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
87 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
88 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
89 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
90 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
91 | + |
|
92 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -101,23 +101,23 @@ discard block |
||
101 | 101 | * @since 1.0 |
102 | 102 | * @return array|bool |
103 | 103 | */ |
104 | -function give_email_template_preview( $array ) { |
|
104 | +function give_email_template_preview($array) { |
|
105 | 105 | |
106 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
106 | + if ( ! current_user_can('manage_give_settings')) { |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | $custom_field = array( |
110 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
111 | - 'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ), |
|
110 | + 'name' => esc_html__('Preview Email', 'give'), |
|
111 | + 'desc' => esc_html__('Click the buttons to preview emails.', 'give'), |
|
112 | 112 | 'id' => 'give_email_preview_buttons', |
113 | 113 | 'type' => 'email_preview_buttons' |
114 | 114 | ); |
115 | 115 | |
116 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
116 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
120 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
120 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Output Email Template Preview Buttons. |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | function give_email_preview_buttons_callback() { |
130 | 130 | ob_start(); |
131 | 131 | ?> |
132 | - <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> |
|
133 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
132 | + <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> |
|
133 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
134 | 134 | 'give_action' => 'send_test_email', |
135 | 135 | 'give-message' => 'sent-test-email', |
136 | 136 | 'tag' => 'emails' |
137 | - ) ), '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> |
|
137 | + )), '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> |
|
138 | 138 | <?php |
139 | 139 | echo ob_get_clean(); |
140 | 140 | } |
@@ -147,46 +147,46 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function give_display_email_template_preview() { |
149 | 149 | |
150 | - if ( empty( $_GET['give_action'] ) ) { |
|
150 | + if (empty($_GET['give_action'])) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
154 | + if ('preview_email' !== $_GET['give_action']) { |
|
155 | 155 | return; |
156 | 156 | } |
157 | 157 | |
158 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
158 | + if ( ! current_user_can('manage_give_settings')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
163 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
164 | 164 | |
165 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
165 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
166 | 166 | |
167 | 167 | echo give_get_preview_email_header(); |
168 | 168 | |
169 | 169 | //Are we previewing an actual payment? |
170 | - if ( ! empty( $payment_id ) ) { |
|
170 | + if ( ! empty($payment_id)) { |
|
171 | 171 | |
172 | - $content = give_get_email_body_content( $payment_id ); |
|
172 | + $content = give_get_email_body_content($payment_id); |
|
173 | 173 | |
174 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
174 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
175 | 175 | |
176 | 176 | } else { |
177 | 177 | |
178 | 178 | //No payment ID, use sample preview content |
179 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
179 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | - echo Give()->emails->build_email( $preview_content ); |
|
183 | + echo Give()->emails->build_email($preview_content); |
|
184 | 184 | |
185 | 185 | exit; |
186 | 186 | |
187 | 187 | } |
188 | 188 | |
189 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
189 | +add_action('init', 'give_display_email_template_preview'); |
|
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Email Template Body. |
@@ -198,18 +198,18 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return string $email_body Body of the email |
200 | 200 | */ |
201 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
201 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
202 | 202 | |
203 | 203 | $default_email_body = give_get_default_donation_receipt_email(); |
204 | 204 | |
205 | - $email_content = give_get_option( 'donation_receipt' ); |
|
206 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
205 | + $email_content = give_get_option('donation_receipt'); |
|
206 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
207 | 207 | |
208 | - $email_body = wpautop( $email_content ); |
|
208 | + $email_body = wpautop($email_content); |
|
209 | 209 | |
210 | - $email_body = apply_filters( "give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data ); |
|
210 | + $email_body = apply_filters("give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data); |
|
211 | 211 | |
212 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
212 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -222,36 +222,36 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string $email_body Body of the email |
224 | 224 | */ |
225 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
225 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
226 | 226 | |
227 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
228 | - $email = give_get_payment_user_email( $payment_id ); |
|
227 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
228 | + $email = give_get_payment_user_email($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $email; |
237 | 237 | } |
238 | 238 | |
239 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
239 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
240 | 240 | |
241 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
242 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
243 | - $default_email_body .= esc_html__( 'Forms sold:', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
245 | - $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"; |
|
246 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
247 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
241 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
242 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
243 | + $default_email_body .= esc_html__('Forms sold:', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
245 | + $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"; |
|
246 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
247 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
248 | 248 | |
249 | - $email = give_get_option( 'donation_notification' ); |
|
250 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
249 | + $email = give_get_option('donation_notification'); |
|
250 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
251 | 251 | |
252 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
252 | + $email_body = give_do_email_tags($email, $payment_id); |
|
253 | 253 | |
254 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
254 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | * @since 1.0 |
265 | 265 | */ |
266 | 266 | function give_render_receipt_in_browser() { |
267 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
268 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
267 | + if ( ! isset($_GET['payment_key'])) { |
|
268 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
269 | 269 | } |
270 | 270 | |
271 | - $key = urlencode( $_GET['payment_key'] ); |
|
271 | + $key = urlencode($_GET['payment_key']); |
|
272 | 272 | |
273 | 273 | ob_start(); |
274 | 274 | //Disallows caching of the page |
275 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
276 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
277 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
278 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
279 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
275 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
276 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
277 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
278 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
279 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
280 | 280 | ?> |
281 | 281 | <!DOCTYPE html> |
282 | 282 | <html lang="en"> |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @since 1.0 |
289 | 289 | */ |
290 | - do_action( 'give_receipt_head' ); |
|
290 | + do_action('give_receipt_head'); |
|
291 | 291 | ?> |
292 | 292 | </head> |
293 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
293 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
294 | 294 | |
295 | 295 | <div id="give_receipt_wrapper"> |
296 | 296 | <?php |
@@ -299,16 +299,16 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @since 1.0 |
301 | 301 | */ |
302 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
302 | + do_action('give_render_receipt_in_browser_before'); |
|
303 | 303 | |
304 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
304 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Fires in the receipt template after the content. |
308 | 308 | * |
309 | 309 | * @since 1.0 |
310 | 310 | */ |
311 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
311 | + do_action('give_render_receipt_in_browser_after'); |
|
312 | 312 | ?> |
313 | 313 | </div> |
314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @since 1.0 |
320 | 320 | */ |
321 | - do_action( 'give_receipt_footer' ); |
|
321 | + do_action('give_receipt_footer'); |
|
322 | 322 | ?> |
323 | 323 | </body> |
324 | 324 | </html> |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | die(); |
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
330 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
331 | 331 | |
332 | 332 | |
333 | 333 | /** |
@@ -342,29 +342,29 @@ discard block |
||
342 | 342 | |
343 | 343 | //Payment receipt switcher |
344 | 344 | $payment_count = give_count_payments()->publish; |
345 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
345 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
346 | 346 | |
347 | - if ( $payment_count <= 0 ) { |
|
347 | + if ($payment_count <= 0) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | |
351 | 351 | //Get payments. |
352 | - $payments = new Give_Payments_Query( array( |
|
352 | + $payments = new Give_Payments_Query(array( |
|
353 | 353 | 'number' => 100 |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | $payments = $payments->get_payments(); |
356 | 356 | $options = array(); |
357 | 357 | |
358 | 358 | //Provide nice human readable options. |
359 | - if ( $payments ) { |
|
360 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
361 | - foreach ( $payments as $payment ) { |
|
359 | + if ($payments) { |
|
360 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
361 | + foreach ($payments as $payment) { |
|
362 | 362 | |
363 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
363 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
364 | 364 | |
365 | 365 | } |
366 | 366 | } else { |
367 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
367 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | //Start constructing HTML output. |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | var selected_trans = transactions.options[transactions.selectedIndex]; |
378 | 378 | console.log(selected_trans); |
379 | 379 | if (selected_trans){ |
380 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
380 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
381 | 381 | window.location = url_string; |
382 | 382 | } |
383 | 383 | } |
384 | 384 | </script>'; |
385 | 385 | |
386 | - $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>'; |
|
386 | + $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>'; |
|
387 | 387 | |
388 | 388 | //The select field with 100 latest transactions |
389 | - $transaction_header .= Give()->html->select( array( |
|
389 | + $transaction_header .= Give()->html->select(array( |
|
390 | 390 | 'name' => 'preview_email_payment_id', |
391 | 391 | 'selected' => $payment_id, |
392 | 392 | 'id' => 'give_preview_email_payment_id', |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | 'select_atts' => 'onchange="change_preview()">', |
397 | 397 | 'show_option_all' => false, |
398 | 398 | 'show_option_none' => false |
399 | - ) ); |
|
399 | + )); |
|
400 | 400 | |
401 | 401 | //Closing tag |
402 | 402 | $transaction_header .= '</div>'; |
403 | 403 | |
404 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
404 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
405 | 405 | |
406 | 406 | } |
407 | 407 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | function give_receipt_head_content() { |
416 | 416 | |
417 | 417 | //Title. |
418 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
418 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
419 | 419 | |
420 | 420 | //Meta. |
421 | 421 | $output .= '<meta charset="utf-8"/> |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | <meta name="robots" content="noindex, nofollow"/>'; |
430 | 430 | |
431 | 431 | //CSS |
432 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
432 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
433 | 433 | |
434 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
434 | + echo apply_filters('give_receipt_head_content', $output); |
|
435 | 435 | |
436 | 436 | } |
437 | 437 | |
438 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
439 | 438 | \ No newline at end of file |
439 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
440 | 440 | \ 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,11 +35,11 @@ discard block |
||
35 | 35 | /* @var WPDB $wpdb */ |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
38 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
39 | 39 | $this->primary_key = 'id'; |
40 | 40 | $this->version = '1.0'; |
41 | 41 | |
42 | - add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 ); |
|
42 | + add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'purchase_value' => 0.00, |
83 | 83 | 'purchase_count' => 0, |
84 | 84 | 'notes' => '', |
85 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
85 | + 'date_created' => date('Y-m-d H:i:s'), |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -96,40 +96,40 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return int|bool |
98 | 98 | */ |
99 | - public function add( $data = array() ) { |
|
99 | + public function add($data = array()) { |
|
100 | 100 | |
101 | 101 | $defaults = array( |
102 | 102 | 'payment_ids' => '' |
103 | 103 | ); |
104 | 104 | |
105 | - $args = wp_parse_args( $data, $defaults ); |
|
105 | + $args = wp_parse_args($data, $defaults); |
|
106 | 106 | |
107 | - if ( empty( $args['email'] ) ) { |
|
107 | + if (empty($args['email'])) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
112 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
111 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
112 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
113 | 113 | } |
114 | 114 | |
115 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
115 | + $customer = $this->get_customer_by('email', $args['email']); |
|
116 | 116 | |
117 | - if ( $customer ) { |
|
117 | + if ($customer) { |
|
118 | 118 | // update an existing customer |
119 | 119 | |
120 | 120 | // Update the payment IDs attached to the customer |
121 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
121 | + if ( ! empty($args['payment_ids'])) { |
|
122 | 122 | |
123 | - if ( empty( $customer->payment_ids ) ) { |
|
123 | + if (empty($customer->payment_ids)) { |
|
124 | 124 | |
125 | 125 | $customer->payment_ids = $args['payment_ids']; |
126 | 126 | |
127 | 127 | } else { |
128 | 128 | |
129 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
130 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
131 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
132 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
129 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
130 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
131 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
132 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | |
138 | 138 | } |
139 | 139 | |
140 | - $this->update( $customer->id, $args ); |
|
140 | + $this->update($customer->id, $args); |
|
141 | 141 | |
142 | 142 | return $customer->id; |
143 | 143 | |
144 | 144 | } else { |
145 | 145 | |
146 | - return $this->insert( $args, 'customer' ); |
|
146 | + return $this->insert($args, 'customer'); |
|
147 | 147 | |
148 | 148 | } |
149 | 149 | |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return bool|int |
164 | 164 | */ |
165 | - public function delete( $_id_or_email = false ) { |
|
165 | + public function delete($_id_or_email = false) { |
|
166 | 166 | |
167 | - if ( empty( $_id_or_email ) ) { |
|
167 | + if (empty($_id_or_email)) { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
172 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
171 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
172 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
173 | 173 | |
174 | - if ( $customer->id > 0 ) { |
|
174 | + if ($customer->id > 0) { |
|
175 | 175 | |
176 | 176 | global $wpdb; |
177 | 177 | |
178 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
178 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
179 | 179 | |
180 | 180 | } else { |
181 | 181 | return false; |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return bool True is exists, false otherwise. |
196 | 196 | */ |
197 | - public function exists( $value = '', $field = 'email' ) { |
|
197 | + public function exists($value = '', $field = 'email') { |
|
198 | 198 | |
199 | 199 | $columns = $this->get_columns(); |
200 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
200 | + if ( ! array_key_exists($field, $columns)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
204 | + return (bool) $this->get_column_by('id', $field, $value); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool |
218 | 218 | */ |
219 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
219 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
220 | 220 | |
221 | - $customer = new Give_Customer( $customer_id ); |
|
221 | + $customer = new Give_Customer($customer_id); |
|
222 | 222 | |
223 | - if ( empty( $customer->id ) ) { |
|
223 | + if (empty($customer->id)) { |
|
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // Attach the payment, but don't increment stats, as this function previously did not |
228 | - return $customer->attach_payment( $payment_id, false ); |
|
228 | + return $customer->attach_payment($payment_id, false); |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool |
242 | 242 | */ |
243 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
243 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
244 | 244 | |
245 | - $customer = new Give_Customer( $customer_id ); |
|
245 | + $customer = new Give_Customer($customer_id); |
|
246 | 246 | |
247 | - if ( ! $customer ) { |
|
247 | + if ( ! $customer) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Remove the payment, but don't decrease stats, as this function previously did not |
252 | - return $customer->remove_payment( $payment_id, false ); |
|
252 | + return $customer->remove_payment($payment_id, false); |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return bool |
265 | 265 | */ |
266 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
266 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
267 | 267 | |
268 | - $customer = new Give_Customer( $customer_id ); |
|
268 | + $customer = new Give_Customer($customer_id); |
|
269 | 269 | |
270 | - if ( empty( $customer->id ) ) { |
|
270 | + if (empty($customer->id)) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $increased_count = $customer->increase_purchase_count(); |
275 | - $increased_value = $customer->increase_value( $amount ); |
|
275 | + $increased_value = $customer->increase_value($amount); |
|
276 | 276 | |
277 | - return ( $increased_count && $increased_value ) ? true : false; |
|
277 | + return ($increased_count && $increased_value) ? true : false; |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return bool |
291 | 291 | */ |
292 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
292 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
293 | 293 | |
294 | - $customer = new Give_Customer( $customer_id ); |
|
294 | + $customer = new Give_Customer($customer_id); |
|
295 | 295 | |
296 | - if ( ! $customer ) { |
|
296 | + if ( ! $customer) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | 300 | $decreased_count = $customer->decrease_purchase_count(); |
301 | - $decreased_value = $customer->decrease_value( $amount ); |
|
301 | + $decreased_value = $customer->decrease_value($amount); |
|
302 | 302 | |
303 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
303 | + return ($decreased_count && $decreased_value) ? true : false; |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -315,31 +315,31 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
|
318 | + public function update_customer_email_on_user_update($user_id = 0, $old_user_data) { |
|
319 | 319 | |
320 | - $customer = new Give_Customer( $user_id, true ); |
|
320 | + $customer = new Give_Customer($user_id, true); |
|
321 | 321 | |
322 | - if( ! $customer ) { |
|
322 | + if ( ! $customer) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $user = get_userdata( $user_id ); |
|
326 | + $user = get_userdata($user_id); |
|
327 | 327 | |
328 | - if( ! empty( $user ) && $user->user_email !== $customer->email ) { |
|
328 | + if ( ! empty($user) && $user->user_email !== $customer->email) { |
|
329 | 329 | |
330 | - if( ! $this->get_customer_by( 'email', $user->user_email ) ) { |
|
330 | + if ( ! $this->get_customer_by('email', $user->user_email)) { |
|
331 | 331 | |
332 | - $success = $this->update( $customer->id, array( 'email' => $user->user_email ) ); |
|
332 | + $success = $this->update($customer->id, array('email' => $user->user_email)); |
|
333 | 333 | |
334 | - if( $success ) { |
|
334 | + if ($success) { |
|
335 | 335 | // Update some payment meta if we need to |
336 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
336 | + $payments_array = explode(',', $customer->payment_ids); |
|
337 | 337 | |
338 | - if( ! empty( $payments_array ) ) { |
|
338 | + if ( ! empty($payments_array)) { |
|
339 | 339 | |
340 | - foreach ( $payments_array as $payment_id ) { |
|
340 | + foreach ($payments_array as $payment_id) { |
|
341 | 341 | |
342 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
342 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
343 | 343 | |
344 | 344 | } |
345 | 345 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param WP_User $user WordPress User object. |
354 | 354 | * @param Give_Customer $customer Give customer object. |
355 | 355 | */ |
356 | - do_action( 'give_update_customer_email_on_user_update', $user, $customer ); |
|
356 | + do_action('give_update_customer_email_on_user_update', $user, $customer); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
@@ -374,46 +374,46 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
376 | 376 | */ |
377 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
377 | + public function get_customer_by($field = 'id', $value = 0) { |
|
378 | 378 | /* @var WPDB $wpdb */ |
379 | 379 | global $wpdb; |
380 | 380 | |
381 | - if ( empty( $field ) || empty( $value ) ) { |
|
381 | + if (empty($field) || empty($value)) { |
|
382 | 382 | return null; |
383 | 383 | } |
384 | 384 | |
385 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
385 | + if ('id' == $field || 'user_id' == $field) { |
|
386 | 386 | // Make sure the value is numeric to avoid casting objects, for example, |
387 | 387 | // to int 1. |
388 | - if ( ! is_numeric( $value ) ) { |
|
388 | + if ( ! is_numeric($value)) { |
|
389 | 389 | return false; |
390 | 390 | } |
391 | 391 | |
392 | - $value = intval( $value ); |
|
392 | + $value = intval($value); |
|
393 | 393 | |
394 | - if ( $value < 1 ) { |
|
394 | + if ($value < 1) { |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - } elseif ( 'email' === $field ) { |
|
398 | + } elseif ('email' === $field) { |
|
399 | 399 | |
400 | - if ( ! is_email( $value ) ) { |
|
400 | + if ( ! is_email($value)) { |
|
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - $value = trim( $value ); |
|
404 | + $value = trim($value); |
|
405 | 405 | } |
406 | 406 | |
407 | - if ( ! $value ) { |
|
407 | + if ( ! $value) { |
|
408 | 408 | return false; |
409 | 409 | } |
410 | 410 | |
411 | - switch ( $field ) { |
|
411 | + switch ($field) { |
|
412 | 412 | case 'id': |
413 | 413 | $db_field = 'id'; |
414 | 414 | break; |
415 | 415 | case 'email': |
416 | - $value = sanitize_text_field( $value ); |
|
416 | + $value = sanitize_text_field($value); |
|
417 | 417 | $db_field = 'email'; |
418 | 418 | break; |
419 | 419 | case 'user_id': |
@@ -423,15 +423,15 @@ discard block |
||
423 | 423 | return false; |
424 | 424 | } |
425 | 425 | |
426 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
426 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
427 | 427 | |
428 | 428 | // Look for customer from an additional email |
429 | - if( 'email' === $field ) { |
|
429 | + if ('email' === $field) { |
|
430 | 430 | $meta_table = Give()->customer_meta->table_name; |
431 | - $customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) ); |
|
431 | + $customer_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value)); |
|
432 | 432 | |
433 | - if( ! empty( $customer_id ) ) { |
|
434 | - return $this->get( $customer_id ); |
|
433 | + if ( ! empty($customer_id)) { |
|
434 | + return $this->get($customer_id); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return array|object|null Customers array or object. Null if not found. |
453 | 453 | */ |
454 | - public function get_customers( $args = array() ) { |
|
454 | + public function get_customers($args = array()) { |
|
455 | 455 | /* @var WPDB $wpdb */ |
456 | 456 | global $wpdb; |
457 | 457 | |
@@ -463,21 +463,21 @@ discard block |
||
463 | 463 | 'order' => 'DESC' |
464 | 464 | ); |
465 | 465 | |
466 | - $args = wp_parse_args( $args, $defaults ); |
|
466 | + $args = wp_parse_args($args, $defaults); |
|
467 | 467 | |
468 | - if ( $args['number'] < 1 ) { |
|
468 | + if ($args['number'] < 1) { |
|
469 | 469 | $args['number'] = 999999999999; |
470 | 470 | } |
471 | 471 | |
472 | 472 | $where = ' WHERE 1=1 '; |
473 | 473 | |
474 | 474 | // specific customers |
475 | - if ( ! empty( $args['id'] ) ) { |
|
475 | + if ( ! empty($args['id'])) { |
|
476 | 476 | |
477 | - if ( is_array( $args['id'] ) ) { |
|
478 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
477 | + if (is_array($args['id'])) { |
|
478 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
479 | 479 | } else { |
480 | - $ids = intval( $args['id'] ); |
|
480 | + $ids = intval($args['id']); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -485,12 +485,12 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | // customers for specific user accounts |
488 | - if ( ! empty( $args['user_id'] ) ) { |
|
488 | + if ( ! empty($args['user_id'])) { |
|
489 | 489 | |
490 | - if ( is_array( $args['user_id'] ) ) { |
|
491 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
490 | + if (is_array($args['user_id'])) { |
|
491 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
492 | 492 | } else { |
493 | - $user_ids = intval( $args['user_id'] ); |
|
493 | + $user_ids = intval($args['user_id']); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -498,41 +498,41 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | //specific customers by email |
501 | - if( ! empty( $args['email'] ) ) { |
|
501 | + if ( ! empty($args['email'])) { |
|
502 | 502 | |
503 | - if( is_array( $args['email'] ) ) { |
|
503 | + if (is_array($args['email'])) { |
|
504 | 504 | |
505 | - $emails_count = count( $args['email'] ); |
|
506 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
507 | - $emails = implode( ', ', $emails_placeholder ); |
|
505 | + $emails_count = count($args['email']); |
|
506 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
507 | + $emails = implode(', ', $emails_placeholder); |
|
508 | 508 | |
509 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
509 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
510 | 510 | } else { |
511 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
511 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // specific customers by name |
516 | - if( ! empty( $args['name'] ) ) { |
|
517 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
516 | + if ( ! empty($args['name'])) { |
|
517 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // Customers created for a specific date or in a date range |
521 | - if ( ! empty( $args['date'] ) ) { |
|
521 | + if ( ! empty($args['date'])) { |
|
522 | 522 | |
523 | - if ( is_array( $args['date'] ) ) { |
|
523 | + if (is_array($args['date'])) { |
|
524 | 524 | |
525 | - if ( ! empty( $args['date']['start'] ) ) { |
|
525 | + if ( ! empty($args['date']['start'])) { |
|
526 | 526 | |
527 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
527 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
528 | 528 | |
529 | 529 | $where .= " AND `date_created` >= '{$start}'"; |
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - if ( ! empty( $args['date']['end'] ) ) { |
|
533 | + if ( ! empty($args['date']['end'])) { |
|
534 | 534 | |
535 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
535 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
536 | 536 | |
537 | 537 | $where .= " AND `date_created` <= '{$end}'"; |
538 | 538 | |
@@ -540,31 +540,31 @@ discard block |
||
540 | 540 | |
541 | 541 | } else { |
542 | 542 | |
543 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
544 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
545 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
543 | + $year = date('Y', strtotime($args['date'])); |
|
544 | + $month = date('m', strtotime($args['date'])); |
|
545 | + $day = date('d', strtotime($args['date'])); |
|
546 | 546 | |
547 | 547 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
548 | 548 | } |
549 | 549 | |
550 | 550 | } |
551 | 551 | |
552 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
552 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
553 | 553 | |
554 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
554 | + if ('purchase_value' == $args['orderby']) { |
|
555 | 555 | $args['orderby'] = 'purchase_value+0'; |
556 | 556 | } |
557 | 557 | |
558 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
558 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
559 | 559 | |
560 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
560 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
561 | 561 | |
562 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
563 | - $args['order'] = esc_sql( $args['order'] ); |
|
562 | + $args['orderby'] = esc_sql($args['orderby']); |
|
563 | + $args['order'] = esc_sql($args['order']); |
|
564 | 564 | |
565 | - if ( $customers === false ) { |
|
566 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
567 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
565 | + if ($customers === false) { |
|
566 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
567 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | return $customers; |
@@ -582,26 +582,26 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return int Total number of customers. |
584 | 584 | */ |
585 | - public function count( $args = array() ) { |
|
585 | + public function count($args = array()) { |
|
586 | 586 | /* @var WPDB $wpdb */ |
587 | 587 | global $wpdb; |
588 | 588 | |
589 | 589 | $where = ' WHERE 1=1 '; |
590 | 590 | |
591 | - if ( ! empty( $args['date'] ) ) { |
|
591 | + if ( ! empty($args['date'])) { |
|
592 | 592 | |
593 | - if ( is_array( $args['date'] ) ) { |
|
593 | + if (is_array($args['date'])) { |
|
594 | 594 | |
595 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
596 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
595 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
596 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
597 | 597 | |
598 | 598 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
599 | 599 | |
600 | 600 | } else { |
601 | 601 | |
602 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
603 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
604 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
602 | + $year = date('Y', strtotime($args['date'])); |
|
603 | + $month = date('m', strtotime($args['date'])); |
|
604 | + $day = date('d', strtotime($args['date'])); |
|
605 | 605 | |
606 | 606 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
607 | 607 | } |
@@ -609,16 +609,16 @@ discard block |
||
609 | 609 | } |
610 | 610 | |
611 | 611 | |
612 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
612 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
613 | 613 | |
614 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
614 | + $count = wp_cache_get($cache_key, 'customers'); |
|
615 | 615 | |
616 | - if ( $count === false ) { |
|
617 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
618 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
616 | + if ($count === false) { |
|
617 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
618 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
619 | 619 | } |
620 | 620 | |
621 | - return absint( $count ); |
|
621 | + return absint($count); |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | */ |
633 | 633 | public function create_table() { |
634 | 634 | |
635 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
635 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
636 | 636 | |
637 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
637 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
638 | 638 | id bigint(20) NOT NULL AUTO_INCREMENT, |
639 | 639 | user_id bigint(20) NOT NULL, |
640 | 640 | email varchar(50) NOT NULL, |
@@ -649,9 +649,9 @@ discard block |
||
649 | 649 | KEY user (user_id) |
650 | 650 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
651 | 651 | |
652 | - dbDelta( $sql ); |
|
652 | + dbDelta($sql); |
|
653 | 653 | |
654 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
654 | + update_option($this->table_name.'_db_version', $this->version); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * @return bool Returns if the customers table was installed and upgrade routine run. |
664 | 664 | */ |
665 | 665 | public function installed() { |
666 | - return $this->table_exists( $this->table_name ); |
|
666 | + return $this->table_exists($this->table_name); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function transactions_dropdown( $args = array() ) { |
|
38 | + public function transactions_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'transactions', |
@@ -45,34 +45,34 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => esc_html__( 'Select a transaction', 'give' ) |
|
48 | + 'placeholder' => esc_html__('Select a transaction', 'give') |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | 53 | |
54 | - $payments = new Give_Payments_Query( array( |
|
54 | + $payments = new Give_Payments_Query(array( |
|
55 | 55 | 'number' => $args['number'] |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | $payments = $payments->get_payments(); |
59 | 59 | |
60 | 60 | $options = array(); |
61 | 61 | |
62 | 62 | //Provide nice human readable options. |
63 | - if ( $payments ) { |
|
64 | - $options[0] = esc_html__( 'Select a donation', 'give' ); |
|
65 | - foreach ( $payments as $payment ) { |
|
63 | + if ($payments) { |
|
64 | + $options[0] = esc_html__('Select a donation', 'give'); |
|
65 | + foreach ($payments as $payment) { |
|
66 | 66 | |
67 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title); |
|
67 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | } else { |
71 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
71 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | - $output = $this->select( array( |
|
75 | + $output = $this->select(array( |
|
76 | 76 | 'name' => $args['name'], |
77 | 77 | 'selected' => $args['selected'], |
78 | 78 | 'id' => $args['id'], |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'select_atts' => $args['select_atts'], |
85 | 85 | 'show_option_all' => false, |
86 | 86 | 'show_option_none' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | 89 | return $output; |
90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Give forms dropdown. |
103 | 103 | */ |
104 | - public function forms_dropdown( $args = array() ) { |
|
104 | + public function forms_dropdown($args = array()) { |
|
105 | 105 | |
106 | 106 | $defaults = array( |
107 | 107 | 'name' => 'forms', |
@@ -111,43 +111,43 @@ discard block |
||
111 | 111 | 'selected' => 0, |
112 | 112 | 'chosen' => false, |
113 | 113 | 'number' => 30, |
114 | - 'placeholder' => esc_attr__( 'Select a Form', 'give' ) |
|
114 | + 'placeholder' => esc_attr__('Select a Form', 'give') |
|
115 | 115 | ); |
116 | 116 | |
117 | - $args = wp_parse_args( $args, $defaults ); |
|
117 | + $args = wp_parse_args($args, $defaults); |
|
118 | 118 | |
119 | - $forms = get_posts( array( |
|
119 | + $forms = get_posts(array( |
|
120 | 120 | 'post_type' => 'give_forms', |
121 | 121 | 'orderby' => 'title', |
122 | 122 | 'order' => 'ASC', |
123 | 123 | 'posts_per_page' => $args['number'] |
124 | - ) ); |
|
124 | + )); |
|
125 | 125 | |
126 | 126 | $options = array(); |
127 | 127 | |
128 | - if ( $forms ) { |
|
129 | - $options[0] = esc_attr__( 'Select a Form', 'give' ); |
|
130 | - foreach ( $forms as $form ) { |
|
131 | - $options[ absint( $form->ID ) ] = esc_html( $form->post_title ); |
|
128 | + if ($forms) { |
|
129 | + $options[0] = esc_attr__('Select a Form', 'give'); |
|
130 | + foreach ($forms as $form) { |
|
131 | + $options[absint($form->ID)] = esc_html($form->post_title); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
134 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // This ensures that any selected forms are included in the drop down |
138 | - if ( is_array( $args['selected'] ) ) { |
|
139 | - foreach ( $args['selected'] as $item ) { |
|
140 | - if ( ! in_array( $item, $options ) ) { |
|
141 | - $options[ $item ] = get_the_title( $item ); |
|
138 | + if (is_array($args['selected'])) { |
|
139 | + foreach ($args['selected'] as $item) { |
|
140 | + if ( ! in_array($item, $options)) { |
|
141 | + $options[$item] = get_the_title($item); |
|
142 | 142 | } |
143 | 143 | } |
144 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
145 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
146 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
144 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
145 | + if ( ! in_array($args['selected'], $options)) { |
|
146 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $output = $this->select( array( |
|
150 | + $output = $this->select(array( |
|
151 | 151 | 'name' => $args['name'], |
152 | 152 | 'selected' => $args['selected'], |
153 | 153 | 'id' => $args['id'], |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'placeholder' => $args['placeholder'], |
159 | 159 | 'show_option_all' => false, |
160 | 160 | 'show_option_none' => false |
161 | - ) ); |
|
161 | + )); |
|
162 | 162 | |
163 | 163 | return $output; |
164 | 164 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return string Donors dropdown. |
177 | 177 | */ |
178 | - public function donor_dropdown( $args = array() ) { |
|
178 | + public function donor_dropdown($args = array()) { |
|
179 | 179 | |
180 | 180 | $defaults = array( |
181 | 181 | 'name' => 'customers', |
@@ -184,38 +184,38 @@ discard block |
||
184 | 184 | 'multiple' => false, |
185 | 185 | 'selected' => 0, |
186 | 186 | 'chosen' => true, |
187 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
187 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
188 | 188 | 'number' => 30 |
189 | 189 | ); |
190 | 190 | |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args($args, $defaults); |
|
192 | 192 | |
193 | - $customers = Give()->customers->get_customers( array( |
|
193 | + $customers = Give()->customers->get_customers(array( |
|
194 | 194 | 'number' => $args['number'] |
195 | - ) ); |
|
195 | + )); |
|
196 | 196 | |
197 | 197 | $options = array(); |
198 | 198 | |
199 | - if ( $customers ) { |
|
200 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
201 | - foreach ( $customers as $customer ) { |
|
202 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
199 | + if ($customers) { |
|
200 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
201 | + foreach ($customers as $customer) { |
|
202 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
203 | 203 | } |
204 | 204 | } else { |
205 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
205 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( ! empty( $args['selected'] ) ) { |
|
208 | + if ( ! empty($args['selected'])) { |
|
209 | 209 | |
210 | 210 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
211 | 211 | |
212 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
212 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
213 | 213 | |
214 | - $customer = new Give_Customer( $args['selected'] ); |
|
214 | + $customer = new Give_Customer($args['selected']); |
|
215 | 215 | |
216 | - if ( $customer ) { |
|
216 | + if ($customer) { |
|
217 | 217 | |
218 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
218 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - $output = $this->select( array( |
|
226 | + $output = $this->select(array( |
|
227 | 227 | 'name' => $args['name'], |
228 | 228 | 'selected' => $args['selected'], |
229 | 229 | 'id' => $args['id'], |
230 | - 'class' => $args['class'] . ' give-customer-select', |
|
230 | + 'class' => $args['class'].' give-customer-select', |
|
231 | 231 | 'options' => $options, |
232 | 232 | 'multiple' => $args['multiple'], |
233 | 233 | 'chosen' => $args['chosen'], |
234 | 234 | 'show_option_all' => false, |
235 | 235 | 'show_option_none' => false |
236 | - ) ); |
|
236 | + )); |
|
237 | 237 | |
238 | 238 | return $output; |
239 | 239 | } |
@@ -251,21 +251,21 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return string Categories dropdown. |
253 | 253 | */ |
254 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) { |
|
255 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
254 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0) { |
|
255 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
256 | 256 | $options = array(); |
257 | 257 | |
258 | - foreach ( $categories as $category ) { |
|
259 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
258 | + foreach ($categories as $category) { |
|
259 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
260 | 260 | } |
261 | 261 | |
262 | - $output = $this->select( array( |
|
262 | + $output = $this->select(array( |
|
263 | 263 | 'name' => $name, |
264 | 264 | 'selected' => $selected, |
265 | 265 | 'options' => $options, |
266 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
266 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
267 | 267 | 'show_option_none' => false |
268 | - ) ); |
|
268 | + )); |
|
269 | 269 | |
270 | 270 | return $output; |
271 | 271 | } |
@@ -285,25 +285,25 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return string Years dropdown. |
287 | 287 | */ |
288 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
289 | - $current = date( 'Y' ); |
|
290 | - $start_year = $current - absint( $years_before ); |
|
291 | - $end_year = $current + absint( $years_after ); |
|
292 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
288 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
289 | + $current = date('Y'); |
|
290 | + $start_year = $current - absint($years_before); |
|
291 | + $end_year = $current + absint($years_after); |
|
292 | + $selected = empty($selected) ? date('Y') : $selected; |
|
293 | 293 | $options = array(); |
294 | 294 | |
295 | - while ( $start_year <= $end_year ) { |
|
296 | - $options[ absint( $start_year ) ] = $start_year; |
|
297 | - $start_year ++; |
|
295 | + while ($start_year <= $end_year) { |
|
296 | + $options[absint($start_year)] = $start_year; |
|
297 | + $start_year++; |
|
298 | 298 | } |
299 | 299 | |
300 | - $output = $this->select( array( |
|
300 | + $output = $this->select(array( |
|
301 | 301 | 'name' => $name, |
302 | 302 | 'selected' => $selected, |
303 | 303 | 'options' => $options, |
304 | 304 | 'show_option_all' => false, |
305 | 305 | 'show_option_none' => false |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | |
308 | 308 | return $output; |
309 | 309 | } |
@@ -321,23 +321,23 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string Months dropdown. |
323 | 323 | */ |
324 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
324 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
325 | 325 | $month = 1; |
326 | 326 | $options = array(); |
327 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
327 | + $selected = empty($selected) ? date('n') : $selected; |
|
328 | 328 | |
329 | - while ( $month <= 12 ) { |
|
330 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
331 | - $month ++; |
|
329 | + while ($month <= 12) { |
|
330 | + $options[absint($month)] = give_month_num_to_name($month); |
|
331 | + $month++; |
|
332 | 332 | } |
333 | 333 | |
334 | - $output = $this->select( array( |
|
334 | + $output = $this->select(array( |
|
335 | 335 | 'name' => $name, |
336 | 336 | 'selected' => $selected, |
337 | 337 | 'options' => $options, |
338 | 338 | 'show_option_all' => false, |
339 | 339 | 'show_option_none' => false |
340 | - ) ); |
|
340 | + )); |
|
341 | 341 | |
342 | 342 | return $output; |
343 | 343 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return string The dropdown. |
356 | 356 | */ |
357 | - public function select( $args = array() ) { |
|
357 | + public function select($args = array()) { |
|
358 | 358 | $defaults = array( |
359 | 359 | 'options' => array(), |
360 | 360 | 'name' => null, |
@@ -365,60 +365,60 @@ discard block |
||
365 | 365 | 'placeholder' => null, |
366 | 366 | 'multiple' => false, |
367 | 367 | 'select_atts' => false, |
368 | - 'show_option_all' => esc_html__( 'All', 'give' ), |
|
369 | - 'show_option_none' => esc_html__( 'None', 'give' ) |
|
368 | + 'show_option_all' => esc_html__('All', 'give'), |
|
369 | + 'show_option_none' => esc_html__('None', 'give') |
|
370 | 370 | ); |
371 | 371 | |
372 | - $args = wp_parse_args( $args, $defaults ); |
|
372 | + $args = wp_parse_args($args, $defaults); |
|
373 | 373 | |
374 | - if ( $args['multiple'] ) { |
|
374 | + if ($args['multiple']) { |
|
375 | 375 | $multiple = ' MULTIPLE'; |
376 | 376 | } else { |
377 | 377 | $multiple = ''; |
378 | 378 | } |
379 | 379 | |
380 | - if ( $args['chosen'] ) { |
|
380 | + if ($args['chosen']) { |
|
381 | 381 | $args['class'] .= ' give-select-chosen'; |
382 | 382 | } |
383 | 383 | |
384 | - if ( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '">'; |
|
391 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'">'; |
|
392 | 392 | |
393 | - if ( $args['show_option_all'] ) { |
|
394 | - if ( $args['multiple'] ) { |
|
395 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
393 | + if ($args['show_option_all']) { |
|
394 | + if ($args['multiple']) { |
|
395 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
396 | 396 | } else { |
397 | - $selected = selected( $args['selected'], 0, false ); |
|
397 | + $selected = selected($args['selected'], 0, false); |
|
398 | 398 | } |
399 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
399 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $args['options'] ) ) { |
|
402 | + if ( ! empty($args['options'])) { |
|
403 | 403 | |
404 | - if ( $args['show_option_none'] ) { |
|
405 | - if ( $args['multiple'] ) { |
|
406 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
404 | + if ($args['show_option_none']) { |
|
405 | + if ($args['multiple']) { |
|
406 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
407 | 407 | } else { |
408 | - $selected = selected( $args['selected'], - 1, false ); |
|
408 | + $selected = selected($args['selected'], - 1, false); |
|
409 | 409 | } |
410 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
410 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
411 | 411 | } |
412 | 412 | |
413 | - foreach ( $args['options'] as $key => $option ) { |
|
413 | + foreach ($args['options'] as $key => $option) { |
|
414 | 414 | |
415 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
416 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
415 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
416 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
417 | 417 | } else { |
418 | - $selected = selected( $args['selected'], $key, false ); |
|
418 | + $selected = selected($args['selected'], $key, false); |
|
419 | 419 | } |
420 | 420 | |
421 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
421 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return string The checkbox. |
441 | 441 | */ |
442 | - public function checkbox( $args = array() ) { |
|
442 | + public function checkbox($args = array()) { |
|
443 | 443 | $defaults = array( |
444 | 444 | 'name' => null, |
445 | 445 | 'current' => null, |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | |
453 | - $args = wp_parse_args( $args, $defaults ); |
|
453 | + $args = wp_parse_args($args, $defaults); |
|
454 | 454 | |
455 | 455 | $options = ''; |
456 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
456 | + if ( ! empty($args['options']['disabled'])) { |
|
457 | 457 | $options .= ' disabled="disabled"'; |
458 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
458 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
459 | 459 | $options .= ' readonly'; |
460 | 460 | } |
461 | 461 | |
462 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
462 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
463 | 463 | |
464 | 464 | return $output; |
465 | 465 | } |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return string The text field. |
478 | 478 | */ |
479 | - public function text( $args = array() ) { |
|
479 | + public function text($args = array()) { |
|
480 | 480 | // Backwards compatibility |
481 | - if ( func_num_args() > 1 ) { |
|
481 | + if (func_num_args() > 1) { |
|
482 | 482 | $args = func_get_args(); |
483 | 483 | |
484 | 484 | $name = $args[0]; |
485 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
486 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
487 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
485 | + $value = isset($args[1]) ? $args[1] : ''; |
|
486 | + $label = isset($args[2]) ? $args[2] : ''; |
|
487 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | $defaults = array( |
491 | - 'name' => isset( $name ) ? $name : 'text', |
|
492 | - 'value' => isset( $value ) ? $value : null, |
|
493 | - 'label' => isset( $label ) ? $label : null, |
|
494 | - 'desc' => isset( $desc ) ? $desc : null, |
|
491 | + 'name' => isset($name) ? $name : 'text', |
|
492 | + 'value' => isset($value) ? $value : null, |
|
493 | + 'label' => isset($label) ? $label : null, |
|
494 | + 'desc' => isset($desc) ? $desc : null, |
|
495 | 495 | 'placeholder' => '', |
496 | 496 | 'class' => 'regular-text', |
497 | 497 | 'disabled' => false, |
@@ -499,29 +499,29 @@ discard block |
||
499 | 499 | 'data' => false |
500 | 500 | ); |
501 | 501 | |
502 | - $args = wp_parse_args( $args, $defaults ); |
|
502 | + $args = wp_parse_args($args, $defaults); |
|
503 | 503 | |
504 | 504 | $disabled = ''; |
505 | - if ( $args['disabled'] ) { |
|
505 | + if ($args['disabled']) { |
|
506 | 506 | $disabled = ' disabled="disabled"'; |
507 | 507 | } |
508 | 508 | |
509 | 509 | $data = ''; |
510 | - if ( ! empty( $args['data'] ) ) { |
|
511 | - foreach ( $args['data'] as $key => $value ) { |
|
512 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
510 | + if ( ! empty($args['data'])) { |
|
511 | + foreach ($args['data'] as $key => $value) { |
|
512 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
516 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
517 | 517 | |
518 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
518 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
519 | 519 | |
520 | - if ( ! empty( $args['desc'] ) ) { |
|
521 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
520 | + if ( ! empty($args['desc'])) { |
|
521 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
522 | 522 | } |
523 | 523 | |
524 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
524 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
525 | 525 | |
526 | 526 | $output .= '</span>'; |
527 | 527 | |
@@ -540,15 +540,15 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string The date picker. |
542 | 542 | */ |
543 | - public function date_field( $args = array() ) { |
|
543 | + public function date_field($args = array()) { |
|
544 | 544 | |
545 | - if ( empty( $args['class'] ) ) { |
|
545 | + if (empty($args['class'])) { |
|
546 | 546 | $args['class'] = 'give_datepicker'; |
547 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
547 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
548 | 548 | $args['class'] .= ' give_datepicker'; |
549 | 549 | } |
550 | 550 | |
551 | - return $this->text( $args ); |
|
551 | + return $this->text($args); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string The textarea. |
565 | 565 | */ |
566 | - public function textarea( $args = array() ) { |
|
566 | + public function textarea($args = array()) { |
|
567 | 567 | $defaults = array( |
568 | 568 | 'name' => 'textarea', |
569 | 569 | 'value' => null, |
@@ -573,21 +573,21 @@ discard block |
||
573 | 573 | 'disabled' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | 578 | $disabled = ''; |
579 | - if ( $args['disabled'] ) { |
|
579 | + if ($args['disabled']) { |
|
580 | 580 | $disabled = ' disabled="disabled"'; |
581 | 581 | } |
582 | 582 | |
583 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
583 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
584 | 584 | |
585 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
585 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
586 | 586 | |
587 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
587 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
588 | 588 | |
589 | - if ( ! empty( $args['desc'] ) ) { |
|
590 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
589 | + if ( ! empty($args['desc'])) { |
|
590 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | $output .= '</span>'; |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return string The text field with ajax search. |
609 | 609 | */ |
610 | - public function ajax_user_search( $args = array() ) { |
|
610 | + public function ajax_user_search($args = array()) { |
|
611 | 611 | |
612 | 612 | $defaults = array( |
613 | 613 | 'name' => 'user_id', |
614 | 614 | 'value' => null, |
615 | - 'placeholder' => esc_attr__( 'Enter username', 'give' ), |
|
615 | + 'placeholder' => esc_attr__('Enter username', 'give'), |
|
616 | 616 | 'label' => null, |
617 | 617 | 'desc' => null, |
618 | 618 | 'class' => '', |
@@ -621,13 +621,13 @@ discard block |
||
621 | 621 | 'data' => false |
622 | 622 | ); |
623 | 623 | |
624 | - $args = wp_parse_args( $args, $defaults ); |
|
624 | + $args = wp_parse_args($args, $defaults); |
|
625 | 625 | |
626 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
626 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
627 | 627 | |
628 | 628 | $output = '<span class="give_user_search_wrap">'; |
629 | - $output .= $this->text( $args ); |
|
630 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="' . esc_attr__( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
629 | + $output .= $this->text($args); |
|
630 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="'.esc_attr__('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
631 | 631 | $output .= '</span>'; |
632 | 632 | |
633 | 633 | return $output; |