PluginProbe
Tutor LMS – eLearning and online course solution / 3.4.1
Tutor LMS – eLearning and online course solution v3.4.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/Shortcode.php +36 -26 4.0.23.4.1 View file →
@@ -41,19 +41,10 @@
41 41 /**
42 42 * Register hooks
43 43 *
44 44 * @since 1.0.0
45 - * @since 3.8.0
46 - *
47 - * @param bool $register_hooks register hooks or not.
48 - *
49 - * @return void
50 45 */
51 - public function __construct( $register_hooks = true ) {
52 - if ( ! $register_hooks ) {
53 - return;
54 - }
55 -
46 + public function __construct() {
56 47 add_shortcode( 'tutor_student_registration_form', array( $this, 'student_registration_form' ) );
57 48 add_shortcode( 'tutor_dashboard', array( $this, 'tutor_dashboard' ) );
58 49 add_shortcode( 'tutor_instructor_registration_form', array( $this, 'instructor_registration_form' ) );
59 50 add_shortcode( 'tutor_course', array( $this, 'tutor_course' ) );
@@ -169,10 +160,8 @@
169 160 ),
170 161 $atts
171 162 );
172 163
173 - $a = apply_filters( 'tutor_get_course_list_filter_args', $a );
174 -
175 164 $supported_filters = tutor_utils()->get_option( 'supported_course_filters', array() );
176 165 $course_filter_category = array();
177 166 $course_filter_exclude_ids = array();
178 167 $course_filter_post_ids = array();
@@ -201,9 +190,9 @@
201 190 $a['tax_query'] = array();
202 191
203 192 $category_ids = array_filter(
204 193 $category,
205 - function ( $id ) {
194 + function( $id ) {
206 195 return is_numeric( $id );
207 196 }
208 197 );
209 198
@@ -208,9 +197,9 @@
208 197 );
209 198
210 199 $category_names = array_filter(
211 200 $category,
212 - function ( $id ) {
201 + function( $id ) {
213 202 return ! is_numeric( $id );
214 203 }
215 204 );
216 205
@@ -338,8 +327,9 @@
338 327 *
339 328 * @return string
340 329 */
341 330 public function tutor_instructor_list( $atts ) {
331 + global $wpdb;
342 332 ! is_array( $atts ) ? $atts = array() : 0;
343 333
344 334 $current_page = (int) tutor_utils()->array_get( 'instructor-page', $_GET, 1 );
345 335 $current_page = Input::get( 'instructor-page', 1, Input::TYPE_INT );
@@ -345,10 +335,8 @@
345 335 $current_page = Input::get( 'instructor-page', 1, Input::TYPE_INT );
346 336 $current_page = $current_page >= 1 ? $current_page : 1;
347 337
348 338 $show_filter = isset( $atts['filter'] ) ? 'on' === $atts['filter'] : tutor_utils()->get_option( 'instructor_list_show_filter', false );
349 - $category_limit = (int) isset( $atts['category_limit'] ) ? $atts['category_limit'] : 0;
350 - $hide_empty_category = isset( $atts['hide_empty_category'] ) ? '1' == $atts['hide_empty_category'] : false;
351 339 $atts['show_filter'] = $show_filter;
352 340
353 341 // Get instructor list to sow.
354 342 $payload = $this->prepare_instructor_list( $current_page, $atts );
@@ -358,18 +346,39 @@
358 346 tutor_load_template( 'shortcode.tutor-instructor', $payload );
359 347 $content = ob_get_clean();
360 348
361 349 if ( $show_filter ) {
350 + $limit = 8;
362 351 $course_taxonomy = CourseModel::COURSE_CATEGORY;
363 - $term_args = array(
364 - 'taxonomy' => $course_taxonomy,
365 - 'hide_empty' => $hide_empty_category,
366 - 'orderby' => 'count',
367 - 'order' => 'DESC',
368 - 'number' => $category_limit,
352 + $course_cats = $wpdb->get_results(
353 + $wpdb->prepare(
354 + "SELECT
355 + *
356 + FROM {$wpdb->terms} AS term
357 +
358 + INNER JOIN {$wpdb->term_taxonomy} AS taxonomy
359 + ON taxonomy.term_id = term.term_id AND taxonomy.taxonomy = %s
360 +
361 + ORDER BY term.term_id DESC
362 + LIMIT %d
363 + ",
364 + $course_taxonomy,
365 + $limit
366 + )
369 367 );
370 368
371 - $course_cats = get_terms( $term_args );
369 + $all_cats = $wpdb->get_var(
370 + $wpdb->prepare(
371 + "SELECT
372 + COUNT(*) as total
373 + FROM {$wpdb->terms} AS term
374 + INNER JOIN {$wpdb->term_taxonomy} AS taxonomy
375 + ON taxonomy.term_id = term.term_id AND taxonomy.taxonomy = %s
376 + ORDER BY term.term_id DESC
377 + ",
378 + $course_taxonomy
379 + )
380 + );
372 381
373 382 $attributes = $payload;
374 383 unset( $attributes['instructors'] );
375 384
@@ -376,8 +385,9 @@
376 385 $payload = array(
377 386 'show_filter' => $show_filter,
378 387 'content' => $content,
379 388 'categories' => $course_cats,
389 + 'all_cats' => $all_cats,
380 390 'attributes' => array_merge( $atts, $attributes ),
381 391 );
382 392
383 393 ob_start();
@@ -406,9 +416,9 @@
406 416 $course_taxonomy = CourseModel::COURSE_CATEGORY;
407 417
408 418 $remaining_categories = $wpdb->get_var(
409 419 $wpdb->prepare(
410 - "SELECT
420 + "SElECT
411 421 COUNT(*) AS total
412 422 FROM {$wpdb->terms} AS term
413 423 INNER JOIN {$wpdb->term_taxonomy} AS taxonomy
414 424 ON taxonomy.term_id = term.term_id AND taxonomy.taxonomy = %s
@@ -421,9 +431,9 @@
421 431 );
422 432
423 433 $add_categories = $wpdb->get_results(
424 434 $wpdb->prepare(
425 - "SELECT
435 + "SElECT
426 436 *
427 437 FROM {$wpdb->terms} term
428 438 INNER JOIN {$wpdb->term_taxonomy} as taxonomy
429 439 ON taxonomy.term_id = term.term_id AND taxonomy.taxonomy = %s
@@ -466,9 +476,9 @@
466 476
467 477 $category = (array) tutor_utils()->array_get( 'category', $_post, array() );
468 478 $category = array_filter(
469 479 $category,
470 - function ( $cat ) {
480 + function( $cat ) {
471 481 return is_numeric( $cat );
472 482 }
473 483 );
474 484