PluginProbe
Tutor LMS – eLearning and online course solution / 2.0.10
Tutor LMS – eLearning and online course solution v2.0.10
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/Course_Widget.php +26 -66 trunk2.0.10 View file →
@@ -1,42 +1,28 @@
1 1 <?php
2 +
2 3 /**
3 - * Course Widget Register
4 + * Widget class
4 5 *
6 + * @author: themeum
7 + * @author_uri: https://themeum.com
5 8 * @package Tutor
6 - * @author Themeum <support@themeum.com>
7 - * @link https://themeum.com
8 - * @since 1.3.1
9 + * @since v.1.3.1
9 10 */
10 11
11 12 namespace TUTOR;
12 13
13 -use Tutor\Models\CourseModel;
14 -
15 14 if ( ! defined( 'ABSPATH' ) ) {
16 15 exit;
17 16 }
18 17
19 -/**
20 - * Course Widget Class
21 - *
22 - * @since 1.3.1
23 - */
24 18 class Course_Widget extends \WP_Widget {
25 19
26 - /**
27 - * Constructor
28 - *
29 - * @since 1.3.1
30 - * @return void
31 - */
32 - public function __construct() {
20 + function __construct() {
33 21 parent::__construct(
34 - 'tutor_course_widget', // Base ID.
35 - _x( 'Tutor Course', 'widget title', 'tutor' ),
36 - array(
37 - 'description' => _x( 'Display courses wherever widget support is available.', 'widget description', 'tutor' ),
38 - )
22 + 'tutor_course_widget', // Base ID
23 + esc_html__( 'Tutor Course', 'tutor' ), // Name
24 + array( 'description' => esc_html__( 'Display courses wherever widget support is available.', 'tutor' ) ) // Args
39 25 );
40 26 }
41 27
42 28 /**
@@ -41,34 +27,17 @@
41 27
42 28 /**
43 29 * Front-end display of widget.
44 30 *
45 - * @since 1.3.1
46 31 * @see WP_Widget::widget()
47 32 *
48 33 * @param array $args Widget arguments.
49 34 * @param array $instance Saved values from database.
50 - *
51 - * @return void
52 35 */
53 36 public function widget( $args, $instance ) {
54 - echo wp_kses(
55 - $args['before_widget'],
56 - array(
57 - 'section' => array(
58 - 'id' => true,
59 - 'class' => true,
60 - ),
61 - 'div' => array(
62 - 'id' => true,
63 - 'class' => true,
64 - ),
65 - )
66 - );
37 + echo $args['before_widget'];
67 38 if ( ! empty( $instance['title'] ) ) {
68 - echo wp_kses( $args['before_title'], array( 'h2' => array( 'class' => true ) ) );
69 - echo esc_html( apply_filters( 'widget_title', $instance['title'] ) );
70 - echo wp_kses( $args['after_title'], array( 'h2' => array() ) );
39 + echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
71 40 }
72 41
73 42 $course_post_type = tutor()->course_post_type;
74 43
@@ -103,9 +72,9 @@
103 72 $category = (array) explode( ',', $a['category'] );
104 73
105 74 $a['tax_query'] = array(
106 75 array(
107 - 'taxonomy' => CourseModel::COURSE_CATEGORY,
76 + 'taxonomy' => 'course-category',
108 77 'field' => 'term_id',
109 78 'terms' => $category,
110 79 'operator' => 'IN',
111 80 ),
@@ -119,27 +88,19 @@
119 88 tutor_load_template( 'widget.courses' );
120 89 $output = ob_get_clean();
121 90 wp_reset_query();
122 91
123 - echo wp_kses_post( $output );
92 + echo $output;
124 93
125 - echo wp_kses(
126 - $args['after_widget'],
127 - array(
128 - 'section' => array(),
129 - 'div' => array(),
130 - )
131 - );
94 + echo $args['after_widget'];
132 95 }
133 96
134 97 /**
135 98 * Back-end widget form.
136 99 *
137 - * @since 1.3.1
138 100 * @see WP_Widget::form()
139 101 *
140 102 * @param array $instance Previously saved values from database.
141 - * @return void
142 103 */
143 104 public function form( $instance ) {
144 105 $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'New title', 'tutor' );
145 106 $id = ! empty( $instance['id'] ) ? $instance['id'] : '';
@@ -150,9 +111,9 @@
150 111 $count = ! empty( $instance['count'] ) ? $instance['count'] : '6';
151 112 ?>
152 113 <p>
153 114 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
154 - <?php esc_html_e( 'Title', 'tutor' ); ?>:
115 + <?php _e( 'Title', 'tutor' ); ?>:
155 116 </label>
156 117 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
157 118 </p>
158 119
@@ -157,37 +118,37 @@
157 118 </p>
158 119
159 120 <p>
160 121 <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>">
161 - <?php esc_html_e( 'ID', 'tutor' ); ?>:
122 + <?php _e( 'ID', 'tutor' ); ?>:
162 123 </label>
163 124 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" type="text" value="<?php echo esc_attr( $id ); ?>"> <br />
164 125 <span style="color: #AAAAAA">
165 - <?php esc_html_e( 'Place single course id or comma (,) separated course ids', 'tutor' ); ?>
126 + <?php _e( 'Place single course id or comma (,) separated course ids', 'tutor' ); ?>
166 127 </span>
167 128 </p>
168 129
169 130 <p>
170 131 <label for="<?php echo esc_attr( $this->get_field_id( 'exclude_ids' ) ); ?>"><?php esc_attr_e( 'Exclude IDS:', 'tutor' ); ?></label>
171 - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'exclude_ids' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude_ids' ) ); ?>" type="text" value="<?php echo esc_attr( $exclude_ids ); ?>"> <br />
132 + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'exclude_ids' ) ); ?>" name="<?php echo esc_attr($this->get_field_name( 'exclude_ids' )); ?>" type="text" value="<?php echo esc_attr( $exclude_ids ); ?>"> <br />
172 133 <span style="color: #AAAAAA">
173 - <?php esc_html_e( 'Place comma (,) separated courses ids which you like to exclude from the query', 'tutor' ); ?>
134 + <?php _e( 'Place comma (,) separated courses ids which you like to exclude from the query', 'tutor' ); ?>
174 135 </span>
175 136 </p>
176 137
177 138 <p>
178 139 <label for="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>">
179 - <?php esc_html_e( 'Category', 'tutor' ); ?>:
140 + <?php _e( 'Category', 'tutor' ); ?>:
180 141 </label>
181 - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>" type="text" value="<?php echo esc_attr( $category ); ?>"> <br />
142 + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr($this->get_field_name( 'category' )); ?>" type="text" value="<?php echo esc_attr( $category ); ?>"> <br />
182 143 <span style="color: #AAAAAA">
183 - <?php esc_html_e( 'Place comma (,) separated category ids', 'tutor' ); ?>
144 + <?php _e( 'Place comma (,) separated category ids', 'tutor' ); ?>
184 145 </span>
185 146 </p>
186 147
187 148 <p>
188 149 <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>">
189 - <?php esc_html_e( 'OrderBy', 'tutor' ); ?>
150 + <?php _e( 'OrderBy', 'tutor' ); ?>
190 151 </label>
191 152
192 153 <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" >
193 154 <option value="ID" <?php selected( 'ID', $orderby ); ?> >ID</option>
@@ -200,9 +161,9 @@
200 161 </p>
201 162
202 163 <p>
203 164 <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>">
204 - <?php esc_html_e( 'Order', 'tutor' ); ?>
165 + <?php _e( 'Order', 'tutor' ); ?>
205 166 </label>
206 167
207 168 <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" >
208 169 <option value="DESC" <?php selected( 'DESC', $order ); ?> >DESC</option>
@@ -211,11 +172,11 @@
211 172 </p>
212 173
213 174 <p>
214 175 <label for="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>"><?php esc_attr_e( 'Count:', 'tutor' ); ?></label>
215 - <input class="widefat tutor-form-number-verify" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>" type="number" value="<?php echo esc_attr( $count ); ?>" min="1"> <br />
176 + <input class="widefat tutor-form-number-verify" id="<?php echo esc_attr( $this->get_field_id( 'count' ) ); ?>" name="<?php echo esc_attr($this->get_field_name( 'count' ) ); ?>" type="number" value="<?php echo esc_attr( $count ); ?>" min="1"> <br />
216 177 <span style="color: #AAAAAA">
217 - <?php esc_html_e( 'Total results you like to show', 'tutor' ); ?>
178 + <?php _e('Total results you like to show', 'tutor'); ?>
218 179 </span>
219 180 </p>
220 181
221 182 <?php
@@ -223,9 +184,8 @@
223 184
224 185 /**
225 186 * Sanitize widget form values as they are saved.
226 187 *
227 - * @since 1.3.1
228 188 * @see WP_Widget::update()
229 189 *
230 190 * @param array $new_instance Values just sent to be saved.
231 191 * @param array $old_instance Previously saved values from database.