Addons.php
4 years ago
Admin.php
4 years ago
Ajax.php
4 years ago
Announcements.php
4 years ago
Assets.php
4 years ago
Backend_Page_Trait.php
4 years ago
Course.php
4 years ago
Course_Filter.php
4 years ago
Course_List.php
4 years ago
Course_Settings_Tabs.php
4 years ago
Course_Widget.php
4 years ago
Custom_Validation.php
4 years ago
Dashboard.php
4 years ago
FormHandler.php
4 years ago
Frontend.php
4 years ago
Gutenberg.php
4 years ago
Input.php
4 years ago
Instructor.php
4 years ago
Instructors_List.php
4 years ago
Lesson.php
4 years ago
Options_V2.php
4 years ago
Post_types.php
4 years ago
Private_Course_Access.php
4 years ago
Q_and_A.php
4 years ago
Question_Answers_List.php
4 years ago
Quiz.php
4 years ago
Quiz_Attempts_List.php
4 years ago
RestAPI.php
4 years ago
Reviews.php
4 years ago
Rewrite_Rules.php
4 years ago
Shortcode.php
4 years ago
Student.php
4 years ago
Students_List.php
4 years ago
Taxonomies.php
4 years ago
Template.php
4 years ago
Theme_Compatibility.php
5 years ago
Tools.php
4 years ago
Tools_V2.php
4 years ago
Tutor.php
4 years ago
TutorEDD.php
4 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
4 years ago
Tutor_Setup.php
4 years ago
Upgrader.php
4 years ago
User.php
4 years ago
Utils.php
4 years ago
Video_Stream.php
4 years ago
Withdraw.php
4 years ago
Withdraw_Requests_List.php
4 years ago
WooCommerce.php
4 years ago
Admin.php
538 lines
| 1 | <?php |
| 2 | |
| 3 | namespace TUTOR; |
| 4 | |
| 5 | use TUTOR\Input; |
| 6 | |
| 7 | /** |
| 8 | * Class Admin |
| 9 | * |
| 10 | * @package TUTOR |
| 11 | * |
| 12 | * @since v.1.0.0 |
| 13 | */ |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | class Admin { |
| 20 | public function __construct() { |
| 21 | add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
| 22 | // Force activate menu for necessary |
| 23 | add_filter( 'parent_file', array( $this, 'parent_menu_active' ) ); |
| 24 | add_filter( 'submenu_file', array( $this, 'submenu_file_active' ), 10, 2 ); |
| 25 | |
| 26 | add_action( 'admin_init', array( $this, 'filter_posts_for_instructors' ) ); |
| 27 | add_action( 'load-post.php', array( $this, 'check_if_current_users_post' ) ); |
| 28 | |
| 29 | add_action( 'admin_action_uninstall_tutor_and_erase', array( $this, 'erase_tutor_data' ) ); |
| 30 | add_filter( 'plugin_action_links_' . plugin_basename( TUTOR_FILE ), array( $this, 'plugin_action_links' ) ); |
| 31 | |
| 32 | // Plugin Row Meta |
| 33 | add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); |
| 34 | |
| 35 | // Admin Footer Text |
| 36 | add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
| 37 | // Register Course Widget |
| 38 | add_action( 'widgets_init', array( $this, 'register_course_widget' ) ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Register admin menus |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | public function register_menu() { |
| 47 | $hasPro = tutor()->has_pro; |
| 48 | |
| 49 | $unanswered_questions = tutor_utils()->unanswered_question_count(); |
| 50 | $unanswered_bubble = ''; |
| 51 | if ( $unanswered_questions ) { |
| 52 | $unanswered_bubble = '<span class="update-plugins count-' . $unanswered_questions . '"><span class="plugin-count">' . $unanswered_questions . '</span></span>'; |
| 53 | } |
| 54 | |
| 55 | $course_post_type = tutor()->course_post_type; |
| 56 | |
| 57 | $pro_text = ''; |
| 58 | if ( $hasPro ) { |
| 59 | $pro_text = ' ' . __( 'Pro', 'tutor' ); |
| 60 | } |
| 61 | |
| 62 | $enable_course_marketplace = (bool) tutor_utils()->get_option( 'enable_course_marketplace' ); |
| 63 | |
| 64 | $welcome = Tutor_Setup::is_welcome_page_visited(); |
| 65 | |
| 66 | $root_page = array( $this, 'tutor_course_list' ); |
| 67 | if ( false === $welcome && Input::has( 'page' ) && 'tutor' === Input::get( 'page' ) && Input::has( 'welcome' ) ) { |
| 68 | $root_page = array( $this, 'welcome_page' ); |
| 69 | } |
| 70 | |
| 71 | $icon_base64_uri = 'data:image/svg+xml;base64,' . base64_encode( '<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1139"><defs/><path fill-rule="evenodd" clip-rule="evenodd" d="M341.652 622.4c-23.412 0-43.222-19.8-43.222-43.2v-99c0-23.4 19.81-43.2 43.222-43.2 23.412 0 43.222 19.8 43.222 43.2v99c0 23.4-18.009 43.2-43.222 43.2 1.801 0 1.801 0 0 0zM655.01 622.4c-23.412 0-43.222-18-43.222-43.2v-99c0-23.4 19.81-43.2 43.222-43.2 23.412 0 43.222 19.8 43.222 43.2v99c0 25.2-19.81 43.2-43.222 43.2z" fill="#9DA2A8"/><path fill-rule="evenodd" clip-rule="evenodd" d="M255.204 406.4c18.009-37.8 54.028-63 95.449-63 61.231 1.8 108.055 52.2 106.254 113.4v203.4c3.602 21.6 23.412 37.8 45.023 34.2 18.009-1.8 32.416-16.2 34.217-34.2V455c-1.801-61.2 46.824-111.6 106.254-113.4 39.621 0 75.639 21.6 93.648 59.4 68.435 133.2 14.407 295.2-117.06 363.6C487.523 833 325.44 779 258.806 647.6c-39.62-75.6-39.62-165.6-3.602-241.2zM426.291 140h151.277v59.4c-25.212-5.4-52.226-9-77.439-9-25.213 0-50.426 3.6-75.639 7.2l1.801-57.6zm414.211 388.8c0-122.4-66.634-235.8-172.888-295.2V140h64.833c25.213 0 45.023-19.8 45.023-45s-21.611-45-45.023-45H271.413C246.2 51.8 226.39 71.6 226.39 96.8c0 25.2 19.81 45 45.023 45h66.633v91.8c-163.883 90-230.517 298.8-135.068 459 3.602 5.4-3.602-5.4 0 0C338.046 930.2 687.424 948.2 802.683 950c10.805 0 19.81-3.6 27.014-10.8 7.203-7.2 10.805-18 10.805-27V528.8z" fill="#9DA2A8"/></svg>' ); |
| 72 | $menu_position = 2; |
| 73 | |
| 74 | add_menu_page( |
| 75 | __( 'Tutor LMS', 'tutor' ) . $pro_text, |
| 76 | __( 'Tutor LMS', 'tutor' ) . $pro_text, |
| 77 | 'manage_tutor_instructor', |
| 78 | 'tutor', |
| 79 | $root_page, |
| 80 | $icon_base64_uri, |
| 81 | $menu_position |
| 82 | ); |
| 83 | |
| 84 | // @since v2.0.0 |
| 85 | add_submenu_page( 'tutor', __( 'Courses', 'tutor' ), __( 'Courses', 'tutor' ), 'manage_tutor_instructor', 'tutor', array( $this, 'tutor_course_list' ) ); |
| 86 | |
| 87 | add_submenu_page( 'tutor', __( 'Categories', 'tutor' ), __( 'Categories', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type, null ); |
| 88 | |
| 89 | add_submenu_page( 'tutor', __( 'Tags', 'tutor' ), __( 'Tags', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type, null ); |
| 90 | |
| 91 | add_submenu_page( 'tutor', __( 'Students', 'tutor' ), __( 'Students', 'tutor' ), 'manage_tutor', Students_List::STUDENTS_LIST_PAGE, array( $this, 'tutor_students' ) ); |
| 92 | |
| 93 | if ( $enable_course_marketplace ) { |
| 94 | add_submenu_page( 'tutor', __( 'Instructors', 'tutor' ), __( 'Instructors', 'tutor' ), 'manage_tutor', Instructors_List::INSTRUCTOR_LIST_PAGE, array( $this, 'tutor_instructors' ) ); |
| 95 | } |
| 96 | |
| 97 | add_submenu_page( 'tutor', __( 'Announcements', 'tutor' ), __( 'Announcements', 'tutor' ), 'manage_tutor_instructor', 'tutor_announcements', array( $this, 'tutor_announcements' ) ); |
| 98 | |
| 99 | add_submenu_page( 'tutor', __( 'Q & A', 'tutor' ), __( 'Q & A ', 'tutor' ) . $unanswered_bubble, 'manage_tutor_instructor', Question_Answers_List::Question_Answer_PAGE, array( $this, 'question_answer' ) ); |
| 100 | |
| 101 | add_submenu_page( 'tutor', __( 'Quiz Attempts', 'tutor' ), __( 'Quiz Attempts', 'tutor' ), 'manage_tutor_instructor', Quiz_Attempts_List::QUIZ_ATTEMPT_PAGE, array( $this, 'quiz_attempts' ) ); |
| 102 | |
| 103 | if ( $enable_course_marketplace ) { |
| 104 | add_submenu_page( 'tutor', __( 'Withdraw Requests', 'tutor' ), __( 'Withdraw Requests', 'tutor' ), 'manage_tutor', Withdraw_Requests_List::WITHDRAW_REQUEST_LIST_PAGE, array( $this, 'withdraw_requests' ) ); |
| 105 | } |
| 106 | |
| 107 | add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), __( 'Add-ons', 'tutor' ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) ); |
| 108 | |
| 109 | do_action( 'tutor_admin_register' ); |
| 110 | |
| 111 | add_submenu_page( 'tutor', __( 'Tools', 'tutor' ), __( 'Tools', 'tutor' ), 'manage_tutor', 'tutor-tools', array( new \TUTOR\Tools_V2(), 'load_tools_page' ) ); |
| 112 | |
| 113 | add_submenu_page( 'tutor', __( 'Settings', 'tutor' ), __( 'Settings', 'tutor' ), 'manage_tutor', 'tutor_settings', array( new \TUTOR\Options_V2(), 'load_settings_page' ) ); |
| 114 | |
| 115 | if ( ! $hasPro ) { |
| 116 | add_submenu_page( 'tutor', __( 'Get Pro', 'tutor' ), __( '<span class="dashicons dashicons-awards tutor-get-pro-text"></span> Get Pro', 'tutor' ), 'manage_options', 'tutor-get-pro', array( $this, 'tutor_get_pro' ) ); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | public function tutor_students() { |
| 121 | include tutor()->path . 'views/pages/students.php'; |
| 122 | } |
| 123 | |
| 124 | public function tutor_instructors() { |
| 125 | include tutor()->path . 'views/pages/instructors.php'; |
| 126 | } |
| 127 | |
| 128 | public function tutor_announcements() { |
| 129 | include tutor()->path . 'views/pages/announcements.php'; |
| 130 | } |
| 131 | |
| 132 | public function question_answer() { |
| 133 | include tutor()->path . 'views/pages/question_answer.php'; |
| 134 | } |
| 135 | |
| 136 | public function quiz_attempts() { |
| 137 | include tutor()->path . 'views/pages/quiz_attempts.php'; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Show the withdraw requests table |
| 142 | * |
| 143 | * @since v.1.2.0 |
| 144 | */ |
| 145 | public function withdraw_requests() { |
| 146 | include tutor()->path . 'views/pages/withdraw_requests.php'; |
| 147 | } |
| 148 | |
| 149 | public function enable_disable_addons() { |
| 150 | |
| 151 | if ( defined( 'TUTOR_PRO_VERSION' ) ) { |
| 152 | include tutor()->path . 'views/pages/enable_disable_addons.php'; |
| 153 | } else { |
| 154 | include tutor()->path . 'views/pages/tutor-pro-addons.php'; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | public function tutor_tools_old() { |
| 159 | $tutor_admin_tools_page = Input::get( 'tutor_admin_tools_page' ); |
| 160 | if ( $tutor_admin_tools_page ) { |
| 161 | include apply_filters( 'tutor_admin_tools_page', tutor()->path . "views/pages/{$tutor_admin_tools_page}.php", $tutor_admin_tools_page ); |
| 162 | } else { |
| 163 | $pages = apply_filters( |
| 164 | 'tutor_tool_pages', |
| 165 | array( |
| 166 | 'tutor_pages' => array( 'title' => __( 'Tutor Pages', 'tutor' ) ), |
| 167 | 'status' => __( 'Status', 'tutor' ), |
| 168 | ) |
| 169 | ); |
| 170 | |
| 171 | $current_page = 'tutor_pages'; |
| 172 | $requested_page = Input::get( 'sub_page' ); |
| 173 | if ( $requested_page ) { |
| 174 | $current_page = $requested_page; |
| 175 | } |
| 176 | |
| 177 | $current_page = str_replace( '/', '', $current_page ); |
| 178 | $current_page = str_replace( '.', '', $current_page ); |
| 179 | $current_page = str_replace( '\\', '', $current_page ); |
| 180 | $current_page = trim( $current_page ); |
| 181 | |
| 182 | include tutor()->path . 'views/pages/tools.php'; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | public function tutor_get_pro() { |
| 187 | include tutor()->path . 'views/pages/get-pro.php'; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Parent menu active |
| 192 | * |
| 193 | * @param string $parent_file |
| 194 | * @return string |
| 195 | */ |
| 196 | public function parent_menu_active( $parent_file ) { |
| 197 | $taxonomy = Input::get( 'taxonomy' ); |
| 198 | if ( $taxonomy === 'course-category' || $taxonomy === 'course-tag' ) { |
| 199 | return 'tutor'; |
| 200 | } |
| 201 | |
| 202 | return $parent_file; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Sub-menu active |
| 207 | * |
| 208 | * @param string $submenu_file |
| 209 | * @param string $parent_file |
| 210 | * @return string |
| 211 | */ |
| 212 | public function submenu_file_active( $submenu_file, $parent_file ) { |
| 213 | $taxonomy = Input::get( 'taxonomy' ); |
| 214 | $course_post_type = tutor()->course_post_type; |
| 215 | |
| 216 | if ( $taxonomy === 'course-category' ) { |
| 217 | return 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type; |
| 218 | } |
| 219 | if ( $taxonomy === 'course-tag' ) { |
| 220 | return 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type; |
| 221 | } |
| 222 | |
| 223 | return $submenu_file; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Filter posts for instructor |
| 228 | */ |
| 229 | public function filter_posts_for_instructors() { |
| 230 | if ( ! current_user_can( 'administrator' ) && current_user_can( tutor()->instructor_role ) ) { |
| 231 | @remove_menu_page( 'edit-comments.php' ); // Comments |
| 232 | add_filter( 'posts_clauses_request', array( $this, 'posts_clauses_request' ) ); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | public function posts_clauses_request( $clauses ) { |
| 237 | |
| 238 | if ( ! is_admin() || ( ! Input::has( 'post_type' ) || Input::get( 'post_type' ) != tutor()->course_post_type ) || tutor_utils()->has_user_role( array( 'administrator', 'editor' ) ) ) { |
| 239 | return $clauses; |
| 240 | } |
| 241 | |
| 242 | // Need multi instructor check |
| 243 | global $wpdb; |
| 244 | |
| 245 | $user_id = get_current_user_id(); |
| 246 | |
| 247 | $get_assigned_courses_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value from {$wpdb->usermeta} WHERE meta_key = '_tutor_instructor_course_id' AND user_id = %d", $user_id ) ); |
| 248 | $own_courses = is_array( $get_assigned_courses_ids ) ? $get_assigned_courses_ids : array(); |
| 249 | |
| 250 | $in_query_pre = count( $own_courses ) ? implode( ',', $own_courses ) : null; |
| 251 | $in_query_where = $in_query_pre ? " OR {$wpdb->posts}.ID IN({$in_query_pre})" : ''; |
| 252 | |
| 253 | $course_post_type = tutor()->course_post_type; |
| 254 | $custom_author_query = " AND ({$wpdb->posts}.post_type!='{$course_post_type}' OR {$wpdb->posts}.post_author = {$user_id}) {$in_query_where}"; |
| 255 | |
| 256 | $clauses['where'] .= $custom_author_query; |
| 257 | |
| 258 | return $clauses; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Prevent unauthorised course/lesson edit page by direct URL |
| 263 | * |
| 264 | * @since v.1.0.0 |
| 265 | */ |
| 266 | public function check_if_current_users_post() { |
| 267 | if ( current_user_can( 'administrator' ) || ! current_user_can( tutor()->instructor_role ) ) { |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | if ( ! empty( Input::get( 'post' ) ) ) { |
| 272 | $get_post_id = Input::get( 'post', Input::TYPE_INT ); |
| 273 | $get_post = get_post( $get_post_id ); |
| 274 | $tutor_post_types = array( tutor()->course_post_type, tutor()->lesson_post_type ); |
| 275 | |
| 276 | $current_user = get_current_user_id(); |
| 277 | |
| 278 | if ( in_array( $get_post->post_type, $tutor_post_types ) && $get_post->post_author != $current_user ) { |
| 279 | global $wpdb; |
| 280 | |
| 281 | $get_assigned_courses_ids = (int) $wpdb->get_var( |
| 282 | $wpdb->prepare( |
| 283 | "SELECT user_id |
| 284 | from {$wpdb->usermeta} |
| 285 | WHERE user_id = %d AND meta_key = '_tutor_instructor_course_id' AND meta_value = %d ", |
| 286 | $current_user, |
| 287 | $get_post_id |
| 288 | ) |
| 289 | ); |
| 290 | |
| 291 | if ( ! $get_assigned_courses_ids ) { |
| 292 | wp_die( __( 'Permission Denied', 'tutor' ) ); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Status |
| 300 | */ |
| 301 | |
| 302 | public static function scan_template_files( $template_path = null ) { |
| 303 | if ( ! $template_path ) { |
| 304 | $template_path = tutor()->path . 'templates/'; |
| 305 | } |
| 306 | |
| 307 | $files = @scandir($template_path); // @codingStandardsIgnoreLine. |
| 308 | $result = array(); |
| 309 | |
| 310 | if ( ! empty( $files ) ) { |
| 311 | foreach ( $files as $key => $value ) { |
| 312 | if ( ! in_array( $value, array( '.', '..', '.DS_Store' ), true ) ) { |
| 313 | if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { |
| 314 | $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); |
| 315 | foreach ( $sub_files as $sub_file ) { |
| 316 | $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; |
| 317 | } |
| 318 | } else { |
| 319 | $result[] = $value; |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | return $result; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Get Template overridden files |
| 329 | * |
| 330 | * @return array |
| 331 | */ |
| 332 | public static function template_overridden_files() { |
| 333 | $template_files = self::scan_template_files(); |
| 334 | |
| 335 | $override_files = array(); |
| 336 | foreach ( $template_files as $file ) { |
| 337 | $file_path = null; |
| 338 | if ( file_exists( trailingslashit( get_stylesheet_directory() ) . tutor()->template_path . $file ) ) { |
| 339 | $file_path = $file; |
| 340 | } elseif ( file_exists( trailingslashit( get_template_directory() ) . tutor()->template_path . $file ) ) { |
| 341 | $file_path = $file; |
| 342 | } |
| 343 | |
| 344 | if ( $file_path ) { |
| 345 | $override_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $file_path ); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | return $override_files; |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Erase tutor data |
| 354 | * |
| 355 | * @return void |
| 356 | */ |
| 357 | public function erase_tutor_data() { |
| 358 | global $wpdb; |
| 359 | |
| 360 | $is_erase_data = tutor_utils()->get_option( 'delete_on_uninstall' ); |
| 361 | // => Deleting Data |
| 362 | |
| 363 | $plugin_file = tutor()->basename; |
| 364 | if ( $is_erase_data && current_user_can( 'deactivate_plugin', $plugin_file ) ) { |
| 365 | /** |
| 366 | * Deleting Post Type, Meta Data, taxonomy |
| 367 | */ |
| 368 | $course_post_type = tutor()->course_post_type; |
| 369 | $lesson_post_type = tutor()->lesson_post_type; |
| 370 | |
| 371 | $post_types = array( |
| 372 | $course_post_type, |
| 373 | $lesson_post_type, |
| 374 | 'tutor_quiz', |
| 375 | 'tutor_enrolled', |
| 376 | 'topics', |
| 377 | 'tutor_enrolled', |
| 378 | 'tutor_announcements', |
| 379 | ); |
| 380 | |
| 381 | $post_type_strings = "'" . implode( "','", $post_types ) . "'"; |
| 382 | $tutor_posts = $wpdb->get_col( "SELECT ID from {$wpdb->posts} WHERE post_type in({$post_type_strings}) ;" ); |
| 383 | |
| 384 | if ( is_array( $tutor_posts ) && count( $tutor_posts ) ) { |
| 385 | foreach ( $tutor_posts as $post_id ) { |
| 386 | // Delete categories |
| 387 | $terms = wp_get_object_terms( $post_id, 'course-category' ); |
| 388 | foreach ( $terms as $term ) { |
| 389 | wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-category' ); |
| 390 | } |
| 391 | |
| 392 | // Delete tags if available |
| 393 | $terms = wp_get_object_terms( $post_id, 'course-tag' ); |
| 394 | foreach ( $terms as $term ) { |
| 395 | wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-tag' ); |
| 396 | } |
| 397 | |
| 398 | // Delete All Meta |
| 399 | $wpdb->delete( $wpdb->postmeta, array( 'post_id' => $post_id ) ); |
| 400 | $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Deleting Comments (reviews, questions, quiz_answers, etc) |
| 406 | */ |
| 407 | $tutor_comments = $wpdb->get_col( "SELECT comment_ID from {$wpdb->comments} WHERE comment_agent = 'comment_agent' ;" ); |
| 408 | $comments_ids_strings = "'" . implode( "','", $tutor_comments ) . "'"; |
| 409 | if ( is_array( $tutor_comments ) && count( $tutor_comments ) ) { |
| 410 | $wpdb->query( "DELETE from {$wpdb->commentmeta} WHERE comment_ID in({$comments_ids_strings}) " ); |
| 411 | } |
| 412 | $wpdb->delete( $wpdb->comments, array( 'comment_agent' => 'comment_agent' ) ); |
| 413 | |
| 414 | /** |
| 415 | * Delete Options |
| 416 | */ |
| 417 | |
| 418 | delete_option( 'tutor_option' ); |
| 419 | $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_student' ) ); |
| 420 | $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_approved' ) ); |
| 421 | $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_tutor_instructor_status' ) ); |
| 422 | $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => '_is_tutor_instructor' ) ); |
| 423 | $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_tutor_completed_lesson_id_%' " ); |
| 424 | |
| 425 | // Deleting Table |
| 426 | $prefix = $wpdb->prefix; |
| 427 | $wpdb->query( "DROP TABLE IF EXISTS {$prefix}tutor_quiz_attempts, {$prefix}tutor_quiz_attempt_answers, {$prefix}tutor_quiz_questions, {$prefix}tutor_quiz_question_answers, {$prefix}tutor_earnings, {$prefix}tutor_withdraws " ); |
| 428 | |
| 429 | deactivate_plugins( $plugin_file ); |
| 430 | } |
| 431 | |
| 432 | wp_redirect( 'plugins.php' ); |
| 433 | die(); |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * Plugin activation link |
| 438 | * |
| 439 | * @param array $actions |
| 440 | * @return array |
| 441 | */ |
| 442 | public function plugin_action_links( $actions ) { |
| 443 | $hasPro = tutor()->has_pro; |
| 444 | |
| 445 | if ( ! $hasPro ) { |
| 446 | $actions['tutor_pro_link'] = |
| 447 | '<a href="https://www.themeum.com/product/tutor-lms/#pricing?utm_source=tutor_plugin_action_link&utm_medium=wordpress_dashboard&utm_campaign=go_premium" target="_blank"> |
| 448 | <span style="color: #ff7742; font-weight: bold;">' . |
| 449 | __( 'Upgrade to Pro', 'wp-megamenu' ) . |
| 450 | '</span> |
| 451 | </a>'; |
| 452 | } |
| 453 | |
| 454 | $actions['settings'] = '<a href="admin.php?page=tutor_settings">' . __( 'Settings', 'tutor' ) . '</a>'; |
| 455 | |
| 456 | return $actions; |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Add plugin meta data in WP plugins list page |
| 461 | * |
| 462 | * @param array $plugin_meta |
| 463 | * @param string $plugin_file |
| 464 | * @return array |
| 465 | */ |
| 466 | public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 467 | |
| 468 | if ( $plugin_file === tutor()->basename ) { |
| 469 | $plugin_meta[] = sprintf( |
| 470 | '<a href="%s">%s</a>', |
| 471 | esc_url( 'https://docs.themeum.com/tutor-lms/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ), |
| 472 | __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor' ) |
| 473 | ); |
| 474 | $plugin_meta[] = sprintf( |
| 475 | '<a href="%s">%s</a>', |
| 476 | esc_url( 'https://www.themeum.com/contact-us/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ), |
| 477 | __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor' ) |
| 478 | ); |
| 479 | } |
| 480 | |
| 481 | return $plugin_meta; |
| 482 | } |
| 483 | |
| 484 | /** |
| 485 | * @param $footer_text |
| 486 | * |
| 487 | * @return string |
| 488 | * |
| 489 | * Add footer text only on tutor pages |
| 490 | */ |
| 491 | public function admin_footer_text( $footer_text ) { |
| 492 | $current_screen = get_current_screen(); |
| 493 | |
| 494 | /** |
| 495 | * We are making sure that this message will be only on Tutor Admin page |
| 496 | */ |
| 497 | if ( apply_filters( 'tutor_display_admin_footer_text', ( tutor_utils()->array_get( 'parent_base', $current_screen ) === 'tutor' ) ) ) { |
| 498 | $footer_text = sprintf( |
| 499 | __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'tutor' ), |
| 500 | sprintf( '<strong>%s</strong>', esc_html__( 'Tutor LMS', 'tutor' ) ), |
| 501 | '<a href="https://wordpress.org/support/plugin/tutor/reviews?rate=5#new-post" target="_blank" class="tutor-rating-link">★★★★★</a>' |
| 502 | ); |
| 503 | } |
| 504 | |
| 505 | return $footer_text; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Register course widget |
| 510 | * |
| 511 | * @return void |
| 512 | */ |
| 513 | public function register_course_widget() { |
| 514 | register_widget( 'Tutor\Course_Widget' ); |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Tutor Course List |
| 519 | * |
| 520 | * @package Course List |
| 521 | * @since v2.0.0 |
| 522 | */ |
| 523 | public function tutor_course_list() { |
| 524 | include tutor()->path . 'views/pages/course-list.php'; |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Show welcome page |
| 529 | * |
| 530 | * @return void |
| 531 | */ |
| 532 | public function welcome_page() { |
| 533 | Tutor_Setup::mark_as_visited(); |
| 534 | include tutor()->path . 'views/pages/welcome.php'; |
| 535 | exit; |
| 536 | } |
| 537 | } |
| 538 |