1414use Tutor \Ecommerce \Tax ;
1515use Tutor \Cache \TutorCache ;
1616use Tutor \Models \QuizModel ;
17- use Tutor \Helpers \UrlHelper ;
1817use Tutor \Helpers \HttpHelper ;
1918use Tutor \Models \CourseModel ;
2019use Tutor \Ecommerce \Ecommerce ;
@@ -4254,7 +4253,7 @@ public function get_reviews_by_user( $user_id = 0, $offset = 0, $limit = null, $
42544253 * @param int $limit limit.
42554254 * @param string $course_id course id.
42564255 * @param string $date_filter date filter.
4257- * @param array $args Optional query arguments .
4256+ * @param array $args Optional additional WHERE conditions .
42584257 *
42594258 * @return array|null|object
42604259 */
@@ -4271,8 +4270,12 @@ public function get_reviews_by_instructor( $instructor_id = 0, $offset = 0, $lim
42714270 $ date_query = '' ;
42724271 $ where_clause = '' ;
42734272
4274- if ( ! empty ( $ args ['where ' ] ) && is_array ( $ args ['where ' ] ) ) {
4275- $ where_clause = count ( $ args ['where ' ] ) ? ' AND ' . QueryHelper::prepare_where_clause ( $ args ['where ' ] ) : '' ;
4273+ if ( ! empty ( $ args ['from ' ] ) && ! empty ( $ args ['to ' ] ) ) {
4274+ $ from = Input::sanitize ( $ args ['from ' ] );
4275+ $ to = Input::sanitize ( $ args ['to ' ] );
4276+
4277+ $ where ['comment_date ' ] = array ( 'BETWEEN ' , array ( $ from , $ to ) );
4278+ $ where_clause = ' AND ' . QueryHelper::prepare_where_clause ( $ where );
42764279 }
42774280
42784281 if ( '' !== $ course_id ) {
@@ -4362,11 +4365,11 @@ public function get_reviews_by_instructor( $instructor_id = 0, $offset = 0, $lim
43624365 * @since 4.0.0 Added $where Parameter.
43634366 *
43644367 * @param int $instructor_id instructor id.
4365- * @param array $where Optional additional WHERE conditions.
4368+ * @param array $args Optional additional WHERE conditions.
43664369 *
43674370 * @return object
43684371 */
4369- public function get_instructor_ratings ( $ instructor_id , $ where = array () ) {
4372+ public function get_instructor_ratings ( $ instructor_id , $ args = array () ) {
43704373 global $ wpdb ;
43714374
43724375 $ ratings = array (
@@ -4375,16 +4378,21 @@ public function get_instructor_ratings( $instructor_id, $where = array() ) {
43754378 'rating_avg ' => 0.00 ,
43764379 );
43774380
4378- // Prepare where clause.
4379- $ where_clause = QueryHelper::prepare_where_clause (
4380- $ this ->sanitize_array (
4381- $ where + array (
4382- 'courses.user_id ' => $ instructor_id ,
4383- 'courses.meta_key ' => '_tutor_instructor_course_id ' ,
4384- )
4385- )
4381+ $ where = array (
4382+ 'courses.user_id ' => (int ) $ instructor_id ,
4383+ 'courses.meta_key ' => '_tutor_instructor_course_id ' ,
43864384 );
43874385
4386+ if ( ! empty ( $ args ['from ' ] ) && ! empty ( $ args ['to ' ] ) ) {
4387+ $ from = Input::sanitize ( $ args ['from ' ] );
4388+ $ to = Input::sanitize ( $ args ['to ' ] );
4389+
4390+ $ where ['reviews.comment_date ' ] = array ( 'BETWEEN ' , array ( $ from , $ to ) );
4391+ }
4392+
4393+ // Prepare where clause.
4394+ $ where_clause = QueryHelper::prepare_where_clause ( $ where );
4395+
43884396 $ rating = $ wpdb ->get_row (
43894397 "SELECT COUNT(rating.meta_value) as rating_count, SUM(rating.meta_value) as rating_sum
43904398 FROM {$ wpdb ->usermeta } courses
@@ -6257,24 +6265,24 @@ public function get_earning_statements( $user_id = 0, $filter_data = array() ) {
62576265 * @since 1.1.2
62586266 * @since 4.0.0 Condition added for different monetizations and also added $html_markup for woocommece
62596267 *
6260- * @param int $price price.
6261- * @param bool $html_markup Whether to include HTML markup ( Only for woocommerce as it returns html markup ).
6268+ * @param int $price price.
6269+ * @param bool $html_markup Whether to include HTML markup ( Only for woocommerce as it returns html markup ).
62626270 *
62636271 * @return int|string
62646272 */
62656273 public function tutor_price ( $ price = 0 , $ html_markup = true ) {
62666274
62676275 $ monetize_by = $ this ->get_option ( 'monetize_by ' );
6268-
6276+
62696277 if ( Ecommerce::MONETIZE_BY === $ monetize_by ) {
62706278 return tutor_get_formatted_price ( $ price );
6271- } elseif ( function_exists ( 'wc_price ' ) && 'wc ' === $ monetize_by ) {
6279+ } elseif ( function_exists ( 'wc_price ' ) && 'wc ' === $ monetize_by ) {
62726280 return wc_price ( $ price , array ( 'in_span ' => $ html_markup ) );
62736281 } elseif ( function_exists ( 'edd_currency_filter ' ) && 'edd ' === $ monetize_by ) {
62746282 return edd_currency_filter ( edd_format_amount ( $ price ) );
6275- } elseif ( function_exists ( 'pmpro_formatPrice ' ) && 'pmpro ' === $ monetize_by ) {
6283+ } elseif ( function_exists ( 'pmpro_formatPrice ' ) && 'pmpro ' === $ monetize_by ) {
62766284 return pmpro_formatPrice ( floatval ( $ price ) );
6277- } else {
6285+ } else {
62786286 return number_format_i18n ( floatval ( $ price ) );
62796287 }
62806288 }
0 commit comments