| 1 |
<?php |
| 2 |
/** |
| 3 |
* Frontend class |
| 4 |
* |
| 5 |
* @author: themeum |
| 6 |
* @author_uri: https://themeum.com |
| 7 |
* @package Tutor |
| 8 |
* @since v.1.5.2 |
| 9 |
*/ |
| 10 |
|
| 11 |
|
| 12 |
namespace TUTOR; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
class Frontend { |
| 19 |
|
| 20 |
public function __construct() { |
| 21 |
add_action( 'after_setup_theme', array( $this, 'remove_admin_bar' ) ); |
| 22 |
add_filter( 'nav_menu_link_attributes', array( $this, 'add_menu_atts' ), 10, 3 ); |
| 23 |
// add_action('pre_get_posts', array($this, 'tutor_offset_courses')); |
| 24 |
} |
| 25 |
function tutor_offset_courses($query){ |
| 26 |
if (!is_admin() && $query->is_main_query() && is_archive(tutor()->course_post_type)) $query->set('offset', 0); |
| 27 |
} |
| 28 |
/** |
| 29 |
* Remove admin bar based on option |
| 30 |
*/ |
| 31 |
function remove_admin_bar() { |
| 32 |
$hide_admin_bar_for_users = (bool) get_tutor_option( 'hide_admin_bar_for_users' ); |
| 33 |
if ( ! current_user_can( 'administrator' ) && ! is_admin() && $hide_admin_bar_for_users ) { |
| 34 |
show_admin_bar( false ); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* add_menu_atts |
| 40 |
* |
| 41 |
* @param mixed $atts |
| 42 |
* @param mixed $item |
| 43 |
* @param mixed $args |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
function add_menu_atts( $atts, $item, $args ) { |
| 47 |
$atts['onClick'] = 'return true'; |
| 48 |
return $atts; |
| 49 |
} |
| 50 |
} |
| 51 |
|