Skip to content

Instantly share code, notes, and snippets.

@ibrahim-kardi
Last active November 4, 2021 04:48
Show Gist options
  • Save ibrahim-kardi/c08cfdff6112a447d3512dcdc13157b1 to your computer and use it in GitHub Desktop.
Save ibrahim-kardi/c08cfdff6112a447d3512dcdc13157b1 to your computer and use it in GitHub Desktop.
Need to modify the filters.php file ,here : plugins\tutor\templates\course-filter\filters.php ,added a line in 12 and modified code 58-64
<?php
$filter_object = new \TUTOR\Course_Filter();
// $filter_levels = array(
// 'beginner' => __('Beginner', 'tutor'),
// 'intermediate' => __('Intermediate', 'tutor'),
// 'expert' => __('Expert', 'tutor')
// );
$filter_prices = array(
'free' => __('Free', 'tutor'),
'paid' => __('Paid', 'tutor'),
);
$course_levels = tutor_utils()->course_levels();
$supported_filters = tutor_utils()->get_option('supported_course_filters', array());
$supported_filters = array_keys($supported_filters);
?>
<form>
<?php do_action('tutor_course_filter/before'); ?>
<?php
if (in_array('search', $supported_filters)) {
?>
<div class="tutor-course-search-field">
<input type="text" name="keyword" placeholder="<?php _e('Search...'); ?>" />
<i class="tutor-icon-magnifying-glass-1"></i>
</div>
<?php
}
?>
<div>
<?php
if (in_array('category', $supported_filters)) {
?>
<div>
<h4><?php _e('Category', 'tutor'); ?></h4>
<?php $filter_object->render_terms('category'); ?>
</div>
<?php
}
if (in_array('tag', $supported_filters)) {
?>
<div>
<h4><?php _e('Tag', 'tutor'); ?></h4>
<?php $filter_object->render_terms('tag'); ?>
</div>
<?php
}
?>
</div>
<div>
<?php
if (in_array('difficulty_level', $supported_filters)) {
?>
<div>
<h4><?php _e('Level', 'tutor'); ?></h4>
<?php
foreach ($course_levels as $value => $title) {
if ($key == 'all_levels') continue; ?>
<label for="<?php echo esc_attr($key); ?>">
<input type="checkbox" name="tutor-course-filter-level" value="<?php echo $value; ?>" />&nbsp;
<?php echo $title; ?>
</label>
<?php
}
?>
</div>
<?php
}
$is_membership = get_tutor_option('monetize_by') == 'pmpro' && tutils()->has_pmpro();
if (!$is_membership && in_array('price_type', $supported_filters)) {
?>
<div>
<h4><?php _e('Price', 'tutor'); ?></h4>
<?php
foreach ($filter_prices as $value => $title) {
?>
<label>
<input type="checkbox" name="tutor-course-filter-price" value="<?php echo $value; ?>" />&nbsp;
<?php echo $title; ?>
</label>
<?php
}
?>
</div>
<?php
}
?>
</div>
<div class="tutor-clear-all-filter">
<a href="#" onclick="window.location.reload()">
<i class="tutor-icon-cross"></i> Clear All Filter
</a>
</div>
<?php do_action('tutor_course_filter/after'); ?>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment