@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | */ |
5 | 5 | $give_map_deprecated_filters = give_deprecated_filters(); |
6 | 6 | |
7 | -foreach ( $give_map_deprecated_filters as $new => $old ) { |
|
8 | - add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 ); |
|
7 | +foreach ($give_map_deprecated_filters as $new => $old) { |
|
8 | + add_filter($new, 'give_deprecated_filter_mapping', 10, 4); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | -function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
|
44 | +function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') { |
|
45 | 45 | $give_map_deprecated_filters = give_deprecated_filters(); |
46 | 46 | $filter = current_filter(); |
47 | 47 | |
48 | - if ( isset( $give_map_deprecated_filters[ $filter ] ) ) { |
|
49 | - if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) { |
|
50 | - $data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 ); |
|
48 | + if (isset($give_map_deprecated_filters[$filter])) { |
|
49 | + if (has_filter($give_map_deprecated_filters[$filter])) { |
|
50 | + $data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3); |
|
51 | 51 | |
52 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
52 | + if ( ! defined('DOING_AJAX')) { |
|
53 | 53 | _give_deprecated_function( |
54 | 54 | sprintf( |
55 | 55 | /* translators: %s: filter name */ |
56 | - __( 'The %s filter' ), |
|
57 | - $give_map_deprecated_filters[ $filter ] |
|
56 | + __('The %s filter'), |
|
57 | + $give_map_deprecated_filters[$filter] |
|
58 | 58 | ), |
59 | 59 | '1.7', |
60 | 60 | $filter |
@@ -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 | |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => __('PayPal', 'give'), |
|
29 | 29 | ), |
30 | 30 | 'manual' => array( |
31 | - 'admin_label' => __( 'Test Donation', 'give' ), |
|
32 | - 'checkout_label' => __( 'Test Donation', 'give' ) |
|
31 | + 'admin_label' => __('Test Donation', 'give'), |
|
32 | + 'checkout_label' => __('Test Donation', 'give') |
|
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | |
36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
36 | + return apply_filters('give_payment_gateways', $gateways); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array $gateway_list All the available gateways |
48 | 48 | */ |
49 | -function give_get_enabled_payment_gateways( $form_id = 0 ) { |
|
49 | +function give_get_enabled_payment_gateways($form_id = 0) { |
|
50 | 50 | |
51 | 51 | $gateways = give_get_payment_gateways(); |
52 | 52 | |
53 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
53 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
54 | 54 | |
55 | 55 | $gateway_list = array(); |
56 | 56 | |
57 | - foreach ( $gateways as $key => $gateway ) { |
|
58 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
59 | - $gateway_list[ $key ] = $gateway; |
|
57 | + foreach ($gateways as $key => $gateway) { |
|
58 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
59 | + $gateway_list[$key] = $gateway; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Set order of payment gateway in list. |
64 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
64 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
65 | 65 | |
66 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id ); |
|
66 | + return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return boolean true if enabled, false otherwise |
77 | 77 | */ |
78 | -function give_is_gateway_active( $gateway ) { |
|
78 | +function give_is_gateway_active($gateway) { |
|
79 | 79 | $gateways = give_get_enabled_payment_gateways(); |
80 | 80 | |
81 | - $ret = array_key_exists( $gateway, $gateways ); |
|
81 | + $ret = array_key_exists($gateway, $gateways); |
|
82 | 82 | |
83 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
83 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string Gateway ID |
94 | 94 | */ |
95 | -function give_get_default_gateway( $form_id ) { |
|
95 | +function give_get_default_gateway($form_id) { |
|
96 | 96 | |
97 | 97 | $give_options = give_get_settings(); |
98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
100 | 100 | |
101 | 101 | // Single Form settings varies compared to the Global default settings. |
102 | - if ( ! empty( $form_default ) && |
|
102 | + if ( ! empty($form_default) && |
|
103 | 103 | $form_id !== null && |
104 | 104 | $default !== $form_default && |
105 | 105 | $form_default !== 'global' && |
106 | - give_is_gateway_active( $form_default ) |
|
106 | + give_is_gateway_active($form_default) |
|
107 | 107 | ) { |
108 | 108 | $default = $form_default; |
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_default_gateway', $default ); |
|
111 | + return apply_filters('give_default_gateway', $default); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string Gateway admin label |
122 | 122 | */ |
123 | -function give_get_gateway_admin_label( $gateway ) { |
|
123 | +function give_get_gateway_admin_label($gateway) { |
|
124 | 124 | $gateways = give_get_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
127 | 127 | |
128 | - if ( $gateway == 'manual' && $payment ) { |
|
129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
130 | - $label = __( 'Test Donation', 'give' ); |
|
128 | + if ($gateway == 'manual' && $payment) { |
|
129 | + if (give_get_payment_amount($payment) == 0) { |
|
130 | + $label = __('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Checkout label for the gateway |
145 | 145 | */ |
146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
146 | +function give_get_gateway_checkout_label($gateway) { |
|
147 | 147 | $gateways = give_get_payment_gateways(); |
148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
149 | 149 | |
150 | - if ( $gateway == 'manual' ) { |
|
151 | - $label = __( 'Test Donation', 'give' ); |
|
150 | + if ($gateway == 'manual') { |
|
151 | + $label = __('Test Donation', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Options the gateway supports |
165 | 165 | */ |
166 | -function give_get_gateway_supports( $gateway ) { |
|
166 | +function give_get_gateway_supports($gateway) { |
|
167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
169 | 169 | |
170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return void |
182 | 182 | */ |
183 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
183 | +function give_send_to_gateway($gateway, $payment_data) { |
|
184 | 184 | |
185 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
185 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Fires while loading payment gateway via AJAX. |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param array $payment_data All the payment data to be sent to the gateway. |
195 | 195 | */ |
196 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
196 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -207,34 +207,34 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return string $enabled_gateway The slug of the gateway |
209 | 209 | */ |
210 | -function give_get_chosen_gateway( $form_id ) { |
|
210 | +function give_get_chosen_gateway($form_id) { |
|
211 | 211 | |
212 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
212 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
213 | 213 | |
214 | 214 | // Back to check if 'form-id' is present. |
215 | - if ( empty( $request_form_id ) ) { |
|
216 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
215 | + if (empty($request_form_id)) { |
|
216 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
217 | 217 | } |
218 | 218 | |
219 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
219 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
220 | 220 | $chosen = false; |
221 | 221 | |
222 | 222 | // If both 'payment-mode' and 'form-id' then set for only this form. |
223 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
223 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
224 | 224 | $chosen = $request_payment_mode; |
225 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
225 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
226 | 226 | // If no 'form-id' but there is 'payment-mode'. |
227 | 227 | $chosen = $request_payment_mode; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Get the enable gateway based of chosen var. |
231 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
232 | - $enabled_gateway = urldecode( $chosen ); |
|
231 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
232 | + $enabled_gateway = urldecode($chosen); |
|
233 | 233 | } else { |
234 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
234 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
235 | 235 | } |
236 | 236 | |
237 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
237 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return int ID of the new log entry |
254 | 254 | */ |
255 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
256 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
255 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
256 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return int |
268 | 268 | */ |
269 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
269 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
270 | 270 | |
271 | 271 | $ret = 0; |
272 | 272 | $args = array( |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | 'fields' => 'ids', |
279 | 279 | ); |
280 | 280 | |
281 | - $payments = new WP_Query( $args ); |
|
281 | + $payments = new WP_Query($args); |
|
282 | 282 | |
283 | - if ( $payments ) { |
|
283 | + if ($payments) { |
|
284 | 284 | $ret = $payments->post_count; |
285 | 285 | } |
286 | 286 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return array $gateways All the available gateways |
299 | 299 | */ |
300 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
300 | +function give_get_ordered_payment_gateways($gateways) { |
|
301 | 301 | |
302 | 302 | // Get gateways setting. |
303 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
303 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
304 | 304 | |
305 | 305 | // Return from here if we do not have gateways setting. |
306 | - if ( empty( $gateways_setting ) ) { |
|
306 | + if (empty($gateways_setting)) { |
|
307 | 307 | return $gateways; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Reverse array to order payment gateways. |
311 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
311 | + $gateways_setting = array_reverse($gateways_setting); |
|
312 | 312 | |
313 | 313 | // Reorder gateways array |
314 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
314 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
315 | 315 | |
316 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
317 | - unset( $gateways[ $gateway_key ] ); |
|
316 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
317 | + unset($gateways[$gateway_key]); |
|
318 | 318 | |
319 | - if ( ! empty( $new_gateway_value ) ) { |
|
320 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
319 | + if ( ! empty($new_gateway_value)) { |
|
320 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -328,5 +328,5 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @param array $gateways All the available gateways |
330 | 330 | */ |
331 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
331 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
332 | 332 | } |
333 | 333 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | function give_test_ajax_works() { |
27 | 27 | |
28 | 28 | // Check if the Airplane Mode plugin is installed |
29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
29 | + if (class_exists('Airplane_Mode_Core')) { |
|
30 | 30 | |
31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
32 | 32 | |
33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
33 | + if (method_exists($airplane, 'enabled')) { |
|
34 | 34 | |
35 | - if ( $airplane->enabled() ) { |
|
35 | + if ($airplane->enabled()) { |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( $airplane->check_status() == 'on' ) { |
|
40 | + if ($airplane->check_status() == 'on') { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
48 | + if (get_transient('_give_ajax_works')) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ), |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | |
62 | 62 | $works = true; |
63 | 63 | |
64 | - if ( is_wp_error( $ajax ) ) { |
|
64 | + if (is_wp_error($ajax)) { |
|
65 | 65 | |
66 | 66 | $works = false; |
67 | 67 | |
68 | 68 | } else { |
69 | 69 | |
70 | - if ( empty( $ajax['response'] ) ) { |
|
70 | + if (empty($ajax['response'])) { |
|
71 | 71 | $works = false; |
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
75 | 75 | $works = false; |
76 | 76 | } |
77 | 77 | |
78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
79 | 79 | $works = false; |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
83 | 83 | $works = false; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
87 | + if ($works) { |
|
88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | */ |
102 | 102 | function give_get_ajax_url() { |
103 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
104 | 104 | |
105 | 105 | $current_url = give_get_current_page_url(); |
106 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
106 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
107 | 107 | |
108 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
109 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
108 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
109 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
110 | 110 | } |
111 | 111 | |
112 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
112 | + return apply_filters('give_ajax_url', $ajax_url); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.7 |
127 | 127 | */ |
128 | - do_action( 'give_donation_form_login_fields' ); |
|
128 | + do_action('give_donation_form_login_fields'); |
|
129 | 129 | |
130 | 130 | give_die(); |
131 | 131 | } |
132 | 132 | |
133 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
133 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Load Checkout Fields |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | */ |
142 | 142 | function give_load_checkout_fields() { |
143 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
143 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
144 | 144 | |
145 | 145 | ob_start(); |
146 | 146 | |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @since 1.7 |
151 | 151 | */ |
152 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
152 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
153 | 153 | |
154 | 154 | $fields = ob_get_clean(); |
155 | 155 | |
156 | - wp_send_json( array( |
|
157 | - 'fields' => wp_json_encode( $fields ), |
|
158 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
159 | - ) ); |
|
156 | + wp_send_json(array( |
|
157 | + 'fields' => wp_json_encode($fields), |
|
158 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
163 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
162 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
163 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function give_ajax_get_form_title() { |
173 | - if ( isset( $_POST['form_id'] ) ) { |
|
174 | - $title = get_the_title( $_POST['form_id'] ); |
|
175 | - if ( $title ) { |
|
173 | + if (isset($_POST['form_id'])) { |
|
174 | + $title = get_the_title($_POST['form_id']); |
|
175 | + if ($title) { |
|
176 | 176 | echo $title; |
177 | 177 | } else { |
178 | 178 | echo 'fail'; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
185 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
184 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
185 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Retrieve a states drop down |
@@ -193,23 +193,23 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function give_ajax_get_states_field() { |
195 | 195 | |
196 | - if ( empty( $_POST['country'] ) ) { |
|
196 | + if (empty($_POST['country'])) { |
|
197 | 197 | $_POST['country'] = give_get_country(); |
198 | 198 | } |
199 | - $states = give_get_states( $_POST['country'] ); |
|
199 | + $states = give_get_states($_POST['country']); |
|
200 | 200 | |
201 | - if ( ! empty( $states ) ) { |
|
201 | + if ( ! empty($states)) { |
|
202 | 202 | |
203 | 203 | $args = array( |
204 | 204 | 'name' => $_POST['field_name'], |
205 | 205 | 'id' => $_POST['field_name'], |
206 | - 'class' => $_POST['field_name'] . ' give-select', |
|
207 | - 'options' => give_get_states( $_POST['country'] ), |
|
206 | + 'class' => $_POST['field_name'].' give-select', |
|
207 | + 'options' => give_get_states($_POST['country']), |
|
208 | 208 | 'show_option_all' => false, |
209 | 209 | 'show_option_none' => false, |
210 | 210 | ); |
211 | 211 | |
212 | - $response = Give()->html->select( $args ); |
|
212 | + $response = Give()->html->select($args); |
|
213 | 213 | |
214 | 214 | } else { |
215 | 215 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | give_die(); |
222 | 222 | } |
223 | 223 | |
224 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
225 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
224 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
225 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Retrieve a states drop down |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | function give_ajax_form_search() { |
235 | 235 | global $wpdb; |
236 | 236 | |
237 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
237 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
238 | 238 | $results = array(); |
239 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
240 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
239 | + if (current_user_can('edit_give_forms')) { |
|
240 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
241 | 241 | } else { |
242 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
242 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
243 | 243 | } |
244 | 244 | |
245 | - if ( $items ) { |
|
245 | + if ($items) { |
|
246 | 246 | |
247 | - foreach ( $items as $item ) { |
|
247 | + foreach ($items as $item) { |
|
248 | 248 | |
249 | 249 | $results[] = array( |
250 | 250 | 'id' => $item->ID, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | |
256 | 256 | $items[] = array( |
257 | 257 | 'id' => 0, |
258 | - 'name' => esc_html__( 'No forms found.', 'give' ), |
|
258 | + 'name' => esc_html__('No forms found.', 'give'), |
|
259 | 259 | ); |
260 | 260 | |
261 | 261 | } |
262 | 262 | |
263 | - echo json_encode( $results ); |
|
263 | + echo json_encode($results); |
|
264 | 264 | |
265 | 265 | give_die(); |
266 | 266 | } |
267 | 267 | |
268 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
269 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
268 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
269 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Search the donors database via Ajax |
@@ -278,38 +278,38 @@ discard block |
||
278 | 278 | function give_ajax_donor_search() { |
279 | 279 | global $wpdb; |
280 | 280 | |
281 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
281 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
282 | 282 | $results = array(); |
283 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
283 | + if ( ! current_user_can('view_give_reports')) { |
|
284 | 284 | $donors = array(); |
285 | 285 | } else { |
286 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
286 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( $donors ) { |
|
289 | + if ($donors) { |
|
290 | 290 | |
291 | - foreach ( $donors as $donor ) { |
|
291 | + foreach ($donors as $donor) { |
|
292 | 292 | |
293 | 293 | $results[] = array( |
294 | 294 | 'id' => $donor->id, |
295 | - 'name' => $donor->name . '(' . $donor->email . ')', |
|
295 | + 'name' => $donor->name.'('.$donor->email.')', |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | } else { |
299 | 299 | |
300 | 300 | $donors[] = array( |
301 | 301 | 'id' => 0, |
302 | - 'name' => esc_html__( 'No donors found.', 'give' ), |
|
302 | + 'name' => esc_html__('No donors found.', 'give'), |
|
303 | 303 | ); |
304 | 304 | |
305 | 305 | } |
306 | 306 | |
307 | - echo json_encode( $results ); |
|
307 | + echo json_encode($results); |
|
308 | 308 | |
309 | 309 | give_die(); |
310 | 310 | } |
311 | 311 | |
312 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
312 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
313 | 313 | |
314 | 314 | |
315 | 315 | /** |
@@ -321,42 +321,42 @@ discard block |
||
321 | 321 | */ |
322 | 322 | function give_ajax_search_users() { |
323 | 323 | |
324 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
324 | + if (current_user_can('manage_give_settings')) { |
|
325 | 325 | |
326 | - $search_query = trim( $_POST['user_name'] ); |
|
327 | - $exclude = trim( $_POST['exclude'] ); |
|
326 | + $search_query = trim($_POST['user_name']); |
|
327 | + $exclude = trim($_POST['exclude']); |
|
328 | 328 | |
329 | 329 | $get_users_args = array( |
330 | 330 | 'number' => 9999, |
331 | - 'search' => $search_query . '*', |
|
331 | + 'search' => $search_query.'*', |
|
332 | 332 | ); |
333 | 333 | |
334 | - if ( ! empty( $exclude ) ) { |
|
335 | - $exclude_array = explode( ',', $exclude ); |
|
334 | + if ( ! empty($exclude)) { |
|
335 | + $exclude_array = explode(',', $exclude); |
|
336 | 336 | $get_users_args['exclude'] = $exclude_array; |
337 | 337 | } |
338 | 338 | |
339 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
339 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
340 | 340 | |
341 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
341 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
342 | 342 | |
343 | 343 | $user_list = '<ul>'; |
344 | - if ( $found_users ) { |
|
345 | - foreach ( $found_users as $user ) { |
|
346 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
344 | + if ($found_users) { |
|
345 | + foreach ($found_users as $user) { |
|
346 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
347 | 347 | } |
348 | 348 | } else { |
349 | - $user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>'; |
|
349 | + $user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>'; |
|
350 | 350 | } |
351 | 351 | $user_list .= '</ul>'; |
352 | 352 | |
353 | - echo json_encode( array( 'results' => $user_list ) ); |
|
353 | + echo json_encode(array('results' => $user_list)); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | die(); |
357 | 357 | } |
358 | 358 | |
359 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
359 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | /** |
@@ -368,32 +368,32 @@ discard block |
||
368 | 368 | */ |
369 | 369 | function give_check_for_form_price_variations() { |
370 | 370 | |
371 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
372 | - die( '-1' ); |
|
371 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
372 | + die('-1'); |
|
373 | 373 | } |
374 | 374 | |
375 | - $form_id = intval( $_POST['form_id'] ); |
|
376 | - $form = get_post( $form_id ); |
|
375 | + $form_id = intval($_POST['form_id']); |
|
376 | + $form = get_post($form_id); |
|
377 | 377 | |
378 | - if ( 'give_forms' != $form->post_type ) { |
|
379 | - die( '-2' ); |
|
378 | + if ('give_forms' != $form->post_type) { |
|
379 | + die('-2'); |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( give_has_variable_prices( $form_id ) ) { |
|
383 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
382 | + if (give_has_variable_prices($form_id)) { |
|
383 | + $variable_prices = give_get_variable_prices($form_id); |
|
384 | 384 | |
385 | - if ( $variable_prices ) { |
|
385 | + if ($variable_prices) { |
|
386 | 386 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
387 | 387 | |
388 | - if ( isset( $_POST['all_prices'] ) ) { |
|
389 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
388 | + if (isset($_POST['all_prices'])) { |
|
389 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
390 | 390 | } |
391 | 391 | |
392 | - foreach ( $variable_prices as $key => $price ) { |
|
392 | + foreach ($variable_prices as $key => $price) { |
|
393 | 393 | |
394 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
394 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
395 | 395 | |
396 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
396 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
397 | 397 | } |
398 | 398 | $ajax_response .= '</select>'; |
399 | 399 | echo $ajax_response; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | give_die(); |
404 | 404 | } |
405 | 405 | |
406 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
406 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
407 | 407 | |
408 | 408 | |
409 | 409 | /** |
@@ -414,29 +414,29 @@ discard block |
||
414 | 414 | * @return void |
415 | 415 | */ |
416 | 416 | function give_check_for_form_price_variations_html() { |
417 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
417 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
418 | 418 | wp_die(); |
419 | 419 | } |
420 | 420 | |
421 | - $form_id = intval( $_POST['form_id'] ); |
|
422 | - $payment_id = intval( $_POST['payment_id'] ); |
|
423 | - $form = get_post( $form_id ); |
|
421 | + $form_id = intval($_POST['form_id']); |
|
422 | + $payment_id = intval($_POST['payment_id']); |
|
423 | + $form = get_post($form_id); |
|
424 | 424 | |
425 | - if ( 'give_forms' != $form->post_type ) { |
|
425 | + if ('give_forms' != $form->post_type) { |
|
426 | 426 | wp_die(); |
427 | 427 | } |
428 | 428 | |
429 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
430 | - esc_html_e( 'n/a', 'give' ); |
|
429 | + if ( ! give_has_variable_prices($form_id)) { |
|
430 | + esc_html_e('n/a', 'give'); |
|
431 | 431 | } else { |
432 | 432 | // Payment object. |
433 | - $payment = new Give_Payment( $payment_id ); |
|
433 | + $payment = new Give_Payment($payment_id); |
|
434 | 434 | |
435 | 435 | |
436 | 436 | $prices_atts = ''; |
437 | - if( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
438 | - foreach ( $variable_prices as $variable_price ) { |
|
439 | - $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount( $variable_price['_give_amount'] ); |
|
437 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
438 | + foreach ($variable_prices as $variable_price) { |
|
439 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | 'chosen' => true, |
452 | 452 | 'show_option_all' => '', |
453 | 453 | 'show_option_none' => '', |
454 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
454 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
455 | 455 | 'selected' => $payment_meta['price_id'], |
456 | 456 | ); |
457 | 457 | |
458 | 458 | // Render variable prices select tag html. |
459 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
459 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | give_die(); |
463 | 463 | } |
464 | 464 | |
465 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
465 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
@@ -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,36 +23,36 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | // Give Forms single post and archive options. |
26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
28 | 28 | |
29 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
29 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
30 | 30 | // Support for old 'GIVE_FORMS_SLUG' constant |
31 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
31 | + if (defined('GIVE_FORMS_SLUG')) { |
|
32 | 32 | $give_forms_slug = GIVE_FORMS_SLUG; |
33 | 33 | } |
34 | 34 | |
35 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
35 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | 36 | 'slug' => $give_forms_slug, |
37 | 37 | 'with_front' => false, |
38 | 38 | ); |
39 | 39 | |
40 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
41 | - 'name' => esc_html__( 'Donation Forms', 'give' ), |
|
42 | - 'singular_name' => esc_html__( 'Form', 'give' ), |
|
43 | - 'add_new' => esc_html__( 'Add Form', 'give' ), |
|
44 | - 'add_new_item' => esc_html__( 'Add New Donation Form', 'give' ), |
|
45 | - 'edit_item' => esc_html__( 'Edit Donation Form', 'give' ), |
|
46 | - 'new_item' => esc_html__( 'New Form', 'give' ), |
|
47 | - 'all_items' => esc_html__( 'All Forms', 'give' ), |
|
48 | - 'view_item' => esc_html__( 'View Form', 'give' ), |
|
49 | - 'search_items' => esc_html__( 'Search Forms', 'give' ), |
|
50 | - 'not_found' => esc_html__( 'No forms found.', 'give' ), |
|
51 | - 'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ), |
|
40 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
41 | + 'name' => esc_html__('Donation Forms', 'give'), |
|
42 | + 'singular_name' => esc_html__('Form', 'give'), |
|
43 | + 'add_new' => esc_html__('Add Form', 'give'), |
|
44 | + 'add_new_item' => esc_html__('Add New Donation Form', 'give'), |
|
45 | + 'edit_item' => esc_html__('Edit Donation Form', 'give'), |
|
46 | + 'new_item' => esc_html__('New Form', 'give'), |
|
47 | + 'all_items' => esc_html__('All Forms', 'give'), |
|
48 | + 'view_item' => esc_html__('View Form', 'give'), |
|
49 | + 'search_items' => esc_html__('Search Forms', 'give'), |
|
50 | + 'not_found' => esc_html__('No forms found.', 'give'), |
|
51 | + 'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'), |
|
52 | 52 | 'parent_item_colon' => '', |
53 | - 'menu_name' => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ), |
|
54 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ), |
|
55 | - ) ); |
|
53 | + 'menu_name' => apply_filters('give_menu_name', esc_html__('Donations', 'give')), |
|
54 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')), |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | // Default give_forms supports. |
58 | 58 | $give_form_supports = array( |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Has the user disabled the excerpt? |
67 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
68 | - unset( $give_form_supports[2] ); |
|
67 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
68 | + unset($give_form_supports[2]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Has user disabled the featured image? |
72 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
73 | - unset( $give_form_supports[1] ); |
|
74 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
72 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
73 | + unset($give_form_supports[1]); |
|
74 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $give_forms_args = array( |
@@ -87,42 +87,42 @@ discard block |
||
87 | 87 | 'has_archive' => $give_forms_archives, |
88 | 88 | 'menu_icon' => 'dashicons-give', |
89 | 89 | 'hierarchical' => false, |
90 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
90 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
91 | 91 | ); |
92 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
92 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
93 | 93 | |
94 | 94 | /** Donation Post Type */ |
95 | 95 | $payment_labels = array( |
96 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
97 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
98 | - 'add_new' => esc_html__( 'Add New', 'give' ), |
|
99 | - 'add_new_item' => esc_html__( 'Add New Donation', 'give' ), |
|
100 | - 'edit_item' => esc_html__( 'Edit Donation', 'give' ), |
|
101 | - 'new_item' => esc_html__( 'New Donation', 'give' ), |
|
102 | - 'all_items' => esc_html__( 'All Donations', 'give' ), |
|
103 | - 'view_item' => esc_html__( 'View Donation', 'give' ), |
|
104 | - 'search_items' => esc_html__( 'Search Donations', 'give' ), |
|
105 | - 'not_found' => esc_html__( 'No donations found.', 'give' ), |
|
106 | - 'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ), |
|
96 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
97 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
98 | + 'add_new' => esc_html__('Add New', 'give'), |
|
99 | + 'add_new_item' => esc_html__('Add New Donation', 'give'), |
|
100 | + 'edit_item' => esc_html__('Edit Donation', 'give'), |
|
101 | + 'new_item' => esc_html__('New Donation', 'give'), |
|
102 | + 'all_items' => esc_html__('All Donations', 'give'), |
|
103 | + 'view_item' => esc_html__('View Donation', 'give'), |
|
104 | + 'search_items' => esc_html__('Search Donations', 'give'), |
|
105 | + 'not_found' => esc_html__('No donations found.', 'give'), |
|
106 | + 'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'), |
|
107 | 107 | 'parent_item_colon' => '', |
108 | - 'menu_name' => esc_html__( 'Donations', 'give' ), |
|
108 | + 'menu_name' => esc_html__('Donations', 'give'), |
|
109 | 109 | ); |
110 | 110 | |
111 | 111 | $payment_args = array( |
112 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
112 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
113 | 113 | 'public' => false, |
114 | 114 | 'query_var' => false, |
115 | 115 | 'rewrite' => false, |
116 | 116 | 'map_meta_cap' => true, |
117 | 117 | 'capability_type' => 'give_payment', |
118 | - 'supports' => array( 'title' ), |
|
118 | + 'supports' => array('title'), |
|
119 | 119 | 'can_export' => true, |
120 | 120 | ); |
121 | - register_post_type( 'give_payment', $payment_args ); |
|
121 | + register_post_type('give_payment', $payment_args); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
125 | +add_action('init', 'give_setup_post_types', 1); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | /** |
@@ -135,30 +135,30 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function give_setup_taxonomies() { |
137 | 137 | |
138 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
138 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
139 | 139 | |
140 | 140 | /** Categories */ |
141 | 141 | $category_labels = array( |
142 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
143 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
144 | - 'search_items' => esc_html__( 'Search Categories', 'give' ), |
|
145 | - 'all_items' => esc_html__( 'All Categories', 'give' ), |
|
146 | - 'parent_item' => esc_html__( 'Parent Category', 'give' ), |
|
147 | - 'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ), |
|
148 | - 'edit_item' => esc_html__( 'Edit Category', 'give' ), |
|
149 | - 'update_item' => esc_html__( 'Update Category', 'give' ), |
|
150 | - 'add_new_item' => esc_html__( 'Add New Category', 'give' ), |
|
151 | - 'new_item_name' => esc_html__( 'New Category Name', 'give' ), |
|
152 | - 'menu_name' => esc_html__( 'Categories', 'give' ), |
|
142 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
143 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
144 | + 'search_items' => esc_html__('Search Categories', 'give'), |
|
145 | + 'all_items' => esc_html__('All Categories', 'give'), |
|
146 | + 'parent_item' => esc_html__('Parent Category', 'give'), |
|
147 | + 'parent_item_colon' => esc_html__('Parent Category:', 'give'), |
|
148 | + 'edit_item' => esc_html__('Edit Category', 'give'), |
|
149 | + 'update_item' => esc_html__('Update Category', 'give'), |
|
150 | + 'add_new_item' => esc_html__('Add New Category', 'give'), |
|
151 | + 'new_item_name' => esc_html__('New Category Name', 'give'), |
|
152 | + 'menu_name' => esc_html__('Categories', 'give'), |
|
153 | 153 | ); |
154 | 154 | |
155 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
155 | + $category_args = apply_filters('give_forms_category_args', array( |
|
156 | 156 | 'hierarchical' => true, |
157 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
157 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
158 | 158 | 'show_ui' => true, |
159 | 159 | 'query_var' => 'give_forms_category', |
160 | 160 | 'rewrite' => array( |
161 | - 'slug' => $slug . '/category', |
|
161 | + 'slug' => $slug.'/category', |
|
162 | 162 | 'with_front' => false, |
163 | 163 | 'hierarchical' => true, |
164 | 164 | ), |
@@ -172,33 +172,33 @@ discard block |
||
172 | 172 | ); |
173 | 173 | |
174 | 174 | // Does the user want categories? |
175 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
176 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
177 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
175 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
176 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
177 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** Tags */ |
181 | 181 | $tag_labels = array( |
182 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
183 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
184 | - 'search_items' => esc_html__( 'Search Tags', 'give' ), |
|
185 | - 'all_items' => esc_html__( 'All Tags', 'give' ), |
|
186 | - 'parent_item' => esc_html__( 'Parent Tag', 'give' ), |
|
187 | - 'parent_item_colon' => esc_html__( 'Parent Tag:', 'give' ), |
|
188 | - 'edit_item' => esc_html__( 'Edit Tag', 'give' ), |
|
189 | - 'update_item' => esc_html__( 'Update Tag', 'give' ), |
|
190 | - 'add_new_item' => esc_html__( 'Add New Tag', 'give' ), |
|
191 | - 'new_item_name' => esc_html__( 'New Tag Name', 'give' ), |
|
192 | - 'menu_name' => esc_html__( 'Tags', 'give' ), |
|
193 | - 'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ), |
|
182 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
183 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
184 | + 'search_items' => esc_html__('Search Tags', 'give'), |
|
185 | + 'all_items' => esc_html__('All Tags', 'give'), |
|
186 | + 'parent_item' => esc_html__('Parent Tag', 'give'), |
|
187 | + 'parent_item_colon' => esc_html__('Parent Tag:', 'give'), |
|
188 | + 'edit_item' => esc_html__('Edit Tag', 'give'), |
|
189 | + 'update_item' => esc_html__('Update Tag', 'give'), |
|
190 | + 'add_new_item' => esc_html__('Add New Tag', 'give'), |
|
191 | + 'new_item_name' => esc_html__('New Tag Name', 'give'), |
|
192 | + 'menu_name' => esc_html__('Tags', 'give'), |
|
193 | + 'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'), |
|
194 | 194 | ); |
195 | 195 | |
196 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
196 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
197 | 197 | 'hierarchical' => false, |
198 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
198 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
199 | 199 | 'show_ui' => true, |
200 | 200 | 'query_var' => 'give_forms_tag', |
201 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
201 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
202 | 202 | 'capabilities' => array( |
203 | 203 | 'manage_terms' => 'manage_give_form_terms', |
204 | 204 | 'edit_terms' => 'edit_give_form_terms', |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ) |
209 | 209 | ); |
210 | 210 | |
211 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
212 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
213 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
211 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
212 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
213 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | } |
217 | 217 | |
218 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
218 | +add_action('init', 'give_setup_taxonomies', 0); |
|
219 | 219 | |
220 | 220 | |
221 | 221 | /** |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function give_get_default_form_labels() { |
228 | 228 | $defaults = array( |
229 | - 'singular' => esc_html__( 'Form', 'give' ), |
|
230 | - 'plural' => esc_html__( 'Forms', 'give' ), |
|
229 | + 'singular' => esc_html__('Form', 'give'), |
|
230 | + 'plural' => esc_html__('Forms', 'give'), |
|
231 | 231 | ); |
232 | 232 | |
233 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
233 | + return apply_filters('give_default_form_name', $defaults); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return string $defaults['singular'] Singular label |
244 | 244 | */ |
245 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
245 | +function give_get_forms_label_singular($lowercase = false) { |
|
246 | 246 | $defaults = give_get_default_form_labels(); |
247 | 247 | |
248 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
248 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | * @since 1.0 |
255 | 255 | * @return string $defaults['plural'] Plural label |
256 | 256 | */ |
257 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
257 | +function give_get_forms_label_plural($lowercase = false) { |
|
258 | 258 | $defaults = give_get_default_form_labels(); |
259 | 259 | |
260 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
260 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,24 +269,24 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string $title New placeholder text |
271 | 271 | */ |
272 | -function give_change_default_title( $title ) { |
|
272 | +function give_change_default_title($title) { |
|
273 | 273 | // If a frontend plugin uses this filter (check extensions before changing this function) |
274 | - if ( ! is_admin() ) { |
|
275 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
274 | + if ( ! is_admin()) { |
|
275 | + $title = esc_html__('Enter form title here', 'give'); |
|
276 | 276 | |
277 | 277 | return $title; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $screen = get_current_screen(); |
281 | 281 | |
282 | - if ( 'give_forms' == $screen->post_type ) { |
|
283 | - $title = esc_html__( 'Enter form title here', 'give' ); |
|
282 | + if ('give_forms' == $screen->post_type) { |
|
283 | + $title = esc_html__('Enter form title here', 'give'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $title; |
287 | 287 | } |
288 | 288 | |
289 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
289 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Registers Custom Post Statuses which are used by the Payments |
@@ -296,50 +296,50 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function give_register_post_type_statuses() { |
298 | 298 | // Payment Statuses |
299 | - register_post_status( 'refunded', array( |
|
300 | - 'label' => esc_html__( 'Refunded', 'give' ), |
|
299 | + register_post_status('refunded', array( |
|
300 | + 'label' => esc_html__('Refunded', 'give'), |
|
301 | 301 | 'public' => true, |
302 | 302 | 'exclude_from_search' => false, |
303 | 303 | 'show_in_admin_all_list' => true, |
304 | 304 | 'show_in_admin_status_list' => true, |
305 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
306 | - ) ); |
|
307 | - register_post_status( 'failed', array( |
|
308 | - 'label' => esc_html__( 'Failed', 'give' ), |
|
305 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
306 | + )); |
|
307 | + register_post_status('failed', array( |
|
308 | + 'label' => esc_html__('Failed', 'give'), |
|
309 | 309 | 'public' => true, |
310 | 310 | 'exclude_from_search' => false, |
311 | 311 | 'show_in_admin_all_list' => true, |
312 | 312 | 'show_in_admin_status_list' => true, |
313 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
314 | - ) ); |
|
315 | - register_post_status( 'revoked', array( |
|
316 | - 'label' => esc_html__( 'Revoked', 'give' ), |
|
313 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
314 | + )); |
|
315 | + register_post_status('revoked', array( |
|
316 | + 'label' => esc_html__('Revoked', 'give'), |
|
317 | 317 | 'public' => true, |
318 | 318 | 'exclude_from_search' => false, |
319 | 319 | 'show_in_admin_all_list' => true, |
320 | 320 | 'show_in_admin_status_list' => true, |
321 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
322 | - ) ); |
|
323 | - register_post_status( 'cancelled', array( |
|
324 | - 'label' => esc_html__( 'Cancelled', 'give' ), |
|
321 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
322 | + )); |
|
323 | + register_post_status('cancelled', array( |
|
324 | + 'label' => esc_html__('Cancelled', 'give'), |
|
325 | 325 | 'public' => true, |
326 | 326 | 'exclude_from_search' => false, |
327 | 327 | 'show_in_admin_all_list' => true, |
328 | 328 | 'show_in_admin_status_list' => true, |
329 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
330 | - ) ); |
|
331 | - register_post_status( 'abandoned', array( |
|
332 | - 'label' => esc_html__( 'Abandoned', 'give' ), |
|
329 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
330 | + )); |
|
331 | + register_post_status('abandoned', array( |
|
332 | + 'label' => esc_html__('Abandoned', 'give'), |
|
333 | 333 | 'public' => true, |
334 | 334 | 'exclude_from_search' => false, |
335 | 335 | 'show_in_admin_all_list' => true, |
336 | 336 | 'show_in_admin_status_list' => true, |
337 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
338 | - ) ); |
|
337 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
338 | + )); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
342 | +add_action('init', 'give_register_post_type_statuses'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Updated Messages |
@@ -352,27 +352,27 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return array $messages New post updated messages |
354 | 354 | */ |
355 | -function give_updated_messages( $messages ) { |
|
355 | +function give_updated_messages($messages) { |
|
356 | 356 | global $post, $post_ID; |
357 | 357 | |
358 | - if ( give_get_option( 'disable_forms_singular' ) === 'on' ) { |
|
358 | + if (give_get_option('disable_forms_singular') === 'on') { |
|
359 | 359 | |
360 | 360 | $messages['give_forms'] = array( |
361 | - 1 => esc_html__( 'Form updated.', 'give' ), |
|
362 | - 4 => esc_html__( 'Form updated.', 'give' ), |
|
363 | - 6 => esc_html__( 'Form published.', 'give' ), |
|
364 | - 7 => esc_html__( 'Form saved.', 'give' ), |
|
365 | - 8 => esc_html__( 'Form submitted.', 'give' ), |
|
361 | + 1 => esc_html__('Form updated.', 'give'), |
|
362 | + 4 => esc_html__('Form updated.', 'give'), |
|
363 | + 6 => esc_html__('Form published.', 'give'), |
|
364 | + 7 => esc_html__('Form saved.', 'give'), |
|
365 | + 8 => esc_html__('Form submitted.', 'give'), |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | } else { |
369 | 369 | |
370 | 370 | $messages['give_forms'] = array( |
371 | - 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' ) ), |
|
372 | - 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' ) ), |
|
373 | - 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' ) ), |
|
374 | - 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' ) ), |
|
375 | - 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' ) ), |
|
371 | + 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')), |
|
372 | + 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')), |
|
373 | + 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')), |
|
374 | + 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')), |
|
375 | + 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')), |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | } |
@@ -380,27 +380,27 @@ discard block |
||
380 | 380 | return $messages; |
381 | 381 | } |
382 | 382 | |
383 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
383 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Setup Post Type Images |
388 | 388 | */ |
389 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
389 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
390 | 390 | |
391 | 391 | /** |
392 | 392 | * Ensure post thumbnail support is turned on |
393 | 393 | */ |
394 | 394 | function give_add_thumbnail_support() { |
395 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
395 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
396 | 396 | return; |
397 | 397 | } |
398 | 398 | |
399 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
400 | - add_theme_support( 'post-thumbnails' ); |
|
399 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
400 | + add_theme_support('post-thumbnails'); |
|
401 | 401 | } |
402 | 402 | |
403 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
403 | + add_post_type_support('give_forms', 'thumbnail'); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -412,21 +412,21 @@ discard block |
||
412 | 412 | |
413 | 413 | // Single Give Forms (disabled if single turned off in settings) |
414 | 414 | if ( |
415 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
416 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
415 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
416 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
417 | 417 | ) { |
418 | 418 | |
419 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
420 | - 'name' => esc_html__( 'Give Single Form Sidebar', 'give' ), |
|
419 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
420 | + 'name' => esc_html__('Give Single Form Sidebar', 'give'), |
|
421 | 421 | 'id' => 'give-forms-sidebar', |
422 | - '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 | + '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'), |
|
423 | 423 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
424 | 424 | 'after_widget' => '</div>', |
425 | 425 | 'before_title' => '<h3 class="widgettitle widget-title">', |
426 | 426 | 'after_title' => '</h3>', |
427 | - ) ) ); |
|
427 | + ))); |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
432 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } elseif ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } elseif (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
55 | + $args = apply_filters('give_get_users_donations_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date', |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
139 | - $completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : ''; |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | + $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1, |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1, |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool True if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int The total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | // Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
262 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
263 | 263 | |
264 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
264 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return float The total amount the user has spent |
276 | 276 | */ |
277 | -function give_purchase_total_of_user( $user = null ) { |
|
277 | +function give_purchase_total_of_user($user = null) { |
|
278 | 278 | |
279 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
279 | + $stats = give_get_purchase_stats_by_user($user); |
|
280 | 280 | |
281 | 281 | return $stats['total_spent']; |
282 | 282 | } |
@@ -292,40 +292,40 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | -function give_validate_username( $username, $form_id = 0 ) { |
|
295 | +function give_validate_username($username, $form_id = 0) { |
|
296 | 296 | $valid = true; |
297 | 297 | |
298 | 298 | // Validate username. |
299 | - if ( ! empty( $username ) ) { |
|
299 | + if ( ! empty($username)) { |
|
300 | 300 | |
301 | 301 | // Sanitize username. |
302 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
302 | + $sanitized_user_name = sanitize_user($username, false); |
|
303 | 303 | |
304 | 304 | // We have an user name, check if it already exists. |
305 | - if ( username_exists( $username ) ) { |
|
305 | + if (username_exists($username)) { |
|
306 | 306 | // Username already registered. |
307 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
307 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
308 | 308 | $valid = false; |
309 | 309 | |
310 | 310 | // Check if it's valid. |
311 | - } elseif ( $sanitized_user_name !== $username ) { |
|
311 | + } elseif ($sanitized_user_name !== $username) { |
|
312 | 312 | // Invalid username. |
313 | - if ( is_multisite() ) { |
|
314 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
313 | + if (is_multisite()) { |
|
314 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | } else { |
317 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
317 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
318 | 318 | $valid = false; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | } else { |
322 | 322 | // Username is empty. |
323 | - give_set_error( 'username_empty', esc_html__( 'Enter an username.', 'give' ) ); |
|
323 | + give_set_error('username_empty', esc_html__('Enter an username.', 'give')); |
|
324 | 324 | $valid = false; |
325 | 325 | |
326 | 326 | // Check if guest checkout is disable for form. |
327 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
328 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
327 | + if ($form_id && give_logged_in_only($form_id)) { |
|
328 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
329 | 329 | $valid = false; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string $username |
340 | 340 | * @param bool $form_id |
341 | 341 | */ |
342 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
342 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
343 | 343 | |
344 | 344 | return $valid; |
345 | 345 | } |
@@ -355,22 +355,22 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return bool |
357 | 357 | */ |
358 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
358 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
359 | 359 | $valid = true; |
360 | 360 | |
361 | - if ( empty( $email ) ) { |
|
361 | + if (empty($email)) { |
|
362 | 362 | // No email. |
363 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
363 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
364 | 364 | $valid = false; |
365 | 365 | |
366 | - } elseif ( ! is_email( $email ) ) { |
|
366 | + } elseif ( ! is_email($email)) { |
|
367 | 367 | // Validate email. |
368 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
368 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
369 | 369 | $valid = false; |
370 | 370 | |
371 | - } elseif ( $registering_new_user && email_exists( $email ) ) { |
|
371 | + } elseif ($registering_new_user && email_exists($email)) { |
|
372 | 372 | // Check if email exists. |
373 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
373 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
374 | 374 | $valid = false; |
375 | 375 | } |
376 | 376 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param string $email |
384 | 384 | * @param bool $registering_new_user |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | - if ( $password && $confirm_password ) { |
|
405 | + if ($password && $confirm_password) { |
|
406 | 406 | // Verify confirmation matches. |
407 | - if ( $password != $confirm_password ) { |
|
407 | + if ($password != $confirm_password) { |
|
408 | 408 | // Passwords do not match |
409 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
409 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | - } elseif ( $registering_new_user ) { |
|
412 | + } elseif ($registering_new_user) { |
|
413 | 413 | // Password or confirmation missing. |
414 | - if ( ! $password ) { |
|
414 | + if ( ! $password) { |
|
415 | 415 | // The password is invalid. |
416 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
416 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
417 | 417 | $valid = false; |
418 | - } elseif ( ! $confirm_password ) { |
|
418 | + } elseif ( ! $confirm_password) { |
|
419 | 419 | // Confirmation password is invalid. |
420 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
420 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
421 | 421 | $valid = false; |
422 | 422 | } |
423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param string $confirm_password |
433 | 433 | * @param bool $registering_new_user |
434 | 434 | */ |
435 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
435 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
436 | 436 | |
437 | 437 | return $valid; |
438 | 438 | } |
@@ -451,32 +451,32 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
454 | +function give_add_past_purchases_to_new_user($user_id) { |
|
455 | 455 | |
456 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
456 | + $email = get_the_author_meta('user_email', $user_id); |
|
457 | 457 | |
458 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
458 | + $payments = give_get_payments(array('s' => $email)); |
|
459 | 459 | |
460 | - if ( $payments ) { |
|
461 | - foreach ( $payments as $payment ) { |
|
462 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
460 | + if ($payments) { |
|
461 | + foreach ($payments as $payment) { |
|
462 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
463 | 463 | continue; |
464 | 464 | } // This payment already associated with an account |
465 | 465 | |
466 | - $meta = give_get_payment_meta( $payment->ID ); |
|
467 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
466 | + $meta = give_get_payment_meta($payment->ID); |
|
467 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
468 | 468 | $meta['user_info']['id'] = $user_id; |
469 | 469 | $meta['user_info'] = $meta['user_info']; |
470 | 470 | |
471 | 471 | // Store the updated user ID in the payment meta |
472 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
473 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
472 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
473 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
479 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
480 | 480 | |
481 | 481 | |
482 | 482 | /** |
@@ -502,34 +502,34 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array The donor's address, if any |
504 | 504 | */ |
505 | -function give_get_donor_address( $user_id = 0 ) { |
|
506 | - if ( empty( $user_id ) ) { |
|
505 | +function give_get_donor_address($user_id = 0) { |
|
506 | + if (empty($user_id)) { |
|
507 | 507 | $user_id = get_current_user_id(); |
508 | 508 | } |
509 | 509 | |
510 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
510 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
511 | 511 | |
512 | - if ( ! isset( $address['line1'] ) ) { |
|
512 | + if ( ! isset($address['line1'])) { |
|
513 | 513 | $address['line1'] = ''; |
514 | 514 | } |
515 | 515 | |
516 | - if ( ! isset( $address['line2'] ) ) { |
|
516 | + if ( ! isset($address['line2'])) { |
|
517 | 517 | $address['line2'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['city'] ) ) { |
|
520 | + if ( ! isset($address['city'])) { |
|
521 | 521 | $address['city'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['zip'] ) ) { |
|
524 | + if ( ! isset($address['zip'])) { |
|
525 | 525 | $address['zip'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['country'] ) ) { |
|
528 | + if ( ! isset($address['country'])) { |
|
529 | 529 | $address['country'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['state'] ) ) { |
|
532 | + if ( ! isset($address['state'])) { |
|
533 | 533 | $address['state'] = ''; |
534 | 534 | } |
535 | 535 | |
@@ -549,42 +549,42 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return void |
551 | 551 | */ |
552 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
552 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
553 | 553 | |
554 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
554 | + if (empty($user_id) || empty($user_data)) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
557 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
558 | 558 | |
559 | 559 | /* translators: %s: site name */ |
560 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
560 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
561 | 561 | /* translators: %s: user login */ |
562 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
562 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
563 | 563 | /* translators: %s: user email */ |
564 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
564 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
565 | 565 | |
566 | 566 | @wp_mail( |
567 | - get_option( 'admin_email' ), |
|
567 | + get_option('admin_email'), |
|
568 | 568 | sprintf( |
569 | 569 | /* translators: %s: site name */ |
570 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
570 | + esc_attr__('[%s] New User Registration', 'give'), |
|
571 | 571 | $blogname |
572 | 572 | ), |
573 | 573 | $message |
574 | 574 | ); |
575 | 575 | |
576 | 576 | /* translators: %s: user login */ |
577 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
577 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
578 | 578 | /* translators: %s: paswword */ |
579 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
579 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
580 | 580 | |
581 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
581 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
582 | 582 | |
583 | 583 | wp_mail( |
584 | 584 | $user_data['user_email'], |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: site name */ |
587 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
587 | + esc_attr__('[%s] Your username and password', 'give'), |
|
588 | 588 | $blogname |
589 | 589 | ), |
590 | 590 | $message |
@@ -592,4 +592,4 @@ discard block |
||
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
595 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function transactions_dropdown( $args = array() ) { |
|
38 | + public function transactions_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'transactions', |
@@ -45,33 +45,33 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => esc_html__( 'Select a transaction', 'give' ) |
|
48 | + 'placeholder' => esc_html__('Select a transaction', 'give') |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'] |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | //Provide nice human readable options. |
62 | - if ( $payments ) { |
|
63 | - $options[0] = esc_html__( 'Select a donation', 'give' ); |
|
64 | - foreach ( $payments as $payment ) { |
|
62 | + if ($payments) { |
|
63 | + $options[0] = esc_html__('Select a donation', 'give'); |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
70 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | - $output = $this->select( array( |
|
74 | + $output = $this->select(array( |
|
75 | 75 | 'name' => $args['name'], |
76 | 76 | 'selected' => $args['selected'], |
77 | 77 | 'id' => $args['id'], |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'select_atts' => $args['select_atts'], |
84 | 84 | 'show_option_all' => false, |
85 | 85 | 'show_option_none' => false |
86 | - ) ); |
|
86 | + )); |
|
87 | 87 | |
88 | 88 | return $output; |
89 | 89 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return string Give forms dropdown. |
102 | 102 | */ |
103 | - public function forms_dropdown( $args = array() ) { |
|
103 | + public function forms_dropdown($args = array()) { |
|
104 | 104 | |
105 | 105 | $defaults = array( |
106 | 106 | 'name' => 'forms', |
@@ -110,31 +110,31 @@ discard block |
||
110 | 110 | 'selected' => 0, |
111 | 111 | 'chosen' => false, |
112 | 112 | 'number' => 30, |
113 | - 'placeholder' => esc_attr__( 'Select a Donation Form', 'give' ) |
|
113 | + 'placeholder' => esc_attr__('Select a Donation Form', 'give') |
|
114 | 114 | ); |
115 | 115 | |
116 | - $args = wp_parse_args( $args, $defaults ); |
|
116 | + $args = wp_parse_args($args, $defaults); |
|
117 | 117 | |
118 | - $forms = get_posts( array( |
|
118 | + $forms = get_posts(array( |
|
119 | 119 | 'post_type' => 'give_forms', |
120 | 120 | 'orderby' => 'title', |
121 | 121 | 'order' => 'ASC', |
122 | 122 | 'posts_per_page' => $args['number'] |
123 | - ) ); |
|
123 | + )); |
|
124 | 124 | |
125 | 125 | $options = array(); |
126 | 126 | |
127 | - if ( $forms ) { |
|
128 | - $options[0] = esc_attr__( 'Select a Donation Form', 'give' ); |
|
129 | - foreach ( $forms as $form ) { |
|
130 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
131 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
127 | + if ($forms) { |
|
128 | + $options[0] = esc_attr__('Select a Donation Form', 'give'); |
|
129 | + foreach ($forms as $form) { |
|
130 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
131 | + $options[absint($form->ID)] = esc_html($form_title); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
134 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
135 | 135 | } |
136 | 136 | |
137 | - $output = $this->select( array( |
|
137 | + $output = $this->select(array( |
|
138 | 138 | 'name' => $args['name'], |
139 | 139 | 'selected' => $args['selected'], |
140 | 140 | 'id' => $args['id'], |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'placeholder' => $args['placeholder'], |
146 | 146 | 'show_option_all' => false, |
147 | 147 | 'show_option_none' => false |
148 | - ) ); |
|
148 | + )); |
|
149 | 149 | |
150 | 150 | return $output; |
151 | 151 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string Donors dropdown. |
164 | 164 | */ |
165 | - public function donor_dropdown( $args = array() ) { |
|
165 | + public function donor_dropdown($args = array()) { |
|
166 | 166 | |
167 | 167 | $defaults = array( |
168 | 168 | 'name' => 'customers', |
@@ -171,38 +171,38 @@ discard block |
||
171 | 171 | 'multiple' => false, |
172 | 172 | 'selected' => 0, |
173 | 173 | 'chosen' => true, |
174 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
174 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
175 | 175 | 'number' => 30 |
176 | 176 | ); |
177 | 177 | |
178 | - $args = wp_parse_args( $args, $defaults ); |
|
178 | + $args = wp_parse_args($args, $defaults); |
|
179 | 179 | |
180 | - $customers = Give()->customers->get_customers( array( |
|
180 | + $customers = Give()->customers->get_customers(array( |
|
181 | 181 | 'number' => $args['number'] |
182 | - ) ); |
|
182 | + )); |
|
183 | 183 | |
184 | 184 | $options = array(); |
185 | 185 | |
186 | - if ( $customers ) { |
|
187 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
188 | - foreach ( $customers as $customer ) { |
|
189 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
186 | + if ($customers) { |
|
187 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
188 | + foreach ($customers as $customer) { |
|
189 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
190 | 190 | } |
191 | 191 | } else { |
192 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
192 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( ! empty( $args['selected'] ) ) { |
|
195 | + if ( ! empty($args['selected'])) { |
|
196 | 196 | |
197 | 197 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
198 | 198 | |
199 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
199 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
200 | 200 | |
201 | - $customer = new Give_Customer( $args['selected'] ); |
|
201 | + $customer = new Give_Customer($args['selected']); |
|
202 | 202 | |
203 | - if ( $customer ) { |
|
203 | + if ($customer) { |
|
204 | 204 | |
205 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
205 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | |
211 | 211 | } |
212 | 212 | |
213 | - $output = $this->select( array( |
|
213 | + $output = $this->select(array( |
|
214 | 214 | 'name' => $args['name'], |
215 | 215 | 'selected' => $args['selected'], |
216 | 216 | 'id' => $args['id'], |
217 | - 'class' => $args['class'] . ' give-customer-select', |
|
217 | + 'class' => $args['class'].' give-customer-select', |
|
218 | 218 | 'options' => $options, |
219 | 219 | 'multiple' => $args['multiple'], |
220 | 220 | 'chosen' => $args['chosen'], |
221 | 221 | 'show_option_all' => false, |
222 | 222 | 'show_option_none' => false |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | |
225 | 225 | return $output; |
226 | 226 | } |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return string Categories dropdown. |
241 | 241 | */ |
242 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
243 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
242 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
243 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
244 | 244 | $options = array(); |
245 | 245 | |
246 | - foreach ( $categories as $category ) { |
|
247 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
246 | + foreach ($categories as $category) { |
|
247 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
248 | 248 | } |
249 | 249 | |
250 | - $output = $this->select( wp_parse_args( |
|
250 | + $output = $this->select(wp_parse_args( |
|
251 | 251 | $args, |
252 | 252 | array( |
253 | 253 | 'name' => $name, |
254 | 254 | 'selected' => $selected, |
255 | 255 | 'options' => $options, |
256 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
256 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
257 | 257 | 'show_option_none' => false |
258 | 258 | ) |
259 | - ) ); |
|
259 | + )); |
|
260 | 260 | |
261 | 261 | return $output; |
262 | 262 | } |
@@ -275,24 +275,24 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return string Tags dropdown. |
277 | 277 | */ |
278 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
279 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
278 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
279 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
280 | 280 | $options = array(); |
281 | 281 | |
282 | - foreach ( $tags as $tag ) { |
|
283 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
282 | + foreach ($tags as $tag) { |
|
283 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
284 | 284 | } |
285 | 285 | |
286 | - $output = $this->select( wp_parse_args( |
|
286 | + $output = $this->select(wp_parse_args( |
|
287 | 287 | $args, |
288 | 288 | array( |
289 | 289 | 'name' => $name, |
290 | 290 | 'selected' => $selected, |
291 | 291 | 'options' => $options, |
292 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
292 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
293 | 293 | 'show_option_none' => false, |
294 | 294 | ) |
295 | - ) ); |
|
295 | + )); |
|
296 | 296 | |
297 | 297 | return $output; |
298 | 298 | } |
@@ -312,25 +312,25 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return string Years dropdown. |
314 | 314 | */ |
315 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
316 | - $current = date( 'Y' ); |
|
317 | - $start_year = $current - absint( $years_before ); |
|
318 | - $end_year = $current + absint( $years_after ); |
|
319 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
315 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
316 | + $current = date('Y'); |
|
317 | + $start_year = $current - absint($years_before); |
|
318 | + $end_year = $current + absint($years_after); |
|
319 | + $selected = empty($selected) ? date('Y') : $selected; |
|
320 | 320 | $options = array(); |
321 | 321 | |
322 | - while ( $start_year <= $end_year ) { |
|
323 | - $options[ absint( $start_year ) ] = $start_year; |
|
324 | - $start_year ++; |
|
322 | + while ($start_year <= $end_year) { |
|
323 | + $options[absint($start_year)] = $start_year; |
|
324 | + $start_year++; |
|
325 | 325 | } |
326 | 326 | |
327 | - $output = $this->select( array( |
|
327 | + $output = $this->select(array( |
|
328 | 328 | 'name' => $name, |
329 | 329 | 'selected' => $selected, |
330 | 330 | 'options' => $options, |
331 | 331 | 'show_option_all' => false, |
332 | 332 | 'show_option_none' => false |
333 | - ) ); |
|
333 | + )); |
|
334 | 334 | |
335 | 335 | return $output; |
336 | 336 | } |
@@ -348,23 +348,23 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return string Months dropdown. |
350 | 350 | */ |
351 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
351 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
352 | 352 | $month = 1; |
353 | 353 | $options = array(); |
354 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
354 | + $selected = empty($selected) ? date('n') : $selected; |
|
355 | 355 | |
356 | - while ( $month <= 12 ) { |
|
357 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
358 | - $month ++; |
|
356 | + while ($month <= 12) { |
|
357 | + $options[absint($month)] = give_month_num_to_name($month); |
|
358 | + $month++; |
|
359 | 359 | } |
360 | 360 | |
361 | - $output = $this->select( array( |
|
361 | + $output = $this->select(array( |
|
362 | 362 | 'name' => $name, |
363 | 363 | 'selected' => $selected, |
364 | 364 | 'options' => $options, |
365 | 365 | 'show_option_all' => false, |
366 | 366 | 'show_option_none' => false |
367 | - ) ); |
|
367 | + )); |
|
368 | 368 | |
369 | 369 | return $output; |
370 | 370 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return string The dropdown. |
383 | 383 | */ |
384 | - public function select( $args = array() ) { |
|
384 | + public function select($args = array()) { |
|
385 | 385 | $defaults = array( |
386 | 386 | 'options' => array(), |
387 | 387 | 'name' => null, |
@@ -392,60 +392,60 @@ discard block |
||
392 | 392 | 'placeholder' => null, |
393 | 393 | 'multiple' => false, |
394 | 394 | 'select_atts' => false, |
395 | - 'show_option_all' => esc_html__( 'All', 'give' ), |
|
396 | - 'show_option_none' => esc_html__( 'None', 'give' ) |
|
395 | + 'show_option_all' => esc_html__('All', 'give'), |
|
396 | + 'show_option_none' => esc_html__('None', 'give') |
|
397 | 397 | ); |
398 | 398 | |
399 | - $args = wp_parse_args( $args, $defaults ); |
|
399 | + $args = wp_parse_args($args, $defaults); |
|
400 | 400 | |
401 | - if ( $args['multiple'] ) { |
|
401 | + if ($args['multiple']) { |
|
402 | 402 | $multiple = ' MULTIPLE'; |
403 | 403 | } else { |
404 | 404 | $multiple = ''; |
405 | 405 | } |
406 | 406 | |
407 | - if ( $args['chosen'] ) { |
|
407 | + if ($args['chosen']) { |
|
408 | 408 | $args['class'] .= ' give-select-chosen'; |
409 | 409 | } |
410 | 410 | |
411 | - if ( $args['placeholder'] ) { |
|
411 | + if ($args['placeholder']) { |
|
412 | 412 | $placeholder = $args['placeholder']; |
413 | 413 | } else { |
414 | 414 | $placeholder = ''; |
415 | 415 | } |
416 | 416 | |
417 | 417 | |
418 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '">'; |
|
418 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'">'; |
|
419 | 419 | |
420 | - if ( $args['show_option_all'] ) { |
|
421 | - if ( $args['multiple'] ) { |
|
422 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
420 | + if ($args['show_option_all']) { |
|
421 | + if ($args['multiple']) { |
|
422 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
423 | 423 | } else { |
424 | - $selected = selected( $args['selected'], 0, false ); |
|
424 | + $selected = selected($args['selected'], 0, false); |
|
425 | 425 | } |
426 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
426 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
427 | 427 | } |
428 | 428 | |
429 | - if ( ! empty( $args['options'] ) ) { |
|
429 | + if ( ! empty($args['options'])) { |
|
430 | 430 | |
431 | - if ( $args['show_option_none'] ) { |
|
432 | - if ( $args['multiple'] ) { |
|
433 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
431 | + if ($args['show_option_none']) { |
|
432 | + if ($args['multiple']) { |
|
433 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
434 | 434 | } else { |
435 | - $selected = selected( $args['selected'], - 1, false ); |
|
435 | + $selected = selected($args['selected'], - 1, false); |
|
436 | 436 | } |
437 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
437 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
438 | 438 | } |
439 | 439 | |
440 | - foreach ( $args['options'] as $key => $option ) { |
|
440 | + foreach ($args['options'] as $key => $option) { |
|
441 | 441 | |
442 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
443 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
442 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
443 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
444 | 444 | } else { |
445 | - $selected = selected( $args['selected'], $key, false ); |
|
445 | + $selected = selected($args['selected'], $key, false); |
|
446 | 446 | } |
447 | 447 | |
448 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
448 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return string The checkbox. |
468 | 468 | */ |
469 | - public function checkbox( $args = array() ) { |
|
469 | + public function checkbox($args = array()) { |
|
470 | 470 | $defaults = array( |
471 | 471 | 'name' => null, |
472 | 472 | 'current' => null, |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | ) |
478 | 478 | ); |
479 | 479 | |
480 | - $args = wp_parse_args( $args, $defaults ); |
|
480 | + $args = wp_parse_args($args, $defaults); |
|
481 | 481 | |
482 | 482 | $options = ''; |
483 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
483 | + if ( ! empty($args['options']['disabled'])) { |
|
484 | 484 | $options .= ' disabled="disabled"'; |
485 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
485 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
486 | 486 | $options .= ' readonly'; |
487 | 487 | } |
488 | 488 | |
489 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
489 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
490 | 490 | |
491 | 491 | return $output; |
492 | 492 | } |
@@ -503,22 +503,22 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return string The text field. |
505 | 505 | */ |
506 | - public function text( $args = array() ) { |
|
506 | + public function text($args = array()) { |
|
507 | 507 | // Backwards compatibility |
508 | - if ( func_num_args() > 1 ) { |
|
508 | + if (func_num_args() > 1) { |
|
509 | 509 | $args = func_get_args(); |
510 | 510 | |
511 | 511 | $name = $args[0]; |
512 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
513 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
514 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
512 | + $value = isset($args[1]) ? $args[1] : ''; |
|
513 | + $label = isset($args[2]) ? $args[2] : ''; |
|
514 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $defaults = array( |
518 | - 'name' => isset( $name ) ? $name : 'text', |
|
519 | - 'value' => isset( $value ) ? $value : null, |
|
520 | - 'label' => isset( $label ) ? $label : null, |
|
521 | - 'desc' => isset( $desc ) ? $desc : null, |
|
518 | + 'name' => isset($name) ? $name : 'text', |
|
519 | + 'value' => isset($value) ? $value : null, |
|
520 | + 'label' => isset($label) ? $label : null, |
|
521 | + 'desc' => isset($desc) ? $desc : null, |
|
522 | 522 | 'placeholder' => '', |
523 | 523 | 'class' => 'regular-text', |
524 | 524 | 'disabled' => false, |
@@ -526,29 +526,29 @@ discard block |
||
526 | 526 | 'data' => false |
527 | 527 | ); |
528 | 528 | |
529 | - $args = wp_parse_args( $args, $defaults ); |
|
529 | + $args = wp_parse_args($args, $defaults); |
|
530 | 530 | |
531 | 531 | $disabled = ''; |
532 | - if ( $args['disabled'] ) { |
|
532 | + if ($args['disabled']) { |
|
533 | 533 | $disabled = ' disabled="disabled"'; |
534 | 534 | } |
535 | 535 | |
536 | 536 | $data = ''; |
537 | - if ( ! empty( $args['data'] ) ) { |
|
538 | - foreach ( $args['data'] as $key => $value ) { |
|
539 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
537 | + if ( ! empty($args['data'])) { |
|
538 | + foreach ($args['data'] as $key => $value) { |
|
539 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
543 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
544 | 544 | |
545 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
545 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
546 | 546 | |
547 | - if ( ! empty( $args['desc'] ) ) { |
|
548 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
547 | + if ( ! empty($args['desc'])) { |
|
548 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
549 | 549 | } |
550 | 550 | |
551 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
551 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
552 | 552 | |
553 | 553 | $output .= '</span>'; |
554 | 554 | |
@@ -567,15 +567,15 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @return string The date picker. |
569 | 569 | */ |
570 | - public function date_field( $args = array() ) { |
|
570 | + public function date_field($args = array()) { |
|
571 | 571 | |
572 | - if ( empty( $args['class'] ) ) { |
|
572 | + if (empty($args['class'])) { |
|
573 | 573 | $args['class'] = 'give_datepicker'; |
574 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
574 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
575 | 575 | $args['class'] .= ' give_datepicker'; |
576 | 576 | } |
577 | 577 | |
578 | - return $this->text( $args ); |
|
578 | + return $this->text($args); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return string The textarea. |
592 | 592 | */ |
593 | - public function textarea( $args = array() ) { |
|
593 | + public function textarea($args = array()) { |
|
594 | 594 | $defaults = array( |
595 | 595 | 'name' => 'textarea', |
596 | 596 | 'value' => null, |
@@ -600,21 +600,21 @@ discard block |
||
600 | 600 | 'disabled' => false |
601 | 601 | ); |
602 | 602 | |
603 | - $args = wp_parse_args( $args, $defaults ); |
|
603 | + $args = wp_parse_args($args, $defaults); |
|
604 | 604 | |
605 | 605 | $disabled = ''; |
606 | - if ( $args['disabled'] ) { |
|
606 | + if ($args['disabled']) { |
|
607 | 607 | $disabled = ' disabled="disabled"'; |
608 | 608 | } |
609 | 609 | |
610 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
610 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
611 | 611 | |
612 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
612 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
613 | 613 | |
614 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
614 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
615 | 615 | |
616 | - if ( ! empty( $args['desc'] ) ) { |
|
617 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
616 | + if ( ! empty($args['desc'])) { |
|
617 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | $output .= '</span>'; |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string The text field with ajax search. |
636 | 636 | */ |
637 | - public function ajax_user_search( $args = array() ) { |
|
637 | + public function ajax_user_search($args = array()) { |
|
638 | 638 | |
639 | 639 | $defaults = array( |
640 | 640 | 'name' => 'user_id', |
641 | 641 | 'value' => null, |
642 | - 'placeholder' => esc_attr__( 'Enter username', 'give' ), |
|
642 | + 'placeholder' => esc_attr__('Enter username', 'give'), |
|
643 | 643 | 'label' => null, |
644 | 644 | 'desc' => null, |
645 | 645 | 'class' => '', |
@@ -648,13 +648,13 @@ discard block |
||
648 | 648 | 'data' => false |
649 | 649 | ); |
650 | 650 | |
651 | - $args = wp_parse_args( $args, $defaults ); |
|
651 | + $args = wp_parse_args($args, $defaults); |
|
652 | 652 | |
653 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
653 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
654 | 654 | |
655 | 655 | $output = '<span class="give_user_search_wrap">'; |
656 | - $output .= $this->text( $args ); |
|
657 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="' . esc_attr__( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
656 | + $output .= $this->text($args); |
|
657 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" aria-label="'.esc_attr__('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
658 | 658 | $output .= '</span>'; |
659 | 659 | |
660 | 660 | return $output; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference. |
51 | 51 | * |
52 | - * @return bool |
|
52 | + * @return false|null |
|
53 | 53 | */ |
54 | 54 | public function give_admin_bar_menu( $wp_admin_bar ) { |
55 | 55 |
@@ -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 | |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * @since 1.0 |
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
37 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
38 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000, 1 ); |
|
36 | + add_action('admin_notices', array($this, 'show_notices')); |
|
37 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
38 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000, 1); |
|
39 | 39 | |
40 | 40 | $this->notices = array( |
41 | 41 | 'updated' => array(), |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function give_admin_bar_menu( $wp_admin_bar ) { |
|
54 | + public function give_admin_bar_menu($wp_admin_bar) { |
|
55 | 55 | |
56 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
56 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Add the main siteadmin menu item. |
61 | - $wp_admin_bar->add_menu( array( |
|
61 | + $wp_admin_bar->add_menu(array( |
|
62 | 62 | 'id' => 'give-test-notice', |
63 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
63 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
64 | 64 | 'parent' => 'top-secondary', |
65 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
66 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
67 | - ) ); |
|
65 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
66 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
67 | + )); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
@@ -75,100 +75,100 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function show_notices() { |
77 | 77 | |
78 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
78 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
79 | 79 | echo '<div class="error">'; |
80 | - echo '<p>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
80 | + echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
81 | 81 | /* translators: %s: http://docs.givewp.com/ajax-blocked */ |
82 | - echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'http://docs.givewp.com/ajax-blocked' ) ) . '</p>'; |
|
83 | - echo '<p><a href="' . add_query_arg( array( |
|
82 | + echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('http://docs.givewp.com/ajax-blocked')).'</p>'; |
|
83 | + echo '<p><a href="'.add_query_arg(array( |
|
84 | 84 | 'give_action' => 'dismiss_notices', |
85 | 85 | 'give_notice' => 'admin_ajax_inaccessible', |
86 | - ) ) . '">' . esc_html__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
86 | + )).'">'.esc_html__('Dismiss Notice', 'give').'</a></p>'; |
|
87 | 87 | echo '</div>'; |
88 | 88 | } |
89 | 89 | |
90 | - if ( isset( $_GET['give-message'] ) ) { |
|
90 | + if (isset($_GET['give-message'])) { |
|
91 | 91 | |
92 | 92 | // Donation reports errors. |
93 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
94 | - switch ( $_GET['give-message'] ) { |
|
93 | + if (current_user_can('view_give_reports')) { |
|
94 | + switch ($_GET['give-message']) { |
|
95 | 95 | case 'donation_deleted' : |
96 | - $this->notices['updated']['give-donation-deleted'] = esc_attr__( 'The donation has been deleted.', 'give' ); |
|
96 | + $this->notices['updated']['give-donation-deleted'] = esc_attr__('The donation has been deleted.', 'give'); |
|
97 | 97 | break; |
98 | 98 | case 'email_sent' : |
99 | - $this->notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
99 | + $this->notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
100 | 100 | break; |
101 | 101 | case 'refreshed-reports' : |
102 | - $this->notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
102 | + $this->notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
103 | 103 | break; |
104 | 104 | case 'donation-note-deleted' : |
105 | - $this->notices['updated']['give-donation-note-deleted'] = esc_attr__( 'The donation note has been deleted.', 'give' ); |
|
105 | + $this->notices['updated']['give-donation-note-deleted'] = esc_attr__('The donation note has been deleted.', 'give'); |
|
106 | 106 | break; |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Give settings notices and errors. |
111 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
112 | - switch ( $_GET['give-message'] ) { |
|
111 | + if (current_user_can('manage_give_settings')) { |
|
112 | + switch ($_GET['give-message']) { |
|
113 | 113 | case 'settings-imported' : |
114 | - $this->notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
114 | + $this->notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
115 | 115 | break; |
116 | 116 | case 'api-key-generated' : |
117 | - $this->notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys have been generated.', 'give' ); |
|
117 | + $this->notices['updated']['give-api-key-generated'] = esc_attr__('API keys have been generated.', 'give'); |
|
118 | 118 | break; |
119 | 119 | case 'api-key-exists' : |
120 | - $this->notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
120 | + $this->notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
121 | 121 | break; |
122 | 122 | case 'api-key-regenerated' : |
123 | - $this->notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys have been regenerated.', 'give' ); |
|
123 | + $this->notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys have been regenerated.', 'give'); |
|
124 | 124 | break; |
125 | 125 | case 'api-key-revoked' : |
126 | - $this->notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys have been revoked.', 'give' ); |
|
126 | + $this->notices['updated']['give-api-key-revoked'] = esc_attr__('API keys have been revoked.', 'give'); |
|
127 | 127 | break; |
128 | 128 | case 'sent-test-email' : |
129 | - $this->notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
129 | + $this->notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
130 | 130 | break; |
131 | 131 | case 'matched-success-failure-page': |
132 | - $this->notices['updated']['give-matched-success-failure-page'] = esc_html__( 'You cannot set the success and failed pages to the same page', 'give' ); |
|
132 | + $this->notices['updated']['give-matched-success-failure-page'] = esc_html__('You cannot set the success and failed pages to the same page', 'give'); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | // Payments errors. |
136 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
137 | - switch ( $_GET['give-message'] ) { |
|
136 | + if (current_user_can('edit_give_payments')) { |
|
137 | + switch ($_GET['give-message']) { |
|
138 | 138 | case 'note-added' : |
139 | - $this->notices['updated']['give-note-added'] = esc_attr__( 'The donation note has been added.', 'give' ); |
|
139 | + $this->notices['updated']['give-note-added'] = esc_attr__('The donation note has been added.', 'give'); |
|
140 | 140 | break; |
141 | 141 | case 'payment-updated' : |
142 | - $this->notices['updated']['give-payment-updated'] = esc_attr__( 'The donation has been updated.', 'give' ); |
|
142 | + $this->notices['updated']['give-payment-updated'] = esc_attr__('The donation has been updated.', 'give'); |
|
143 | 143 | break; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Customer Notices. |
148 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
149 | - switch ( $_GET['give-message'] ) { |
|
148 | + if (current_user_can('edit_give_payments')) { |
|
149 | + switch ($_GET['give-message']) { |
|
150 | 150 | case 'customer-deleted' : |
151 | - $this->notices['updated']['give-customer-deleted'] = esc_attr__( 'The donor has been deleted.', 'give' ); |
|
151 | + $this->notices['updated']['give-customer-deleted'] = esc_attr__('The donor has been deleted.', 'give'); |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case 'email-added' : |
155 | - $this->notices['updated']['give-customer-email-added'] = esc_attr__( 'Donor email added', 'give' ); |
|
155 | + $this->notices['updated']['give-customer-email-added'] = esc_attr__('Donor email added', 'give'); |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'email-removed' : |
159 | - $this->notices['updated']['give-customer-email-removed'] = esc_attr__( 'Donor email removed', 'give' ); |
|
159 | + $this->notices['updated']['give-customer-email-removed'] = esc_attr__('Donor email removed', 'give'); |
|
160 | 160 | break; |
161 | 161 | |
162 | 162 | case 'email-remove-failed' : |
163 | - $this->notices['error']['give-customer-email-remove-failed'] = esc_attr__( 'Failed to remove donor email', 'give' ); |
|
163 | + $this->notices['error']['give-customer-email-remove-failed'] = esc_attr__('Failed to remove donor email', 'give'); |
|
164 | 164 | break; |
165 | 165 | |
166 | 166 | case 'primary-email-updated' : |
167 | - $this->notices['updated']['give-customer-primary-email-updated'] = esc_attr__( 'Primary email updated for donor', 'give' ); |
|
167 | + $this->notices['updated']['give-customer-primary-email-updated'] = esc_attr__('Primary email updated for donor', 'give'); |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'primary-email-failed' : |
171 | - $this->notices['error']['give-customer-primary-email-failed'] = esc_attr__( 'Failed to set primary email', 'give' ); |
|
171 | + $this->notices['error']['give-customer-primary-email-failed'] = esc_attr__('Failed to set primary email', 'give'); |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | } |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | |
177 | 177 | $this->add_payment_bulk_action_notice(); |
178 | 178 | |
179 | - if ( count( $this->notices['updated'] ) > 0 ) { |
|
180 | - foreach ( $this->notices['updated'] as $notice => $message ) { |
|
181 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
179 | + if (count($this->notices['updated']) > 0) { |
|
180 | + foreach ($this->notices['updated'] as $notice => $message) { |
|
181 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if ( count( $this->notices['error'] ) > 0 ) { |
|
186 | - foreach ( $this->notices['error'] as $notice => $message ) { |
|
187 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
185 | + if (count($this->notices['error']) > 0) { |
|
186 | + foreach ($this->notices['error'] as $notice => $message) { |
|
187 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - settings_errors( 'give-notices' ); |
|
191 | + settings_errors('give-notices'); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | * @return void |
201 | 201 | */ |
202 | 202 | function give_admin_addons_notices() { |
203 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
204 | - settings_errors( 'give-notices' ); |
|
203 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
204 | + settings_errors('give-notices'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * @return void |
213 | 213 | */ |
214 | 214 | function dismiss_notices() { |
215 | - if ( isset( $_GET['give_notice'] ) ) { |
|
216 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
217 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
215 | + if (isset($_GET['give_notice'])) { |
|
216 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
217 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
218 | 218 | exit; |
219 | 219 | } |
220 | 220 | } |
@@ -229,24 +229,24 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function add_payment_bulk_action_notice() { |
231 | 231 | if ( |
232 | - current_user_can( 'edit_give_payments' ) |
|
233 | - && isset( $_GET['action'] ) |
|
234 | - && ! empty( $_GET['action'] ) |
|
235 | - && isset( $_GET['payment'] ) |
|
236 | - && ! empty( $_GET['payment'] ) |
|
232 | + current_user_can('edit_give_payments') |
|
233 | + && isset($_GET['action']) |
|
234 | + && ! empty($_GET['action']) |
|
235 | + && isset($_GET['payment']) |
|
236 | + && ! empty($_GET['payment']) |
|
237 | 237 | ) { |
238 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
238 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
239 | 239 | |
240 | - switch ( $_GET['action'] ) { |
|
240 | + switch ($_GET['action']) { |
|
241 | 241 | case 'delete': |
242 | - if ( $payment_count ) { |
|
243 | - $this->notices['updated']['bulk_action_delete'] = sprintf( _n( 'Successfully deleted only one transaction.', 'Successfully deleted %d number of transactions.', $payment_count, 'give' ), $payment_count ); |
|
242 | + if ($payment_count) { |
|
243 | + $this->notices['updated']['bulk_action_delete'] = sprintf(_n('Successfully deleted only one transaction.', 'Successfully deleted %d number of transactions.', $payment_count, 'give'), $payment_count); |
|
244 | 244 | } |
245 | 245 | break; |
246 | 246 | |
247 | 247 | case 'resend-receipt': |
248 | - if ( $payment_count ) { |
|
249 | - $this->notices['updated']['bulk_action_resend_receipt'] = sprintf( _n( 'Successfully send email receipt to only one recipient.', 'Successfully send email receipts to %d recipients.', $payment_count, 'give' ), $payment_count ); |
|
248 | + if ($payment_count) { |
|
249 | + $this->notices['updated']['bulk_action_resend_receipt'] = sprintf(_n('Successfully send email receipt to only one recipient.', 'Successfully send email receipts to %d recipients.', $payment_count, 'give'), $payment_count); |
|
250 | 250 | } |
251 | 251 | break; |
252 | 252 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return string |
269 | 269 | */ |
270 | - public static function notice_html( $message, $type = 'updated' ) { |
|
270 | + public static function notice_html($message, $type = 'updated') { |
|
271 | 271 | ob_start(); |
272 | 272 | ?> |
273 | 273 | <div class="<?php echo $type; ?> notice"> |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @access public |
50 | 50 | * @since 1.5 |
51 | 51 | * |
52 | - * @return array $data The data for the CSV file |
|
52 | + * @return boolean $data The data for the CSV file |
|
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -55,32 +55,32 @@ discard block |
||
55 | 55 | |
56 | 56 | $args = array( |
57 | 57 | 'number' => $this->per_step, |
58 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
58 | + 'offset' => $this->per_step * ($this->step - 1), |
|
59 | 59 | 'orderby' => 'id', |
60 | 60 | 'order' => 'DESC', |
61 | 61 | ); |
62 | 62 | |
63 | - $customers = Give()->customers->get_customers( $args ); |
|
63 | + $customers = Give()->customers->get_customers($args); |
|
64 | 64 | |
65 | - if ( $customers ) { |
|
65 | + if ($customers) { |
|
66 | 66 | |
67 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
67 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
68 | 68 | |
69 | - foreach ( $customers as $customer ) { |
|
69 | + foreach ($customers as $customer) { |
|
70 | 70 | |
71 | - $attached_payment_ids = explode( ',', $customer->payment_ids ); |
|
71 | + $attached_payment_ids = explode(',', $customer->payment_ids); |
|
72 | 72 | |
73 | 73 | $attached_args = array( |
74 | 74 | 'post__in' => $attached_payment_ids, |
75 | - 'number' => - 1, |
|
75 | + 'number' => -1, |
|
76 | 76 | 'status' => $allowed_payment_status, |
77 | 77 | ); |
78 | 78 | |
79 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
79 | + $attached_payments = (array) give_get_payments($attached_args); |
|
80 | 80 | |
81 | 81 | $unattached_args = array( |
82 | 82 | 'post__not_in' => $attached_payment_ids, |
83 | - 'number' => - 1, |
|
83 | + 'number' => -1, |
|
84 | 84 | 'status' => $allowed_payment_status, |
85 | 85 | 'meta_query' => array( |
86 | 86 | array( |
@@ -91,29 +91,29 @@ discard block |
||
91 | 91 | ), |
92 | 92 | ); |
93 | 93 | |
94 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
94 | + $unattached_payments = give_get_payments($unattached_args); |
|
95 | 95 | |
96 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
96 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
97 | 97 | |
98 | 98 | $purchase_value = 0.00; |
99 | 99 | $purchase_count = 0; |
100 | 100 | $payment_ids = array(); |
101 | 101 | |
102 | - if ( $payments ) { |
|
102 | + if ($payments) { |
|
103 | 103 | |
104 | - foreach ( $payments as $payment ) { |
|
104 | + foreach ($payments as $payment) { |
|
105 | 105 | |
106 | 106 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
107 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
107 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
108 | 108 | |
109 | - if ( true === $should_process_payment ) { |
|
109 | + if (true === $should_process_payment) { |
|
110 | 110 | |
111 | - if ( apply_filters( 'give_customer_recount_should_increase_value', true, $payment ) ) { |
|
112 | - $purchase_value += give_get_payment_amount( $payment->ID ); |
|
111 | + if (apply_filters('give_customer_recount_should_increase_value', true, $payment)) { |
|
112 | + $purchase_value += give_get_payment_amount($payment->ID); |
|
113 | 113 | } |
114 | 114 | |
115 | - if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) { |
|
116 | - $purchase_count ++; |
|
115 | + if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) { |
|
116 | + $purchase_count++; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | - $payment_ids = implode( ',', $payment_ids ); |
|
126 | + $payment_ids = implode(',', $payment_ids); |
|
127 | 127 | |
128 | 128 | $customer_update_data = array( |
129 | 129 | 'purchase_count' => $purchase_count, |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | 'payment_ids' => $payment_ids, |
132 | 132 | ); |
133 | 133 | |
134 | - $customer_instance = new Give_Customer( $customer->id ); |
|
135 | - $customer_instance->update( $customer_update_data ); |
|
134 | + $customer_instance = new Give_Customer($customer->id); |
|
135 | + $customer_instance->update($customer_update_data); |
|
136 | 136 | |
137 | 137 | } |
138 | 138 | |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | public function get_percentage_complete() { |
153 | 153 | |
154 | 154 | $args = array( |
155 | - 'number' => - 1, |
|
155 | + 'number' => -1, |
|
156 | 156 | 'orderby' => 'id', |
157 | 157 | 'order' => 'DESC', |
158 | 158 | ); |
159 | 159 | |
160 | - $customers = Give()->customers->get_customers( $args ); |
|
161 | - $total = count( $customers ); |
|
160 | + $customers = Give()->customers->get_customers($args); |
|
161 | + $total = count($customers); |
|
162 | 162 | |
163 | 163 | $percentage = 100; |
164 | 164 | |
165 | - if ( $total > 0 ) { |
|
166 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
165 | + if ($total > 0) { |
|
166 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $percentage > 100 ) { |
|
169 | + if ($percentage > 100) { |
|
170 | 170 | $percentage = 100; |
171 | 171 | } |
172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param array $request The Form Data passed into the batch processing |
182 | 182 | */ |
183 | - public function set_properties( $request ) { |
|
183 | + public function set_properties($request) { |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function process_step() { |
193 | 193 | |
194 | - if ( ! $this->can_export() ) { |
|
195 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
194 | + if ( ! $this->can_export()) { |
|
195 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $had_data = $this->get_data(); |
199 | 199 | |
200 | - if ( $had_data ) { |
|
200 | + if ($had_data) { |
|
201 | 201 | $this->done = false; |
202 | 202 | |
203 | 203 | return true; |
204 | 204 | } else { |
205 | 205 | $this->done = true; |
206 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
206 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
207 | 207 | |
208 | 208 | return false; |
209 | 209 | } |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | * Headers |
214 | 214 | */ |
215 | 215 | public function headers() { |
216 | - ignore_user_abort( true ); |
|
216 | + ignore_user_abort(true); |
|
217 | 217 | |
218 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
219 | - set_time_limit( 0 ); |
|
218 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
219 | + set_time_limit(0); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @since 1.5 |
51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
52 | 52 | * Database API |
53 | - * @return array $data The data for the CSV file |
|
53 | + * @return boolean $data The data for the CSV file |
|
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | global $give_logs, $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | public function get_data() { |
63 | 63 | global $give_logs, $wpdb; |
64 | 64 | |
65 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
65 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
66 | 66 | |
67 | - if ( $this->step == 1 ) { |
|
68 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
67 | + if ($this->step == 1) { |
|
68 | + $this->delete_data('give_temp_recount_form_stats'); |
|
69 | 69 | } |
70 | 70 | |
71 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
71 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
72 | 72 | |
73 | - if ( false === $totals ) { |
|
73 | + if (false === $totals) { |
|
74 | 74 | $totals = array( |
75 | 75 | 'earnings' => (float) 0, |
76 | 76 | 'sales' => 0, |
77 | 77 | ); |
78 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
78 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
79 | 79 | } |
80 | 80 | |
81 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
81 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
82 | 82 | 'post_parent' => $this->form_id, |
83 | 83 | 'post_type' => 'give_log', |
84 | 84 | 'posts_per_page' => $this->per_step, |
@@ -86,49 +86,49 @@ discard block |
||
86 | 86 | 'paged' => $this->step, |
87 | 87 | 'log_type' => 'sale', |
88 | 88 | 'fields' => 'ids', |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
91 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
92 | 92 | $this->_log_ids_debug = array(); |
93 | 93 | |
94 | - if ( $log_ids ) { |
|
95 | - $log_ids = implode( ',', $log_ids ); |
|
96 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
97 | - unset( $log_ids ); |
|
94 | + if ($log_ids) { |
|
95 | + $log_ids = implode(',', $log_ids); |
|
96 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
97 | + unset($log_ids); |
|
98 | 98 | |
99 | - $payment_ids = implode( ',', $payment_ids ); |
|
100 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
101 | - unset( $payment_ids ); |
|
99 | + $payment_ids = implode(',', $payment_ids); |
|
100 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
101 | + unset($payment_ids); |
|
102 | 102 | |
103 | - foreach ( $payments as $payment ) { |
|
103 | + foreach ($payments as $payment) { |
|
104 | 104 | |
105 | - $payment = new Give_Payment( $payment->ID ); |
|
105 | + $payment = new Give_Payment($payment->ID); |
|
106 | 106 | |
107 | 107 | //Ensure acceptible status only |
108 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
108 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | 112 | //Ensure only payments for this form are counted |
113 | - if ( $payment->form_id != $this->form_id ) { |
|
113 | + if ($payment->form_id != $this->form_id) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $this->_log_ids_debug[] = $payment->ID; |
118 | 118 | |
119 | - $totals['sales'] ++; |
|
119 | + $totals['sales']++; |
|
120 | 120 | $totals['earnings'] += $payment->total; |
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
124 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
125 | 125 | |
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
131 | - update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] ); |
|
130 | + update_post_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
131 | + update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']); |
|
132 | 132 | |
133 | 133 | return false; |
134 | 134 | |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | public function get_percentage_complete() { |
144 | 144 | global $give_logs, $wpdb; |
145 | 145 | |
146 | - if ( $this->step == 1 ) { |
|
147 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
146 | + if ($this->step == 1) { |
|
147 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
148 | 148 | } |
149 | 149 | |
150 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
151 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
150 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
151 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
152 | 152 | |
153 | - if ( false === $total ) { |
|
153 | + if (false === $total) { |
|
154 | 154 | $total = 0; |
155 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
155 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
156 | 156 | 'post_parent' => $this->form_id, |
157 | 157 | 'post_type' => 'give_log', |
158 | 158 | 'post_status' => 'publish', |
159 | 159 | 'log_type' => 'sale', |
160 | 160 | 'fields' => 'ids', |
161 | 161 | 'nopaging' => true, |
162 | - ) ); |
|
162 | + )); |
|
163 | 163 | |
164 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
164 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
165 | 165 | |
166 | - if ( $log_ids ) { |
|
167 | - $log_ids = implode( ',', $log_ids ); |
|
168 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" ); |
|
169 | - unset( $log_ids ); |
|
166 | + if ($log_ids) { |
|
167 | + $log_ids = implode(',', $log_ids); |
|
168 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)"); |
|
169 | + unset($log_ids); |
|
170 | 170 | |
171 | - $payment_ids = implode( ',', $payment_ids ); |
|
172 | - $payments = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" ); |
|
173 | - unset( $payment_ids ); |
|
171 | + $payment_ids = implode(',', $payment_ids); |
|
172 | + $payments = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")"); |
|
173 | + unset($payment_ids); |
|
174 | 174 | |
175 | - foreach ( $payments as $payment ) { |
|
176 | - if ( in_array( $payment->post_status, $accepted_statuses ) ) { |
|
175 | + foreach ($payments as $payment) { |
|
176 | + if (in_array($payment->post_status, $accepted_statuses)) { |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | |
180 | - $total ++; |
|
180 | + $total++; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
184 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $percentage = 100; |
188 | 188 | |
189 | - if ( $total > 0 ) { |
|
190 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
189 | + if ($total > 0) { |
|
190 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( $percentage > 100 ) { |
|
193 | + if ($percentage > 100) { |
|
194 | 194 | $percentage = 100; |
195 | 195 | } |
196 | 196 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @param array $request The Form Data passed into the batch processing |
206 | 206 | */ |
207 | - public function set_properties( $request ) { |
|
208 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
207 | + public function set_properties($request) { |
|
208 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -216,31 +216,31 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function process_step() { |
218 | 218 | |
219 | - if ( ! $this->can_export() ) { |
|
220 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
219 | + if ( ! $this->can_export()) { |
|
220 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $had_data = $this->get_data(); |
224 | 224 | |
225 | - if ( $had_data ) { |
|
225 | + if ($had_data) { |
|
226 | 226 | $this->done = false; |
227 | 227 | |
228 | 228 | return true; |
229 | 229 | } else { |
230 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
231 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
230 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
231 | + $this->delete_data('give_temp_recount_form_stats'); |
|
232 | 232 | $this->done = true; |
233 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
233 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
234 | 234 | |
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | public function headers() { |
240 | - ignore_user_abort( true ); |
|
240 | + ignore_user_abort(true); |
|
241 | 241 | |
242 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
243 | - set_time_limit( 0 ); |
|
242 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
243 | + set_time_limit(0); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return mixed Returns the data from the database |
270 | 270 | */ |
271 | - private function get_stored_data( $key ) { |
|
271 | + private function get_stored_data($key) { |
|
272 | 272 | global $wpdb; |
273 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
273 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
274 | 274 | |
275 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
275 | + return empty($value) ? false : maybe_unserialize($value); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @return void |
287 | 287 | */ |
288 | - private function store_data( $key, $value ) { |
|
288 | + private function store_data($key, $value) { |
|
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $value = maybe_serialize( $value ); |
|
291 | + $value = maybe_serialize($value); |
|
292 | 292 | |
293 | 293 | $data = array( |
294 | 294 | 'option_name' => $key, |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | '%s', |
303 | 303 | ); |
304 | 304 | |
305 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
305 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return void |
316 | 316 | */ |
317 | - private function delete_data( $key ) { |
|
317 | + private function delete_data($key) { |
|
318 | 318 | global $wpdb; |
319 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
319 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | } |