Code Duplication    Length = 16-19 lines in 4 locations

includes/class-sensei-course.php 3 locations

@@ 1035-1050 (lines=16) @@
1032
	 * @param  int $course_id (default: 0)
1033
	 * @return int
1034
	 */
1035
	public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) {
1036
1037
        $lesson_args = array(	'post_type' 		=> 'lesson',
1038
								'posts_per_page' 		=> -1,
1039
		    					'author'         	=> $author_id,
1040
		    					'meta_key'        	=> '_lesson_course',
1041
    							'meta_value'      	=> $course_id,
1042
    	    					'post_status'      	=> 'publish',
1043
    	    					'suppress_filters' 	=> 0,
1044
								'fields'            => 'ids', // less data to retrieve
1045
		    				);
1046
		$lessons_array = get_posts( $lesson_args );
1047
		$count = count( $lessons_array );
1048
		return $count;
1049
1050
	} // End course_author_lesson_count()
1051
1052
	/**
1053
	 * course_lesson_count function.
@@ 1059-1075 (lines=17) @@
1056
	 * @param  int $course_id (default: 0)
1057
	 * @return int
1058
	 */
1059
	public function course_lesson_count( $course_id = 0 ) {
1060
1061
		$lesson_args = array(	'post_type' 		=> 'lesson',
1062
								'posts_per_page' 		=> -1,
1063
		    					'meta_key'        	=> '_lesson_course',
1064
    							'meta_value'      	=> $course_id,
1065
    	    					'post_status'      	=> 'publish',
1066
    	    					'suppress_filters' 	=> 0,
1067
								'fields'            => 'ids', // less data to retrieve
1068
		    				);
1069
		$lessons_array = get_posts( $lesson_args );
1070
1071
        $count = count( $lessons_array );
1072
1073
        return $count;
1074
1075
	} // End course_lesson_count()
1076
1077
	/**
1078
	 * course_lesson_preview_count function.
@@ 1117-1135 (lines=19) @@
1114
	 * @param  int $product_id (default: 0)
1115
	 * @return array
1116
	 */
1117
	public function get_product_courses( $product_id = 0 ) {
1118
1119
		$posts_array = array();
1120
		// Check for WooCommerce
1121
		if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) {
1122
			$post_args = array(	'post_type' 		=> 'course',
1123
								'posts_per_page' 		=> -1,
1124
								'meta_key'        	=> '_course_woocommerce_product',
1125
	    						'meta_value'      	=> $product_id,
1126
	    						'post_status'       => 'publish',
1127
								'suppress_filters' 	=> 0,
1128
								'orderby' 			=> 'menu_order date',
1129
								'order' 			=> 'ASC',
1130
								);
1131
			$posts_array = get_posts( $post_args );
1132
		} // End If Statement
1133
		return $posts_array;
1134
1135
	} // End get_product_courses()
1136
1137
	/**
1138
	 * Fix posts_per_page for My Courses page

includes/class-sensei-lesson.php 1 location

@@ 2547-2564 (lines=18) @@
2544
	 * @param string $fields (default: 'ids')
2545
	 * @return int $quiz_id
2546
	 */
2547
	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2548
2549
		$posts_array = array();
2550
2551
		$post_args = array(	'post_type' 		=> 'quiz',
2552
							'posts_per_page' 		=> 1,
2553
							'orderby'         	=> 'title',
2554
    						'order'           	=> 'DESC',
2555
    						'post_parent'      	=> $lesson_id,
2556
    						'post_status'		=> $post_status,
2557
							'suppress_filters' 	=> 0,
2558
							'fields'            => $fields
2559
							);
2560
		$posts_array = get_posts( $post_args );
2561
        $quiz_id = array_shift($posts_array);
2562
2563
		return $quiz_id;
2564
	} // End lesson_quizzes()
2565
2566
2567
	/**