@@ -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 | |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool $ret True if guest checkout is enabled, false otherwise |
30 | 30 | */ |
31 | -function give_no_guest_checkout( $form_id ) { |
|
31 | +function give_no_guest_checkout($form_id) { |
|
32 | 32 | |
33 | 33 | $backtrace = debug_backtrace(); |
34 | 34 | |
35 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
35 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
36 | 36 | |
37 | - $ret = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
37 | + $ret = get_post_meta($form_id, '_give_logged_in_only', true); |
|
38 | 38 | |
39 | - return (bool) apply_filters( 'give_no_guest_checkout', $ret ); |
|
39 | + return (bool) apply_filters('give_no_guest_checkout', $ret); |
|
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -661,7 +661,7 @@ |
||
661 | 661 | * |
662 | 662 | * @since 1.6.3 |
663 | 663 | * |
664 | - * @param $pending_reason |
|
664 | + * @param string $pending_reason |
|
665 | 665 | * |
666 | 666 | * @return string |
667 | 667 | */ |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Payment. |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_payment( $payment_data ) { |
|
35 | +function give_process_paypal_payment($payment_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $payment_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($payment_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
42 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
41 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
42 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
43 | 43 | |
44 | 44 | // Collect Give's payment data. |
45 | 45 | $insert_payment_args = array( |
@@ -57,101 +57,101 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment. |
60 | - $payment_id = give_insert_payment( $insert_payment_args ); |
|
60 | + $payment_id = give_insert_payment($insert_payment_args); |
|
61 | 61 | |
62 | 62 | // Check payment. |
63 | - if ( ! $payment_id ) { |
|
63 | + if ( ! $payment_id) { |
|
64 | 64 | // Record the error. |
65 | 65 | give_record_gateway_error( |
66 | - esc_html__( 'Payment Error', 'give' ), |
|
66 | + esc_html__('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment_id |
73 | 73 | ); |
74 | 74 | // Problems? Send back. |
75 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
76 | 76 | |
77 | 77 | } else { |
78 | 78 | |
79 | 79 | // Only send to PayPal if the pending payment is created successfully. |
80 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
80 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
81 | 81 | |
82 | 82 | // Get the success url. |
83 | - $return_url = add_query_arg( array( |
|
83 | + $return_url = add_query_arg(array( |
|
84 | 84 | 'payment-confirmation' => 'paypal', |
85 | 85 | 'payment-id' => $payment_id |
86 | 86 | |
87 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
87 | + ), get_permalink(give_get_option('success_page'))); |
|
88 | 88 | |
89 | 89 | // Get the PayPal redirect uri. |
90 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
90 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
91 | 91 | |
92 | 92 | //Item name - pass level name if variable priced. |
93 | 93 | $item_name = $payment_data['post_data']['give-form-title']; |
94 | 94 | |
95 | 95 | //Verify has variable prices. |
96 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
96 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
97 | 97 | |
98 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
98 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
100 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
101 | 101 | |
102 | 102 | //Donation given doesn't match selected level (must be a custom amount). |
103 | - if ( $price_level_amount != give_sanitize_amount( $payment_data['price'] ) ) { |
|
104 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
103 | + if ($price_level_amount != give_sanitize_amount($payment_data['price'])) { |
|
104 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
105 | 105 | //user custom amount text if any, fallback to default if not. |
106 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
106 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
107 | 107 | |
108 | 108 | } //Is there any donation level text? |
109 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
110 | - $item_name .= ' - ' . $item_price_level_text; |
|
109 | + elseif ( ! empty($item_price_level_text)) { |
|
110 | + $item_name .= ' - '.$item_price_level_text; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } //Single donation: Custom Amount. |
114 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $payment_data['price'] ) ) { |
|
115 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
114 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($payment_data['price'])) { |
|
115 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
116 | 116 | //user custom amount text if any, fallback to default if not. |
117 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
117 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Setup PayPal API params. |
121 | 121 | $paypal_args = array( |
122 | - 'business' => give_get_option( 'paypal_email', false ), |
|
122 | + 'business' => give_get_option('paypal_email', false), |
|
123 | 123 | 'first_name' => $payment_data['user_info']['first_name'], |
124 | 124 | 'last_name' => $payment_data['user_info']['last_name'], |
125 | 125 | 'email' => $payment_data['user_email'], |
126 | 126 | 'invoice' => $payment_data['purchase_key'], |
127 | 127 | 'amount' => $payment_data['price'], |
128 | - 'item_name' => stripslashes( $item_name ), |
|
128 | + 'item_name' => stripslashes($item_name), |
|
129 | 129 | 'no_shipping' => '1', |
130 | 130 | 'shipping' => '0', |
131 | 131 | 'no_note' => '1', |
132 | 132 | 'currency_code' => give_get_currency(), |
133 | - 'charset' => get_bloginfo( 'charset' ), |
|
133 | + 'charset' => get_bloginfo('charset'), |
|
134 | 134 | 'custom' => $payment_id, |
135 | 135 | 'rm' => '2', |
136 | 136 | 'return' => $return_url, |
137 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
137 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
138 | 138 | 'notify_url' => $listener_url, |
139 | 139 | 'page_style' => give_get_paypal_page_style(), |
140 | - 'cbt' => get_bloginfo( 'name' ), |
|
140 | + 'cbt' => get_bloginfo('name'), |
|
141 | 141 | 'bn' => 'givewp_SP' |
142 | 142 | ); |
143 | 143 | |
144 | 144 | //Add user address if present. |
145 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
146 | - $paypal_args['address1'] = isset( $payment_data['user_info']['address']['line1'] ) ? $payment_data['user_info']['address']['line1'] : ''; |
|
147 | - $paypal_args['address2'] = isset( $payment_data['user_info']['address']['line2'] ) ? $payment_data['user_info']['address']['line2'] : ''; |
|
148 | - $paypal_args['city'] = isset( $payment_data['user_info']['address']['city'] ) ? $payment_data['user_info']['address']['city'] : ''; |
|
149 | - $paypal_args['state'] = isset( $payment_data['user_info']['address']['state'] ) ? $payment_data['user_info']['address']['state'] : ''; |
|
150 | - $paypal_args['country'] = isset( $payment_data['user_info']['address']['country'] ) ? $payment_data['user_info']['address']['country'] : ''; |
|
145 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
146 | + $paypal_args['address1'] = isset($payment_data['user_info']['address']['line1']) ? $payment_data['user_info']['address']['line1'] : ''; |
|
147 | + $paypal_args['address2'] = isset($payment_data['user_info']['address']['line2']) ? $payment_data['user_info']['address']['line2'] : ''; |
|
148 | + $paypal_args['city'] = isset($payment_data['user_info']['address']['city']) ? $payment_data['user_info']['address']['city'] : ''; |
|
149 | + $paypal_args['state'] = isset($payment_data['user_info']['address']['state']) ? $payment_data['user_info']['address']['state'] : ''; |
|
150 | + $paypal_args['country'] = isset($payment_data['user_info']['address']['country']) ? $payment_data['user_info']['address']['country'] : ''; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | //Donations or regular transactions? |
154 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
154 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
155 | 155 | $paypal_extra_args = array( |
156 | 156 | 'cmd' => '_xclick', |
157 | 157 | ); |
@@ -161,23 +161,23 @@ discard block |
||
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
165 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
164 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
165 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
166 | 166 | |
167 | 167 | // Build query. |
168 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
168 | + $paypal_redirect .= http_build_query($paypal_args); |
|
169 | 169 | |
170 | 170 | // Fix for some sites that encode the entities. |
171 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
171 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
172 | 172 | |
173 | 173 | // Redirect to PayPal. |
174 | - wp_redirect( $paypal_redirect ); |
|
174 | + wp_redirect($paypal_redirect); |
|
175 | 175 | exit; |
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | 179 | |
180 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
180 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function give_listen_for_paypal_ipn() { |
189 | 189 | // Regular PayPal IPN |
190 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
190 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
191 | 191 | /** |
192 | 192 | * Fires while verifying PayPal IPN |
193 | 193 | * |
194 | 194 | * @since 1.0 |
195 | 195 | */ |
196 | - do_action( 'give_verify_paypal_ipn' ); |
|
196 | + do_action('give_verify_paypal_ipn'); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
200 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Process PayPal IPN |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | function give_process_paypal_ipn() { |
209 | 209 | |
210 | 210 | // Check the request method is POST |
211 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
211 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | $post_data = ''; |
217 | 217 | |
218 | 218 | // Fallback just in case post_max_size is lower than needed |
219 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
220 | - $post_data = file_get_contents( 'php://input' ); |
|
219 | + if (ini_get('allow_url_fopen')) { |
|
220 | + $post_data = file_get_contents('php://input'); |
|
221 | 221 | } else { |
222 | 222 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
223 | - ini_set( 'post_max_size', '12M' ); |
|
223 | + ini_set('post_max_size', '12M'); |
|
224 | 224 | } |
225 | 225 | // Start the encoded data collection with notification command |
226 | 226 | $encoded_data = 'cmd=_notify-validate'; |
@@ -229,40 +229,40 @@ discard block |
||
229 | 229 | $arg_separator = give_get_php_arg_separator_output(); |
230 | 230 | |
231 | 231 | // Verify there is a post_data |
232 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
232 | + if ($post_data || strlen($post_data) > 0) { |
|
233 | 233 | // Append the data |
234 | - $encoded_data .= $arg_separator . $post_data; |
|
234 | + $encoded_data .= $arg_separator.$post_data; |
|
235 | 235 | } else { |
236 | 236 | // Check if POST is empty |
237 | - if ( empty( $_POST ) ) { |
|
237 | + if (empty($_POST)) { |
|
238 | 238 | // Nothing to do |
239 | 239 | return; |
240 | 240 | } else { |
241 | 241 | // Loop through each POST |
242 | - foreach ( $_POST as $key => $value ) { |
|
242 | + foreach ($_POST as $key => $value) { |
|
243 | 243 | // Encode the value and append the data. |
244 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
244 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | // Convert collected post data to an array. |
250 | - parse_str( $encoded_data, $encoded_data_array ); |
|
250 | + parse_str($encoded_data, $encoded_data_array); |
|
251 | 251 | |
252 | - foreach ( $encoded_data_array as $key => $value ) { |
|
252 | + foreach ($encoded_data_array as $key => $value) { |
|
253 | 253 | |
254 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
255 | - $new_key = str_replace( '&', '&', $key ); |
|
256 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
254 | + if (false !== strpos($key, 'amp;')) { |
|
255 | + $new_key = str_replace('&', '&', $key); |
|
256 | + $new_key = str_replace('amp;', '&', $new_key); |
|
257 | 257 | |
258 | - unset( $encoded_data_array[ $key ] ); |
|
259 | - $encoded_data_array[ $new_key ] = $value; |
|
258 | + unset($encoded_data_array[$key]); |
|
259 | + $encoded_data_array[$new_key] = $value; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | 264 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
265 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
265 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
266 | 266 | |
267 | 267 | $remote_post_vars = array( |
268 | 268 | 'method' => 'POST', |
@@ -282,28 +282,28 @@ discard block |
||
282 | 282 | ); |
283 | 283 | |
284 | 284 | // Validate the IPN. |
285 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
285 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
286 | 286 | |
287 | - if ( is_wp_error( $api_response ) ) { |
|
287 | + if (is_wp_error($api_response)) { |
|
288 | 288 | give_record_gateway_error( |
289 | - esc_html__( 'IPN Error', 'give' ), |
|
289 | + esc_html__('IPN Error', 'give'), |
|
290 | 290 | sprintf( |
291 | 291 | /* translators: %s: Paypal IPN response */ |
292 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
293 | - json_encode( $api_response ) |
|
292 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
293 | + json_encode($api_response) |
|
294 | 294 | ) |
295 | 295 | ); |
296 | 296 | |
297 | 297 | return; // Something went wrong |
298 | 298 | } |
299 | 299 | |
300 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
300 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
301 | 301 | give_record_gateway_error( |
302 | - esc_html__( 'IPN Error', 'give' ), |
|
302 | + esc_html__('IPN Error', 'give'), |
|
303 | 303 | sprintf( |
304 | 304 | /* translators: %s: Paypal IPN response */ |
305 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
306 | - json_encode( $api_response ) |
|
305 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
306 | + json_encode($api_response) |
|
307 | 307 | ) |
308 | 308 | ); |
309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | // Check if $post_data_array has been populated |
316 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
316 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | 'payment_status' => '' |
323 | 323 | ); |
324 | 324 | |
325 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
325 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
326 | 326 | |
327 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
327 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
328 | 328 | $txn_type = $encoded_data_array['txn_type']; |
329 | 329 | |
330 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
330 | + if (has_action('give_paypal_'.$txn_type)) { |
|
331 | 331 | /** |
332 | 332 | * Fires while processing PayPal IPN $txn_type. |
333 | 333 | * |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param array $encoded_data_array Encoded data. |
339 | 339 | * @param int $payment_id Payment id. |
340 | 340 | */ |
341 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
341 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
342 | 342 | } else { |
343 | 343 | /** |
344 | 344 | * Fires while process PayPal IPN. |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | * @param array $encoded_data_array Encoded data. |
351 | 351 | * @param int $payment_id Payment id. |
352 | 352 | */ |
353 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
353 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
354 | 354 | } |
355 | 355 | exit; |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
358 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Process web accept (one time) payment IPNs. |
@@ -367,128 +367,128 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return void |
369 | 369 | */ |
370 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
370 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
371 | 371 | |
372 | 372 | //Only allow through these transaction types. |
373 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower( $data['payment_status'] ) != 'refunded' ) { |
|
373 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower($data['payment_status']) != 'refunded') { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | //Need $payment_id to continue. |
378 | - if ( empty( $payment_id ) ) { |
|
378 | + if (empty($payment_id)) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Collect donation payment details. |
383 | 383 | $paypal_amount = $data['mc_gross']; |
384 | - $payment_status = strtolower( $data['payment_status'] ); |
|
385 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
386 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
387 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
384 | + $payment_status = strtolower($data['payment_status']); |
|
385 | + $currency_code = strtolower($data['mc_currency']); |
|
386 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
387 | + $payment_meta = give_get_payment_meta($payment_id); |
|
388 | 388 | |
389 | 389 | // Must be a PayPal standard IPN. |
390 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
390 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
391 | 391 | return; |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Verify payment recipient |
395 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
395 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
396 | 396 | |
397 | 397 | give_record_gateway_error( |
398 | - esc_html__( 'IPN Error', 'give' ), |
|
398 | + esc_html__('IPN Error', 'give'), |
|
399 | 399 | sprintf( |
400 | 400 | /* translators: %s: Paypal IPN response */ |
401 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
402 | - json_encode( $data ) |
|
401 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
402 | + json_encode($data) |
|
403 | 403 | ), |
404 | 404 | $payment_id |
405 | 405 | ); |
406 | - give_update_payment_status( $payment_id, 'failed' ); |
|
407 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
406 | + give_update_payment_status($payment_id, 'failed'); |
|
407 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
408 | 408 | |
409 | 409 | return; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Verify payment currency. |
413 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
413 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
414 | 414 | |
415 | 415 | give_record_gateway_error( |
416 | - esc_html__( 'IPN Error', 'give' ), |
|
416 | + esc_html__('IPN Error', 'give'), |
|
417 | 417 | sprintf( |
418 | 418 | /* translators: %s: Paypal IPN response */ |
419 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
420 | - json_encode( $data ) |
|
419 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
420 | + json_encode($data) |
|
421 | 421 | ), |
422 | 422 | $payment_id |
423 | 423 | ); |
424 | - give_update_payment_status( $payment_id, 'failed' ); |
|
425 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
424 | + give_update_payment_status($payment_id, 'failed'); |
|
425 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
426 | 426 | |
427 | 427 | return; |
428 | 428 | } |
429 | 429 | |
430 | 430 | //Process refunds & reversed. |
431 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
432 | - give_process_paypal_refund( $data, $payment_id ); |
|
431 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
432 | + give_process_paypal_refund($data, $payment_id); |
|
433 | 433 | |
434 | 434 | return; |
435 | 435 | } |
436 | 436 | |
437 | 437 | // Only complete payments once. |
438 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
438 | + if (get_post_status($payment_id) == 'publish') { |
|
439 | 439 | return; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // Retrieve the total donation amount (before PayPal). |
443 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
443 | + $payment_amount = give_get_payment_amount($payment_id); |
|
444 | 444 | |
445 | 445 | //Check that the donation PP and local db amounts match. |
446 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
446 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
447 | 447 | // The prices don't match |
448 | 448 | give_record_gateway_error( |
449 | - esc_html__( 'IPN Error', 'give' ), |
|
449 | + esc_html__('IPN Error', 'give'), |
|
450 | 450 | sprintf( |
451 | 451 | /* translators: %s: Paypal IPN response */ |
452 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
453 | - json_encode( $data ) |
|
452 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
453 | + json_encode($data) |
|
454 | 454 | ), |
455 | 455 | $payment_id |
456 | 456 | ); |
457 | - give_update_payment_status( $payment_id, 'failed' ); |
|
458 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
457 | + give_update_payment_status($payment_id, 'failed'); |
|
458 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
459 | 459 | |
460 | 460 | return; |
461 | 461 | } |
462 | 462 | |
463 | 463 | //Process completed donations. |
464 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
464 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
465 | 465 | |
466 | 466 | give_insert_payment_note( |
467 | 467 | $payment_id, |
468 | 468 | sprintf( |
469 | 469 | /* translators: %s: Paypal transaction ID */ |
470 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
470 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
471 | 471 | $data['txn_id'] |
472 | 472 | ) |
473 | 473 | ); |
474 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
475 | - give_update_payment_status( $payment_id, 'publish' ); |
|
474 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
475 | + give_update_payment_status($payment_id, 'publish'); |
|
476 | 476 | |
477 | - } elseif ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
477 | + } elseif ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
478 | 478 | |
479 | 479 | // Look for possible pending reasons, such as an echeck. |
480 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
480 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
481 | 481 | |
482 | - if ( ! empty( $note ) ) { |
|
482 | + if ( ! empty($note)) { |
|
483 | 483 | |
484 | - give_insert_payment_note( $payment_id, $note ); |
|
484 | + give_insert_payment_note($payment_id, $note); |
|
485 | 485 | |
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | 489 | } |
490 | 490 | |
491 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
491 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
492 | 492 | |
493 | 493 | /** |
494 | 494 | * Process PayPal IPN Refunds |
@@ -500,28 +500,28 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return void |
502 | 502 | */ |
503 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
503 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
504 | 504 | |
505 | 505 | // Collect payment details |
506 | 506 | |
507 | - if ( empty( $payment_id ) ) { |
|
507 | + if (empty($payment_id)) { |
|
508 | 508 | return; |
509 | 509 | } |
510 | 510 | |
511 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
511 | + if (get_post_status($payment_id) == 'refunded') { |
|
512 | 512 | return; // Only refund payments once |
513 | 513 | } |
514 | 514 | |
515 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
515 | + $payment_amount = give_get_payment_amount($payment_id); |
|
516 | 516 | $refund_amount = $data['payment_gross'] * - 1; |
517 | 517 | |
518 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
518 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
519 | 519 | |
520 | 520 | give_insert_payment_note( |
521 | 521 | $payment_id, |
522 | 522 | sprintf( |
523 | 523 | /* translators: %s: Paypal parent transaction ID */ |
524 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
524 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
525 | 525 | $data['parent_txn_id'] |
526 | 526 | ) |
527 | 527 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $payment_id, |
535 | 535 | sprintf( |
536 | 536 | /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
537 | - esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), |
|
537 | + esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), |
|
538 | 538 | $data['parent_txn_id'], |
539 | 539 | $data['reason_code'] |
540 | 540 | ) |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $payment_id, |
544 | 544 | sprintf( |
545 | 545 | /* translators: %s: Paypal transaction ID */ |
546 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
546 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
547 | 547 | $data['txn_id'] |
548 | 548 | ) |
549 | 549 | ); |
550 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
550 | + give_update_payment_status($payment_id, 'refunded'); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -559,24 +559,24 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return string |
561 | 561 | */ |
562 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
562 | +function give_get_paypal_redirect($ssl_check = false) { |
|
563 | 563 | |
564 | - if ( is_ssl() || ! $ssl_check ) { |
|
564 | + if (is_ssl() || ! $ssl_check) { |
|
565 | 565 | $protocal = 'https://'; |
566 | 566 | } else { |
567 | 567 | $protocal = 'http://'; |
568 | 568 | } |
569 | 569 | |
570 | 570 | // Check the current payment mode |
571 | - if ( give_is_test_mode() ) { |
|
571 | + if (give_is_test_mode()) { |
|
572 | 572 | // Test mode |
573 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
573 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
574 | 574 | } else { |
575 | 575 | // Live mode |
576 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
576 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
577 | 577 | } |
578 | 578 | |
579 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
579 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -586,9 +586,9 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | */ |
588 | 588 | function give_get_paypal_page_style() { |
589 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
589 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
590 | 590 | |
591 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
591 | + return apply_filters('give_paypal_page_style', $page_style); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -603,26 +603,26 @@ discard block |
||
603 | 603 | * @return string |
604 | 604 | * |
605 | 605 | */ |
606 | -function give_paypal_success_page_content( $content ) { |
|
606 | +function give_paypal_success_page_content($content) { |
|
607 | 607 | |
608 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
608 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
609 | 609 | return $content; |
610 | 610 | } |
611 | 611 | |
612 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
612 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
613 | 613 | |
614 | - if ( ! $payment_id ) { |
|
614 | + if ( ! $payment_id) { |
|
615 | 615 | $session = give_get_purchase_session(); |
616 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
616 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
617 | 617 | } |
618 | 618 | |
619 | - $payment = get_post( $payment_id ); |
|
620 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
619 | + $payment = get_post($payment_id); |
|
620 | + if ($payment && 'pending' == $payment->post_status) { |
|
621 | 621 | |
622 | 622 | // Payment is still pending so show processing indicator to fix the race condition. |
623 | 623 | ob_start(); |
624 | 624 | |
625 | - give_get_template_part( 'payment', 'processing' ); |
|
625 | + give_get_template_part('payment', 'processing'); |
|
626 | 626 | |
627 | 627 | $content = ob_get_clean(); |
628 | 628 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | |
633 | 633 | } |
634 | 634 | |
635 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
635 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
636 | 636 | |
637 | 637 | /** |
638 | 638 | * Given a Payment ID, extract the transaction ID |
@@ -643,22 +643,22 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return string Transaction ID |
645 | 645 | */ |
646 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
646 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
647 | 647 | |
648 | 648 | $transaction_id = ''; |
649 | - $notes = give_get_payment_notes( $payment_id ); |
|
649 | + $notes = give_get_payment_notes($payment_id); |
|
650 | 650 | |
651 | - foreach ( $notes as $note ) { |
|
652 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
651 | + foreach ($notes as $note) { |
|
652 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
653 | 653 | $transaction_id = $match[1]; |
654 | 654 | continue; |
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
658 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
659 | 659 | } |
660 | 660 | |
661 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
661 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
662 | 662 | |
663 | 663 | /** |
664 | 664 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -670,16 +670,16 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return string A link to the PayPal transaction details |
672 | 672 | */ |
673 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
673 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
674 | 674 | |
675 | 675 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
676 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
676 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
677 | 677 | |
678 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
678 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
682 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
683 | 683 | |
684 | 684 | |
685 | 685 | /** |
@@ -691,64 +691,64 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return string |
693 | 693 | */ |
694 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
694 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
695 | 695 | |
696 | 696 | $note = ''; |
697 | 697 | |
698 | - switch ( $pending_reason ) { |
|
698 | + switch ($pending_reason) { |
|
699 | 699 | |
700 | 700 | case 'echeck' : |
701 | 701 | |
702 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
702 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
703 | 703 | |
704 | 704 | break; |
705 | 705 | |
706 | 706 | case 'address' : |
707 | 707 | |
708 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
708 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
709 | 709 | |
710 | 710 | break; |
711 | 711 | |
712 | 712 | case 'intl' : |
713 | 713 | |
714 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
714 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
715 | 715 | |
716 | 716 | break; |
717 | 717 | |
718 | 718 | case 'multi-currency' : |
719 | 719 | |
720 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
720 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
721 | 721 | |
722 | 722 | break; |
723 | 723 | |
724 | 724 | case 'paymentreview' : |
725 | 725 | case 'regulatory_review' : |
726 | 726 | |
727 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
727 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
728 | 728 | |
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'unilateral' : |
732 | 732 | |
733 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
733 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
734 | 734 | |
735 | 735 | break; |
736 | 736 | |
737 | 737 | case 'upgrade' : |
738 | 738 | |
739 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
739 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
740 | 740 | |
741 | 741 | break; |
742 | 742 | |
743 | 743 | case 'verify' : |
744 | 744 | |
745 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
745 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
746 | 746 | |
747 | 747 | break; |
748 | 748 | |
749 | 749 | case 'other' : |
750 | 750 | |
751 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
751 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
752 | 752 | |
753 | 753 | break; |
754 | 754 |
@@ -731,7 +731,7 @@ |
||
731 | 731 | * @param bool $colon Check if add colon between heading and message. |
732 | 732 | * @param string $color Heading color. |
733 | 733 | * |
734 | - * @return mixed |
|
734 | + * @return string |
|
735 | 735 | */ |
736 | 736 | private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
737 | 737 | // Add colon. |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | // Add give command. |
15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @subcommand logo |
70 | 70 | */ |
71 | - public function ascii( $args, $assoc_args ) { |
|
72 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
71 | + public function ascii($args, $assoc_args) { |
|
72 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -94,54 +94,54 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @subcommand details |
96 | 96 | */ |
97 | - public function details( $args, $assoc_args ) { |
|
97 | + public function details($args, $assoc_args) { |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Plugin Information |
101 | 101 | */ |
102 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
102 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * General Information. |
106 | 106 | */ |
107 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
107 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
108 | 108 | |
109 | - $success_page = give_get_option( 'success_page' ); |
|
110 | - $failure_page = give_get_option( 'failure_page' ); |
|
111 | - $history_page = give_get_option( 'history_page' ); |
|
109 | + $success_page = give_get_option('success_page'); |
|
110 | + $failure_page = give_get_option('failure_page'); |
|
111 | + $history_page = give_get_option('history_page'); |
|
112 | 112 | |
113 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
114 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
115 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
116 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
113 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
114 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
115 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
116 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Currency Information. |
120 | 120 | */ |
121 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
121 | + $default_gateway = give_get_option('default_gateway'); |
|
122 | 122 | |
123 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
123 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
124 | 124 | |
125 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
126 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
127 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
128 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
129 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
130 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
131 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
125 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
126 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
127 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
128 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
129 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
130 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
131 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
132 | 132 | |
133 | 133 | // Payment gateways Information. |
134 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
135 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
134 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
135 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
136 | 136 | |
137 | - if ( ! empty( $gateways ) ) { |
|
137 | + if ( ! empty($gateways)) { |
|
138 | 138 | self::$counter = 1; |
139 | - foreach ( $gateways as $gateway ) { |
|
140 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
141 | - self::$counter ++; |
|
139 | + foreach ($gateways as $gateway) { |
|
140 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
141 | + self::$counter++; |
|
142 | 142 | } |
143 | 143 | } else { |
144 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
144 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @subcommand forms |
175 | 175 | */ |
176 | - public function forms( $args, $assoc_args ) { |
|
176 | + public function forms($args, $assoc_args) { |
|
177 | 177 | global $wp_query; |
178 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
179 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
178 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
179 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
180 | 180 | $start = time(); |
181 | 181 | |
182 | 182 | // Cache previous number query var. |
183 | 183 | $is_set_number = $cache_per_page = false; |
184 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
184 | + if (isset($wp_query->query_vars['number'])) { |
|
185 | 185 | $cache_per_page = $wp_query->query_vars['number']; |
186 | 186 | $is_set_number = true; |
187 | 187 | } |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | $wp_query->query_vars['number'] = $number; |
191 | 191 | |
192 | 192 | // Get forms. |
193 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
193 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
194 | 194 | |
195 | 195 | // Reset number query var. |
196 | - if ( $is_set_number ) { |
|
196 | + if ($is_set_number) { |
|
197 | 197 | $wp_query->query_vars['number'] = $cache_per_page; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // Bailout. |
201 | - if ( array_key_exists( 'error', $forms ) ) { |
|
201 | + if (array_key_exists('error', $forms)) { |
|
202 | 202 | |
203 | - WP_CLI::warning( $forms['error'] ); |
|
203 | + WP_CLI::warning($forms['error']); |
|
204 | 204 | |
205 | 205 | return; |
206 | - } elseif ( empty( $forms['forms'] ) ) { |
|
206 | + } elseif (empty($forms['forms'])) { |
|
207 | 207 | |
208 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
208 | + WP_CLI::error(__('No forms found.', 'give')); |
|
209 | 209 | |
210 | 210 | return; |
211 | 211 | } |
@@ -213,25 +213,25 @@ discard block |
||
213 | 213 | // Param to check if form typeis already showed or not. |
214 | 214 | $is_show_form_type = false; |
215 | 215 | |
216 | - if ( 1 === count( $forms ) && $form_id ) { |
|
216 | + if (1 === count($forms) && $form_id) { |
|
217 | 217 | // Show single form. |
218 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
219 | - switch ( $key ) { |
|
218 | + foreach ($forms['forms'][0] as $key => $info) { |
|
219 | + switch ($key) { |
|
220 | 220 | case 'stats': |
221 | - $this->color_main_heading( ucfirst( $key ) ); |
|
221 | + $this->color_main_heading(ucfirst($key)); |
|
222 | 222 | |
223 | - foreach ( $info as $heading => $data ) { |
|
224 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
225 | - switch ( $heading ) { |
|
223 | + foreach ($info as $heading => $data) { |
|
224 | + $this->color_sub_heading(ucfirst($heading)); |
|
225 | + switch ($heading) { |
|
226 | 226 | default: |
227 | - foreach ( $data as $subheading => $subdata ) { |
|
227 | + foreach ($data as $subheading => $subdata) { |
|
228 | 228 | |
229 | - switch ( $subheading ) { |
|
229 | + switch ($subheading) { |
|
230 | 230 | case 'earnings': |
231 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
231 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
232 | 232 | break; |
233 | 233 | default: |
234 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
234 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | case 'pricing': |
242 | 242 | case 'info': |
243 | 243 | default: |
244 | - $this->color_main_heading( ucfirst( $key ) ); |
|
244 | + $this->color_main_heading(ucfirst($key)); |
|
245 | 245 | |
246 | 246 | // Show form type. |
247 | - if ( ! $is_show_form_type ) { |
|
248 | - $form = new Give_Donate_Form( $form_id ); |
|
247 | + if ( ! $is_show_form_type) { |
|
248 | + $form = new Give_Donate_Form($form_id); |
|
249 | 249 | $is_show_form_type = true; |
250 | 250 | |
251 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
251 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
252 | 252 | } |
253 | 253 | |
254 | - foreach ( $info as $heading => $data ) { |
|
254 | + foreach ($info as $heading => $data) { |
|
255 | 255 | |
256 | - switch ( $heading ) { |
|
256 | + switch ($heading) { |
|
257 | 257 | case 'id': |
258 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
258 | + WP_CLI::log($this->color_message($heading, $data)); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | default: |
262 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
263 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
262 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
263 | + WP_CLI::log($this->color_message($heading, $data)); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -271,37 +271,37 @@ discard block |
||
271 | 271 | $is_table_first_row_set = false; |
272 | 272 | $table_column_count = 0; |
273 | 273 | |
274 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
274 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
275 | 275 | |
276 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
276 | + foreach ($forms['forms'] as $index => $form_data) { |
|
277 | 277 | |
278 | 278 | // Default table data. |
279 | 279 | $table_first_row = array(); |
280 | 280 | $table_row = array(); |
281 | 281 | |
282 | - foreach ( $form_data['info'] as $key => $form ) { |
|
282 | + foreach ($form_data['info'] as $key => $form) { |
|
283 | 283 | |
284 | 284 | // Do not show thumbnail, content and link in table. |
285 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
285 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( ! $is_table_first_row_set ) { |
|
289 | + if ( ! $is_table_first_row_set) { |
|
290 | 290 | $table_first_row[] = $key; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $table_row[] = $form; |
294 | 294 | |
295 | - if ( 'status' === $key ) { |
|
295 | + if ('status' === $key) { |
|
296 | 296 | // First array item will be an form id in our case. |
297 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
297 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
298 | 298 | |
299 | 299 | $table_row[] = $form->get_type(); |
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Set table first row. |
304 | - if ( ! $is_table_first_row_set ) { |
|
304 | + if ( ! $is_table_first_row_set) { |
|
305 | 305 | |
306 | 306 | // Add extra column to table. |
307 | 307 | $table_first_row[] = 'type'; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $table_data[] = $table_row; |
315 | 315 | } |
316 | 316 | |
317 | - $this->display_table( $table_data ); |
|
317 | + $this->display_table($table_data); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -366,37 +366,37 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @subcommand donors |
368 | 368 | */ |
369 | - public function donors( $args, $assoc_args ) { |
|
369 | + public function donors($args, $assoc_args) { |
|
370 | 370 | global $wp_query; |
371 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
372 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
373 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
374 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
375 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
376 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
377 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
371 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
372 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
373 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
374 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
375 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
376 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
377 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
378 | 378 | $start = time(); |
379 | 379 | |
380 | - if ( $create ) { |
|
380 | + if ($create) { |
|
381 | 381 | $number = 1; |
382 | 382 | |
383 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
384 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
383 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
384 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
385 | 385 | |
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Create one or more donors. |
390 | - if ( ! $email ) { |
|
390 | + if ( ! $email) { |
|
391 | 391 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
392 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
392 | + $number = is_numeric($create) ? absint($create) : 1; |
|
393 | 393 | } |
394 | 394 | |
395 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
396 | - if ( ! $email ) { |
|
395 | + for ($i = 0; $i < $number; $i++) { |
|
396 | + if ( ! $email) { |
|
397 | 397 | |
398 | 398 | // Generate fake email. |
399 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
399 | + $email = 'customer-'.uniqid().'@test.com'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $args = array( |
@@ -404,19 +404,19 @@ discard block |
||
404 | 404 | 'name' => $name, |
405 | 405 | ); |
406 | 406 | |
407 | - $customer_id = Give()->customers->add( $args ); |
|
407 | + $customer_id = Give()->customers->add($args); |
|
408 | 408 | |
409 | - if ( $customer_id ) { |
|
410 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) ); |
|
409 | + if ($customer_id) { |
|
410 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id))); |
|
411 | 411 | } else { |
412 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
412 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | // Reset email to false so it is generated on the next loop (if creating donors). |
416 | 416 | $email = false; |
417 | 417 | } |
418 | 418 | |
419 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
419 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
420 | 420 | |
421 | 421 | } else { |
422 | 422 | // Counter. |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | // Cache previous number query var. |
432 | 432 | $is_set_number = $cache_per_page = false; |
433 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
433 | + if (isset($wp_query->query_vars['number'])) { |
|
434 | 434 | $cache_per_page = $wp_query->query_vars['number']; |
435 | 435 | $is_set_number = true; |
436 | 436 | } |
@@ -439,24 +439,24 @@ discard block |
||
439 | 439 | $wp_query->query_vars['number'] = $number; |
440 | 440 | |
441 | 441 | // Get donors. |
442 | - if ( $form_id ) { |
|
442 | + if ($form_id) { |
|
443 | 443 | // @TODO: Allow user to get a list of donors by donation status. |
444 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
444 | + $donors = $this->get_donors_by_form_id($form_id); |
|
445 | 445 | } else { |
446 | - $donors = $this->api->get_customers( $search ); |
|
446 | + $donors = $this->api->get_customers($search); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // Reset number query var. |
450 | - if ( $is_set_number ) { |
|
450 | + if ($is_set_number) { |
|
451 | 451 | $wp_query->query_vars['number'] = $cache_per_page; |
452 | 452 | } |
453 | 453 | |
454 | - if ( isset( $donors['error'] ) ) { |
|
455 | - WP_CLI::error( $donors['error'] ); |
|
454 | + if (isset($donors['error'])) { |
|
455 | + WP_CLI::error($donors['error']); |
|
456 | 456 | } |
457 | 457 | |
458 | - if ( empty( $donors ) ) { |
|
459 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
458 | + if (empty($donors)) { |
|
459 | + WP_CLI::error(__('No donors found.', 'give')); |
|
460 | 460 | |
461 | 461 | return; |
462 | 462 | } |
@@ -464,24 +464,24 @@ discard block |
||
464 | 464 | $table_data = array(); |
465 | 465 | $is_table_first_row_set = false; |
466 | 466 | |
467 | - foreach ( $donors['donors'] as $donor_data ) { |
|
467 | + foreach ($donors['donors'] as $donor_data) { |
|
468 | 468 | // Set default table row data. |
469 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
470 | - $table_row = array( self::$counter ); |
|
469 | + $table_first_row = array(__('s_no', 'give')); |
|
470 | + $table_row = array(self::$counter); |
|
471 | 471 | |
472 | - foreach ( $donor_data as $key => $donor ) { |
|
473 | - switch ( $key ) { |
|
472 | + foreach ($donor_data as $key => $donor) { |
|
473 | + switch ($key) { |
|
474 | 474 | case 'stats': |
475 | - foreach ( $donor as $heading => $data ) { |
|
475 | + foreach ($donor as $heading => $data) { |
|
476 | 476 | |
477 | 477 | // Get first row. |
478 | - if ( ! $is_table_first_row_set ) { |
|
478 | + if ( ! $is_table_first_row_set) { |
|
479 | 479 | $table_first_row[] = $heading; |
480 | 480 | } |
481 | 481 | |
482 | - switch ( $heading ) { |
|
482 | + switch ($heading) { |
|
483 | 483 | case 'total_spent': |
484 | - $table_row[] = give_currency_filter( $data ); |
|
484 | + $table_row[] = give_currency_filter($data); |
|
485 | 485 | break; |
486 | 486 | |
487 | 487 | default: |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | |
493 | 493 | case 'info': |
494 | 494 | default: |
495 | - foreach ( $donor as $heading => $data ) { |
|
495 | + foreach ($donor as $heading => $data) { |
|
496 | 496 | |
497 | 497 | // Get first row. |
498 | - if ( ! $is_table_first_row_set ) { |
|
498 | + if ( ! $is_table_first_row_set) { |
|
499 | 499 | $table_first_row[] = $heading; |
500 | 500 | } |
501 | 501 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | // Add first row data to table data. |
508 | - if ( ! $is_table_first_row_set ) { |
|
508 | + if ( ! $is_table_first_row_set) { |
|
509 | 509 | $table_data[] = $table_first_row; |
510 | 510 | $is_table_first_row_set = true; |
511 | 511 | } |
@@ -514,44 +514,44 @@ discard block |
||
514 | 514 | $table_data[] = $table_row; |
515 | 515 | |
516 | 516 | // Increase counter. |
517 | - self::$counter ++; |
|
517 | + self::$counter++; |
|
518 | 518 | } |
519 | 519 | |
520 | - switch ( $format ) { |
|
520 | + switch ($format) { |
|
521 | 521 | case 'json': |
522 | 522 | $table_column_name = $table_data[0]; |
523 | - unset( $table_data[0] ); |
|
523 | + unset($table_data[0]); |
|
524 | 524 | |
525 | 525 | $new_table_data = array(); |
526 | - foreach ( $table_data as $index => $data ) { |
|
527 | - foreach ( $data as $key => $value ) { |
|
528 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
526 | + foreach ($table_data as $index => $data) { |
|
527 | + foreach ($data as $key => $value) { |
|
528 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
532 | + WP_CLI::log(json_encode($new_table_data)); |
|
533 | 533 | break; |
534 | 534 | |
535 | 535 | case 'csv': |
536 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
537 | - $fp = fopen( $file_path, 'w' ); |
|
536 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
537 | + $fp = fopen($file_path, 'w'); |
|
538 | 538 | |
539 | - if ( is_writable( $file_path ) ) { |
|
540 | - foreach ( $table_data as $fields ) { |
|
541 | - fputcsv( $fp, $fields ); |
|
539 | + if (is_writable($file_path)) { |
|
540 | + foreach ($table_data as $fields) { |
|
541 | + fputcsv($fp, $fields); |
|
542 | 542 | } |
543 | 543 | |
544 | - fclose( $fp ); |
|
544 | + fclose($fp); |
|
545 | 545 | |
546 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
546 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
547 | 547 | } else { |
548 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
548 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | break; |
552 | 552 | |
553 | 553 | default: |
554 | - $this->display_table( $table_data ); |
|
554 | + $this->display_table($table_data); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @subcommand donations |
583 | 583 | */ |
584 | - public function donations( $args, $assoc_args ) { |
|
584 | + public function donations($args, $assoc_args) { |
|
585 | 585 | global $wp_query; |
586 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
586 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
587 | 587 | |
588 | 588 | // Cache previous number query var. |
589 | 589 | $is_set_number = $cache_per_page = false; |
590 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
590 | + if (isset($wp_query->query_vars['number'])) { |
|
591 | 591 | $cache_per_page = $wp_query->query_vars['number']; |
592 | 592 | $is_set_number = true; |
593 | 593 | } |
@@ -599,46 +599,46 @@ discard block |
||
599 | 599 | $donations = $this->api->get_recent_donations(); |
600 | 600 | |
601 | 601 | // Reset number query var. |
602 | - if ( $is_set_number ) { |
|
602 | + if ($is_set_number) { |
|
603 | 603 | $wp_query->query_vars['number'] = $cache_per_page; |
604 | 604 | } |
605 | 605 | |
606 | - if ( empty( $donations ) ) { |
|
607 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
606 | + if (empty($donations)) { |
|
607 | + WP_CLI::error(__('No donations found.', 'give')); |
|
608 | 608 | |
609 | 609 | return; |
610 | 610 | } |
611 | 611 | |
612 | 612 | self::$counter = 1; |
613 | 613 | |
614 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
615 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
616 | - self::$counter ++; |
|
614 | + foreach ($donations['donations'] as $key => $donation) { |
|
615 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
616 | + self::$counter++; |
|
617 | 617 | |
618 | - foreach ( $donation as $column => $data ) { |
|
618 | + foreach ($donation as $column => $data) { |
|
619 | 619 | |
620 | - if ( is_array( $data ) ) { |
|
621 | - $this->color_sub_heading( $column ); |
|
622 | - foreach ( $data as $subcolumn => $subdata ) { |
|
620 | + if (is_array($data)) { |
|
621 | + $this->color_sub_heading($column); |
|
622 | + foreach ($data as $subcolumn => $subdata) { |
|
623 | 623 | |
624 | 624 | // Decode html codes. |
625 | - switch ( $subcolumn ) { |
|
625 | + switch ($subcolumn) { |
|
626 | 626 | case 'name': |
627 | - $subdata = html_entity_decode( $subdata ); |
|
627 | + $subdata = html_entity_decode($subdata); |
|
628 | 628 | break; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
632 | - if ( is_array( $subdata ) ) { |
|
632 | + if (is_array($subdata)) { |
|
633 | 633 | continue; |
634 | 634 | } |
635 | 635 | |
636 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
636 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
637 | 637 | } |
638 | 638 | continue; |
639 | 639 | } |
640 | 640 | |
641 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
641 | + WP_CLI::log($this->color_message($column, $data)); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } |
@@ -677,27 +677,27 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @return void |
679 | 679 | */ |
680 | - public function report( $args, $assoc_args ) { |
|
680 | + public function report($args, $assoc_args) { |
|
681 | 681 | $stats = new Give_Payment_Stats(); |
682 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
683 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
684 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
685 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
682 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
683 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
684 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
685 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
686 | 686 | |
687 | - if ( ! empty( $date ) ) { |
|
687 | + if ( ! empty($date)) { |
|
688 | 688 | $start_date = $date; |
689 | 689 | $end_date = false; |
690 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
690 | + } elseif (empty($date) && empty($start_date)) { |
|
691 | 691 | $start_date = 'this_month'; |
692 | 692 | $end_date = false; |
693 | 693 | } |
694 | 694 | |
695 | 695 | // Get stats. |
696 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
697 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
696 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
697 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
698 | 698 | |
699 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
700 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
699 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
700 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -724,27 +724,27 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @subcommand cache |
726 | 726 | */ |
727 | - public function cache( $args, $assoc_args ) { |
|
728 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
727 | + public function cache($args, $assoc_args) { |
|
728 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
729 | 729 | |
730 | 730 | // Bailout. |
731 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
732 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
731 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
732 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
733 | 733 | |
734 | 734 | return; |
735 | 735 | } |
736 | 736 | |
737 | - switch ( $action ) { |
|
737 | + switch ($action) { |
|
738 | 738 | case 'delete' : |
739 | 739 | // Reset counter. |
740 | 740 | self::$counter = 1; |
741 | 741 | |
742 | - if ( $this->delete_stats_transients() ) { |
|
742 | + if ($this->delete_stats_transients()) { |
|
743 | 743 | // Report .eading. |
744 | - WP_CLI::success( 'Give cache deleted.' ); |
|
744 | + WP_CLI::success('Give cache deleted.'); |
|
745 | 745 | } else { |
746 | 746 | // Report .eading. |
747 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
747 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
748 | 748 | } |
749 | 749 | break; |
750 | 750 | } |
@@ -773,27 +773,27 @@ discard block |
||
773 | 773 | ARRAY_A |
774 | 774 | ); |
775 | 775 | |
776 | - if ( ! empty( $stat_option_names ) ) { |
|
776 | + if ( ! empty($stat_option_names)) { |
|
777 | 777 | |
778 | - foreach ( $stat_option_names as $option_name ) { |
|
778 | + foreach ($stat_option_names as $option_name) { |
|
779 | 779 | $error = false; |
780 | 780 | $option_name = $option_name['option_name']; |
781 | 781 | |
782 | - switch ( true ) { |
|
783 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
784 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
785 | - $error = delete_transient( $option_name ); |
|
782 | + switch (true) { |
|
783 | + case (false !== strpos($option_name, 'transient')): |
|
784 | + $option_name = str_replace('_transient_', '', $option_name); |
|
785 | + $error = delete_transient($option_name); |
|
786 | 786 | break; |
787 | 787 | |
788 | 788 | default: |
789 | - $error = delete_option( $option_name ); |
|
789 | + $error = delete_option($option_name); |
|
790 | 790 | } |
791 | 791 | |
792 | - if ( $error ) { |
|
793 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
794 | - self::$counter ++; |
|
792 | + if ($error) { |
|
793 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
794 | + self::$counter++; |
|
795 | 795 | } else { |
796 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
796 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return mixed |
816 | 816 | */ |
817 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
817 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
818 | 818 | // Add colon. |
819 | - if ( $colon ) { |
|
820 | - $heading = $heading . ': '; |
|
819 | + if ($colon) { |
|
820 | + $heading = $heading.': '; |
|
821 | 821 | } |
822 | 822 | |
823 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
823 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
839 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
838 | + private function color_main_heading($heading, $color = 'g') { |
|
839 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return void |
851 | 851 | */ |
852 | - private function color_sub_heading( $subheading ) { |
|
853 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
852 | + private function color_sub_heading($subheading) { |
|
853 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | |
@@ -864,17 +864,17 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return void |
866 | 866 | */ |
867 | - private function display_table( $data ) { |
|
867 | + private function display_table($data) { |
|
868 | 868 | $table = new \cli\Table(); |
869 | 869 | |
870 | 870 | // Set table header. |
871 | - $table->setHeaders( $data[0] ); |
|
871 | + $table->setHeaders($data[0]); |
|
872 | 872 | |
873 | 873 | // Remove table header. |
874 | - unset( $data[0] ); |
|
874 | + unset($data[0]); |
|
875 | 875 | |
876 | 876 | // Set table data. |
877 | - $table->setRows( $data ); |
|
877 | + $table->setRows($data); |
|
878 | 878 | |
879 | 879 | // Display table. |
880 | 880 | $table->display(); |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | * @return array |
892 | 892 | */ |
893 | 893 | |
894 | - private function get_donors_by_form_id( $form_id ) { |
|
894 | + private function get_donors_by_form_id($form_id) { |
|
895 | 895 | $donors = array(); |
896 | 896 | |
897 | 897 | $donations = new Give_Payments_Query( |
898 | 898 | array( |
899 | - 'give_forms' => array( $form_id ), |
|
900 | - 'number' => - 1, |
|
901 | - 'status' => array( 'publish' ), |
|
899 | + 'give_forms' => array($form_id), |
|
900 | + 'number' => -1, |
|
901 | + 'status' => array('publish'), |
|
902 | 902 | ) |
903 | 903 | ); |
904 | 904 | |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | $skip_donors = array(); |
907 | 907 | |
908 | 908 | /* @var Give_Payment|object $donation Payment object. */ |
909 | - foreach ( $donations as $donation ) { |
|
909 | + foreach ($donations as $donation) { |
|
910 | 910 | |
911 | - if ( in_array( $donation->customer_id, $skip_donors ) ) { |
|
911 | + if (in_array($donation->customer_id, $skip_donors)) { |
|
912 | 912 | continue; |
913 | 913 | } |
914 | 914 | |
915 | - if ( ! empty( $donors ) ) { |
|
916 | - $donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) ); |
|
915 | + if ( ! empty($donors)) { |
|
916 | + $donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id))); |
|
917 | 917 | } else { |
918 | - $donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) ); |
|
918 | + $donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id)); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | $skip_donors[] = $donation->customer_id; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @since 1.0 |
328 | 328 | * |
329 | - * @param int|bool $form_id Form ID (default: false). |
|
329 | + * @param boolean $form_id Form ID (default: false). |
|
330 | 330 | * @param int $payment_id Payment ID. |
331 | 331 | * |
332 | 332 | * @return void |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * @param int $year Year number. Default is null. |
645 | 645 | * @param int $hour Hour number. Default is null. |
646 | 646 | * |
647 | - * @return int $earnings Earnings |
|
647 | + * @return double $earnings Earnings |
|
648 | 648 | */ |
649 | 649 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
650 | 650 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @param int $payment_id Payment ID. |
961 | 961 | * |
962 | - * @return int $form_id Form ID. |
|
962 | + * @return string $form_id Form ID. |
|
963 | 963 | */ |
964 | 964 | function give_get_payment_form_id( $payment_id ) { |
965 | 965 | $payment = new Give_Payment( $payment_id ); |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return object $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
224 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
225 | 225 | |
226 | - $payment = new Give_Payment( $payment_id ); |
|
226 | + $payment = new Give_Payment($payment_id); |
|
227 | 227 | $payment->status = $new_status; |
228 | 228 | $updated = $payment->save(); |
229 | 229 | |
@@ -242,37 +242,37 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return void |
244 | 244 | */ |
245 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
245 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
246 | 246 | global $give_logs; |
247 | 247 | |
248 | - $payment = new Give_Payment( $payment_id ); |
|
249 | - $amount = give_get_payment_amount( $payment_id ); |
|
248 | + $payment = new Give_Payment($payment_id); |
|
249 | + $amount = give_get_payment_amount($payment_id); |
|
250 | 250 | $status = $payment->post_status; |
251 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
252 | - $customer = new Give_Customer( $customer_id ); |
|
251 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
252 | + $customer = new Give_Customer($customer_id); |
|
253 | 253 | |
254 | 254 | // Only undo donations that aren't these statuses. |
255 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
255 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
256 | 256 | 'pending', |
257 | 257 | 'cancelled', |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | |
260 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
261 | - give_undo_purchase( false, $payment_id ); |
|
260 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
261 | + give_undo_purchase(false, $payment_id); |
|
262 | 262 | } |
263 | 263 | |
264 | - if ( $status == 'publish' ) { |
|
264 | + if ($status == 'publish') { |
|
265 | 265 | |
266 | 266 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
267 | - give_decrease_total_earnings( $amount ); |
|
267 | + give_decrease_total_earnings($amount); |
|
268 | 268 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
269 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
269 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
270 | 270 | |
271 | - if ( $customer->id && $update_customer ) { |
|
271 | + if ($customer->id && $update_customer) { |
|
272 | 272 | |
273 | 273 | // Decrement the stats for the donor. |
274 | 274 | $customer->decrease_purchase_count(); |
275 | - $customer->decrease_value( $amount ); |
|
275 | + $customer->decrease_value($amount); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | } |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $payment_id Payment ID. |
286 | 286 | */ |
287 | - do_action( 'give_payment_delete', $payment_id ); |
|
287 | + do_action('give_payment_delete', $payment_id); |
|
288 | 288 | |
289 | - if ( $customer->id && $update_customer ) { |
|
289 | + if ($customer->id && $update_customer) { |
|
290 | 290 | |
291 | 291 | // Remove the payment ID from the donor. |
292 | - $customer->remove_payment( $payment_id ); |
|
292 | + $customer->remove_payment($payment_id); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Remove the payment. |
297 | - wp_delete_post( $payment_id, true ); |
|
297 | + wp_delete_post($payment_id, true); |
|
298 | 298 | |
299 | 299 | // Remove related sale log entries. |
300 | 300 | $give_logs->delete_logs( |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @param int $payment_id Payment ID. |
317 | 317 | */ |
318 | - do_action( 'give_payment_deleted', $payment_id ); |
|
318 | + do_action('give_payment_deleted', $payment_id); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return void |
333 | 333 | */ |
334 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
334 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
335 | 335 | |
336 | - if ( ! empty( $form_id ) ) { |
|
336 | + if ( ! empty($form_id)) { |
|
337 | 337 | $form_id = false; |
338 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
338 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
339 | 339 | } |
340 | 340 | |
341 | - $payment = new Give_Payment( $payment_id ); |
|
341 | + $payment = new Give_Payment($payment_id); |
|
342 | 342 | |
343 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
344 | - if ( true === $maybe_decrease_earnings ) { |
|
343 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
344 | + if (true === $maybe_decrease_earnings) { |
|
345 | 345 | // Decrease earnings. |
346 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
346 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
347 | 347 | } |
348 | 348 | |
349 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
350 | - if ( true === $maybe_decrease_sales ) { |
|
349 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
350 | + if (true === $maybe_decrease_sales) { |
|
351 | 351 | // Decrease donation count. |
352 | - give_decrease_purchase_count( $payment->form_id ); |
|
352 | + give_decrease_purchase_count($payment->form_id); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return array $count Number of payments sorted by payment status. |
368 | 368 | */ |
369 | -function give_count_payments( $args = array() ) { |
|
369 | +function give_count_payments($args = array()) { |
|
370 | 370 | |
371 | 371 | global $wpdb; |
372 | 372 | |
@@ -378,18 +378,18 @@ discard block |
||
378 | 378 | 'form_id' => null, |
379 | 379 | ); |
380 | 380 | |
381 | - $args = wp_parse_args( $args, $defaults ); |
|
381 | + $args = wp_parse_args($args, $defaults); |
|
382 | 382 | |
383 | 383 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
384 | 384 | $join = ''; |
385 | 385 | $where = "WHERE p.post_type = 'give_payment'"; |
386 | 386 | |
387 | 387 | // Count payments for a specific user. |
388 | - if ( ! empty( $args['user'] ) ) { |
|
388 | + if ( ! empty($args['user'])) { |
|
389 | 389 | |
390 | - if ( is_email( $args['user'] ) ) { |
|
390 | + if (is_email($args['user'])) { |
|
391 | 391 | $field = 'email'; |
392 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
392 | + } elseif (is_numeric($args['user'])) { |
|
393 | 393 | $field = 'id'; |
394 | 394 | } else { |
395 | 395 | $field = ''; |
@@ -397,105 +397,105 @@ discard block |
||
397 | 397 | |
398 | 398 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
399 | 399 | |
400 | - if ( ! empty( $field ) ) { |
|
400 | + if ( ! empty($field)) { |
|
401 | 401 | $where .= " |
402 | 402 | AND m.meta_key = '_give_payment_user_{$field}' |
403 | 403 | AND m.meta_value = '{$args['user']}'"; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // Count payments for a search. |
407 | - } elseif ( ! empty( $args['s'] ) ) { |
|
407 | + } elseif ( ! empty($args['s'])) { |
|
408 | 408 | |
409 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
409 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
410 | 410 | |
411 | - if ( is_email( $args['s'] ) ) { |
|
411 | + if (is_email($args['s'])) { |
|
412 | 412 | $field = '_give_payment_user_email'; |
413 | 413 | } else { |
414 | 414 | $field = '_give_payment_purchase_key'; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
418 | - $where .= $wpdb->prepare( ' |
|
418 | + $where .= $wpdb->prepare(' |
|
419 | 419 | AND m.meta_key = %s |
420 | 420 | AND m.meta_value = %s', |
421 | 421 | $field, |
422 | 422 | $args['s'] |
423 | 423 | ); |
424 | 424 | |
425 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
425 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
426 | 426 | |
427 | - $search = str_replace( '#:', '', $args['s'] ); |
|
428 | - $search = str_replace( '#', '', $search ); |
|
427 | + $search = str_replace('#:', '', $args['s']); |
|
428 | + $search = str_replace('#', '', $search); |
|
429 | 429 | |
430 | 430 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
431 | 431 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
432 | 432 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
433 | 433 | $where = "WHERE p.post_type = 'give_log' "; |
434 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
434 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
435 | 435 | |
436 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
436 | + } elseif (is_numeric($args['s'])) { |
|
437 | 437 | |
438 | 438 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
439 | - $where .= $wpdb->prepare( " |
|
439 | + $where .= $wpdb->prepare(" |
|
440 | 440 | AND m.meta_key = '_give_payment_user_id' |
441 | 441 | AND m.meta_value = %d", |
442 | 442 | $args['s'] |
443 | 443 | ); |
444 | 444 | |
445 | 445 | } else { |
446 | - $search = $wpdb->esc_like( $args['s'] ); |
|
447 | - $search = '%' . $search . '%'; |
|
446 | + $search = $wpdb->esc_like($args['s']); |
|
447 | + $search = '%'.$search.'%'; |
|
448 | 448 | |
449 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
449 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
453 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
454 | 454 | |
455 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
455 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
456 | 456 | |
457 | 457 | } |
458 | 458 | // Limit payments count by date. |
459 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
459 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
460 | 460 | |
461 | - $date_parts = explode( '/', $args['start-date'] ); |
|
462 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
463 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
464 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
461 | + $date_parts = explode('/', $args['start-date']); |
|
462 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
463 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
464 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
465 | 465 | |
466 | - $is_date = checkdate( $month, $day, $year ); |
|
467 | - if ( false !== $is_date ) { |
|
466 | + $is_date = checkdate($month, $day, $year); |
|
467 | + if (false !== $is_date) { |
|
468 | 468 | |
469 | - $date = new DateTime( $args['start-date'] ); |
|
470 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
469 | + $date = new DateTime($args['start-date']); |
|
470 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
475 | - if ( empty( $args['end-date'] ) ) { |
|
475 | + if (empty($args['end-date'])) { |
|
476 | 476 | $args['end-date'] = $args['start-date']; |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
480 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
481 | 481 | |
482 | - $date_parts = explode( '/', $args['end-date'] ); |
|
482 | + $date_parts = explode('/', $args['end-date']); |
|
483 | 483 | |
484 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
485 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
486 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
484 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
485 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
486 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
487 | 487 | |
488 | - $is_date = checkdate( $month, $day, $year ); |
|
489 | - if ( false !== $is_date ) { |
|
488 | + $is_date = checkdate($month, $day, $year); |
|
489 | + if (false !== $is_date) { |
|
490 | 490 | |
491 | - $date = new DateTime( $args['end-date'] ); |
|
492 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
491 | + $date = new DateTime($args['end-date']); |
|
492 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
498 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
497 | + $where = apply_filters('give_count_payments_where', $where); |
|
498 | + $join = apply_filters('give_count_payments_join', $join); |
|
499 | 499 | |
500 | 500 | $query = "$select |
501 | 501 | FROM $wpdb->posts p |
@@ -504,36 +504,36 @@ discard block |
||
504 | 504 | GROUP BY p.post_status |
505 | 505 | "; |
506 | 506 | |
507 | - $cache_key = md5( $query ); |
|
507 | + $cache_key = md5($query); |
|
508 | 508 | |
509 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
510 | - if ( false !== $count ) { |
|
509 | + $count = wp_cache_get($cache_key, 'counts'); |
|
510 | + if (false !== $count) { |
|
511 | 511 | return $count; |
512 | 512 | } |
513 | 513 | |
514 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
514 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
515 | 515 | |
516 | 516 | $stats = array(); |
517 | 517 | $statuses = get_post_stati(); |
518 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
519 | - unset( $statuses['private'] ); |
|
518 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
519 | + unset($statuses['private']); |
|
520 | 520 | } |
521 | 521 | |
522 | - foreach ( $statuses as $state ) { |
|
523 | - $stats[ $state ] = 0; |
|
522 | + foreach ($statuses as $state) { |
|
523 | + $stats[$state] = 0; |
|
524 | 524 | } |
525 | 525 | |
526 | - foreach ( (array) $count as $row ) { |
|
526 | + foreach ((array) $count as $row) { |
|
527 | 527 | |
528 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
528 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
529 | 529 | continue; |
530 | 530 | } |
531 | 531 | |
532 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
532 | + $stats[$row['post_status']] = $row['num_posts']; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | $stats = (object) $stats; |
536 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
536 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
537 | 537 | |
538 | 538 | return $stats; |
539 | 539 | } |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return bool $exists True if payment exists, false otherwise. |
550 | 550 | */ |
551 | -function give_check_for_existing_payment( $payment_id ) { |
|
551 | +function give_check_for_existing_payment($payment_id) { |
|
552 | 552 | $exists = false; |
553 | - $payment = new Give_Payment( $payment_id ); |
|
553 | + $payment = new Give_Payment($payment_id); |
|
554 | 554 | |
555 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
555 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
556 | 556 | $exists = true; |
557 | 557 | } |
558 | 558 | |
@@ -570,31 +570,31 @@ discard block |
||
570 | 570 | * |
571 | 571 | * @return bool|mixed True if payment status exists, false otherwise. |
572 | 572 | */ |
573 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
573 | +function give_get_payment_status($payment, $return_label = false) { |
|
574 | 574 | |
575 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
575 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
576 | 576 | return false; |
577 | 577 | } |
578 | 578 | |
579 | 579 | $statuses = give_get_payment_statuses(); |
580 | 580 | |
581 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
581 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
582 | 582 | return false; |
583 | 583 | } |
584 | 584 | |
585 | 585 | // Get payment object if no already given. |
586 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
586 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
587 | 587 | |
588 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
589 | - if ( true === $return_label ) { |
|
588 | + if (array_key_exists($payment->status, $statuses)) { |
|
589 | + if (true === $return_label) { |
|
590 | 590 | // Return translated status label. |
591 | - return $statuses[ $payment->status ]; |
|
591 | + return $statuses[$payment->status]; |
|
592 | 592 | } else { |
593 | 593 | // Account that our 'publish' status is labeled 'Complete' |
594 | 594 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
595 | 595 | |
596 | 596 | // Make sure we're matching cases, since they matter |
597 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
597 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
@@ -610,17 +610,17 @@ discard block |
||
610 | 610 | */ |
611 | 611 | function give_get_payment_statuses() { |
612 | 612 | $payment_statuses = array( |
613 | - 'pending' => __( 'Pending', 'give' ), |
|
614 | - 'publish' => __( 'Complete', 'give' ), |
|
615 | - 'refunded' => __( 'Refunded', 'give' ), |
|
616 | - 'failed' => __( 'Failed', 'give' ), |
|
617 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
618 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
619 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
620 | - 'revoked' => __( 'Revoked', 'give' ), |
|
613 | + 'pending' => __('Pending', 'give'), |
|
614 | + 'publish' => __('Complete', 'give'), |
|
615 | + 'refunded' => __('Refunded', 'give'), |
|
616 | + 'failed' => __('Failed', 'give'), |
|
617 | + 'cancelled' => __('Cancelled', 'give'), |
|
618 | + 'abandoned' => __('Abandoned', 'give'), |
|
619 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
620 | + 'revoked' => __('Revoked', 'give'), |
|
621 | 621 | ); |
622 | 622 | |
623 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
623 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | * @return array $payment_status All the available payment statuses. |
634 | 634 | */ |
635 | 635 | function give_get_payment_status_keys() { |
636 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
637 | - asort( $statuses ); |
|
636 | + $statuses = array_keys(give_get_payment_statuses()); |
|
637 | + asort($statuses); |
|
638 | 638 | |
639 | - return array_values( $statuses ); |
|
639 | + return array_values($statuses); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | * |
652 | 652 | * @return int $earnings Earnings |
653 | 653 | */ |
654 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
654 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
655 | 655 | |
656 | 656 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
657 | 657 | global $wpdb; |
@@ -661,41 +661,41 @@ discard block |
||
661 | 661 | 'nopaging' => true, |
662 | 662 | 'year' => $year, |
663 | 663 | 'monthnum' => $month_num, |
664 | - 'post_status' => array( 'publish' ), |
|
664 | + 'post_status' => array('publish'), |
|
665 | 665 | 'fields' => 'ids', |
666 | 666 | 'update_post_term_cache' => false, |
667 | 667 | ); |
668 | - if ( ! empty( $day ) ) { |
|
668 | + if ( ! empty($day)) { |
|
669 | 669 | $args['day'] = $day; |
670 | 670 | } |
671 | 671 | |
672 | - if ( ! empty( $hour ) ) { |
|
672 | + if ( ! empty($hour)) { |
|
673 | 673 | $args['hour'] = $hour; |
674 | 674 | } |
675 | 675 | |
676 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
677 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
676 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
677 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
678 | 678 | |
679 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
679 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
680 | 680 | $earnings = false; |
681 | 681 | } else { |
682 | - $earnings = get_transient( $key ); |
|
682 | + $earnings = get_transient($key); |
|
683 | 683 | } |
684 | 684 | |
685 | - if ( false === $earnings ) { |
|
686 | - $sales = get_posts( $args ); |
|
685 | + if (false === $earnings) { |
|
686 | + $sales = get_posts($args); |
|
687 | 687 | $earnings = 0; |
688 | - if ( $sales ) { |
|
689 | - $sales = implode( ',', $sales ); |
|
688 | + if ($sales) { |
|
689 | + $sales = implode(',', $sales); |
|
690 | 690 | |
691 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
691 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
692 | 692 | |
693 | 693 | } |
694 | 694 | // Cache the results for one hour. |
695 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
695 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
696 | 696 | } |
697 | 697 | |
698 | - return round( $earnings, 2 ); |
|
698 | + return round($earnings, 2); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @return int $count Sales |
712 | 712 | */ |
713 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
713 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
714 | 714 | |
715 | 715 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
716 | 716 | $args = array( |
@@ -718,14 +718,14 @@ discard block |
||
718 | 718 | 'nopaging' => true, |
719 | 719 | 'year' => $year, |
720 | 720 | 'fields' => 'ids', |
721 | - 'post_status' => array( 'publish' ), |
|
721 | + 'post_status' => array('publish'), |
|
722 | 722 | 'update_post_meta_cache' => false, |
723 | 723 | 'update_post_term_cache' => false, |
724 | 724 | ); |
725 | 725 | |
726 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
726 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
727 | 727 | |
728 | - if ( false === $show_free ) { |
|
728 | + if (false === $show_free) { |
|
729 | 729 | $args['meta_query'] = array( |
730 | 730 | array( |
731 | 731 | 'key' => '_give_payment_total', |
@@ -736,33 +736,33 @@ discard block |
||
736 | 736 | ); |
737 | 737 | } |
738 | 738 | |
739 | - if ( ! empty( $month_num ) ) { |
|
739 | + if ( ! empty($month_num)) { |
|
740 | 740 | $args['monthnum'] = $month_num; |
741 | 741 | } |
742 | 742 | |
743 | - if ( ! empty( $day ) ) { |
|
743 | + if ( ! empty($day)) { |
|
744 | 744 | $args['day'] = $day; |
745 | 745 | } |
746 | 746 | |
747 | - if ( ! empty( $hour ) ) { |
|
747 | + if ( ! empty($hour)) { |
|
748 | 748 | $args['hour'] = $hour; |
749 | 749 | } |
750 | 750 | |
751 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
751 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
752 | 752 | |
753 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
753 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
754 | 754 | |
755 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
755 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
756 | 756 | $count = false; |
757 | 757 | } else { |
758 | - $count = get_transient( $key ); |
|
758 | + $count = get_transient($key); |
|
759 | 759 | } |
760 | 760 | |
761 | - if ( false === $count ) { |
|
762 | - $sales = new WP_Query( $args ); |
|
761 | + if (false === $count) { |
|
762 | + $sales = new WP_Query($args); |
|
763 | 763 | $count = (int) $sales->post_count; |
764 | 764 | // Cache the results for one hour. |
765 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
765 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | return $count; |
@@ -777,19 +777,19 @@ discard block |
||
777 | 777 | * |
778 | 778 | * @return bool $ret True if complete, false otherwise. |
779 | 779 | */ |
780 | -function give_is_payment_complete( $payment_id ) { |
|
781 | - $payment = new Give_Payment( $payment_id ); |
|
780 | +function give_is_payment_complete($payment_id) { |
|
781 | + $payment = new Give_Payment($payment_id); |
|
782 | 782 | |
783 | 783 | $ret = false; |
784 | 784 | |
785 | - if ( $payment->ID > 0 ) { |
|
785 | + if ($payment->ID > 0) { |
|
786 | 786 | |
787 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
787 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
788 | 788 | $ret = true; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
792 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -815,57 +815,57 @@ discard block |
||
815 | 815 | */ |
816 | 816 | function give_get_total_earnings() { |
817 | 817 | |
818 | - $total = get_option( 'give_earnings_total', false ); |
|
818 | + $total = get_option('give_earnings_total', false); |
|
819 | 819 | |
820 | 820 | // If no total stored in DB, use old method of calculating total earnings. |
821 | - if ( false === $total ) { |
|
821 | + if (false === $total) { |
|
822 | 822 | |
823 | 823 | global $wpdb; |
824 | 824 | |
825 | - $total = get_transient( 'give_earnings_total' ); |
|
825 | + $total = get_transient('give_earnings_total'); |
|
826 | 826 | |
827 | - if ( false === $total ) { |
|
827 | + if (false === $total) { |
|
828 | 828 | |
829 | 829 | $total = (float) 0; |
830 | 830 | |
831 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
831 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
832 | 832 | 'offset' => 0, |
833 | - 'number' => - 1, |
|
834 | - 'status' => array( 'publish' ), |
|
833 | + 'number' => -1, |
|
834 | + 'status' => array('publish'), |
|
835 | 835 | 'fields' => 'ids', |
836 | - ) ); |
|
836 | + )); |
|
837 | 837 | |
838 | - $payments = give_get_payments( $args ); |
|
839 | - if ( $payments ) { |
|
838 | + $payments = give_get_payments($args); |
|
839 | + if ($payments) { |
|
840 | 840 | |
841 | 841 | /** |
842 | 842 | * If performing a donation, we need to skip the very last payment in the database, |
843 | 843 | * since it calls give_increase_total_earnings() on completion, |
844 | 844 | * which results in duplicated earnings for the very first donation. |
845 | 845 | */ |
846 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
847 | - array_pop( $payments ); |
|
846 | + if (did_action('give_update_payment_status')) { |
|
847 | + array_pop($payments); |
|
848 | 848 | } |
849 | 849 | |
850 | - if ( ! empty( $payments ) ) { |
|
851 | - $payments = implode( ',', $payments ); |
|
852 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
850 | + if ( ! empty($payments)) { |
|
851 | + $payments = implode(',', $payments); |
|
852 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
856 | 856 | // Cache results for 1 day. This cache is cleared automatically when a payment is made. |
857 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
857 | + set_transient('give_earnings_total', $total, 86400); |
|
858 | 858 | |
859 | 859 | // Store the total for the first time. |
860 | - update_option( 'give_earnings_total', $total ); |
|
860 | + update_option('give_earnings_total', $total); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
864 | - if ( $total < 0 ) { |
|
864 | + if ($total < 0) { |
|
865 | 865 | $total = 0; // Don't ever show negative earnings. |
866 | 866 | } |
867 | 867 | |
868 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
868 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -878,10 +878,10 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @return float $total Total earnings. |
880 | 880 | */ |
881 | -function give_increase_total_earnings( $amount = 0 ) { |
|
881 | +function give_increase_total_earnings($amount = 0) { |
|
882 | 882 | $total = give_get_total_earnings(); |
883 | 883 | $total += $amount; |
884 | - update_option( 'give_earnings_total', $total ); |
|
884 | + update_option('give_earnings_total', $total); |
|
885 | 885 | |
886 | 886 | return $total; |
887 | 887 | } |
@@ -895,13 +895,13 @@ discard block |
||
895 | 895 | * |
896 | 896 | * @return float $total Total earnings. |
897 | 897 | */ |
898 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
898 | +function give_decrease_total_earnings($amount = 0) { |
|
899 | 899 | $total = give_get_total_earnings(); |
900 | 900 | $total -= $amount; |
901 | - if ( $total < 0 ) { |
|
901 | + if ($total < 0) { |
|
902 | 902 | $total = 0; |
903 | 903 | } |
904 | - update_option( 'give_earnings_total', $total ); |
|
904 | + update_option('give_earnings_total', $total); |
|
905 | 905 | |
906 | 906 | return $total; |
907 | 907 | } |
@@ -917,10 +917,10 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @return mixed $meta Payment Meta. |
919 | 919 | */ |
920 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
921 | - $payment = new Give_Payment( $payment_id ); |
|
920 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
921 | + $payment = new Give_Payment($payment_id); |
|
922 | 922 | |
923 | - return $payment->get_meta( $meta_key, $single ); |
|
923 | + return $payment->get_meta($meta_key, $single); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -933,10 +933,10 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @return mixed Meta ID if successful, false if unsuccessful. |
935 | 935 | */ |
936 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
937 | - $payment = new Give_Payment( $payment_id ); |
|
936 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
937 | + $payment = new Give_Payment($payment_id); |
|
938 | 938 | |
939 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
939 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @return string $user_info User Info Meta Values. |
950 | 950 | */ |
951 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
952 | - $payment = new Give_Payment( $payment_id ); |
|
951 | +function give_get_payment_meta_user_info($payment_id) { |
|
952 | + $payment = new Give_Payment($payment_id); |
|
953 | 953 | |
954 | 954 | return $payment->user_info; |
955 | 955 | } |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @return int $form_id Form ID. |
967 | 967 | */ |
968 | -function give_get_payment_form_id( $payment_id ) { |
|
969 | - $payment = new Give_Payment( $payment_id ); |
|
968 | +function give_get_payment_form_id($payment_id) { |
|
969 | + $payment = new Give_Payment($payment_id); |
|
970 | 970 | |
971 | 971 | return $payment->form_id; |
972 | 972 | } |
@@ -980,8 +980,8 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @return string $email User email. |
982 | 982 | */ |
983 | -function give_get_payment_user_email( $payment_id ) { |
|
984 | - $payment = new Give_Payment( $payment_id ); |
|
983 | +function give_get_payment_user_email($payment_id) { |
|
984 | + $payment = new Give_Payment($payment_id); |
|
985 | 985 | |
986 | 986 | return $payment->email; |
987 | 987 | } |
@@ -995,11 +995,11 @@ discard block |
||
995 | 995 | * |
996 | 996 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
997 | 997 | */ |
998 | -function give_is_guest_payment( $payment_id ) { |
|
999 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1000 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
998 | +function give_is_guest_payment($payment_id) { |
|
999 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1000 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1001 | 1001 | |
1002 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1002 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @return int $user_id User ID. |
1013 | 1013 | */ |
1014 | -function give_get_payment_user_id( $payment_id ) { |
|
1015 | - $payment = new Give_Payment( $payment_id ); |
|
1014 | +function give_get_payment_user_id($payment_id) { |
|
1015 | + $payment = new Give_Payment($payment_id); |
|
1016 | 1016 | |
1017 | 1017 | return $payment->user_id; |
1018 | 1018 | } |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | * |
1027 | 1027 | * @return int $customer_id Customer ID. |
1028 | 1028 | */ |
1029 | -function give_get_payment_customer_id( $payment_id ) { |
|
1030 | - $payment = new Give_Payment( $payment_id ); |
|
1029 | +function give_get_payment_customer_id($payment_id) { |
|
1030 | + $payment = new Give_Payment($payment_id); |
|
1031 | 1031 | |
1032 | 1032 | return $payment->customer_id; |
1033 | 1033 | } |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return string $ip User IP. |
1043 | 1043 | */ |
1044 | -function give_get_payment_user_ip( $payment_id ) { |
|
1045 | - $payment = new Give_Payment( $payment_id ); |
|
1044 | +function give_get_payment_user_ip($payment_id) { |
|
1045 | + $payment = new Give_Payment($payment_id); |
|
1046 | 1046 | |
1047 | 1047 | return $payment->ip; |
1048 | 1048 | } |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | * |
1057 | 1057 | * @return string $date The date the payment was completed. |
1058 | 1058 | */ |
1059 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1060 | - $payment = new Give_Payment( $payment_id ); |
|
1059 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1060 | + $payment = new Give_Payment($payment_id); |
|
1061 | 1061 | |
1062 | 1062 | return $payment->completed_date; |
1063 | 1063 | } |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * |
1072 | 1072 | * @return string $gateway Gateway. |
1073 | 1073 | */ |
1074 | -function give_get_payment_gateway( $payment_id ) { |
|
1075 | - $payment = new Give_Payment( $payment_id ); |
|
1074 | +function give_get_payment_gateway($payment_id) { |
|
1075 | + $payment = new Give_Payment($payment_id); |
|
1076 | 1076 | |
1077 | 1077 | return $payment->gateway; |
1078 | 1078 | } |
@@ -1086,8 +1086,8 @@ discard block |
||
1086 | 1086 | * |
1087 | 1087 | * @return string $currency The currency code. |
1088 | 1088 | */ |
1089 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1090 | - $payment = new Give_Payment( $payment_id ); |
|
1089 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1090 | + $payment = new Give_Payment($payment_id); |
|
1091 | 1091 | |
1092 | 1092 | return $payment->currency; |
1093 | 1093 | } |
@@ -1101,10 +1101,10 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * @return string $currency The currency name. |
1103 | 1103 | */ |
1104 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1105 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1104 | +function give_get_payment_currency($payment_id = 0) { |
|
1105 | + $currency = give_get_payment_currency_code($payment_id); |
|
1106 | 1106 | |
1107 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1107 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
@@ -1116,8 +1116,8 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string $key Donation key. |
1118 | 1118 | */ |
1119 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1120 | - $payment = new Give_Payment( $payment_id ); |
|
1119 | +function give_get_payment_key($payment_id = 0) { |
|
1120 | + $payment = new Give_Payment($payment_id); |
|
1121 | 1121 | |
1122 | 1122 | return $payment->key; |
1123 | 1123 | } |
@@ -1133,8 +1133,8 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return string $number Payment order number. |
1135 | 1135 | */ |
1136 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1137 | - $payment = new Give_Payment( $payment_id ); |
|
1136 | +function give_get_payment_number($payment_id = 0) { |
|
1137 | + $payment = new Give_Payment($payment_id); |
|
1138 | 1138 | |
1139 | 1139 | return $payment->number; |
1140 | 1140 | } |
@@ -1148,23 +1148,23 @@ discard block |
||
1148 | 1148 | * |
1149 | 1149 | * @return string The formatted payment number. |
1150 | 1150 | */ |
1151 | -function give_format_payment_number( $number ) { |
|
1151 | +function give_format_payment_number($number) { |
|
1152 | 1152 | |
1153 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1153 | + if ( ! give_get_option('enable_sequential')) { |
|
1154 | 1154 | return $number; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - if ( ! is_numeric( $number ) ) { |
|
1157 | + if ( ! is_numeric($number)) { |
|
1158 | 1158 | return $number; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1162 | - $number = absint( $number ); |
|
1163 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1161 | + $prefix = give_get_option('sequential_prefix'); |
|
1162 | + $number = absint($number); |
|
1163 | + $postfix = give_get_option('sequential_postfix'); |
|
1164 | 1164 | |
1165 | - $formatted_number = $prefix . $number . $postfix; |
|
1165 | + $formatted_number = $prefix.$number.$postfix; |
|
1166 | 1166 | |
1167 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1167 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | /** |
@@ -1177,17 +1177,17 @@ discard block |
||
1177 | 1177 | */ |
1178 | 1178 | function give_get_next_payment_number() { |
1179 | 1179 | |
1180 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1180 | + if ( ! give_get_option('enable_sequential')) { |
|
1181 | 1181 | return false; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - $number = get_option( 'give_last_payment_number' ); |
|
1185 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1184 | + $number = get_option('give_last_payment_number'); |
|
1185 | + $start = give_get_option('sequential_start', 1); |
|
1186 | 1186 | $increment_number = true; |
1187 | 1187 | |
1188 | - if ( false !== $number ) { |
|
1188 | + if (false !== $number) { |
|
1189 | 1189 | |
1190 | - if ( empty( $number ) ) { |
|
1190 | + if (empty($number)) { |
|
1191 | 1191 | |
1192 | 1192 | $number = $start; |
1193 | 1193 | $increment_number = false; |
@@ -1196,24 +1196,24 @@ discard block |
||
1196 | 1196 | } else { |
1197 | 1197 | |
1198 | 1198 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1199 | - $payments = new Give_Payments_Query( array( |
|
1199 | + $payments = new Give_Payments_Query(array( |
|
1200 | 1200 | 'number' => 1, |
1201 | 1201 | 'order' => 'DESC', |
1202 | 1202 | 'orderby' => 'ID', |
1203 | 1203 | 'output' => 'posts', |
1204 | 1204 | 'fields' => 'ids', |
1205 | - ) ); |
|
1205 | + )); |
|
1206 | 1206 | $last_payment = $payments->get_payments(); |
1207 | 1207 | |
1208 | - if ( ! empty( $last_payment ) ) { |
|
1208 | + if ( ! empty($last_payment)) { |
|
1209 | 1209 | |
1210 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1210 | + $number = give_get_payment_number($last_payment[0]); |
|
1211 | 1211 | |
1212 | 1212 | } |
1213 | 1213 | |
1214 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1214 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1215 | 1215 | |
1216 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1216 | + $number = give_remove_payment_prefix_postfix($number); |
|
1217 | 1217 | |
1218 | 1218 | } else { |
1219 | 1219 | |
@@ -1222,13 +1222,13 @@ discard block |
||
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | |
1225 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1225 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1226 | 1226 | |
1227 | - if ( $increment_number ) { |
|
1228 | - $number ++; |
|
1227 | + if ($increment_number) { |
|
1228 | + $number++; |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1231 | + return apply_filters('give_get_next_payment_number', $number); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | /** |
@@ -1240,25 +1240,25 @@ discard block |
||
1240 | 1240 | * |
1241 | 1241 | * @return string The new Payment number without prefix and postfix. |
1242 | 1242 | */ |
1243 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1243 | +function give_remove_payment_prefix_postfix($number) { |
|
1244 | 1244 | |
1245 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1246 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1245 | + $prefix = give_get_option('sequential_prefix'); |
|
1246 | + $postfix = give_get_option('sequential_postfix'); |
|
1247 | 1247 | |
1248 | 1248 | // Remove prefix. |
1249 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1249 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1250 | 1250 | |
1251 | 1251 | // Remove the postfix. |
1252 | - $length = strlen( $number ); |
|
1253 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1254 | - if ( false !== $postfix_pos ) { |
|
1255 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1252 | + $length = strlen($number); |
|
1253 | + $postfix_pos = strrpos($number, $postfix); |
|
1254 | + if (false !== $postfix_pos) { |
|
1255 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | // Ensure it's a whole number. |
1259 | - $number = intval( $number ); |
|
1259 | + $number = intval($number); |
|
1260 | 1260 | |
1261 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1261 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1262 | 1262 | |
1263 | 1263 | } |
1264 | 1264 | |
@@ -1274,10 +1274,10 @@ discard block |
||
1274 | 1274 | * |
1275 | 1275 | * @return string $amount Fully formatted payment amount. |
1276 | 1276 | */ |
1277 | -function give_payment_amount( $payment_id = 0 ) { |
|
1278 | - $amount = give_get_payment_amount( $payment_id ); |
|
1277 | +function give_payment_amount($payment_id = 0) { |
|
1278 | + $amount = give_get_payment_amount($payment_id); |
|
1279 | 1279 | |
1280 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1280 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | /** |
@@ -1290,11 +1290,11 @@ discard block |
||
1290 | 1290 | * |
1291 | 1291 | * @return mixed|void |
1292 | 1292 | */ |
1293 | -function give_get_payment_amount( $payment_id ) { |
|
1293 | +function give_get_payment_amount($payment_id) { |
|
1294 | 1294 | |
1295 | - $payment = new Give_Payment( $payment_id ); |
|
1295 | + $payment = new Give_Payment($payment_id); |
|
1296 | 1296 | |
1297 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1297 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | /** |
@@ -1310,10 +1310,10 @@ discard block |
||
1310 | 1310 | * |
1311 | 1311 | * @return array Fully formatted payment subtotal. |
1312 | 1312 | */ |
1313 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1314 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1313 | +function give_payment_subtotal($payment_id = 0) { |
|
1314 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1315 | 1315 | |
1316 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1316 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | /** |
@@ -1327,8 +1327,8 @@ discard block |
||
1327 | 1327 | * |
1328 | 1328 | * @return float $subtotal Subtotal for payment (non formatted). |
1329 | 1329 | */ |
1330 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1331 | - $payment = new G_Payment( $payment_id ); |
|
1330 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1331 | + $payment = new G_Payment($payment_id); |
|
1332 | 1332 | |
1333 | 1333 | return $payment->subtotal; |
1334 | 1334 | } |
@@ -1343,10 +1343,10 @@ discard block |
||
1343 | 1343 | * |
1344 | 1344 | * @return mixed array if payment fees found, false otherwise. |
1345 | 1345 | */ |
1346 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1347 | - $payment = new Give_Payment( $payment_id ); |
|
1346 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1347 | + $payment = new Give_Payment($payment_id); |
|
1348 | 1348 | |
1349 | - return $payment->get_fees( $type ); |
|
1349 | + return $payment->get_fees($type); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | /** |
@@ -1358,8 +1358,8 @@ discard block |
||
1358 | 1358 | * |
1359 | 1359 | * @return string The donation ID. |
1360 | 1360 | */ |
1361 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1362 | - $payment = new Give_Payment( $payment_id ); |
|
1361 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1362 | + $payment = new Give_Payment($payment_id); |
|
1363 | 1363 | |
1364 | 1364 | return $payment->transaction_id; |
1365 | 1365 | } |
@@ -1374,15 +1374,15 @@ discard block |
||
1374 | 1374 | * |
1375 | 1375 | * @return bool|mixed |
1376 | 1376 | */ |
1377 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1377 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1378 | 1378 | |
1379 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1379 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1380 | 1380 | return false; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1383 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1384 | 1384 | |
1385 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1385 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | /** |
@@ -1395,12 +1395,12 @@ discard block |
||
1395 | 1395 | * |
1396 | 1396 | * @return int $purchase Donation ID. |
1397 | 1397 | */ |
1398 | -function give_get_purchase_id_by_key( $key ) { |
|
1398 | +function give_get_purchase_id_by_key($key) { |
|
1399 | 1399 | global $wpdb; |
1400 | 1400 | |
1401 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1401 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1402 | 1402 | |
1403 | - if ( $purchase != null ) { |
|
1403 | + if ($purchase != null) { |
|
1404 | 1404 | return $purchase; |
1405 | 1405 | } |
1406 | 1406 | |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | * |
1419 | 1419 | * @return int $purchase Donation ID. |
1420 | 1420 | */ |
1421 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1421 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1422 | 1422 | global $wpdb; |
1423 | 1423 | |
1424 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1424 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1425 | 1425 | |
1426 | - if ( $purchase != null ) { |
|
1426 | + if ($purchase != null) { |
|
1427 | 1427 | return $purchase; |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1440,19 +1440,19 @@ discard block |
||
1440 | 1440 | * |
1441 | 1441 | * @return array $notes Donation Notes |
1442 | 1442 | */ |
1443 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1443 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1444 | 1444 | |
1445 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1445 | + if (empty($payment_id) && empty($search)) { |
|
1446 | 1446 | return false; |
1447 | 1447 | } |
1448 | 1448 | |
1449 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1450 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1449 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1450 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1451 | 1451 | |
1452 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1452 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1453 | 1453 | |
1454 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1455 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1454 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1455 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1456 | 1456 | |
1457 | 1457 | return $notes; |
1458 | 1458 | } |
@@ -1468,8 +1468,8 @@ discard block |
||
1468 | 1468 | * |
1469 | 1469 | * @return int The new note ID |
1470 | 1470 | */ |
1471 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1472 | - if ( empty( $payment_id ) ) { |
|
1471 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1472 | + if (empty($payment_id)) { |
|
1473 | 1473 | return false; |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1481,14 +1481,14 @@ discard block |
||
1481 | 1481 | * @param int $payment_id Payment ID. |
1482 | 1482 | * @param string $note The note. |
1483 | 1483 | */ |
1484 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1484 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1485 | 1485 | |
1486 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1486 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1487 | 1487 | 'comment_post_ID' => $payment_id, |
1488 | 1488 | 'comment_content' => $note, |
1489 | 1489 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1490 | - 'comment_date' => current_time( 'mysql' ), |
|
1491 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1490 | + 'comment_date' => current_time('mysql'), |
|
1491 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1492 | 1492 | 'comment_approved' => 1, |
1493 | 1493 | 'comment_parent' => 0, |
1494 | 1494 | 'comment_author' => '', |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | 'comment_author_email' => '', |
1498 | 1498 | 'comment_type' => 'give_payment_note', |
1499 | 1499 | |
1500 | - ) ) ); |
|
1500 | + ))); |
|
1501 | 1501 | |
1502 | 1502 | /** |
1503 | 1503 | * Fires after payment note inserted. |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | * @param int $payment_id Payment ID. |
1509 | 1509 | * @param string $note The note. |
1510 | 1510 | */ |
1511 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1511 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1512 | 1512 | |
1513 | 1513 | return $note_id; |
1514 | 1514 | } |
@@ -1523,8 +1523,8 @@ discard block |
||
1523 | 1523 | * |
1524 | 1524 | * @return bool True on success, false otherwise. |
1525 | 1525 | */ |
1526 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1527 | - if ( empty( $comment_id ) ) { |
|
1526 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1527 | + if (empty($comment_id)) { |
|
1528 | 1528 | return false; |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1536,9 +1536,9 @@ discard block |
||
1536 | 1536 | * @param int $comment_id Note ID. |
1537 | 1537 | * @param int $payment_id Payment ID. |
1538 | 1538 | */ |
1539 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1539 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1540 | 1540 | |
1541 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1541 | + $ret = wp_delete_comment($comment_id, true); |
|
1542 | 1542 | |
1543 | 1543 | /** |
1544 | 1544 | * Fires after donation note deleted. |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * @param int $comment_id Note ID. |
1549 | 1549 | * @param int $payment_id Payment ID. |
1550 | 1550 | */ |
1551 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1551 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1552 | 1552 | |
1553 | 1553 | return $ret; |
1554 | 1554 | } |
@@ -1563,34 +1563,34 @@ discard block |
||
1563 | 1563 | * |
1564 | 1564 | * @return string |
1565 | 1565 | */ |
1566 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1566 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1567 | 1567 | |
1568 | - if ( is_numeric( $note ) ) { |
|
1569 | - $note = get_comment( $note ); |
|
1568 | + if (is_numeric($note)) { |
|
1569 | + $note = get_comment($note); |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | - if ( ! empty( $note->user_id ) ) { |
|
1573 | - $user = get_userdata( $note->user_id ); |
|
1572 | + if ( ! empty($note->user_id)) { |
|
1573 | + $user = get_userdata($note->user_id); |
|
1574 | 1574 | $user = $user->display_name; |
1575 | 1575 | } else { |
1576 | - $user = esc_html__( 'System', 'give' ); |
|
1576 | + $user = esc_html__('System', 'give'); |
|
1577 | 1577 | } |
1578 | 1578 | |
1579 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1579 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1580 | 1580 | |
1581 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1581 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1582 | 1582 | 'give-action' => 'delete_payment_note', |
1583 | 1583 | 'note_id' => $note->comment_ID, |
1584 | 1584 | 'payment_id' => $payment_id, |
1585 | - ) ), |
|
1586 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1585 | + )), |
|
1586 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1587 | 1587 | ); |
1588 | 1588 | |
1589 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1589 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1590 | 1590 | $note_html .= '<p>'; |
1591 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1591 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1592 | 1592 | $note_html .= $note->comment_content; |
1593 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1593 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1594 | 1594 | $note_html .= '</p>'; |
1595 | 1595 | $note_html .= '</div>'; |
1596 | 1596 | |
@@ -1608,18 +1608,18 @@ discard block |
||
1608 | 1608 | * |
1609 | 1609 | * @return void |
1610 | 1610 | */ |
1611 | -function give_hide_payment_notes( $query ) { |
|
1612 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1613 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1614 | - if ( ! is_array( $types ) ) { |
|
1615 | - $types = array( $types ); |
|
1611 | +function give_hide_payment_notes($query) { |
|
1612 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1613 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1614 | + if ( ! is_array($types)) { |
|
1615 | + $types = array($types); |
|
1616 | 1616 | } |
1617 | 1617 | $types[] = 'give_payment_note'; |
1618 | 1618 | $query->query_vars['type__not_in'] = $types; |
1619 | 1619 | } |
1620 | 1620 | } |
1621 | 1621 | |
1622 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1622 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1623 | 1623 | |
1624 | 1624 | /** |
1625 | 1625 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1631,15 +1631,15 @@ discard block |
||
1631 | 1631 | * |
1632 | 1632 | * @return array $clauses Updated comment clauses. |
1633 | 1633 | */ |
1634 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1635 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1634 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1635 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1636 | 1636 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | return $clauses; |
1640 | 1640 | } |
1641 | 1641 | |
1642 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1642 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1643 | 1643 | |
1644 | 1644 | |
1645 | 1645 | /** |
@@ -1652,15 +1652,15 @@ discard block |
||
1652 | 1652 | * |
1653 | 1653 | * @return string $where |
1654 | 1654 | */ |
1655 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1655 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1656 | 1656 | global $wpdb; |
1657 | 1657 | |
1658 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1658 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1659 | 1659 | |
1660 | 1660 | return $where; |
1661 | 1661 | } |
1662 | 1662 | |
1663 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1663 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1664 | 1664 | |
1665 | 1665 | |
1666 | 1666 | /** |
@@ -1674,32 +1674,32 @@ discard block |
||
1674 | 1674 | * |
1675 | 1675 | * @return array Array of comment counts. |
1676 | 1676 | */ |
1677 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1677 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1678 | 1678 | global $wpdb, $pagenow; |
1679 | 1679 | |
1680 | - if ( 'index.php' != $pagenow ) { |
|
1680 | + if ('index.php' != $pagenow) { |
|
1681 | 1681 | return $stats; |
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | $post_id = (int) $post_id; |
1685 | 1685 | |
1686 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1686 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1687 | 1687 | return $stats; |
1688 | 1688 | } |
1689 | 1689 | |
1690 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1690 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1691 | 1691 | |
1692 | - if ( false !== $stats ) { |
|
1692 | + if (false !== $stats) { |
|
1693 | 1693 | return $stats; |
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | $where = 'WHERE comment_type != "give_payment_note"'; |
1697 | 1697 | |
1698 | - if ( $post_id > 0 ) { |
|
1699 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1698 | + if ($post_id > 0) { |
|
1699 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1700 | 1700 | } |
1701 | 1701 | |
1702 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1702 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1703 | 1703 | |
1704 | 1704 | $total = 0; |
1705 | 1705 | $approved = array( |
@@ -1709,30 +1709,30 @@ discard block |
||
1709 | 1709 | 'trash' => 'trash', |
1710 | 1710 | 'post-trashed' => 'post-trashed', |
1711 | 1711 | ); |
1712 | - foreach ( (array) $count as $row ) { |
|
1712 | + foreach ((array) $count as $row) { |
|
1713 | 1713 | // Don't count post-trashed toward totals. |
1714 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1714 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1715 | 1715 | $total += $row['num_comments']; |
1716 | 1716 | } |
1717 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1718 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1717 | + if (isset($approved[$row['comment_approved']])) { |
|
1718 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1719 | 1719 | } |
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | $stats['total_comments'] = $total; |
1723 | - foreach ( $approved as $key ) { |
|
1724 | - if ( empty( $stats[ $key ] ) ) { |
|
1725 | - $stats[ $key ] = 0; |
|
1723 | + foreach ($approved as $key) { |
|
1724 | + if (empty($stats[$key])) { |
|
1725 | + $stats[$key] = 0; |
|
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | $stats = (object) $stats; |
1730 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1730 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1731 | 1731 | |
1732 | 1732 | return $stats; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1735 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1736 | 1736 | |
1737 | 1737 | |
1738 | 1738 | /** |
@@ -1745,9 +1745,9 @@ discard block |
||
1745 | 1745 | * |
1746 | 1746 | * @return string $where Modified where clause. |
1747 | 1747 | */ |
1748 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1748 | +function give_filter_where_older_than_week($where = '') { |
|
1749 | 1749 | // Payments older than one week. |
1750 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1750 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1751 | 1751 | $where .= " AND post_date <= '{$start}'"; |
1752 | 1752 | |
1753 | 1753 | return $where; |
@@ -1767,38 +1767,38 @@ discard block |
||
1767 | 1767 | * |
1768 | 1768 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1769 | 1769 | */ |
1770 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1770 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1771 | 1771 | |
1772 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1773 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1774 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1772 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1773 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1774 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1775 | 1775 | |
1776 | - if ( $only_level == true ) { |
|
1776 | + if ($only_level == true) { |
|
1777 | 1777 | $form_title = ''; |
1778 | 1778 | } |
1779 | 1779 | |
1780 | 1780 | //If multi-level, append to the form title. |
1781 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1781 | + if (give_has_variable_prices($form_id)) { |
|
1782 | 1782 | |
1783 | 1783 | //Only add separator if there is a form title. |
1784 | - if ( ! empty( $form_title ) ) { |
|
1785 | - $form_title .= ' ' . $separator . ' '; |
|
1784 | + if ( ! empty($form_title)) { |
|
1785 | + $form_title .= ' '.$separator.' '; |
|
1786 | 1786 | } |
1787 | 1787 | |
1788 | 1788 | $form_title .= '<span class="donation-level-text-wrap">'; |
1789 | 1789 | |
1790 | - if ( $price_id == 'custom' ) { |
|
1791 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1792 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1790 | + if ($price_id == 'custom') { |
|
1791 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1792 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1793 | 1793 | } else { |
1794 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1794 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1795 | 1795 | } |
1796 | 1796 | |
1797 | 1797 | $form_title .= '</span>'; |
1798 | 1798 | |
1799 | 1799 | } |
1800 | 1800 | |
1801 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1801 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1802 | 1802 | |
1803 | 1803 | } |
1804 | 1804 | |
@@ -1812,20 +1812,20 @@ discard block |
||
1812 | 1812 | * |
1813 | 1813 | * @return string $price_id |
1814 | 1814 | */ |
1815 | -function give_get_price_id( $form_id, $price ) { |
|
1815 | +function give_get_price_id($form_id, $price) { |
|
1816 | 1816 | |
1817 | 1817 | $price_id = 0; |
1818 | 1818 | |
1819 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1819 | + if (give_has_variable_prices($form_id)) { |
|
1820 | 1820 | |
1821 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1821 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1822 | 1822 | |
1823 | - foreach ( $levels as $level ) { |
|
1823 | + foreach ($levels as $level) { |
|
1824 | 1824 | |
1825 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1825 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1826 | 1826 | |
1827 | 1827 | // Check that this indeed the recurring price. |
1828 | - if ( $level_amount == $price ) { |
|
1828 | + if ($level_amount == $price) { |
|
1829 | 1829 | |
1830 | 1830 | $price_id = $level['_give_id']['level_id']; |
1831 | 1831 | |
@@ -1850,10 +1850,10 @@ discard block |
||
1850 | 1850 | * |
1851 | 1851 | * @return string|void |
1852 | 1852 | */ |
1853 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1854 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1853 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1854 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1855 | 1855 | |
1856 | - if ( ! $echo ) { |
|
1856 | + if ( ! $echo) { |
|
1857 | 1857 | return $form_dropdown_html; |
1858 | 1858 | } |
1859 | 1859 | |
@@ -1870,17 +1870,17 @@ discard block |
||
1870 | 1870 | * |
1871 | 1871 | * @return string|void |
1872 | 1872 | */ |
1873 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1873 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1874 | 1874 | |
1875 | 1875 | // Check for give form id. |
1876 | - if ( empty( $args['id'] ) ) { |
|
1876 | + if (empty($args['id'])) { |
|
1877 | 1877 | return false; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1880 | + $form = new Give_Donate_Form($args['id']); |
|
1881 | 1881 | |
1882 | 1882 | // Check if form has variable prices or not. |
1883 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1883 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1884 | 1884 | return false; |
1885 | 1885 | } |
1886 | 1886 | |
@@ -1888,22 +1888,22 @@ discard block |
||
1888 | 1888 | $variable_price_options = array(); |
1889 | 1889 | |
1890 | 1890 | // Check if multi donation form support custom donation or not. |
1891 | - if ( $form->is_custom_price_mode() ) { |
|
1892 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1891 | + if ($form->is_custom_price_mode()) { |
|
1892 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1893 | 1893 | } |
1894 | 1894 | |
1895 | 1895 | // Get variable price and ID from variable price array. |
1896 | - foreach ( $variable_prices as $variable_price ) { |
|
1897 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1896 | + foreach ($variable_prices as $variable_price) { |
|
1897 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | // Update options. |
1901 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1901 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1902 | 1902 | |
1903 | 1903 | // Generate select html. |
1904 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1904 | + $form_dropdown_html = Give()->html->select($args); |
|
1905 | 1905 | |
1906 | - if ( ! $echo ) { |
|
1906 | + if ( ! $echo) { |
|
1907 | 1907 | return $form_dropdown_html; |
1908 | 1908 | } |
1909 | 1909 |
@@ -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,37 +23,37 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | /** Give Forms Post Type */ |
26 | - $give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false; |
|
26 | + $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false; |
|
27 | 27 | |
28 | - $give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false; |
|
28 | + $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false; |
|
29 | 29 | |
30 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
30 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
31 | 31 | //support for old 'GIVE_FORMS_SLUG' constant |
32 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
32 | + if (defined('GIVE_FORMS_SLUG')) { |
|
33 | 33 | $give_forms_slug = GIVE_FORMS_SLUG; |
34 | 34 | } |
35 | 35 | |
36 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
37 | 37 | 'slug' => $give_forms_slug, |
38 | 38 | 'with_front' => false |
39 | 39 | ); |
40 | 40 | |
41 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
42 | - 'name' => esc_html__( 'Donation Forms', 'give' ), |
|
43 | - 'singular_name' => esc_html__( 'Form', 'give' ), |
|
44 | - 'add_new' => esc_html__( 'Add Form', 'give' ), |
|
45 | - 'add_new_item' => esc_html__( 'Add New Donation Form', 'give' ), |
|
46 | - 'edit_item' => esc_html__( 'Edit Donation Form', 'give' ), |
|
47 | - 'new_item' => esc_html__( 'New Form', 'give' ), |
|
48 | - 'all_items' => esc_html__( 'All Forms', 'give' ), |
|
49 | - 'view_item' => esc_html__( 'View Form', 'give' ), |
|
50 | - 'search_items' => esc_html__( 'Search Forms', 'give' ), |
|
51 | - 'not_found' => esc_html__( 'No forms found.', 'give' ), |
|
52 | - 'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ), |
|
41 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
42 | + 'name' => esc_html__('Donation Forms', 'give'), |
|
43 | + 'singular_name' => esc_html__('Form', 'give'), |
|
44 | + 'add_new' => esc_html__('Add Form', 'give'), |
|
45 | + 'add_new_item' => esc_html__('Add New Donation Form', 'give'), |
|
46 | + 'edit_item' => esc_html__('Edit Donation Form', 'give'), |
|
47 | + 'new_item' => esc_html__('New Form', 'give'), |
|
48 | + 'all_items' => esc_html__('All Forms', 'give'), |
|
49 | + 'view_item' => esc_html__('View Form', 'give'), |
|
50 | + 'search_items' => esc_html__('Search Forms', 'give'), |
|
51 | + 'not_found' => esc_html__('No forms found.', 'give'), |
|
52 | + 'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'), |
|
53 | 53 | 'parent_item_colon' => '', |
54 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
55 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ) |
|
56 | - ) ); |
|
54 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
55 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')) |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | //Default give_forms supports |
59 | 59 | $give_form_supports = array( |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | ); |
66 | 66 | |
67 | 67 | //Has the user disabled the excerpt |
68 | - if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) { |
|
69 | - unset( $give_form_supports[2] ); |
|
68 | + if (give_get_option('disable_forms_excerpt') === 'on') { |
|
69 | + unset($give_form_supports[2]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | //Has user disabled the featured image? |
73 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
74 | - unset( $give_form_supports[1] ); |
|
75 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
73 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
74 | + unset($give_form_supports[1]); |
|
75 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $give_forms_args = array( |
@@ -88,42 +88,42 @@ discard block |
||
88 | 88 | 'has_archive' => $give_forms_archives, |
89 | 89 | 'menu_icon' => 'dashicons-give', |
90 | 90 | 'hierarchical' => false, |
91 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
91 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
92 | 92 | ); |
93 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
93 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
94 | 94 | |
95 | 95 | /** Donation Post Type */ |
96 | 96 | $payment_labels = array( |
97 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
98 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
99 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
100 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
101 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
102 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
103 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
104 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
105 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
106 | - 'not_found' => esc_html__( 'No donations found.', 'give' ), |
|
107 | - 'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ), |
|
97 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
98 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
99 | + 'add_new' => esc_html__('Add New', 'give'), |
|
100 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
101 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
102 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
103 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
104 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
105 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
106 | + 'not_found' => esc_html__('No donations found.', 'give'), |
|
107 | + 'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'), |
|
108 | 108 | 'parent_item_colon' => '', |
109 | - 'menu_name' => esc_html__( 'Donations', 'give' ) |
|
109 | + 'menu_name' => esc_html__('Donations', 'give') |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $payment_args = array( |
113 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
113 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
114 | 114 | 'public' => false, |
115 | 115 | 'query_var' => false, |
116 | 116 | 'rewrite' => false, |
117 | 117 | 'map_meta_cap' => true, |
118 | 118 | 'capability_type' => 'give_payment', |
119 | - 'supports' => array( 'title' ), |
|
119 | + 'supports' => array('title'), |
|
120 | 120 | 'can_export' => true |
121 | 121 | ); |
122 | - register_post_type( 'give_payment', $payment_args ); |
|
122 | + register_post_type('give_payment', $payment_args); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
126 | +add_action('init', 'give_setup_post_types', 1); |
|
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
@@ -136,30 +136,30 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function give_setup_taxonomies() { |
138 | 138 | |
139 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
139 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
140 | 140 | |
141 | 141 | /** Categories */ |
142 | 142 | $category_labels = array( |
143 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
144 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
145 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
146 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
147 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
148 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
149 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
150 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
151 | - 'add_new_item' => esc_html__( 'Add New Category', 'give' ), |
|
152 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
153 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
143 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
144 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
145 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
146 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
147 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
148 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
149 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
150 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
151 | + 'add_new_item' => esc_html__('Add New Category', 'give'), |
|
152 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
153 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
154 | 154 | ); |
155 | 155 | |
156 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
156 | + $category_args = apply_filters('give_forms_category_args', array( |
|
157 | 157 | 'hierarchical' => true, |
158 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
158 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
159 | 159 | 'show_ui' => true, |
160 | 160 | 'query_var' => 'give_forms_category', |
161 | 161 | 'rewrite' => array( |
162 | - 'slug' => $slug . '/category', |
|
162 | + 'slug' => $slug.'/category', |
|
163 | 163 | 'with_front' => false, |
164 | 164 | 'hierarchical' => true |
165 | 165 | ), |
@@ -173,34 +173,34 @@ discard block |
||
173 | 173 | ); |
174 | 174 | |
175 | 175 | //Does the user want categories? |
176 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
177 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
178 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
176 | + if (give_get_option('enable_categories') == 'on') { |
|
177 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
178 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | 182 | /** Tags */ |
183 | 183 | $tag_labels = array( |
184 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
185 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
186 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
187 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
188 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
189 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
190 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
191 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
192 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
193 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
194 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
195 | - 'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ), |
|
184 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
185 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
186 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
187 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
188 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
189 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
190 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
191 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
192 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
193 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
194 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
195 | + 'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
198 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
199 | 199 | 'hierarchical' => false, |
200 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
200 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
201 | 201 | 'show_ui' => true, |
202 | 202 | 'query_var' => 'give_forms_tag', |
203 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
203 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
204 | 204 | 'capabilities' => array( |
205 | 205 | 'manage_terms' => 'manage_give_form_terms', |
206 | 206 | 'edit_terms' => 'edit_give_form_terms', |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | ) |
211 | 211 | ); |
212 | 212 | |
213 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
214 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
215 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
213 | + if (give_get_option('enable_tags') == 'on') { |
|
214 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
215 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
221 | +add_action('init', 'give_setup_taxonomies', 0); |
|
222 | 222 | |
223 | 223 | |
224 | 224 | /** |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function give_get_default_form_labels() { |
231 | 231 | $defaults = array( |
232 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
233 | - 'plural' => esc_html__( 'Forms', 'give' ) |
|
232 | + 'singular' => esc_html__('Form', 'give'), |
|
233 | + 'plural' => esc_html__('Forms', 'give') |
|
234 | 234 | ); |
235 | 235 | |
236 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
236 | + return apply_filters('give_default_form_name', $defaults); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return string $defaults['singular'] Singular label |
247 | 247 | */ |
248 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
248 | +function give_get_forms_label_singular($lowercase = false) { |
|
249 | 249 | $defaults = give_get_default_form_labels(); |
250 | 250 | |
251 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
251 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * @since 1.0 |
258 | 258 | * @return string $defaults['plural'] Plural label |
259 | 259 | */ |
260 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
260 | +function give_get_forms_label_plural($lowercase = false) { |
|
261 | 261 | $defaults = give_get_default_form_labels(); |
262 | 262 | |
263 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
263 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -272,24 +272,24 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return string $title New placeholder text |
274 | 274 | */ |
275 | -function give_change_default_title( $title ) { |
|
275 | +function give_change_default_title($title) { |
|
276 | 276 | // If a frontend plugin uses this filter (check extensions before changing this function) |
277 | - if ( ! is_admin() ) { |
|
278 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
277 | + if ( ! is_admin()) { |
|
278 | + $title = esc_html__('Enter form title here', 'give'); |
|
279 | 279 | |
280 | 280 | return $title; |
281 | 281 | } |
282 | 282 | |
283 | 283 | $screen = get_current_screen(); |
284 | 284 | |
285 | - if ( 'give_forms' == $screen->post_type ) { |
|
286 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
285 | + if ('give_forms' == $screen->post_type) { |
|
286 | + $title = esc_html__('Enter form title here', 'give'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $title; |
290 | 290 | } |
291 | 291 | |
292 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
292 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * Registers Custom Post Statuses which are used by the Payments |
@@ -299,50 +299,50 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function give_register_post_type_statuses() { |
301 | 301 | // Payment Statuses |
302 | - register_post_status( 'refunded', array( |
|
303 | - 'label' => esc_html__( 'Refunded', 'give' ), |
|
302 | + register_post_status('refunded', array( |
|
303 | + 'label' => esc_html__('Refunded', 'give'), |
|
304 | 304 | 'public' => true, |
305 | 305 | 'exclude_from_search' => false, |
306 | 306 | 'show_in_admin_all_list' => true, |
307 | 307 | 'show_in_admin_status_list' => true, |
308 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ) |
|
309 | - ) ); |
|
310 | - register_post_status( 'failed', array( |
|
311 | - 'label' => esc_html__( 'Failed', 'give' ), |
|
308 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give') |
|
309 | + )); |
|
310 | + register_post_status('failed', array( |
|
311 | + 'label' => esc_html__('Failed', 'give'), |
|
312 | 312 | 'public' => true, |
313 | 313 | 'exclude_from_search' => false, |
314 | 314 | 'show_in_admin_all_list' => true, |
315 | 315 | 'show_in_admin_status_list' => true, |
316 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ) |
|
317 | - ) ); |
|
318 | - register_post_status( 'revoked', array( |
|
319 | - 'label' => esc_html__( 'Revoked', 'give' ), |
|
316 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give') |
|
317 | + )); |
|
318 | + register_post_status('revoked', array( |
|
319 | + 'label' => esc_html__('Revoked', 'give'), |
|
320 | 320 | 'public' => true, |
321 | 321 | 'exclude_from_search' => false, |
322 | 322 | 'show_in_admin_all_list' => true, |
323 | 323 | 'show_in_admin_status_list' => true, |
324 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ) |
|
325 | - ) ); |
|
326 | - register_post_status( 'cancelled', array( |
|
327 | - 'label' => esc_html__( 'Cancelled', 'give' ), |
|
324 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give') |
|
325 | + )); |
|
326 | + register_post_status('cancelled', array( |
|
327 | + 'label' => esc_html__('Cancelled', 'give'), |
|
328 | 328 | 'public' => true, |
329 | 329 | 'exclude_from_search' => false, |
330 | 330 | 'show_in_admin_all_list' => true, |
331 | 331 | 'show_in_admin_status_list' => true, |
332 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ) |
|
333 | - ) ); |
|
334 | - register_post_status( 'abandoned', array( |
|
335 | - 'label' => esc_html__( 'Abandoned', 'give' ), |
|
332 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give') |
|
333 | + )); |
|
334 | + register_post_status('abandoned', array( |
|
335 | + 'label' => esc_html__('Abandoned', 'give'), |
|
336 | 336 | 'public' => true, |
337 | 337 | 'exclude_from_search' => false, |
338 | 338 | 'show_in_admin_all_list' => true, |
339 | 339 | 'show_in_admin_status_list' => true, |
340 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ) |
|
341 | - ) ); |
|
340 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give') |
|
341 | + )); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
345 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
345 | +add_action('init', 'give_register_post_type_statuses'); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Updated Messages |
@@ -355,27 +355,27 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return array $messages New post updated messages |
357 | 357 | */ |
358 | -function give_updated_messages( $messages ) { |
|
358 | +function give_updated_messages($messages) { |
|
359 | 359 | global $post, $post_ID; |
360 | 360 | |
361 | - if ( give_get_option( 'disable_forms_singular' ) === 'on' ) { |
|
361 | + if (give_get_option('disable_forms_singular') === 'on') { |
|
362 | 362 | |
363 | 363 | $messages['give_forms'] = array( |
364 | - 1 => esc_html__( 'Form updated.', 'give' ), |
|
365 | - 4 => esc_html__( 'Form updated.', 'give' ), |
|
366 | - 6 => esc_html__( 'Form published.', 'give' ), |
|
367 | - 7 => esc_html__( 'Form saved.', 'give' ), |
|
368 | - 8 => esc_html__( 'Form submitted.', 'give' ) |
|
364 | + 1 => esc_html__('Form updated.', 'give'), |
|
365 | + 4 => esc_html__('Form updated.', 'give'), |
|
366 | + 6 => esc_html__('Form published.', 'give'), |
|
367 | + 7 => esc_html__('Form saved.', 'give'), |
|
368 | + 8 => esc_html__('Form submitted.', 'give') |
|
369 | 369 | ); |
370 | 370 | |
371 | 371 | } else { |
372 | 372 | |
373 | 373 | $messages['give_forms'] = array( |
374 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
375 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
376 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form published.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
377 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form saved.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ), |
|
378 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form submitted.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ) |
|
374 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
375 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
376 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form published.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
377 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form saved.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')), |
|
378 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form submitted.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')) |
|
379 | 379 | ); |
380 | 380 | |
381 | 381 | } |
@@ -383,25 +383,25 @@ discard block |
||
383 | 383 | return $messages; |
384 | 384 | } |
385 | 385 | |
386 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
386 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
387 | 387 | |
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Setup Post Type Images |
391 | 391 | */ |
392 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
392 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
393 | 393 | |
394 | 394 | /** |
395 | 395 | * Ensure post thumbnail support is turned on |
396 | 396 | */ |
397 | 397 | function give_add_thumbnail_support() { |
398 | - if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) { |
|
398 | + if (give_get_option('disable_form_featured_img') === 'on') { |
|
399 | 399 | return; |
400 | 400 | } |
401 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
402 | - add_theme_support( 'post-thumbnails' ); |
|
401 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
402 | + add_theme_support('post-thumbnails'); |
|
403 | 403 | } |
404 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
404 | + add_post_type_support('give_forms', 'thumbnail'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -413,19 +413,19 @@ discard block |
||
413 | 413 | function give_widgets_init() { |
414 | 414 | |
415 | 415 | //Single Give Forms (disabled if single turned off in settings) |
416 | - if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) { |
|
416 | + if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { |
|
417 | 417 | |
418 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
419 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
418 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
419 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
420 | 420 | 'id' => 'give-forms-sidebar', |
421 | - 'description' => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
421 | + 'description' => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
422 | 422 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
423 | 423 | 'after_widget' => '</div>', |
424 | 424 | 'before_title' => '<h3 class="widgettitle widget-title">', |
425 | 425 | 'after_title' => '</h3>', |
426 | - ) ) ); |
|
426 | + ))); |
|
427 | 427 | |
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
431 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * before_widget, and after_widget. |
80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
81 | 81 | */ |
82 | - public function widget( $args, $instance ){ |
|
83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + public function widget($args, $instance) { |
|
83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
85 | 85 | |
86 | 86 | |
87 | 87 | // If user set float labels to global then check global float label setting and update donation form widget accordingly. |
88 | - if( ( 'global' === $instance['float_labels'] ) ) { |
|
89 | - $instance['float_labels'] = ( 'on' === give_get_option( 'enable_floatlabels', '' ) ) ? 'enabled' : 'disabled'; |
|
88 | + if (('global' === $instance['float_labels'])) { |
|
89 | + $instance['float_labels'] = ('on' === give_get_option('enable_floatlabels', '')) ? 'enabled' : 'disabled'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | echo $args['before_widget']; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 1.0 |
98 | 98 | */ |
99 | - do_action( 'give_before_forms_widget' ); |
|
99 | + do_action('give_before_forms_widget'); |
|
100 | 100 | |
101 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
101 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
102 | 102 | |
103 | - give_get_donation_form( $instance ); |
|
103 | + give_get_donation_form($instance); |
|
104 | 104 | |
105 | 105 | echo $args['after_widget']; |
106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @since 1.0 |
111 | 111 | */ |
112 | - do_action( 'give_after_forms_widget' ); |
|
112 | + do_action('give_after_forms_widget'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public function form( $instance ){ |
|
122 | + public function form($instance) { |
|
123 | 123 | $defaults = array( |
124 | 124 | 'title' => '', |
125 | 125 | 'id' => '', |
@@ -127,64 +127,64 @@ discard block |
||
127 | 127 | 'display_style' => 'modal', |
128 | 128 | ); |
129 | 129 | |
130 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
130 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
131 | 131 | |
132 | 132 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
133 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
133 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
134 | 134 | |
135 | 135 | // Query Give Forms |
136 | 136 | $args = array( |
137 | 137 | 'post_type' => 'give_forms', |
138 | - 'posts_per_page' => - 1, |
|
138 | + 'posts_per_page' => -1, |
|
139 | 139 | 'post_status' => 'publish', |
140 | 140 | ); |
141 | 141 | |
142 | - $give_forms = get_posts( $args ); |
|
142 | + $give_forms = get_posts($args); |
|
143 | 143 | |
144 | 144 | // Widget: Title |
145 | 145 | |
146 | 146 | ?><p> |
147 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
148 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
149 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
147 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
148 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
149 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
150 | 150 | </p><?php |
151 | 151 | |
152 | 152 | // Widget: Give Form |
153 | 153 | |
154 | 154 | ?><p> |
155 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
156 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
157 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
158 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
159 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
155 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
156 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
157 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
158 | + <?php foreach ($give_forms as $give_form) { ?> |
|
159 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
160 | 160 | <?php } ?> |
161 | 161 | </select><br> |
162 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
162 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
163 | 163 | </p> |
164 | 164 | |
165 | 165 | <?php // Widget: Display Style ?> |
166 | 166 | <p> |
167 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display style:', 'give' ); ?></label><br> |
|
168 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
169 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
170 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label><br> |
|
167 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display style:', 'give'); ?></label><br> |
|
168 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
169 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
170 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label><br> |
|
171 | 171 | <small class="give-field-description"> |
172 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
172 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
173 | 173 | </small> |
174 | 174 | </p> |
175 | 175 | |
176 | 176 | <?php // Widget: Floating Labels ?> |
177 | 177 | <p> |
178 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
179 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Options', 'give' ); ?></label> |
|
180 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
181 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
178 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
179 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Options', 'give'); ?></label> |
|
180 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
181 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
182 | 182 | <small class="give-field-description"> |
183 | 183 | <?php |
184 | 184 | printf( |
185 | 185 | /* translators: %s: https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
186 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
187 | - esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) |
|
186 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
187 | + esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels') |
|
188 | 188 | ); |
189 | 189 | ?></small> |
190 | 190 | </p><?php |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - function widget_init(){ |
|
199 | - register_widget( $this->self ); |
|
198 | + function widget_init() { |
|
199 | + register_widget($this->self); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - public function update( $new_instance, $old_instance ){ |
|
210 | + public function update($new_instance, $old_instance) { |
|
211 | 211 | $this->flush_widget_cache(); |
212 | 212 | |
213 | 213 | return $new_instance; |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | - public function flush_widget_cache(){ |
|
222 | - wp_cache_delete( $this->self, 'widget' ); |
|
221 | + public function flush_widget_cache() { |
|
222 | + wp_cache_delete($this->self, 'widget'); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
31 | - if( doing_action( 'admin_init' ) && empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (doing_action('admin_init') && empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
49 | -add_action( 'admin_init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | +add_action('admin_init', 'give_get_actions'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Hooks Give actions, when present in the $_POST superglobal. Every give_action |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function give_post_actions() { |
61 | 61 | |
62 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
62 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
63 | 63 | |
64 | 64 | |
65 | 65 | // Add backward compatibility to give-action param ( $_GET or $_POST ) |
66 | - if( doing_action( 'admin_init' ) && empty( $_post_action ) ) { |
|
67 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
66 | + if (doing_action('admin_init') && empty($_post_action)) { |
|
67 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | - if ( isset( $_post_action ) ) { |
|
70 | + if (isset($_post_action)) { |
|
71 | 71 | /** |
72 | 72 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
73 | 73 | * |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param array $_POST Array of HTTP POST variables. |
77 | 77 | */ |
78 | - do_action( "give_{$_post_action}", $_POST ); |
|
78 | + do_action("give_{$_post_action}", $_POST); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'init', 'give_post_actions' ); |
|
84 | -add_action( 'admin_init', 'give_post_actions' ); |
|
83 | +add_action('init', 'give_post_actions'); |
|
84 | +add_action('admin_init', 'give_post_actions'); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Connect WordPress user with Donor. |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | * @param array $user_data User Data |
92 | 92 | * @return void |
93 | 93 | */ |
94 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
95 | - $donor = new Give_Customer( $user_data['user_email'] ); |
|
94 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
95 | + $donor = new Give_Customer($user_data['user_email']); |
|
96 | 96 | |
97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
98 | - if( $donor->id && ! $donor->user_id ) { |
|
98 | + if ($donor->id && ! $donor->user_id) { |
|
99 | 99 | |
100 | 100 | // Update donor user_id. |
101 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
103 | - $donor->add_note( $donor_note ); |
|
101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
103 | + $donor->add_note($donor_note); |
|
104 | 104 | |
105 | 105 | // Update user_id meta in payments. |
106 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
107 | - foreach ( $donations as $donation ) { |
|
108 | - update_post_meta( $donation, '_give_payment_user_id', $user_id ); |
|
106 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
107 | + foreach ($donations as $donation) { |
|
108 | + update_post_meta($donation, '_give_payment_user_id', $user_id); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
114 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | function give_validate_license_when_site_migrated() { |
126 | 126 | // Store current site address if not already stored. |
127 | 127 | $homeurl = home_url(); |
128 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
128 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
129 | 129 | // Update site address. |
130 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
130 | + update_option('give_site_address_before_migrate', $homeurl); |
|
131 | 131 | |
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
135 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
136 | 136 | // Immediately run cron. |
137 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
137 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
138 | 138 | |
139 | 139 | // Update site address. |
140 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
140 | + update_option('give_site_address_before_migrate', home_url()); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
145 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
144 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
145 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today)); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-orders-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - esc_html__( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, false ) |
|
68 | + esc_html__('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, false) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
80 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
81 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
127 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | + $num_posts = wp_count_posts('give_forms'); |
|
128 | 128 | |
129 | - if ( $num_posts && $num_posts->publish ) { |
|
129 | + if ($num_posts && $num_posts->publish) { |
|
130 | 130 | |
131 | 131 | $text = sprintf( |
132 | 132 | /* translators: %s: number of posts published */ |
133 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
133 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
134 | 134 | $num_posts->publish |
135 | 135 | ); |
136 | 136 | |
137 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
137 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
138 | 138 | |
139 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
140 | 140 | $text = sprintf( |
141 | 141 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
142 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
142 | + admin_url('edit.php?post_type=give_forms'), |
|
143 | 143 | $text |
144 | 144 | ); |
145 | 145 | } else { |
@@ -155,4 +155,4 @@ discard block |
||
155 | 155 | return $items; |
156 | 156 | } |
157 | 157 | |
158 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
158 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param $args |
67 | 67 | * |
68 | 68 | */ |
69 | - public function __construct( $args ) { |
|
69 | + public function __construct($args) { |
|
70 | 70 | |
71 | 71 | //Only for admins. |
72 | - if ( ! is_admin() ) { |
|
72 | + if ( ! is_admin()) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | //This plugin is en_US native. |
77 | 77 | $this->locale = get_locale(); |
78 | - if ( 'en_US' === $this->locale ) { |
|
78 | + if ('en_US' === $this->locale) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - $this->init( $args ); |
|
82 | + $this->init($args); |
|
83 | 83 | |
84 | - if ( ! $this->hide_promo() ) { |
|
85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
84 | + if ( ! $this->hide_promo()) { |
|
85 | + add_action($this->hook, array($this, 'promo')); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param array $args |
95 | 95 | */ |
96 | - private function init( $args ) { |
|
97 | - foreach ( $args as $key => $arg ) { |
|
96 | + private function init($args) { |
|
97 | + foreach ($args as $key => $arg) { |
|
98 | 98 | $this->$key = $arg; |
99 | 99 | } |
100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | */ |
110 | 110 | private function hide_promo() { |
111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
112 | - if ( ! $hide_promo ) { |
|
113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
112 | + if ( ! $hide_promo) { |
|
113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
115 | + set_transient('give_i18n_give_promo_hide', true); |
|
116 | 116 | $hide_promo = true; |
117 | 117 | } |
118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | $message = false; |
132 | 132 | |
133 | 133 | //Using a translation less than 90% complete. |
134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
138 | - } elseif ( ! $this->translation_exists ) { |
|
139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
138 | + } elseif ( ! $this->translation_exists) { |
|
139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | //Links. |
143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
145 | 145 | |
146 | 146 | //Message. |
147 | - $message = sprintf( $message, esc_html( $this->locale_name ), esc_html( 'Give' ), $this->percent_translated, $registration_link, $translations_link ); |
|
147 | + $message = sprintf($message, esc_html($this->locale_name), esc_html('Give'), $this->percent_translated, $registration_link, $translations_link); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $this->translation_details(); |
160 | 160 | $message = $this->promo_message(); |
161 | 161 | |
162 | - if ( $message ) { ?> |
|
162 | + if ($message) { ?> |
|
163 | 163 | |
164 | 164 | <style> |
165 | 165 | /* Banner specific styles */ |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
213 | 213 | |
214 | 214 | <div class="give-i18n-notice-content"> |
215 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
215 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
216 | 216 | |
217 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
217 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
218 | 218 | <p><?php echo $message; ?></p> |
219 | 219 | <p> |
220 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
220 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
221 | 221 | </p> |
222 | 222 | </div> |
223 | 223 | </div> |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | */ |
235 | 235 | private function find_or_initialize_translation_details() { |
236 | 236 | |
237 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
237 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
238 | 238 | |
239 | - if ( ! $set ) { |
|
239 | + if ( ! $set) { |
|
240 | 240 | $set = $this->retrieve_translation_details(); |
241 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
241 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $set; |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | private function translation_details() { |
253 | 253 | $set = $this->find_or_initialize_translation_details(); |
254 | 254 | |
255 | - $this->translation_exists = ! is_null( $set ); |
|
256 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
255 | + $this->translation_exists = ! is_null($set); |
|
256 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
257 | 257 | |
258 | - $this->parse_translation_set( $set ); |
|
258 | + $this->parse_translation_set($set); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -267,26 +267,26 @@ discard block |
||
267 | 267 | */ |
268 | 268 | private function retrieve_translation_details() { |
269 | 269 | |
270 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
270 | + $api_url = trailingslashit($this->glotpress_url); |
|
271 | 271 | |
272 | - $resp = wp_remote_get( $api_url ); |
|
272 | + $resp = wp_remote_get($api_url); |
|
273 | 273 | |
274 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
274 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
275 | 275 | return null; |
276 | 276 | } |
277 | 277 | |
278 | - $body = wp_remote_retrieve_body( $resp ); |
|
279 | - unset( $resp ); |
|
278 | + $body = wp_remote_retrieve_body($resp); |
|
279 | + unset($resp); |
|
280 | 280 | |
281 | - if ( $body ) { |
|
282 | - $body = json_decode( $body ); |
|
281 | + if ($body) { |
|
282 | + $body = json_decode($body); |
|
283 | 283 | |
284 | - foreach ( $body->translation_sets as $set ) { |
|
285 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
284 | + foreach ($body->translation_sets as $set) { |
|
285 | + if ( ! property_exists($set, 'wp_locale')) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( $this->locale == $set->wp_locale ) { |
|
289 | + if ($this->locale == $set->wp_locale) { |
|
290 | 290 | return $set; |
291 | 291 | } |
292 | 292 | } |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @access private |
304 | 304 | */ |
305 | - private function parse_translation_set( $set ) { |
|
306 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
305 | + private function parse_translation_set($set) { |
|
306 | + if ($this->translation_exists && is_object($set)) { |
|
307 | 307 | $this->locale_name = $set->name; |
308 | 308 | $this->percent_translated = $set->percent_translated; |
309 | 309 | } else { |