PluginProbe
Tutor LMS – eLearning and online course solution / 2.0.6
Tutor LMS – eLearning and online course solution v2.0.6
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 +48 -18 2.0.52.0.6 View file →
@@ -141,17 +141,41 @@
141 141 $a['post__not_in'] = $exclude_ids;
142 142 }
143 143 if ( ! empty( $a['category'] ) ) {
144 144 $category = (array) explode( ',', $a['category'] );
145 +
146 + $a['tax_query'] = array();
145 147
146 - $a['tax_query'] = array(
147 - array(
148 - 'taxonomy' => 'course-category',
149 - 'field' => 'term_id',
150 - 'terms' => $category,
151 - 'operator' => 'IN',
152 - ),
153 - );
148 + $category_ids = array_filter($category, function($id){
149 + return is_numeric($id);
150 + });
151 +
152 + $category_names = array_filter($category, function($id){
153 + return !is_numeric($id);
154 + });
155 +
156 + if(!empty($category_ids)) {
157 + $a['tax_query'] = array(
158 + array(
159 + 'taxonomy' => 'course-category',
160 + 'field' => 'term_id',
161 + 'terms' => $category_ids,
162 + 'operator' => 'IN',
163 + ),
164 + );
165 + }
166 +
167 + if(!empty($category_names)) {
168 + $a['tax_query'] = array(
169 + array(
170 + 'taxonomy' => 'course-category',
171 + 'field' => 'name',
172 + 'terms' => $category_names,
173 + 'operator' => 'IN',
174 + ),
175 + );
176 + }
177 +
154 178 }
155 179 $a['posts_per_page'] = (int) $a['count'];
156 180
157 181 wp_reset_query();
@@ -159,17 +183,23 @@
159 183
160 184
161 185 // Load the renderer now
162 186 ob_start();
163 - tutor_load_template('archive-course-init', array(
164 - 'course_filter' => isset( $atts['course_filter'] ) && $atts['course_filter'] == 'on',
165 - 'supported_filters' => tutor_utils()->get_option( 'supported_course_filters', array() ),
166 - 'loop_content_only' => false,
167 - 'column_per_row' => isset( $atts['column_per_row'] ) ? $atts['column_per_row'] : null,
168 - 'course_per_page' => $a['posts_per_page'],
169 - 'show_pagination' => isset( $atts['show_pagination'] ) && $atts['show_pagination']=='on',
170 - 'the_query' => $the_query
171 - ));
187 +
188 + if ( $the_query->have_posts() ) {
189 + tutor_load_template('archive-course-init', array(
190 + 'course_filter' => isset( $atts['course_filter'] ) && $atts['course_filter'] == 'on',
191 + 'supported_filters' => tutor_utils()->get_option( 'supported_course_filters', array() ),
192 + 'loop_content_only' => false,
193 + 'column_per_row' => isset( $atts['column_per_row'] ) ? $atts['column_per_row'] : null,
194 + 'course_per_page' => $a['posts_per_page'],
195 + 'show_pagination' => isset( $atts['show_pagination'] ) && $atts['show_pagination']=='on',
196 + 'the_query' => $the_query
197 + ));
198 + } else {
199 + tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() );
200 + }
201 +
172 202 $output = ob_get_clean();
173 203
174 204 wp_reset_postdata();
175 205
@@ -183,9 +213,9 @@
183 213 $page = $current_page - 1;
184 214 $rating_filter = isset( $_POST['rating_filter'] ) ? $_POST['rating_filter'] : '';
185 215
186 216 /**
187 - * Short by Relevant | New | Popular
217 + * Sort by Relevant | New | Popular
188 218 *
189 219 * @since v2.0.0
190 220 */
191 221 $short_by = '';