| @@ 1027-1042 (lines=16) @@ | ||
| 1024 | * @param int $course_id (default: 0) |
|
| 1025 | * @return int |
|
| 1026 | */ |
|
| 1027 | public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) { |
|
| 1028 | ||
| 1029 | $lesson_args = array( 'post_type' => 'lesson', |
|
| 1030 | 'posts_per_page' => -1, |
|
| 1031 | 'author' => $author_id, |
|
| 1032 | 'meta_key' => '_lesson_course', |
|
| 1033 | 'meta_value' => $course_id, |
|
| 1034 | 'post_status' => 'publish', |
|
| 1035 | 'suppress_filters' => 0, |
|
| 1036 | 'fields' => 'ids', // less data to retrieve |
|
| 1037 | ); |
|
| 1038 | $lessons_array = get_posts( $lesson_args ); |
|
| 1039 | $count = count( $lessons_array ); |
|
| 1040 | return $count; |
|
| 1041 | ||
| 1042 | } // End course_author_lesson_count() |
|
| 1043 | ||
| 1044 | /** |
|
| 1045 | * course_lesson_count function. |
|
| @@ 1051-1067 (lines=17) @@ | ||
| 1048 | * @param int $course_id (default: 0) |
|
| 1049 | * @return int |
|
| 1050 | */ |
|
| 1051 | public function course_lesson_count( $course_id = 0 ) { |
|
| 1052 | ||
| 1053 | $lesson_args = array( 'post_type' => 'lesson', |
|
| 1054 | 'posts_per_page' => -1, |
|
| 1055 | 'meta_key' => '_lesson_course', |
|
| 1056 | 'meta_value' => $course_id, |
|
| 1057 | 'post_status' => 'publish', |
|
| 1058 | 'suppress_filters' => 0, |
|
| 1059 | 'fields' => 'ids', // less data to retrieve |
|
| 1060 | ); |
|
| 1061 | $lessons_array = get_posts( $lesson_args ); |
|
| 1062 | ||
| 1063 | $count = count( $lessons_array ); |
|
| 1064 | ||
| 1065 | return $count; |
|
| 1066 | ||
| 1067 | } // End course_lesson_count() |
|
| 1068 | ||
| 1069 | /** |
|
| 1070 | * course_lesson_preview_count function. |
|
| @@ 1109-1127 (lines=19) @@ | ||
| 1106 | * @param int $product_id (default: 0) |
|
| 1107 | * @return array |
|
| 1108 | */ |
|
| 1109 | public function get_product_courses( $product_id = 0 ) { |
|
| 1110 | ||
| 1111 | $posts_array = array(); |
|
| 1112 | // Check for WooCommerce |
|
| 1113 | if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) { |
|
| 1114 | $post_args = array( 'post_type' => 'course', |
|
| 1115 | 'posts_per_page' => -1, |
|
| 1116 | 'meta_key' => '_course_woocommerce_product', |
|
| 1117 | 'meta_value' => $product_id, |
|
| 1118 | 'post_status' => 'publish', |
|
| 1119 | 'suppress_filters' => 0, |
|
| 1120 | 'orderby' => 'menu_order date', |
|
| 1121 | 'order' => 'ASC', |
|
| 1122 | ); |
|
| 1123 | $posts_array = get_posts( $post_args ); |
|
| 1124 | } // End If Statement |
|
| 1125 | return $posts_array; |
|
| 1126 | ||
| 1127 | } // End get_product_courses() |
|
| 1128 | ||
| 1129 | /** |
|
| 1130 | * Fix posts_per_page for My Courses page |
|
| @@ 2538-2555 (lines=18) @@ | ||
| 2535 | * @param string $fields (default: 'ids') |
|
| 2536 | * @return int $quiz_id |
|
| 2537 | */ |
|
| 2538 | public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) { |
|
| 2539 | ||
| 2540 | $posts_array = array(); |
|
| 2541 | ||
| 2542 | $post_args = array( 'post_type' => 'quiz', |
|
| 2543 | 'posts_per_page' => 1, |
|
| 2544 | 'orderby' => 'title', |
|
| 2545 | 'order' => 'DESC', |
|
| 2546 | 'post_parent' => $lesson_id, |
|
| 2547 | 'post_status' => $post_status, |
|
| 2548 | 'suppress_filters' => 0, |
|
| 2549 | 'fields' => $fields |
|
| 2550 | ); |
|
| 2551 | $posts_array = get_posts( $post_args ); |
|
| 2552 | $quiz_id = array_shift($posts_array); |
|
| 2553 | ||
| 2554 | return $quiz_id; |
|
| 2555 | } // End lesson_quizzes() |
|
| 2556 | ||
| 2557 | ||
| 2558 | /** |
|