@@ -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 | |
@@ -50,50 +50,50 @@ discard block |
||
50 | 50 | */ |
51 | 51 | |
52 | 52 | // https://gist.github.com/justinph/5197810 |
53 | - function validate_gravatar( $id_or_email ) { |
|
53 | + function validate_gravatar($id_or_email) { |
|
54 | 54 | //id or email code borrowed from wp-includes/pluggable.php |
55 | 55 | $email = ''; |
56 | - if ( is_numeric( $id_or_email ) ) { |
|
56 | + if (is_numeric($id_or_email)) { |
|
57 | 57 | $id = (int) $id_or_email; |
58 | - $user = get_userdata( $id ); |
|
59 | - if ( $user ) { |
|
58 | + $user = get_userdata($id); |
|
59 | + if ($user) { |
|
60 | 60 | $email = $user->user_email; |
61 | 61 | } |
62 | - } elseif ( is_object( $id_or_email ) ) { |
|
62 | + } elseif (is_object($id_or_email)) { |
|
63 | 63 | // No avatar for pingbacks or trackbacks |
64 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
65 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
64 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
65 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
69 | + if ( ! empty($id_or_email->user_id)) { |
|
70 | 70 | $id = (int) $id_or_email->user_id; |
71 | - $user = get_userdata( $id ); |
|
72 | - if ( $user ) { |
|
71 | + $user = get_userdata($id); |
|
72 | + if ($user) { |
|
73 | 73 | $email = $user->user_email; |
74 | 74 | } |
75 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
75 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
76 | 76 | $email = $id_or_email->comment_author_email; |
77 | 77 | } |
78 | 78 | } else { |
79 | 79 | $email = $id_or_email; |
80 | 80 | } |
81 | 81 | |
82 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
83 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
82 | + $hashkey = md5(strtolower(trim($email))); |
|
83 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
84 | 84 | |
85 | - $data = wp_cache_get( $hashkey ); |
|
86 | - if ( false === $data ) { |
|
87 | - $response = wp_remote_head( $uri ); |
|
88 | - if ( is_wp_error( $response ) ) { |
|
85 | + $data = wp_cache_get($hashkey); |
|
86 | + if (false === $data) { |
|
87 | + $response = wp_remote_head($uri); |
|
88 | + if (is_wp_error($response)) { |
|
89 | 89 | $data = 'not200'; |
90 | 90 | } else { |
91 | 91 | $data = $response['response']['code']; |
92 | 92 | } |
93 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
93 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
94 | 94 | |
95 | 95 | } |
96 | - if ( $data == '200' ) { |
|
96 | + if ($data == '200') { |
|
97 | 97 | return true; |
98 | 98 | } else { |
99 | 99 | return false; |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param int $form_id |
110 | 110 | */ |
111 | - function get_log_ids( $form_id = '' ) { |
|
111 | + function get_log_ids($form_id = '') { |
|
112 | 112 | |
113 | 113 | // get Give_Logging class |
114 | 114 | global $give_logs; |
115 | 115 | |
116 | 116 | // get log for this form |
117 | - $logs = $give_logs->get_logs( $form_id ); |
|
117 | + $logs = $give_logs->get_logs($form_id); |
|
118 | 118 | |
119 | - if ( $logs ) { |
|
119 | + if ($logs) { |
|
120 | 120 | // make an array with all the donor IDs |
121 | - foreach ( $logs as $log ) { |
|
121 | + foreach ($logs as $log) { |
|
122 | 122 | $log_ids[] = $log->ID; |
123 | 123 | } |
124 | 124 | |
@@ -135,49 +135,49 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @since 1.0 |
137 | 137 | */ |
138 | - function get_payment_ids( $form_id = '' ) { |
|
138 | + function get_payment_ids($form_id = '') { |
|
139 | 139 | |
140 | 140 | global $give_options; |
141 | 141 | |
142 | - $log_ids = $this->get_log_ids( $form_id ); |
|
142 | + $log_ids = $this->get_log_ids($form_id); |
|
143 | 143 | |
144 | - if ( $log_ids ) { |
|
144 | + if ($log_ids) { |
|
145 | 145 | |
146 | 146 | $payment_ids = array(); |
147 | 147 | |
148 | - foreach ( $log_ids as $id ) { |
|
148 | + foreach ($log_ids as $id) { |
|
149 | 149 | // get the payment ID for each corresponding log ID |
150 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
150 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // remove donors who have purchased more than once so we can have unique avatars |
154 | 154 | $unique_emails = array(); |
155 | 155 | |
156 | - foreach ( $payment_ids as $key => $id ) { |
|
156 | + foreach ($payment_ids as $key => $id) { |
|
157 | 157 | |
158 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
158 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
159 | 159 | |
160 | - if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { |
|
161 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
160 | + if (isset ($give_options['give_donators_gravatars_has_gravatar_account'])) { |
|
161 | + if ( ! $this->validate_gravatar($email)) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
166 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | 170 | // strip duplicate emails |
171 | - $unique_emails = array_unique( $unique_emails ); |
|
171 | + $unique_emails = array_unique($unique_emails); |
|
172 | 172 | |
173 | 173 | // convert the unique IDs back into simple array |
174 | - foreach ( $unique_emails as $id => $email ) { |
|
174 | + foreach ($unique_emails as $id => $email) { |
|
175 | 175 | $unique_ids[] = $id; |
176 | 176 | } |
177 | 177 | |
178 | 178 | // randomize the payment IDs if enabled |
179 | - if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { |
|
180 | - shuffle( $unique_ids ); |
|
179 | + if (isset($give_options['give_donators_gravatars_random_gravatars'])) { |
|
180 | + shuffle($unique_ids); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // return our unique IDs |
@@ -193,22 +193,22 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @since 1.0 |
195 | 195 | */ |
196 | - function gravatars( $form_id = false, $title = '' ) { |
|
196 | + function gravatars($form_id = false, $title = '') { |
|
197 | 197 | |
198 | 198 | // unique $payment_ids |
199 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
199 | + $payment_ids = $this->get_payment_ids($form_id); |
|
200 | 200 | |
201 | 201 | global $give_options; |
202 | 202 | |
203 | 203 | // return if no ID |
204 | - if ( ! $form_id ) { |
|
204 | + if ( ! $form_id) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // minimum amount of purchases before showing gravatars |
209 | 209 | // if the number of items in array is not greater or equal to the number specified, then exit |
210 | - if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { |
|
211 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { |
|
210 | + if (isset($give_options['give_donators_gravatars_min_purchases_required']) && '' != $give_options['give_donators_gravatars_min_purchases_required']) { |
|
211 | + if ( ! (count($payment_ids) >= $give_options['give_donators_gravatars_min_purchases_required'])) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | } |
@@ -219,51 +219,51 @@ discard block |
||
219 | 219 | echo '<div id="give-purchase-gravatars">'; |
220 | 220 | |
221 | 221 | |
222 | - if ( isset ( $title ) ) { |
|
222 | + if (isset ($title)) { |
|
223 | 223 | |
224 | - if ( $title ) { |
|
225 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_html__( $title ) . '</h3>' ); |
|
226 | - } elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { |
|
227 | - echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_html__( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); |
|
224 | + if ($title) { |
|
225 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_html__($title).'</h3>'); |
|
226 | + } elseif (isset($give_options['give_donators_gravatars_heading'])) { |
|
227 | + echo apply_filters('give_donators_gravatars_title', '<h3 class="give-gravatars-title">'.esc_html__($give_options['give_donators_gravatars_heading']).'</h2>'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | } |
231 | 231 | echo '<ul class="give-purchase-gravatars-list">'; |
232 | 232 | $i = 0; |
233 | 233 | |
234 | - if ( $payment_ids ) { |
|
235 | - foreach ( $payment_ids as $id ) { |
|
234 | + if ($payment_ids) { |
|
235 | + foreach ($payment_ids as $id) { |
|
236 | 236 | |
237 | 237 | // Give saves a blank option even when the control is turned off, hence the extra check |
238 | - if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { |
|
238 | + if (isset($give_options['give_donators_gravatars_maximum_number']) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number']) { |
|
239 | 239 | continue; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // get the payment meta |
243 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
243 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
244 | 244 | |
245 | 245 | // unserialize the payment meta |
246 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
246 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
247 | 247 | |
248 | 248 | // get donor's first name |
249 | 249 | $name = $user_info['first_name']; |
250 | 250 | |
251 | 251 | // get donor's email |
252 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
252 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
253 | 253 | |
254 | 254 | // set gravatar size and provide filter |
255 | - $size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; |
|
255 | + $size = isset($give_options['give_donators_gravatars_gravatar_size']) ? apply_filters('give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size']) : ''; |
|
256 | 256 | |
257 | 257 | // default image |
258 | - $default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); |
|
258 | + $default_image = apply_filters('give_donators_gravatars_gravatar_default_image', false); |
|
259 | 259 | |
260 | 260 | // assemble output |
261 | 261 | $output .= '<li>'; |
262 | 262 | |
263 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
263 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
264 | 264 | $output .= '</li>'; |
265 | 265 | |
266 | - $i ++; |
|
266 | + $i++; |
|
267 | 267 | |
268 | 268 | } // end foreach |
269 | 269 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | echo '</ul>'; |
273 | 273 | echo '</div>'; |
274 | 274 | |
275 | - return apply_filters( 'give_donators_gravatars', ob_get_clean() ); |
|
275 | + return apply_filters('give_donators_gravatars', ob_get_clean()); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @since 1.0 |
282 | 282 | */ |
283 | 283 | function register_widget() { |
284 | - register_widget( 'Give_Donators_Gravatars_Widget' ); |
|
284 | + register_widget('Give_Donators_Gravatars_Widget'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | * @since 1.0 |
291 | 291 | * @todo set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
292 | 292 | */ |
293 | - function shortcode( $atts, $content = null ) { |
|
293 | + function shortcode($atts, $content = null) { |
|
294 | 294 | |
295 | - $atts = shortcode_atts( array( |
|
295 | + $atts = shortcode_atts(array( |
|
296 | 296 | 'id' => '', |
297 | 297 | 'title' => '' |
298 | - ), $atts, 'give_donators_gravatars' ); |
|
298 | + ), $atts, 'give_donators_gravatars'); |
|
299 | 299 | |
300 | 300 | // if no ID is passed on single give_forms pages, get the correct ID |
301 | - if ( is_singular( 'give_forms' ) ) { |
|
301 | + if (is_singular('give_forms')) { |
|
302 | 302 | $id = get_the_ID(); |
303 | 303 | } |
304 | 304 | |
305 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
305 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
306 | 306 | |
307 | 307 | return $content; |
308 | 308 | |
@@ -313,57 +313,57 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @since 1.0 |
315 | 315 | */ |
316 | - function settings( $settings ) { |
|
316 | + function settings($settings) { |
|
317 | 317 | |
318 | 318 | $give_gravatar_settings = array( |
319 | 319 | array( |
320 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
320 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
321 | 321 | 'desc' => '<hr>', |
322 | 322 | 'id' => 'give_title', |
323 | 323 | 'type' => 'give_title' |
324 | 324 | ), |
325 | 325 | array( |
326 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
327 | - 'desc' => esc_html__( 'The heading to display above the Gravatars', 'give' ), |
|
326 | + 'name' => esc_html__('Heading', 'give'), |
|
327 | + 'desc' => esc_html__('The heading to display above the Gravatars', 'give'), |
|
328 | 328 | 'type' => 'text', |
329 | 329 | 'id' => 'give_donators_gravatars_heading' |
330 | 330 | ), |
331 | 331 | array( |
332 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
333 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), |
|
332 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
333 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum)', 'give'), |
|
334 | 334 | 'type' => 'text_small', |
335 | 335 | 'id' => 'give_donators_gravatars_gravatar_size', |
336 | 336 | 'default' => '64' |
337 | 337 | ), |
338 | 338 | array( |
339 | - 'name' => esc_html__( 'Minimum Unique Purchases Required', 'give' ), |
|
339 | + 'name' => esc_html__('Minimum Unique Purchases Required', 'give'), |
|
340 | 340 | /* translators: %s: form singular label */ |
341 | - 'desc' => sprintf( esc_html__( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), |
|
341 | + 'desc' => sprintf(esc_html__('The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), strtolower(give_get_forms_label_singular())), |
|
342 | 342 | 'type' => 'text_small', |
343 | 343 | 'id' => 'give_donators_gravatars_min_purchases_required', |
344 | 344 | ), |
345 | 345 | array( |
346 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
347 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
346 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
347 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
348 | 348 | 'type' => 'text', |
349 | 349 | 'id' => 'give_donators_gravatars_maximum_number', |
350 | 350 | 'default' => '20', |
351 | 351 | ), |
352 | 352 | array( |
353 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
354 | - 'desc' => esc_html__( 'Only show donators with a Gravatar account', 'give' ), |
|
353 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
354 | + 'desc' => esc_html__('Only show donators with a Gravatar account', 'give'), |
|
355 | 355 | 'id' => 'give_donators_gravatars_has_gravatar_account', |
356 | 356 | 'type' => 'checkbox', |
357 | 357 | ), |
358 | 358 | array( |
359 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
360 | - 'desc' => esc_html__( 'Randomize the Gravatars', 'give' ), |
|
359 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
360 | + 'desc' => esc_html__('Randomize the Gravatars', 'give'), |
|
361 | 361 | 'id' => 'give_donators_gravatars_random_gravatars', |
362 | 362 | 'type' => 'checkbox', |
363 | 363 | ), |
364 | 364 | ); |
365 | 365 | |
366 | - return array_merge( $settings, $give_gravatar_settings ); |
|
366 | + return array_merge($settings, $give_gravatar_settings); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | } |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function __construct() { |
383 | 383 | |
384 | - $give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; |
|
384 | + $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; |
|
385 | 385 | |
386 | 386 | // widget settings |
387 | 387 | $widget_ops = array( |
388 | 388 | 'classname' => 'give-donators-gravatars', |
389 | 389 | /* translators: 1: form singular label 2: form singular label */ |
390 | - 'description' => sprintf( esc_html__( 'Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give' ), $give_label_singular, $give_label_singular ) |
|
390 | + 'description' => sprintf(esc_html__('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular) |
|
391 | 391 | ); |
392 | 392 | |
393 | 393 | // widget control settings |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | // create the widget |
401 | 401 | parent::__construct( |
402 | 402 | 'give_donators_gravatars_widget', |
403 | - esc_html__( 'Give Donators Gravatars', 'give' ), |
|
403 | + esc_html__('Give Donators Gravatars', 'give'), |
|
404 | 404 | $widget_ops, |
405 | 405 | $control_ops |
406 | 406 | ); |
@@ -411,30 +411,30 @@ discard block |
||
411 | 411 | /* |
412 | 412 | * Outputs the content of the widget |
413 | 413 | */ |
414 | - function widget( $args, $instance ) { |
|
414 | + function widget($args, $instance) { |
|
415 | 415 | global $give_options; |
416 | 416 | |
417 | 417 | //@TODO: Don't extract it!!! |
418 | - extract( $args ); |
|
418 | + extract($args); |
|
419 | 419 | |
420 | - if ( ! is_singular( 'give_forms' ) ) { |
|
420 | + if ( ! is_singular('give_forms')) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
424 | 424 | // Variables from widget settings |
425 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
425 | + $title = apply_filters('widget_title', $instance['title']); |
|
426 | 426 | |
427 | 427 | // Used by themes. Opens the widget |
428 | 428 | echo $before_widget; |
429 | 429 | |
430 | 430 | // Display the widget title |
431 | - if ( $title ) { |
|
432 | - echo $before_title . $title . $after_title; |
|
431 | + if ($title) { |
|
432 | + echo $before_title.$title.$after_title; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $gravatars = new Give_Donators_Gravatars(); |
436 | 436 | |
437 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
437 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
438 | 438 | |
439 | 439 | // Used by themes. Closes the widget |
440 | 440 | echo $after_widget; |
@@ -444,11 +444,11 @@ discard block |
||
444 | 444 | /* |
445 | 445 | * Update function. Processes widget options to be saved |
446 | 446 | */ |
447 | - function update( $new_instance, $old_instance ) { |
|
447 | + function update($new_instance, $old_instance) { |
|
448 | 448 | |
449 | 449 | $instance = $old_instance; |
450 | 450 | |
451 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
451 | + $instance['title'] = strip_tags($new_instance['title']); |
|
452 | 452 | |
453 | 453 | return $instance; |
454 | 454 | |
@@ -457,19 +457,19 @@ discard block |
||
457 | 457 | /* |
458 | 458 | * Form function. Displays the actual form on the widget page |
459 | 459 | */ |
460 | - function form( $instance ) { |
|
460 | + function form($instance) { |
|
461 | 461 | |
462 | 462 | // Set up some default widget settings. |
463 | 463 | $defaults = array( |
464 | 464 | 'title' => '', |
465 | 465 | ); |
466 | 466 | |
467 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
467 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
468 | 468 | |
469 | 469 | <!-- Title --> |
470 | 470 | <p> |
471 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
472 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
471 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
472 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
473 | 473 | </p> |
474 | 474 | |
475 | 475 |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
15 | +if ( ! class_exists('Give_License')) : |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_License Class |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param string $_optname |
39 | 39 | * @param string $_api_url |
40 | 40 | */ |
41 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { |
|
41 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) { |
|
42 | 42 | global $give_options; |
43 | 43 | |
44 | 44 | $this->file = $_file; |
45 | 45 | $this->item_name = $_item_name; |
46 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
46 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
47 | 47 | $this->version = $_version; |
48 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
48 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
49 | 49 | $this->author = $_author; |
50 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
50 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | // Setup hooks |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | private function includes() { |
66 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
66 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
67 | 67 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
68 | 68 | } |
69 | 69 | } |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | private function hooks() { |
78 | 78 | |
79 | 79 | // Register settings |
80 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
80 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
81 | 81 | |
82 | 82 | // Activate license key on settings save |
83 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
83 | + add_action('admin_init', array($this, 'activate_license')); |
|
84 | 84 | |
85 | 85 | // Deactivate license key |
86 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
86 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
87 | 87 | |
88 | 88 | // Updater |
89 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
89 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
90 | 90 | |
91 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
91 | + add_action('admin_notices', array($this, 'notices')); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function auto_updater() { |
102 | 102 | |
103 | - if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) { |
|
103 | + if ('valid' !== get_option($this->item_shortname.'_license_active')) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public function settings( $settings ) { |
|
130 | + public function settings($settings) { |
|
131 | 131 | |
132 | 132 | $give_license_settings = array( |
133 | 133 | array( |
134 | 134 | 'name' => $this->item_name, |
135 | - 'id' => $this->item_shortname . '_license_key', |
|
135 | + 'id' => $this->item_shortname.'_license_key', |
|
136 | 136 | 'desc' => '', |
137 | 137 | 'type' => 'license_key', |
138 | - 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ), |
|
138 | + 'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'), |
|
139 | 139 | 'size' => 'regular' |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | |
143 | - return array_merge( $settings, $give_license_settings ); |
|
143 | + return array_merge($settings, $give_license_settings); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array |
154 | 154 | */ |
155 | - public function license_settings_content( $settings ) { |
|
155 | + public function license_settings_content($settings) { |
|
156 | 156 | |
157 | 157 | $give_license_settings = array( |
158 | 158 | array( |
159 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
159 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
160 | 160 | 'desc' => '<hr>', |
161 | 161 | 'type' => 'give_title', |
162 | 162 | 'id' => 'give_title' |
163 | 163 | ), |
164 | 164 | ); |
165 | 165 | |
166 | - return array_merge( $settings, $give_license_settings ); |
|
166 | + return array_merge($settings, $give_license_settings); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,34 +175,34 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function activate_license() { |
177 | 177 | |
178 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
178 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - foreach ( $_POST as $key => $value ) { |
|
183 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
182 | + foreach ($_POST as $key => $value) { |
|
183 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
184 | 184 | // Don't activate a key when deactivating a different key |
185 | 185 | return; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
189 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
190 | 190 | |
191 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
191 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
195 | + if ( ! current_user_can('manage_give_settings')) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) { |
|
199 | + if ('valid' === get_option($this->item_shortname.'_license_active')) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
203 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
204 | 204 | |
205 | - if ( empty( $license ) ) { |
|
205 | + if (empty($license)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $api_params = array( |
211 | 211 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
212 | 212 | 'license' => $license, |
213 | - 'item_name' => urlencode( $this->item_name ), |
|
213 | + 'item_name' => urlencode($this->item_name), |
|
214 | 214 | 'url' => home_url() |
215 | 215 | ); |
216 | 216 | |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | ); |
226 | 226 | |
227 | 227 | // Make sure there are no errors |
228 | - if ( is_wp_error( $response ) ) { |
|
228 | + if (is_wp_error($response)) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Tell WordPress to look for updates |
233 | - set_site_transient( 'update_plugins', null ); |
|
233 | + set_site_transient('update_plugins', null); |
|
234 | 234 | |
235 | 235 | // Decode license data |
236 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
236 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
237 | 237 | |
238 | - update_option( $this->item_shortname . '_license_active', $license_data->license ); |
|
238 | + update_option($this->item_shortname.'_license_active', $license_data->license); |
|
239 | 239 | |
240 | - if ( ! (bool) $license_data->success ) { |
|
241 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
240 | + if ( ! (bool) $license_data->success) { |
|
241 | + set_transient('give_license_error', $license_data, 1000); |
|
242 | 242 | } else { |
243 | - delete_transient( 'give_license_error' ); |
|
243 | + delete_transient('give_license_error'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function deactivate_license() { |
255 | 255 | |
256 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
256 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
260 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
261 | 261 | |
262 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
262 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
266 | + if ( ! current_user_can('manage_give_settings')) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Run on deactivate button press |
271 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
271 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
272 | 272 | |
273 | 273 | // Data to send to the API |
274 | 274 | $api_params = array( |
275 | 275 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
276 | 276 | 'license' => $this->license, |
277 | - 'item_name' => urlencode( $this->item_name ), |
|
277 | + 'item_name' => urlencode($this->item_name), |
|
278 | 278 | 'url' => home_url() |
279 | 279 | ); |
280 | 280 | |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | // Make sure there are no errors |
293 | - if ( is_wp_error( $response ) ) { |
|
293 | + if (is_wp_error($response)) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Decode the license data |
298 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
298 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
299 | 299 | |
300 | - delete_option( $this->item_shortname . '_license_active' ); |
|
300 | + delete_option($this->item_shortname.'_license_active'); |
|
301 | 301 | |
302 | - if ( ! (bool) $license_data->success ) { |
|
303 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
302 | + if ( ! (bool) $license_data->success) { |
|
303 | + set_transient('give_license_error', $license_data, 1000); |
|
304 | 304 | } else { |
305 | - delete_transient( 'give_license_error' ); |
|
305 | + delete_transient('give_license_error'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -316,44 +316,44 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function notices() { |
318 | 318 | |
319 | - if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) { |
|
319 | + if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) { |
|
323 | + if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $license_error = get_transient( 'give_license_error' ); |
|
327 | + $license_error = get_transient('give_license_error'); |
|
328 | 328 | |
329 | - if ( false === $license_error ) { |
|
329 | + if (false === $license_error) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | - if ( ! empty( $license_error->error ) ) { |
|
333 | + if ( ! empty($license_error->error)) { |
|
334 | 334 | |
335 | - switch ( $license_error->error ) { |
|
335 | + switch ($license_error->error) { |
|
336 | 336 | |
337 | 337 | case 'item_name_mismatch' : |
338 | 338 | |
339 | - $message = esc_html__( 'This license does not belong to the product you have entered it for.', 'give' ); |
|
339 | + $message = esc_html__('This license does not belong to the product you have entered it for.', 'give'); |
|
340 | 340 | break; |
341 | 341 | |
342 | 342 | case 'no_activations_left' : |
343 | 343 | |
344 | - $message = esc_html__( 'This license does not have any activations left.', 'give' ); |
|
344 | + $message = esc_html__('This license does not have any activations left.', 'give'); |
|
345 | 345 | break; |
346 | 346 | |
347 | 347 | case 'expired' : |
348 | 348 | |
349 | - $message = esc_html__( 'This license key is expired. Please renew it.', 'give' ); |
|
349 | + $message = esc_html__('This license key is expired. Please renew it.', 'give'); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | default : |
353 | 353 | |
354 | 354 | $message = sprintf( |
355 | 355 | /* translators: %s: license error */ |
356 | - esc_html__( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ), |
|
356 | + esc_html__('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'), |
|
357 | 357 | $license_error->error |
358 | 358 | ); |
359 | 359 | break; |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $message ) ) { |
|
365 | + if ( ! empty($message)) { |
|
366 | 366 | |
367 | 367 | echo '<div class="error">'; |
368 | - echo '<p>' . $message . '</p>'; |
|
368 | + echo '<p>'.$message.'</p>'; |
|
369 | 369 | echo '</div>'; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | - delete_transient( 'give_license_error' ); |
|
373 | + delete_transient('give_license_error'); |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | |
31 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
31 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | public function add_roles() { |
42 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
42 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
43 | 43 | 'read' => true, |
44 | 44 | 'edit_posts' => true, |
45 | 45 | 'delete_posts' => true, |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | 'publish_posts' => true, |
69 | 69 | 'read_private_pages' => true, |
70 | 70 | 'read_private_posts' => true |
71 | - ) ); |
|
71 | + )); |
|
72 | 72 | |
73 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
73 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
74 | 74 | 'read' => true, |
75 | 75 | 'edit_posts' => false, |
76 | 76 | 'delete_posts' => false |
77 | - ) ); |
|
77 | + )); |
|
78 | 78 | |
79 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
79 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
80 | 80 | 'read' => true, |
81 | 81 | 'edit_posts' => false, |
82 | 82 | 'upload_files' => true, |
83 | 83 | 'delete_posts' => false |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -96,38 +96,38 @@ discard block |
||
96 | 96 | public function add_caps() { |
97 | 97 | global $wp_roles; |
98 | 98 | |
99 | - if ( class_exists('WP_Roles') ) { |
|
100 | - if ( ! isset( $wp_roles ) ) { |
|
99 | + if (class_exists('WP_Roles')) { |
|
100 | + if ( ! isset($wp_roles)) { |
|
101 | 101 | $wp_roles = new WP_Roles(); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_object( $wp_roles ) ) { |
|
106 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
107 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
108 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
109 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
105 | + if (is_object($wp_roles)) { |
|
106 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
107 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
108 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
109 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
110 | 110 | |
111 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
112 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
113 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
114 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
111 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
112 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
113 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
114 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
115 | 115 | |
116 | 116 | // Add the main post type capabilities |
117 | 117 | $capabilities = $this->get_core_caps(); |
118 | - foreach ( $capabilities as $cap_group ) { |
|
119 | - foreach ( $cap_group as $cap ) { |
|
120 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
121 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
122 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
118 | + foreach ($capabilities as $cap_group) { |
|
119 | + foreach ($cap_group as $cap) { |
|
120 | + $wp_roles->add_cap('administrator', $cap); |
|
121 | + $wp_roles->add_cap('give_manager', $cap); |
|
122 | + $wp_roles->add_cap('give_worker', $cap); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
127 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
128 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
129 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
126 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
127 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
128 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
129 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | } |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | public function get_core_caps() { |
143 | 143 | $capabilities = array(); |
144 | 144 | |
145 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
145 | + $capability_types = array('give_form', 'give_payment'); |
|
146 | 146 | |
147 | - foreach ( $capability_types as $capability_type ) { |
|
148 | - $capabilities[ $capability_type ] = array( |
|
147 | + foreach ($capability_types as $capability_type) { |
|
148 | + $capabilities[$capability_type] = array( |
|
149 | 149 | // Post type |
150 | 150 | "edit_{$capability_type}", |
151 | 151 | "read_{$capability_type}", |
@@ -182,22 +182,22 @@ discard block |
||
182 | 182 | * @since 1.0 |
183 | 183 | * @return array $caps |
184 | 184 | */ |
185 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
185 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
186 | 186 | |
187 | - switch( $cap ) { |
|
187 | + switch ($cap) { |
|
188 | 188 | |
189 | 189 | case 'view_give_forms_stats' : |
190 | 190 | |
191 | - if( empty( $args[0] ) ) { |
|
191 | + if (empty($args[0])) { |
|
192 | 192 | break; |
193 | 193 | } |
194 | 194 | |
195 | - $form = get_post( $args[0] ); |
|
196 | - if ( empty( $form ) ) { |
|
195 | + $form = get_post($args[0]); |
|
196 | + if (empty($form)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | |
200 | - if( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
200 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
201 | 201 | $caps = array(); |
202 | 202 | } |
203 | 203 | |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | |
220 | 220 | global $wp_roles; |
221 | 221 | |
222 | - if ( class_exists( 'WP_Roles' ) ) { |
|
223 | - if ( ! isset( $wp_roles ) ) { |
|
222 | + if (class_exists('WP_Roles')) { |
|
223 | + if ( ! isset($wp_roles)) { |
|
224 | 224 | $wp_roles = new WP_Roles(); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - if ( is_object( $wp_roles ) ) { |
|
228 | + if (is_object($wp_roles)) { |
|
229 | 229 | /** Give Manager Capabilities */ |
230 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
231 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
232 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
233 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
230 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
231 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
232 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
233 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
234 | 234 | |
235 | 235 | /** Site Administrator Capabilities */ |
236 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
237 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
238 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
239 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
236 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
237 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
238 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
239 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
240 | 240 | |
241 | 241 | /** Remove the Main Post Type Capabilities */ |
242 | 242 | $capabilities = $this->get_core_caps(); |
243 | 243 | |
244 | - foreach ( $capabilities as $cap_group ) { |
|
245 | - foreach ( $cap_group as $cap ) { |
|
246 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
247 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
248 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
244 | + foreach ($capabilities as $cap_group) { |
|
245 | + foreach ($cap_group as $cap) { |
|
246 | + $wp_roles->remove_cap('give_manager', $cap); |
|
247 | + $wp_roles->remove_cap('administrator', $cap); |
|
248 | + $wp_roles->remove_cap('give_worker', $cap); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | /** Give Accountant Capabilities */ |
253 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
254 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
255 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
256 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
253 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
254 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
255 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
256 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | } |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function get_predefined_dates() { |
78 | 78 | $predefined = array( |
79 | - 'today' => esc_html__( 'Today', 'give' ), |
|
80 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
81 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
82 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
83 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
84 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
85 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
86 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
87 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
88 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
79 | + 'today' => esc_html__('Today', 'give'), |
|
80 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
81 | + 'this_week' => esc_html__('This Week', 'give'), |
|
82 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
83 | + 'this_month' => esc_html__('This Month', 'give'), |
|
84 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
85 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
86 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
87 | + 'this_year' => esc_html__('This Year', 'give'), |
|
88 | + 'last_year' => esc_html__('Last Year', 'give') |
|
89 | 89 | ); |
90 | 90 | |
91 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
91 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
107 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
108 | 108 | |
109 | - if ( empty( $_start_date ) ) { |
|
109 | + if (empty($_start_date)) { |
|
110 | 110 | $_start_date = 'this_month'; |
111 | 111 | } |
112 | 112 | |
113 | - if ( empty( $_end_date ) ) { |
|
113 | + if (empty($_end_date)) { |
|
114 | 114 | $_end_date = $_start_date; |
115 | 115 | } |
116 | 116 | |
117 | - $this->start_date = $this->convert_date( $_start_date ); |
|
118 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
117 | + $this->start_date = $this->convert_date($_start_date); |
|
118 | + $this->end_date = $this->convert_date($_end_date, true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,26 +125,26 @@ discard block |
||
125 | 125 | * @since 1.0 |
126 | 126 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned |
127 | 127 | */ |
128 | - public function convert_date( $date, $end_date = false ) { |
|
128 | + public function convert_date($date, $end_date = false) { |
|
129 | 129 | |
130 | 130 | $this->timestamp = false; |
131 | 131 | $second = $end_date ? 59 : 0; |
132 | 132 | $minute = $end_date ? 59 : 0; |
133 | 133 | $hour = $end_date ? 23 : 0; |
134 | 134 | $day = 1; |
135 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
136 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
135 | + $month = date('n', current_time('timestamp')); |
|
136 | + $year = date('Y', current_time('timestamp')); |
|
137 | 137 | |
138 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
138 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
139 | 139 | |
140 | 140 | // This is a predefined date rate, such as last_week |
141 | - switch ( $date ) { |
|
141 | + switch ($date) { |
|
142 | 142 | |
143 | 143 | case 'this_month' : |
144 | 144 | |
145 | - if ( $end_date ) { |
|
145 | + if ($end_date) { |
|
146 | 146 | |
147 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
147 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
148 | 148 | $hour = 23; |
149 | 149 | $minute = 59; |
150 | 150 | $second = 59; |
@@ -154,28 +154,28 @@ discard block |
||
154 | 154 | |
155 | 155 | case 'last_month' : |
156 | 156 | |
157 | - if ( $month == 1 ) { |
|
157 | + if ($month == 1) { |
|
158 | 158 | |
159 | 159 | $month = 12; |
160 | - $year --; |
|
160 | + $year--; |
|
161 | 161 | |
162 | 162 | } else { |
163 | 163 | |
164 | - $month --; |
|
164 | + $month--; |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | - if ( $end_date ) { |
|
169 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
168 | + if ($end_date) { |
|
169 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | break; |
173 | 173 | |
174 | 174 | case 'today' : |
175 | 175 | |
176 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
176 | + $day = date('d', current_time('timestamp')); |
|
177 | 177 | |
178 | - if ( $end_date ) { |
|
178 | + if ($end_date) { |
|
179 | 179 | $hour = 23; |
180 | 180 | $minute = 59; |
181 | 181 | $second = 59; |
@@ -185,23 +185,23 @@ discard block |
||
185 | 185 | |
186 | 186 | case 'yesterday' : |
187 | 187 | |
188 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
188 | + $day = date('d', current_time('timestamp')) - 1; |
|
189 | 189 | |
190 | 190 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
191 | - if ( $day < 1 ) { |
|
191 | + if ($day < 1) { |
|
192 | 192 | |
193 | 193 | // If current month is 1 |
194 | - if ( 1 == $month ) { |
|
194 | + if (1 == $month) { |
|
195 | 195 | |
196 | 196 | $year -= 1; // Today is January 1, so skip back to last day of December |
197 | 197 | $month = 12; |
198 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
198 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
199 | 199 | |
200 | 200 | } else { |
201 | 201 | |
202 | 202 | // Go back one month and get the last day of the month |
203 | 203 | $month -= 1; |
204 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
204 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | |
211 | 211 | case 'this_week' : |
212 | 212 | |
213 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
214 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
213 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
214 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
215 | 215 | |
216 | - if ( $today < $days_to_week_start ) { |
|
216 | + if ($today < $days_to_week_start) { |
|
217 | 217 | |
218 | - if ( $month > 1 ) { |
|
218 | + if ($month > 1) { |
|
219 | 219 | $month -= 1; |
220 | 220 | } else { |
221 | 221 | $month = 12; |
@@ -223,19 +223,19 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! $end_date ) { |
|
226 | + if ( ! $end_date) { |
|
227 | 227 | |
228 | 228 | // Getting the start day |
229 | 229 | |
230 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
231 | - $day += get_option( 'start_of_week' ); |
|
230 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
231 | + $day += get_option('start_of_week'); |
|
232 | 232 | |
233 | 233 | } else { |
234 | 234 | |
235 | 235 | // Getting the end day |
236 | 236 | |
237 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
238 | - $day += get_option( 'start_of_week' ) + 6; |
|
237 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
238 | + $day += get_option('start_of_week') + 6; |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | |
244 | 244 | case 'last_week' : |
245 | 245 | |
246 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
247 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
246 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
247 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
248 | 248 | |
249 | - if ( $today < $days_to_week_start ) { |
|
249 | + if ($today < $days_to_week_start) { |
|
250 | 250 | |
251 | - if ( $month > 1 ) { |
|
251 | + if ($month > 1) { |
|
252 | 252 | $month -= 1; |
253 | 253 | } else { |
254 | 254 | $month = 12; |
@@ -256,19 +256,19 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $end_date ) { |
|
259 | + if ( ! $end_date) { |
|
260 | 260 | |
261 | 261 | // Getting the start day |
262 | 262 | |
263 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
264 | - $day += get_option( 'start_of_week' ); |
|
263 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
264 | + $day += get_option('start_of_week'); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
268 | 268 | // Getting the end day |
269 | 269 | |
270 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
271 | - $day += get_option( 'start_of_week' ) + 6; |
|
270 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
271 | + $day += get_option('start_of_week') + 6; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -276,39 +276,39 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'this_quarter' : |
278 | 278 | |
279 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
279 | + $month_now = date('n', current_time('timestamp')); |
|
280 | 280 | |
281 | - if ( $month_now <= 3 ) { |
|
281 | + if ($month_now <= 3) { |
|
282 | 282 | |
283 | - if ( ! $end_date ) { |
|
283 | + if ( ! $end_date) { |
|
284 | 284 | $month = 1; |
285 | 285 | } else { |
286 | 286 | $month = 3; |
287 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
287 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
288 | 288 | $hour = 23; |
289 | 289 | $minute = 59; |
290 | 290 | $second = 59; |
291 | 291 | } |
292 | 292 | |
293 | - } else if ( $month_now <= 6 ) { |
|
293 | + } else if ($month_now <= 6) { |
|
294 | 294 | |
295 | - if ( ! $end_date ) { |
|
295 | + if ( ! $end_date) { |
|
296 | 296 | $month = 4; |
297 | 297 | } else { |
298 | 298 | $month = 6; |
299 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
299 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
300 | 300 | $hour = 23; |
301 | 301 | $minute = 59; |
302 | 302 | $second = 59; |
303 | 303 | } |
304 | 304 | |
305 | - } else if ( $month_now <= 9 ) { |
|
305 | + } else if ($month_now <= 9) { |
|
306 | 306 | |
307 | - if ( ! $end_date ) { |
|
307 | + if ( ! $end_date) { |
|
308 | 308 | $month = 7; |
309 | 309 | } else { |
310 | 310 | $month = 9; |
311 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
311 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
312 | 312 | $hour = 23; |
313 | 313 | $minute = 59; |
314 | 314 | $second = 59; |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | |
317 | 317 | } else { |
318 | 318 | |
319 | - if ( ! $end_date ) { |
|
319 | + if ( ! $end_date) { |
|
320 | 320 | $month = 10; |
321 | 321 | } else { |
322 | 322 | $month = 12; |
323 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
323 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
324 | 324 | $hour = 23; |
325 | 325 | $minute = 59; |
326 | 326 | $second = 59; |
@@ -332,40 +332,40 @@ discard block |
||
332 | 332 | |
333 | 333 | case 'last_quarter' : |
334 | 334 | |
335 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
335 | + $month_now = date('n', current_time('timestamp')); |
|
336 | 336 | |
337 | - if ( $month_now <= 3 ) { |
|
337 | + if ($month_now <= 3) { |
|
338 | 338 | |
339 | - if ( ! $end_date ) { |
|
339 | + if ( ! $end_date) { |
|
340 | 340 | $month = 10; |
341 | 341 | } else { |
342 | 342 | $year -= 1; |
343 | 343 | $month = 12; |
344 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
344 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
345 | 345 | $hour = 23; |
346 | 346 | $minute = 59; |
347 | 347 | $second = 59; |
348 | 348 | } |
349 | 349 | |
350 | - } else if ( $month_now <= 6 ) { |
|
350 | + } else if ($month_now <= 6) { |
|
351 | 351 | |
352 | - if ( ! $end_date ) { |
|
352 | + if ( ! $end_date) { |
|
353 | 353 | $month = 1; |
354 | 354 | } else { |
355 | 355 | $month = 3; |
356 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
356 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
357 | 357 | $hour = 23; |
358 | 358 | $minute = 59; |
359 | 359 | $second = 59; |
360 | 360 | } |
361 | 361 | |
362 | - } else if ( $month_now <= 9 ) { |
|
362 | + } else if ($month_now <= 9) { |
|
363 | 363 | |
364 | - if ( ! $end_date ) { |
|
364 | + if ( ! $end_date) { |
|
365 | 365 | $month = 4; |
366 | 366 | } else { |
367 | 367 | $month = 6; |
368 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
368 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
369 | 369 | $hour = 23; |
370 | 370 | $minute = 59; |
371 | 371 | $second = 59; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - if ( ! $end_date ) { |
|
376 | + if ( ! $end_date) { |
|
377 | 377 | $month = 7; |
378 | 378 | } else { |
379 | 379 | $month = 9; |
380 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
380 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
381 | 381 | $hour = 23; |
382 | 382 | $minute = 59; |
383 | 383 | $second = 59; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | |
390 | 390 | case 'this_year' : |
391 | 391 | |
392 | - if ( ! $end_date ) { |
|
392 | + if ( ! $end_date) { |
|
393 | 393 | $month = 1; |
394 | 394 | } else { |
395 | 395 | $month = 12; |
396 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
396 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
397 | 397 | $hour = 23; |
398 | 398 | $minute = 59; |
399 | 399 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | case 'last_year' : |
405 | 405 | |
406 | 406 | $year -= 1; |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | - } else if ( is_numeric( $date ) ) { |
|
422 | + } else if (is_numeric($date)) { |
|
423 | 423 | |
424 | 424 | // return $date unchanged since it is a timestamp |
425 | 425 | $this->timestamp = true; |
426 | 426 | |
427 | - } else if ( false !== strtotime( $date ) ) { |
|
427 | + } else if (false !== strtotime($date)) { |
|
428 | 428 | |
429 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
430 | - $year = date( 'Y', $date ); |
|
431 | - $month = date( 'm', $date ); |
|
432 | - $day = date( 'd', $date ); |
|
429 | + $date = strtotime($date, current_time('timestamp')); |
|
430 | + $year = date('Y', $date); |
|
431 | + $month = date('m', $date); |
|
432 | + $day = date('d', $date); |
|
433 | 433 | |
434 | 434 | } else { |
435 | 435 | |
436 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
436 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | - if ( false === $this->timestamp ) { |
|
440 | + if (false === $this->timestamp) { |
|
441 | 441 | // Create an exact timestamp |
442 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
442 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
443 | 443 | } |
444 | 444 | |
445 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
445 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | * @since 1.0 |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function count_where( $where = '' ) { |
|
456 | + public function count_where($where = '') { |
|
457 | 457 | // Only get payments in our date range |
458 | 458 | |
459 | 459 | $start_where = ''; |
460 | 460 | $end_where = ''; |
461 | 461 | |
462 | - if ( $this->start_date ) { |
|
462 | + if ($this->start_date) { |
|
463 | 463 | |
464 | - if ( $this->timestamp ) { |
|
464 | + if ($this->timestamp) { |
|
465 | 465 | $format = 'Y-m-d H:i:s'; |
466 | 466 | } else { |
467 | 467 | $format = 'Y-m-d 00:00:00'; |
468 | 468 | } |
469 | 469 | |
470 | - $start_date = date( $format, $this->start_date ); |
|
470 | + $start_date = date($format, $this->start_date); |
|
471 | 471 | $start_where = " AND p.post_date >= '{$start_date}'"; |
472 | 472 | } |
473 | 473 | |
474 | - if ( $this->end_date ) { |
|
474 | + if ($this->end_date) { |
|
475 | 475 | |
476 | - if ( $this->timestamp ) { |
|
476 | + if ($this->timestamp) { |
|
477 | 477 | $format = 'Y-m-d H:i:s'; |
478 | 478 | } else { |
479 | 479 | $format = 'Y-m-d 23:59:59'; |
480 | 480 | } |
481 | 481 | |
482 | - $end_date = date( $format, $this->end_date ); |
|
482 | + $end_date = date($format, $this->end_date); |
|
483 | 483 | |
484 | 484 | $end_where = " AND p.post_date <= '{$end_date}'"; |
485 | 485 | } |
@@ -499,34 +499,34 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public function payments_where( $where = '' ) { |
|
502 | + public function payments_where($where = '') { |
|
503 | 503 | |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | 506 | $start_where = ''; |
507 | 507 | $end_where = ''; |
508 | 508 | |
509 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
509 | + if ( ! is_wp_error($this->start_date)) { |
|
510 | 510 | |
511 | - if ( $this->timestamp ) { |
|
511 | + if ($this->timestamp) { |
|
512 | 512 | $format = 'Y-m-d H:i:s'; |
513 | 513 | } else { |
514 | 514 | $format = 'Y-m-d 00:00:00'; |
515 | 515 | } |
516 | 516 | |
517 | - $start_date = date( $format, $this->start_date ); |
|
517 | + $start_date = date($format, $this->start_date); |
|
518 | 518 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
521 | + if ( ! is_wp_error($this->end_date)) { |
|
522 | 522 | |
523 | - if ( $this->timestamp ) { |
|
523 | + if ($this->timestamp) { |
|
524 | 524 | $format = 'Y-m-d 00:00:00'; |
525 | 525 | } else { |
526 | 526 | $format = 'Y-m-d 23:59:59'; |
527 | 527 | } |
528 | 528 | |
529 | - $end_date = date( $format, $this->end_date ); |
|
529 | + $end_date = date($format, $this->end_date); |
|
530 | 530 | |
531 | 531 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
532 | 532 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return string Login form |
27 | 27 | */ |
28 | -function give_login_form( $redirect = '' ) { |
|
28 | +function give_login_form($redirect = '') { |
|
29 | 29 | global $give_login_redirect; |
30 | 30 | |
31 | - if ( empty( $redirect ) ) { |
|
31 | + if (empty($redirect)) { |
|
32 | 32 | $redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
33 | 33 | } |
34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | ob_start(); |
38 | 38 | |
39 | - give_get_template_part( 'shortcode', 'login' ); |
|
39 | + give_get_template_part('shortcode', 'login'); |
|
40 | 40 | |
41 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
41 | + return apply_filters('give_login_form', ob_get_clean()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return string Register form |
54 | 54 | */ |
55 | -function give_register_form( $redirect = '' ) { |
|
55 | +function give_register_form($redirect = '') { |
|
56 | 56 | global $give_options, $give_register_redirect; |
57 | 57 | |
58 | - if ( empty( $redirect ) ) { |
|
58 | + if (empty($redirect)) { |
|
59 | 59 | $redirect = give_get_current_page_url(); |
60 | 60 | } |
61 | 61 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | |
64 | 64 | ob_start(); |
65 | 65 | |
66 | - if ( ! is_user_logged_in() ) { |
|
67 | - give_get_template_part( 'shortcode', 'register' ); |
|
66 | + if ( ! is_user_logged_in()) { |
|
67 | + give_get_template_part('shortcode', 'register'); |
|
68 | 68 | } |
69 | 69 | |
70 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
70 | + return apply_filters('give_register_form', ob_get_clean()); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return void |
81 | 81 | */ |
82 | -function give_process_login_form( $data ) { |
|
83 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
84 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
85 | - if ( ! $user_data ) { |
|
86 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
82 | +function give_process_login_form($data) { |
|
83 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
84 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
85 | + if ( ! $user_data) { |
|
86 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
87 | 87 | } |
88 | - if ( $user_data ) { |
|
88 | + if ($user_data) { |
|
89 | 89 | $user_ID = $user_data->ID; |
90 | 90 | $user_email = $user_data->user_email; |
91 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
92 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
91 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
92 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
93 | 93 | } else { |
94 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
94 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
95 | 95 | } |
96 | 96 | } else { |
97 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
97 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
98 | 98 | } |
99 | 99 | // Check for errors and redirect if none present |
100 | 100 | $errors = give_get_errors(); |
101 | - if ( ! $errors ) { |
|
102 | - $redirect = apply_filters( 'give_login_redirect', $data['give_redirect'], $user_ID ); |
|
103 | - wp_redirect( $redirect ); |
|
101 | + if ( ! $errors) { |
|
102 | + $redirect = apply_filters('give_login_redirect', $data['give_redirect'], $user_ID); |
|
103 | + wp_redirect($redirect); |
|
104 | 104 | give_die(); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
109 | +add_action('give_user_login', 'give_process_login_form'); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Log User In |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return void |
121 | 121 | */ |
122 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
123 | - if ( $user_id < 1 ) { |
|
122 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
123 | + if ($user_id < 1) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | - wp_set_auth_cookie( $user_id ); |
|
128 | - wp_set_current_user( $user_id, $user_login ); |
|
129 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
130 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
127 | + wp_set_auth_cookie($user_id); |
|
128 | + wp_set_current_user($user_id, $user_login); |
|
129 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
130 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -140,70 +140,70 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_process_register_form( $data ) { |
|
143 | +function give_process_register_form($data) { |
|
144 | 144 | |
145 | - if ( is_user_logged_in() ) { |
|
145 | + if (is_user_logged_in()) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
149 | + if (empty($_POST['give_register_submit'])) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - do_action( 'give_pre_process_register_form' ); |
|
153 | + do_action('give_pre_process_register_form'); |
|
154 | 154 | |
155 | - if ( empty( $data['give_user_login'] ) ) { |
|
156 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
155 | + if (empty($data['give_user_login'])) { |
|
156 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
160 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
159 | + if (username_exists($data['give_user_login'])) { |
|
160 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
164 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
163 | + if ( ! validate_username($data['give_user_login'])) { |
|
164 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
165 | 165 | } |
166 | 166 | |
167 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
168 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
167 | + if (email_exists($data['give_user_email'])) { |
|
168 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
169 | 169 | } |
170 | 170 | |
171 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
172 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
171 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
172 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
176 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
175 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
176 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
177 | 177 | } |
178 | 178 | |
179 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
180 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
179 | + if (empty($_POST['give_user_pass'])) { |
|
180 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
184 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
183 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
184 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
185 | 185 | } |
186 | 186 | |
187 | - do_action( 'give_process_register_form' ); |
|
187 | + do_action('give_process_register_form'); |
|
188 | 188 | |
189 | 189 | // Check for errors and redirect if none present |
190 | 190 | $errors = give_get_errors(); |
191 | 191 | |
192 | - if ( empty( $errors ) ) { |
|
192 | + if (empty($errors)) { |
|
193 | 193 | |
194 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
194 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
195 | 195 | |
196 | - give_register_and_login_new_user( array( |
|
196 | + give_register_and_login_new_user(array( |
|
197 | 197 | 'user_login' => $data['give_user_login'], |
198 | 198 | 'user_pass' => $data['give_user_pass'], |
199 | 199 | 'user_email' => $data['give_user_email'], |
200 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
201 | - 'role' => get_option( 'default_role' ) |
|
202 | - ) ); |
|
200 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
201 | + 'role' => get_option('default_role') |
|
202 | + )); |
|
203 | 203 | |
204 | - wp_redirect( $redirect ); |
|
204 | + wp_redirect($redirect); |
|
205 | 205 | give_die(); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
210 | 209 | \ No newline at end of file |
210 | +add_action('give_user_register', 'give_process_register_form'); |
|
211 | 211 | \ No newline at end of file |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | /** |
49 | 49 | * Main Give Class |
50 | 50 | * |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * @return Give |
160 | 160 | */ |
161 | 161 | public static function instance() { |
162 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
162 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
163 | 163 | self::$instance = new Give; |
164 | 164 | self::$instance->setup_constants(); |
165 | 165 | |
166 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
166 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
167 | 167 | |
168 | 168 | self::$instance->includes(); |
169 | 169 | self::$instance->roles = new Give_Roles(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function __clone() { |
197 | 197 | // Cloning instances of the class is forbidden |
198 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
198 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function __wakeup() { |
209 | 209 | // Unserializing instances of the class is forbidden |
210 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
210 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,33 +220,33 @@ discard block |
||
220 | 220 | private function setup_constants() { |
221 | 221 | |
222 | 222 | // Plugin version |
223 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
224 | - define( 'GIVE_VERSION', '1.5.2' ); |
|
223 | + if ( ! defined('GIVE_VERSION')) { |
|
224 | + define('GIVE_VERSION', '1.5.2'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Plugin Folder Path |
228 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
229 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
228 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
229 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | // Plugin Folder URL |
233 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
234 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
233 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
234 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Plugin Basename aka: "give/give.php" |
238 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
239 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
238 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
239 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Plugin Root File |
243 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
244 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
243 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
244 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Make sure CAL_GREGORIAN is defined |
248 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
249 | - define( 'CAL_GREGORIAN', 1 ); |
|
248 | + if ( ! defined('CAL_GREGORIAN')) { |
|
249 | + define('CAL_GREGORIAN', 1); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -260,109 +260,109 @@ discard block |
||
260 | 260 | private function includes() { |
261 | 261 | global $give_options; |
262 | 262 | |
263 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
263 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
264 | 264 | $give_options = give_get_settings(); |
265 | 265 | |
266 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
267 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
268 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
269 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
270 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
271 | - |
|
272 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
273 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
274 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
275 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
276 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
277 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
278 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
279 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
280 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
281 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
282 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
283 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
284 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
285 | - |
|
286 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
287 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
288 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
289 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
290 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
291 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
292 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
293 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
294 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
295 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
296 | - require_once GIVE_PLUGIN_DIR . 'includes/process-purchase.php'; |
|
297 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
298 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
299 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
300 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated-functions.php'; |
|
301 | - |
|
302 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
303 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
304 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
305 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
306 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
307 | - |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
313 | - |
|
314 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
319 | - |
|
320 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
321 | - |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
329 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
332 | - |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
335 | - |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
341 | - |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
347 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
349 | - |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
353 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
359 | - |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
361 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
266 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
267 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
268 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
269 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
270 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
271 | + |
|
272 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
273 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
274 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
275 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
276 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
277 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
278 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
279 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
280 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
281 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
282 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
283 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
284 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
285 | + |
|
286 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
287 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
288 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
289 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
290 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
291 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
292 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
293 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
294 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
295 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
296 | + require_once GIVE_PLUGIN_DIR.'includes/process-purchase.php'; |
|
297 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
298 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
299 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
300 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated-functions.php'; |
|
301 | + |
|
302 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
304 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
305 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
306 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
307 | + |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
313 | + |
|
314 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
319 | + |
|
320 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
321 | + |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
329 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
332 | + |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
335 | + |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
341 | + |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
347 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
349 | + |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
353 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
359 | + |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
361 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
365 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -375,26 +375,26 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function load_textdomain() { |
377 | 377 | // Set filter for Give's languages directory |
378 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
379 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
378 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
379 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
380 | 380 | |
381 | 381 | // Traditional WordPress plugin locale filter |
382 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
383 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
382 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
383 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
384 | 384 | |
385 | 385 | // Setup paths to current locale file |
386 | - $mofile_local = $give_lang_dir . $mofile; |
|
387 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
386 | + $mofile_local = $give_lang_dir.$mofile; |
|
387 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
388 | 388 | |
389 | - if ( file_exists( $mofile_global ) ) { |
|
389 | + if (file_exists($mofile_global)) { |
|
390 | 390 | // Look in global /wp-content/languages/give folder |
391 | - load_textdomain( 'give', $mofile_global ); |
|
392 | - } elseif ( file_exists( $mofile_local ) ) { |
|
391 | + load_textdomain('give', $mofile_global); |
|
392 | + } elseif (file_exists($mofile_local)) { |
|
393 | 393 | // Look in local location from filter `give_languages_directory` |
394 | - load_textdomain( 'give', $mofile_local ); |
|
394 | + load_textdomain('give', $mofile_local); |
|
395 | 395 | } else { |
396 | 396 | // Load the default language files packaged up w/ Give |
397 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
397 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |