| @@ 355-380 (lines=26) @@ | ||
| 352 | * @since 1.7.0 |
|
| 353 | * @return array lessons |
|
| 354 | */ |
|
| 355 | private function get_lessons( $args ) { |
|
| 356 | $lesson_args = array( |
|
| 357 | 'post_type' => 'lesson', |
|
| 358 | 'post_status' => 'publish', |
|
| 359 | 'posts_per_page' => $args['per_page'], |
|
| 360 | 'offset' => $args['offset'], |
|
| 361 | 'orderby' => $args['orderby'], |
|
| 362 | 'order' => $args['order'], |
|
| 363 | ); |
|
| 364 | ||
| 365 | if( $this->course_id ) { |
|
| 366 | $lesson_args['meta_query'][] = array( |
|
| 367 | 'key' => '_lesson_course', |
|
| 368 | 'value' => $this->course_id, |
|
| 369 | ); |
|
| 370 | } |
|
| 371 | ||
| 372 | if( $args['search'] ) { |
|
| 373 | $lesson_args['s'] = $args['search']; |
|
| 374 | } |
|
| 375 | ||
| 376 | $lessons_query = new WP_Query( apply_filters( 'sensei_learners_filter_lessons', $lesson_args ) ); |
|
| 377 | ||
| 378 | $this->total_items = $lessons_query->found_posts; |
|
| 379 | return $lessons_query->posts; |
|
| 380 | } // End get_lessons() |
|
| 381 | ||
| 382 | /** |
|
| 383 | * Return array of learners |
|
| @@ 450-474 (lines=25) @@ | ||
| 447 | * @since 1.7.0 |
|
| 448 | * @return array courses |
|
| 449 | */ |
|
| 450 | private function get_courses( $args ) { |
|
| 451 | $course_args = array( |
|
| 452 | 'post_type' => 'course', |
|
| 453 | 'post_status' => array('publish', 'private'), |
|
| 454 | 'posts_per_page' => $args['number'], |
|
| 455 | 'offset' => $args['offset'], |
|
| 456 | 'orderby' => $args['orderby'], |
|
| 457 | 'order' => $args['order'], |
|
| 458 | 'suppress_filters' => 0, |
|
| 459 | ); |
|
| 460 | ||
| 461 | if ( $this->csv_output ) { |
|
| 462 | $course_args['posts_per_page'] = '-1'; |
|
| 463 | } |
|
| 464 | ||
| 465 | if( isset( $args['search'] ) ) { |
|
| 466 | $course_args['s'] = $args['search']; |
|
| 467 | } |
|
| 468 | ||
| 469 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
|
| 470 | $courses_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_courses', $course_args ) ); |
|
| 471 | $this->total_items = $courses_query->found_posts; |
|
| 472 | return $courses_query->posts; |
|
| 473 | ||
| 474 | } // End get_courses() |
|
| 475 | ||
| 476 | /** |
|
| 477 | * Return array of lessons |
|
| @@ 481-504 (lines=24) @@ | ||
| 478 | * @since 1.7.0 |
|
| 479 | * @return array lessons |
|
| 480 | */ |
|
| 481 | private function get_lessons( $args ) { |
|
| 482 | $lessons_args = array( |
|
| 483 | 'post_type' => 'lesson', |
|
| 484 | 'post_status' => array('publish', 'private'), |
|
| 485 | 'posts_per_page' => $args['number'], |
|
| 486 | 'offset' => $args['offset'], |
|
| 487 | 'orderby' => $args['orderby'], |
|
| 488 | 'order' => $args['order'], |
|
| 489 | 'suppress_filters' => 0, |
|
| 490 | ); |
|
| 491 | ||
| 492 | if ( $this->csv_output ) { |
|
| 493 | $lessons_args['posts_per_page'] = '-1'; |
|
| 494 | } |
|
| 495 | ||
| 496 | if( isset( $args['search'] ) ) { |
|
| 497 | $lessons_args['s'] = $args['search']; |
|
| 498 | } |
|
| 499 | ||
| 500 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
|
| 501 | $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_lessons', $lessons_args ) ); |
|
| 502 | $this->total_items = $lessons_query->found_posts; |
|
| 503 | return $lessons_query->posts; |
|
| 504 | } // End get_lessons() |
|
| 505 | ||
| 506 | /** |
|
| 507 | * Return array of learners |
|