PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.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 4.2.0 4.2.1 All 138 releases
learnpress / inc / Widgets / featured-courses.php

featured-courses.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.8, at inc/Widgets/featured-courses.php

107 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Feature Courses Widget.
4 *
5 * @author ThimPress
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_Featured_Courses' ) ) {
15
16 /**
17 * Class LP_Widget_Featured_Courses
18 */
19 class LP_Widget_Featured_Courses extends LP_Widget {
20
21 public function __construct() {
22 $this->widget_cssclass = 'learnpress widget_course_featured';
23 $this->widget_description = esc_html__( 'Display the Featured courses', 'learnpress' );
24 $this->widget_id = 'learnpress_widget_course_featured';
25 $this->widget_name = esc_html__( 'LearnPress - Featured Courses', 'learnpress' );
26 $this->settings = array(
27 'title' => array(
28 'label' => __( 'Title', 'learnpress' ),
29 'type' => 'text',
30 'std' => __( 'Featured Courses', 'learnpress' ),
31 ),
32 'show_teacher' => array(
33 'label' => __( 'Show instructor', 'learnpress' ),
34 'type' => 'checkbox',
35 'std' => 1,
36 ),
37 'show_thumbnail' => array(
38 'label' => __( 'Show thumbnail', 'learnpress' ),
39 'type' => 'checkbox',
40 'std' => 1,
41 ),
42 'limit' => array(
43 'label' => __( 'Limit', 'learnpress' ),
44 'type' => 'number',
45 'min' => 1,
46 'std' => 4,
47 ),
48 'desc_length' => array(
49 'label' => __( 'Description length', 'learnpress' ),
50 'type' => 'number',
51 'min' => 0,
52 'std' => 10,
53 ),
54 'show_price' => array(
55 'label' => __( 'Show price', 'learnpress' ),
56 'type' => 'checkbox',
57 'std' => 1,
58 ),
59 'css_class' => array(
60 'label' => __( 'CSS class', 'learnpress' ),
61 'type' => 'text',
62 'std' => '',
63 ),
64 'bottom_link_text' => array(
65 'label' => __( 'Go to courses', 'learnpress' ),
66 'type' => 'text',
67 'std' => 'Go to Courses',
68 ),
69 );
70
71 parent::__construct();
72 }
73
74 /**
75 * Send content for API
76 *
77 * @param array $instance Widget Instance
78 * @param array $params RestAPI param need for content.
79 * @return string || WP_Error
80 */
81 public function lp_rest_api_content( $instance, $params ) {
82 $instance['show_teacher'] = $instance['show_teacher'] ?? 1;
83 $instance['show_thumbnail'] = $instance['show_thumbnail'] ?? 1;
84 $instance['limit'] = $instance['limit'] ?? 4;
85 $instance['desc_length'] = $instance['desc_length'] ?? 10;
86 $instance['show_price'] = $instance['show_price'] ?? 1;
87 $instance['css_class'] = $instance['css_class'] ?? '';
88 $instance['bottom_link_text'] = $instance['bottom_link_text'] ?? esc_html__( 'Go to Courses', 'learnpress' );
89
90 $filter = new LP_Course_Filter();
91 $filter->limit = $instance['limit'];
92
93 $courses = LP_Course_DB::getInstance()->get_featured_courses( $filter );
94
95 $data = learn_press_get_template_content(
96 'widgets/featured-courses.php',
97 array(
98 'courses' => $courses,
99 'instance' => $instance,
100 )
101 );
102
103 return $data;
104 }
105 }
106 }
107