PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/Widgets/popular-courses.php +108 -108 4.3.8 → 4.4.9 View file →
@@ -1,108 +1,108 @@
1 -<?php
2 -/**
3 - * Popular Courses Widget.
4 - *
5 - * @author ThimPress <nhamdv>
6 - * @category Widgets
7 - * @package Learnpress/Widgets
8 - * @version 4.0.0
9 - * @extends LP_Widget
10 - */
11 -
12 -defined( 'ABSPATH' ) || exit();
13 -
14 -if ( ! class_exists( 'LP_Widget_Popular_Courses' ) ) {
15 - class LP_Widget_Popular_Courses extends LP_Widget {
16 -
17 - public function __construct() {
18 - $this->widget_cssclass = 'learnpress widget_course_popular';
19 - $this->widget_description = esc_html__( 'Display the Popular courses', 'learnpress' );
20 - $this->widget_id = 'learnpress_widget_course_popular';
21 - $this->widget_name = esc_html__( 'LearnPress - Popular Courses', 'learnpress' );
22 - $this->settings = array(
23 - 'title' => array(
24 - 'label' => __( 'Title', 'learnpress' ),
25 - 'type' => 'text',
26 - 'std' => __( 'Popular Courses', 'learnpress' ),
27 - ),
28 - 'show_teacher' => array(
29 - 'label' => __( 'Show instructor', 'learnpress' ),
30 - 'type' => 'checkbox',
31 - 'std' => 1,
32 - ),
33 - 'show_thumbnail' => array(
34 - 'label' => __( 'Show thumbnail', 'learnpress' ),
35 - 'type' => 'checkbox',
36 - 'std' => 1,
37 - ),
38 - 'limit' => array(
39 - 'label' => __( 'Limit', 'learnpress' ),
40 - 'type' => 'number',
41 - 'min' => 1,
42 - 'std' => 4,
43 - ),
44 - 'desc_length' => array(
45 - 'label' => __( 'Description length', 'learnpress' ),
46 - 'id' => 'desc_length',
47 - 'type' => 'number',
48 - 'min' => 0,
49 - 'std' => 10,
50 - ),
51 - 'show_price' => array(
52 - 'label' => __( 'Show price', 'learnpress' ),
53 - 'type' => 'checkbox',
54 - 'std' => 1,
55 - ),
56 - 'css_class' => array(
57 - 'label' => __( 'CSS class', 'learnpress' ),
58 - 'type' => 'text',
59 - 'std' => '',
60 - ),
61 - 'bottom_link_text' => array(
62 - 'label' => __( 'Go to Courses', 'learnpress' ),
63 - 'type' => 'text',
64 - 'std' => 'Go to Courses',
65 - ),
66 - );
67 -
68 - parent::__construct();
69 - }
70 -
71 - /**
72 - * Show widget in frontend.
73 - */
74 - public function lp_rest_api_content( $instance, $params ) {
75 - $data = '';
76 - $lp_course_db = LP_Course_DB::getInstance();
77 -
78 - try {
79 - $instance['show_teacher'] = $instance['show_teacher'] ?? 1;
80 - $instance['show_thumbnail'] = $instance['show_thumbnail'] ?? 1;
81 - $instance['limit'] = $instance['limit'] ?? 3;
82 - $instance['desc_length'] = $instance['desc_length'] ?? 10;
83 - $instance['show_price'] = $instance['show_price'] ?? 1;
84 - $instance['css_class'] = $instance['css_class'] ?? '';
85 - $instance['bottom_link_text'] = $instance['bottom_link_text'] ?? esc_html__( 'Go to Courses', 'learnpress' );
86 -
87 - $filter = new LP_Course_Filter();
88 - $filter->limit = $instance['limit'];
89 - $lp_course_db->get_courses_order_by_popular( $filter );
90 - $courses = $lp_course_db->get_courses( $filter );
91 - $courses = $lp_course_db->get_values_by_key( $courses, 'ID' );
92 -
93 - $data = learn_press_get_template_content(
94 - 'widgets/popular-courses.php',
95 - array(
96 - 'courses' => $courses,
97 - 'instance' => $instance,
98 - )
99 - );
100 - } catch ( Throwable $e ) {
101 - LP_Debug::error_log( $e );
102 - }
103 -
104 - return $data;
105 - }
106 - }
107 -
108 -}
1 +<?php
2 +/**
3 + * Popular Courses Widget.
4 + *
5 + * @author ThimPress <nhamdv>
6 + * @category Widgets
7 + * @package Learnpress/Widgets
8 + * @version 4.0.0
9 + * @extends LP_Widget
10 + */
11 +
12 +defined( 'ABSPATH' ) || exit();
13 +
14 +if ( ! class_exists( 'LP_Widget_Popular_Courses' ) ) {
15 + class LP_Widget_Popular_Courses extends LP_Widget {
16 +
17 + public function __construct() {
18 + $this->widget_cssclass = 'learnpress widget_course_popular';
19 + $this->widget_description = esc_html__( 'Display the Popular courses', 'learnpress' );
20 + $this->widget_id = 'learnpress_widget_course_popular';
21 + $this->widget_name = esc_html__( 'LearnPress - Popular Courses', 'learnpress' );
22 + $this->settings = array(
23 + 'title' => array(
24 + 'label' => __( 'Title', 'learnpress' ),
25 + 'type' => 'text',
26 + 'std' => __( 'Popular Courses', 'learnpress' ),
27 + ),
28 + 'show_teacher' => array(
29 + 'label' => __( 'Show instructor', 'learnpress' ),
30 + 'type' => 'checkbox',
31 + 'std' => 1,
32 + ),
33 + 'show_thumbnail' => array(
34 + 'label' => __( 'Show thumbnail', 'learnpress' ),
35 + 'type' => 'checkbox',
36 + 'std' => 1,
37 + ),
38 + 'limit' => array(
39 + 'label' => __( 'Limit', 'learnpress' ),
40 + 'type' => 'number',
41 + 'min' => 1,
42 + 'std' => 4,
43 + ),
44 + 'desc_length' => array(
45 + 'label' => __( 'Description length', 'learnpress' ),
46 + 'id' => 'desc_length',
47 + 'type' => 'number',
48 + 'min' => 0,
49 + 'std' => 10,
50 + ),
51 + 'show_price' => array(
52 + 'label' => __( 'Show price', 'learnpress' ),
53 + 'type' => 'checkbox',
54 + 'std' => 1,
55 + ),
56 + 'css_class' => array(
57 + 'label' => __( 'CSS class', 'learnpress' ),
58 + 'type' => 'text',
59 + 'std' => '',
60 + ),
61 + 'bottom_link_text' => array(
62 + 'label' => __( 'Go to Courses', 'learnpress' ),
63 + 'type' => 'text',
64 + 'std' => 'Go to Courses',
65 + ),
66 + );
67 +
68 + parent::__construct();
69 + }
70 +
71 + /**
72 + * Show widget in frontend.
73 + */
74 + public function lp_rest_api_content( $instance, $params ) {
75 + $data = '';
76 + $lp_course_db = LP_Course_DB::getInstance();
77 +
78 + try {
79 + $instance['show_teacher'] = $instance['show_teacher'] ?? 1;
80 + $instance['show_thumbnail'] = $instance['show_thumbnail'] ?? 1;
81 + $instance['limit'] = $instance['limit'] ?? 3;
82 + $instance['desc_length'] = $instance['desc_length'] ?? 10;
83 + $instance['show_price'] = $instance['show_price'] ?? 1;
84 + $instance['css_class'] = $instance['css_class'] ?? '';
85 + $instance['bottom_link_text'] = $instance['bottom_link_text'] ?? esc_html__( 'Go to Courses', 'learnpress' );
86 +
87 + $filter = new LP_Course_Filter();
88 + $filter->limit = $instance['limit'];
89 + $lp_course_db->get_courses_order_by_popular( $filter );
90 + $courses = $lp_course_db->get_courses( $filter );
91 + $courses = $lp_course_db->get_values_by_key( $courses, 'ID' );
92 +
93 + $data = learn_press_get_template_content(
94 + 'widgets/popular-courses.php',
95 + array(
96 + 'courses' => $courses,
97 + 'instance' => $instance,
98 + )
99 + );
100 + } catch ( Throwable $e ) {
101 + LP_Debug::error_log( $e );
102 + }
103 +
104 + return $data;
105 + }
106 + }
107 +
108 +}