@@ -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 | |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_predefined_dates() { |
95 | 95 | $predefined = array( |
96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
105 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
96 | + 'today' => esc_html__('Today', 'give'), |
|
97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
105 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return void |
123 | 123 | */ |
124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
125 | 125 | |
126 | - if ( empty( $_start_date ) ) { |
|
126 | + if (empty($_start_date)) { |
|
127 | 127 | $_start_date = 'this_month'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $_end_date ) ) { |
|
130 | + if (empty($_end_date)) { |
|
131 | 131 | $_end_date = $_start_date; |
132 | 132 | } |
133 | 133 | |
134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
134 | + $this->start_date = $this->convert_date($_start_date); |
|
135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
150 | 150 | */ |
151 | - public function convert_date( $date, $end_date = false ) { |
|
151 | + public function convert_date($date, $end_date = false) { |
|
152 | 152 | |
153 | 153 | $this->timestamp = false; |
154 | 154 | $second = $end_date ? 59 : 0; |
155 | 155 | $minute = $end_date ? 59 : 0; |
156 | 156 | $hour = $end_date ? 23 : 0; |
157 | 157 | $day = 1; |
158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
158 | + $month = date('n', current_time('timestamp')); |
|
159 | + $year = date('Y', current_time('timestamp')); |
|
160 | 160 | |
161 | - if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) { |
|
161 | + if (array_key_exists((string) $date, $this->get_predefined_dates())) { |
|
162 | 162 | |
163 | 163 | // This is a predefined date rate, such as last_week |
164 | - switch ( $date ) { |
|
164 | + switch ($date) { |
|
165 | 165 | |
166 | 166 | case 'this_month' : |
167 | 167 | |
168 | - if ( $end_date ) { |
|
168 | + if ($end_date) { |
|
169 | 169 | |
170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
171 | 171 | $hour = 23; |
172 | 172 | $minute = 59; |
173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
177 | 177 | |
178 | 178 | case 'last_month' : |
179 | 179 | |
180 | - if ( $month == 1 ) { |
|
180 | + if ($month == 1) { |
|
181 | 181 | |
182 | 182 | $month = 12; |
183 | - $year --; |
|
183 | + $year--; |
|
184 | 184 | |
185 | 185 | } else { |
186 | 186 | |
187 | - $month --; |
|
187 | + $month--; |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | - if ( $end_date ) { |
|
192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
191 | + if ($end_date) { |
|
192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'today' : |
198 | 198 | |
199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
199 | + $day = date('d', current_time('timestamp')); |
|
200 | 200 | |
201 | - if ( $end_date ) { |
|
201 | + if ($end_date) { |
|
202 | 202 | $hour = 23; |
203 | 203 | $minute = 59; |
204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
208 | 208 | |
209 | 209 | case 'yesterday' : |
210 | 210 | |
211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
211 | + $day = date('d', current_time('timestamp')) - 1; |
|
212 | 212 | |
213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
214 | - if ( $day < 1 ) { |
|
214 | + if ($day < 1) { |
|
215 | 215 | |
216 | 216 | // If current month is 1 |
217 | - if ( 1 == $month ) { |
|
217 | + if (1 == $month) { |
|
218 | 218 | |
219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
220 | 220 | $month = 12; |
221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
222 | 222 | |
223 | 223 | } else { |
224 | 224 | |
225 | 225 | // Go back one month and get the last day of the month |
226 | 226 | $month -= 1; |
227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | |
234 | 234 | case 'this_week' : |
235 | 235 | |
236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
237 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
237 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
238 | 238 | |
239 | - if ( $today < $days_to_week_start ) { |
|
239 | + if ($today < $days_to_week_start) { |
|
240 | 240 | |
241 | - if ( $month > 1 ) { |
|
241 | + if ($month > 1) { |
|
242 | 242 | $month -= 1; |
243 | 243 | } else { |
244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - if ( ! $end_date ) { |
|
249 | + if ( ! $end_date) { |
|
250 | 250 | |
251 | 251 | // Getting the start day |
252 | 252 | |
253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
254 | - $day += get_option( 'start_of_week' ); |
|
253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
254 | + $day += get_option('start_of_week'); |
|
255 | 255 | |
256 | 256 | } else { |
257 | 257 | |
258 | 258 | // Getting the end day |
259 | 259 | |
260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
261 | - $day += get_option( 'start_of_week' ) + 6; |
|
260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
261 | + $day += get_option('start_of_week') + 6; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'last_week' : |
268 | 268 | |
269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
270 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
270 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
271 | 271 | |
272 | - if ( $today < $days_to_week_start ) { |
|
272 | + if ($today < $days_to_week_start) { |
|
273 | 273 | |
274 | - if ( $month > 1 ) { |
|
274 | + if ($month > 1) { |
|
275 | 275 | $month -= 1; |
276 | 276 | } else { |
277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! $end_date ) { |
|
282 | + if ( ! $end_date) { |
|
283 | 283 | |
284 | 284 | // Getting the start day |
285 | 285 | |
286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
287 | - $day += get_option( 'start_of_week' ); |
|
286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
287 | + $day += get_option('start_of_week'); |
|
288 | 288 | |
289 | 289 | } else { |
290 | 290 | |
291 | 291 | // Getting the end day |
292 | 292 | |
293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
294 | - $day += get_option( 'start_of_week' ) + 6; |
|
293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
294 | + $day += get_option('start_of_week') + 6; |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
299 | 299 | |
300 | 300 | case 'this_quarter' : |
301 | 301 | |
302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
302 | + $month_now = date('n', current_time('timestamp')); |
|
303 | 303 | |
304 | - if ( $month_now <= 3 ) { |
|
304 | + if ($month_now <= 3) { |
|
305 | 305 | |
306 | - if ( ! $end_date ) { |
|
306 | + if ( ! $end_date) { |
|
307 | 307 | $month = 1; |
308 | 308 | } else { |
309 | 309 | $month = 3; |
310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
311 | 311 | $hour = 23; |
312 | 312 | $minute = 59; |
313 | 313 | $second = 59; |
314 | 314 | } |
315 | 315 | |
316 | - } else if ( $month_now <= 6 ) { |
|
316 | + } else if ($month_now <= 6) { |
|
317 | 317 | |
318 | - if ( ! $end_date ) { |
|
318 | + if ( ! $end_date) { |
|
319 | 319 | $month = 4; |
320 | 320 | } else { |
321 | 321 | $month = 6; |
322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
323 | 323 | $hour = 23; |
324 | 324 | $minute = 59; |
325 | 325 | $second = 59; |
326 | 326 | } |
327 | 327 | |
328 | - } else if ( $month_now <= 9 ) { |
|
328 | + } else if ($month_now <= 9) { |
|
329 | 329 | |
330 | - if ( ! $end_date ) { |
|
330 | + if ( ! $end_date) { |
|
331 | 331 | $month = 7; |
332 | 332 | } else { |
333 | 333 | $month = 9; |
334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
335 | 335 | $hour = 23; |
336 | 336 | $minute = 59; |
337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | |
340 | 340 | } else { |
341 | 341 | |
342 | - if ( ! $end_date ) { |
|
342 | + if ( ! $end_date) { |
|
343 | 343 | $month = 10; |
344 | 344 | } else { |
345 | 345 | $month = 12; |
346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
347 | 347 | $hour = 23; |
348 | 348 | $minute = 59; |
349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
355 | 355 | |
356 | 356 | case 'last_quarter' : |
357 | 357 | |
358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
358 | + $month_now = date('n', current_time('timestamp')); |
|
359 | 359 | |
360 | - if ( $month_now <= 3 ) { |
|
360 | + if ($month_now <= 3) { |
|
361 | 361 | |
362 | - if ( ! $end_date ) { |
|
362 | + if ( ! $end_date) { |
|
363 | 363 | $month = 10; |
364 | 364 | } else { |
365 | 365 | $year -= 1; |
366 | 366 | $month = 12; |
367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
368 | 368 | $hour = 23; |
369 | 369 | $minute = 59; |
370 | 370 | $second = 59; |
371 | 371 | } |
372 | 372 | |
373 | - } else if ( $month_now <= 6 ) { |
|
373 | + } else if ($month_now <= 6) { |
|
374 | 374 | |
375 | - if ( ! $end_date ) { |
|
375 | + if ( ! $end_date) { |
|
376 | 376 | $month = 1; |
377 | 377 | } else { |
378 | 378 | $month = 3; |
379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
380 | 380 | $hour = 23; |
381 | 381 | $minute = 59; |
382 | 382 | $second = 59; |
383 | 383 | } |
384 | 384 | |
385 | - } else if ( $month_now <= 9 ) { |
|
385 | + } else if ($month_now <= 9) { |
|
386 | 386 | |
387 | - if ( ! $end_date ) { |
|
387 | + if ( ! $end_date) { |
|
388 | 388 | $month = 4; |
389 | 389 | } else { |
390 | 390 | $month = 6; |
391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
392 | 392 | $hour = 23; |
393 | 393 | $minute = 59; |
394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | |
397 | 397 | } else { |
398 | 398 | |
399 | - if ( ! $end_date ) { |
|
399 | + if ( ! $end_date) { |
|
400 | 400 | $month = 7; |
401 | 401 | } else { |
402 | 402 | $month = 9; |
403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
404 | 404 | $hour = 23; |
405 | 405 | $minute = 59; |
406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | case 'this_year' : |
414 | 414 | |
415 | - if ( ! $end_date ) { |
|
415 | + if ( ! $end_date) { |
|
416 | 416 | $month = 1; |
417 | 417 | } else { |
418 | 418 | $month = 12; |
419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
420 | 420 | $hour = 23; |
421 | 421 | $minute = 59; |
422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | case 'last_year' : |
428 | 428 | |
429 | 429 | $year -= 1; |
430 | - if ( ! $end_date ) { |
|
430 | + if ( ! $end_date) { |
|
431 | 431 | $month = 1; |
432 | 432 | } else { |
433 | 433 | $month = 12; |
434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
435 | 435 | $hour = 23; |
436 | 436 | $minute = 59; |
437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | |
445 | - } else if ( is_numeric( $date ) ) { |
|
445 | + } else if (is_numeric($date)) { |
|
446 | 446 | |
447 | 447 | // return $date unchanged since it is a timestamp |
448 | 448 | $this->timestamp = true; |
449 | 449 | |
450 | - } else if ( false !== strtotime( $date ) ) { |
|
450 | + } else if (false !== strtotime($date)) { |
|
451 | 451 | |
452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
453 | - $year = date( 'Y', $date ); |
|
454 | - $month = date( 'm', $date ); |
|
455 | - $day = date( 'd', $date ); |
|
452 | + $date = strtotime($date, current_time('timestamp')); |
|
453 | + $year = date('Y', $date); |
|
454 | + $month = date('m', $date); |
|
455 | + $day = date('d', $date); |
|
456 | 456 | |
457 | 457 | } else { |
458 | 458 | |
459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
463 | - if ( false === $this->timestamp ) { |
|
463 | + if (false === $this->timestamp) { |
|
464 | 464 | // Create an exact timestamp |
465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
466 | 466 | } |
467 | 467 | |
468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
469 | 469 | |
470 | 470 | } |
471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return string |
483 | 483 | */ |
484 | - public function count_where( $where = '' ) { |
|
484 | + public function count_where($where = '') { |
|
485 | 485 | // Only get payments in our date range |
486 | 486 | |
487 | 487 | $start_where = ''; |
488 | 488 | $end_where = ''; |
489 | 489 | |
490 | - if ( $this->start_date ) { |
|
490 | + if ($this->start_date) { |
|
491 | 491 | |
492 | - if ( $this->timestamp ) { |
|
492 | + if ($this->timestamp) { |
|
493 | 493 | $format = 'Y-m-d H:i:s'; |
494 | 494 | } else { |
495 | 495 | $format = 'Y-m-d 00:00:00'; |
496 | 496 | } |
497 | 497 | |
498 | - $start_date = date( $format, $this->start_date ); |
|
498 | + $start_date = date($format, $this->start_date); |
|
499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
500 | 500 | } |
501 | 501 | |
502 | - if ( $this->end_date ) { |
|
502 | + if ($this->end_date) { |
|
503 | 503 | |
504 | - if ( $this->timestamp ) { |
|
504 | + if ($this->timestamp) { |
|
505 | 505 | $format = 'Y-m-d H:i:s'; |
506 | 506 | } else { |
507 | 507 | $format = 'Y-m-d 23:59:59'; |
508 | 508 | } |
509 | 509 | |
510 | - $end_date = date( $format, $this->end_date ); |
|
510 | + $end_date = date($format, $this->end_date); |
|
511 | 511 | |
512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function payments_where( $where = '' ) { |
|
532 | + public function payments_where($where = '') { |
|
533 | 533 | |
534 | 534 | global $wpdb; |
535 | 535 | |
536 | 536 | $start_where = ''; |
537 | 537 | $end_where = ''; |
538 | 538 | |
539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
539 | + if ( ! is_wp_error($this->start_date)) { |
|
540 | 540 | |
541 | - if ( $this->timestamp ) { |
|
541 | + if ($this->timestamp) { |
|
542 | 542 | $format = 'Y-m-d H:i:s'; |
543 | 543 | } else { |
544 | 544 | $format = 'Y-m-d 00:00:00'; |
545 | 545 | } |
546 | 546 | |
547 | - $start_date = date( $format, $this->start_date ); |
|
547 | + $start_date = date($format, $this->start_date); |
|
548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
549 | 549 | } |
550 | 550 | |
551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
551 | + if ( ! is_wp_error($this->end_date)) { |
|
552 | 552 | |
553 | - if ( $this->timestamp ) { |
|
553 | + if ($this->timestamp) { |
|
554 | 554 | $format = 'Y-m-d H:i:s'; |
555 | 555 | } else { |
556 | 556 | $format = 'Y-m-d 23:59:59'; |
557 | 557 | } |
558 | 558 | |
559 | - $end_date = date( $format, $this->end_date ); |
|
559 | + $end_date = date($format, $this->end_date); |
|
560 | 560 | |
561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
562 | 562 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | - 'edit_pages' => true, |
|
92 | + 'edit_pages' => true, |
|
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false, |
95 | 95 | ) ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true, |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | 92 | 'edit_pages' => true, |
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false, |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -111,38 +111,38 @@ discard block |
||
111 | 111 | public function add_caps() { |
112 | 112 | global $wp_roles; |
113 | 113 | |
114 | - if ( class_exists( 'WP_Roles' ) ) { |
|
115 | - if ( ! isset( $wp_roles ) ) { |
|
114 | + if (class_exists('WP_Roles')) { |
|
115 | + if ( ! isset($wp_roles)) { |
|
116 | 116 | $wp_roles = new WP_Roles(); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( is_object( $wp_roles ) ) { |
|
121 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
122 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
123 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
124 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
120 | + if (is_object($wp_roles)) { |
|
121 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
122 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
123 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
124 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
125 | 125 | |
126 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
127 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
128 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
129 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
126 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
127 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
128 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
129 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
130 | 130 | |
131 | 131 | // Add the main post type capabilities. |
132 | 132 | $capabilities = $this->get_core_caps(); |
133 | - foreach ( $capabilities as $cap_group ) { |
|
134 | - foreach ( $cap_group as $cap ) { |
|
135 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
136 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
137 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
133 | + foreach ($capabilities as $cap_group) { |
|
134 | + foreach ($cap_group as $cap) { |
|
135 | + $wp_roles->add_cap('administrator', $cap); |
|
136 | + $wp_roles->add_cap('give_manager', $cap); |
|
137 | + $wp_roles->add_cap('give_worker', $cap); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
142 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
143 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
144 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
145 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
141 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
142 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
143 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
144 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
145 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | } |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | public function get_core_caps() { |
161 | 161 | $capabilities = array(); |
162 | 162 | |
163 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
163 | + $capability_types = array('give_form', 'give_payment'); |
|
164 | 164 | |
165 | - foreach ( $capability_types as $capability_type ) { |
|
166 | - $capabilities[ $capability_type ] = array( |
|
165 | + foreach ($capability_types as $capability_type) { |
|
166 | + $capabilities[$capability_type] = array( |
|
167 | 167 | // Post type. |
168 | 168 | "edit_{$capability_type}", |
169 | 169 | "read_{$capability_type}", |
@@ -209,22 +209,22 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return array $caps Meta capabilities. |
211 | 211 | */ |
212 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
212 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
213 | 213 | |
214 | - switch ( $cap ) { |
|
214 | + switch ($cap) { |
|
215 | 215 | |
216 | 216 | case 'view_give_form_stats' : |
217 | 217 | |
218 | - if ( empty( $args[0] ) ) { |
|
218 | + if (empty($args[0])) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | |
222 | - $form = get_post( $args[0] ); |
|
223 | - if ( empty( $form ) ) { |
|
222 | + $form = get_post($args[0]); |
|
223 | + if (empty($form)) { |
|
224 | 224 | break; |
225 | 225 | } |
226 | 226 | |
227 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
227 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
228 | 228 | $caps = array(); |
229 | 229 | } |
230 | 230 | |
@@ -251,41 +251,41 @@ discard block |
||
251 | 251 | |
252 | 252 | global $wp_roles; |
253 | 253 | |
254 | - if ( class_exists( 'WP_Roles' ) ) { |
|
255 | - if ( ! isset( $wp_roles ) ) { |
|
254 | + if (class_exists('WP_Roles')) { |
|
255 | + if ( ! isset($wp_roles)) { |
|
256 | 256 | $wp_roles = new WP_Roles(); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - if ( is_object( $wp_roles ) ) { |
|
260 | + if (is_object($wp_roles)) { |
|
261 | 261 | // Give Manager Capabilities. |
262 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
263 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
264 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
265 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
262 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
263 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
264 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
265 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
266 | 266 | |
267 | 267 | // Site Administrator Capabilities. |
268 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
269 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
270 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
271 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
268 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
269 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
270 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
271 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
272 | 272 | |
273 | 273 | // Remove the Main Post Type Capabilities. |
274 | 274 | $capabilities = $this->get_core_caps(); |
275 | 275 | |
276 | - foreach ( $capabilities as $cap_group ) { |
|
277 | - foreach ( $cap_group as $cap ) { |
|
278 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
279 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
280 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
276 | + foreach ($capabilities as $cap_group) { |
|
277 | + foreach ($cap_group as $cap) { |
|
278 | + $wp_roles->remove_cap('give_manager', $cap); |
|
279 | + $wp_roles->remove_cap('administrator', $cap); |
|
280 | + $wp_roles->remove_cap('give_worker', $cap); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** Give Accountant Capabilities */ |
285 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
286 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
287 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
288 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
285 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
286 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
287 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
288 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | } |
@@ -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 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @see Give_Cron::weekly_events() |
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | - add_filter( 'cron_schedules', array( $this, 'add_schedules' ) ); |
|
38 | - add_action( 'wp', array( $this, 'schedule_Events' ) ); |
|
37 | + add_filter('cron_schedules', array($this, 'add_schedules')); |
|
38 | + add_action('wp', array($this, 'schedule_Events')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array An array of non-default cron schedules. |
50 | 50 | */ |
51 | - public function add_schedules( $schedules = array() ) { |
|
51 | + public function add_schedules($schedules = array()) { |
|
52 | 52 | // Adds once weekly to the existing schedules. |
53 | 53 | $schedules['weekly'] = array( |
54 | 54 | 'interval' => 604800, |
55 | - 'display' => esc_html__( 'Once Weekly', 'give' ), |
|
55 | + 'display' => esc_html__('Once Weekly', 'give'), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | return $schedules; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | private function weekly_events() { |
83 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
84 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
83 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
84 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | private function daily_events() { |
97 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
98 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
97 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
98 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 |