| @@ -9,10 +9,8 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | namespace TUTOR; |
| 12 | 12 | |
| 13 | -use Tutor\Models\CourseModel; | |
| 14 | - | |
| 15 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | 14 | exit; |
| 17 | 15 | } |
| 18 | 16 | |
| @@ -32,37 +30,14 @@ | ||
| 32 | 30 | public function __construct() { |
| 33 | 31 | add_action( 'after_setup_theme', array( $this, 'remove_admin_bar' ) ); |
| 34 | 32 | add_filter( 'nav_menu_link_attributes', array( $this, 'add_menu_atts' ), 10, 3 ); |
| 35 | 33 | add_action( 'admin_init', array( $this, 'restrict_wp_admin_area' ) ); |
| 36 | - add_action( 'tutor_before_course_builder_load', array( $this, 'restrict_wp_admin_area' ) ); | |
| 37 | 34 | |
| 38 | 35 | // Handle flash toast message for redirect_to util helper. |
| 39 | 36 | add_action( 'wp_head', array( new Utils(), 'handle_flash_message' ), 999 ); |
| 40 | - | |
| 41 | - add_action( 'tutor_course/single/before/wrap', array( $this, 'do_auto_course_complete' ) ); | |
| 42 | - add_filter( 'body_class', array( $this, 'add_kids_mode_attribute' ) ); | |
| 43 | 37 | } |
| 44 | 38 | |
| 45 | 39 | /** |
| 46 | - * Do auto course complete on course details page. | |
| 47 | - * | |
| 48 | - * @return void | |
| 49 | - */ | |
| 50 | - public function do_auto_course_complete() { | |
| 51 | - if ( ! is_user_logged_in() ) { | |
| 52 | - return; | |
| 53 | - } | |
| 54 | - | |
| 55 | - $course_id = get_the_ID(); | |
| 56 | - $user_id = get_current_user_id(); | |
| 57 | - | |
| 58 | - if ( CourseModel::can_autocomplete_course( $course_id, $user_id ) ) { | |
| 59 | - CourseModel::mark_course_as_completed( $course_id, $user_id ); | |
| 60 | - Course::set_review_popup_data( $user_id, $course_id ); | |
| 61 | - } | |
| 62 | - } | |
| 63 | - | |
| 64 | - /** | |
| 65 | 40 | * Check current user has admin area access for tutor |
| 66 | 41 | * |
| 67 | 42 | * @since 2.0.7 |
| 68 | 43 | * @return boolean |
| @@ -103,9 +78,9 @@ | ||
| 103 | 78 | public function restrict_wp_admin_area() { |
| 104 | 79 | $hide_admin_bar_for_users = (bool) get_tutor_option( 'hide_admin_bar_for_users' ); |
| 105 | 80 | $has_access = $this->has_admin_area_access(); |
| 106 | 81 | |
| 107 | - if ( is_admin() && tutor()->has_pro && $hide_admin_bar_for_users && ! $has_access && ! wp_doing_ajax() ) { | |
| 82 | + if ( tutor()->has_pro && $hide_admin_bar_for_users && ! $has_access && ! wp_doing_ajax() ) { | |
| 108 | 83 | wp_die( esc_html__( 'Access Denied!', 'tutor' ) ); |
| 109 | 84 | } |
| 110 | 85 | } |
| 111 | 86 | |
| @@ -122,26 +97,6 @@ | ||
| 122 | 97 | */ |
| 123 | 98 | public function add_menu_atts( $atts, $item, $args ) { |
| 124 | 99 | $atts['onClick'] = 'return true'; |
| 125 | 100 | return $atts; |
| 126 | - } | |
| 127 | - | |
| 128 | - /** | |
| 129 | - * Add kids mode data attribute to the <body> tag. | |
| 130 | - * | |
| 131 | - * Note: body_class filter only accepts class names, not attributes. | |
| 132 | - * | |
| 133 | - * @since 4.0.0 | |
| 134 | - * | |
| 135 | - * @param array $classes Body classes. | |
| 136 | - * | |
| 137 | - * @return array | |
| 138 | - */ | |
| 139 | - public function add_kids_mode_attribute( $classes ) { | |
| 140 | - if ( ! tutor_utils()->is_kids_mode() ) { | |
| 141 | - return $classes; | |
| 142 | - } | |
| 143 | - | |
| 144 | - echo ' data-tutor-ui="kids"'; | |
| 145 | - return $classes; | |
| 146 | 101 | } |
| 147 | 102 | } |