Addons.php
5 years ago
Admin.php
5 years ago
Ajax.php
5 years ago
Assets.php
5 years ago
Course.php
5 years ago
Course_Filter.php
5 years ago
Course_Settings_Tabs.php
5 years ago
Course_Widget.php
5 years ago
Custom_Validation.php
5 years ago
Dashboard.php
5 years ago
Email.php
5 years ago
FormHandler.php
5 years ago
Frontend.php
5 years ago
Gutenberg.php
5 years ago
Instructor.php
5 years ago
Instructors_List.php
5 years ago
Lesson.php
5 years ago
Options.php
5 years ago
Post_types.php
5 years ago
Private_Course_Access.php
5 years ago
Q_and_A.php
5 years ago
Question_Answers_List.php
5 years ago
Quiz.php
5 years ago
Quiz_Attempts_List.php
5 years ago
RestAPI.php
5 years ago
Rewrite_Rules.php
5 years ago
Shortcode.php
5 years ago
Student.php
5 years ago
Students_List.php
5 years ago
Taxonomies.php
5 years ago
Template.php
5 years ago
Theme_Compatibility.php
5 years ago
Tools.php
5 years ago
Tutor.php
5 years ago
TutorEDD.php
5 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
5 years ago
Tutor_Setup.php
5 years ago
Upgrader.php
5 years ago
User.php
5 years ago
Utils.php
5 years ago
Video_Stream.php
5 years ago
Withdraw.php
5 years ago
Withdraw_Requests_List.php
5 years ago
WooCommerce.php
5 years ago
Admin.php
502 lines
| 1 | <?php |
| 2 | namespace TUTOR; |
| 3 | |
| 4 | /** |
| 5 | * Class Admin |
| 6 | * @package TUTOR |
| 7 | * |
| 8 | * @since v.1.0.0 |
| 9 | */ |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) |
| 12 | exit; |
| 13 | |
| 14 | class Admin{ |
| 15 | public function __construct() { |
| 16 | add_action('admin_menu', array($this, 'register_menu')); |
| 17 | //Force activate menu for necessary |
| 18 | add_filter('parent_file', array($this, 'parent_menu_active')); |
| 19 | add_filter('submenu_file', array($this, 'submenu_file_active'), 10, 2); |
| 20 | |
| 21 | add_action('admin_init', array($this, 'filter_posts_for_instructors')); |
| 22 | add_action('load-post.php', array($this, 'check_if_current_users_post') ); |
| 23 | |
| 24 | add_action('admin_action_uninstall_tutor_and_erase', array($this, 'erase_tutor_data')); |
| 25 | add_filter('plugin_action_links_' . plugin_basename(TUTOR_FILE), array( $this, 'plugin_action_links' ) ); |
| 26 | |
| 27 | //Plugin Row Meta |
| 28 | add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
| 29 | |
| 30 | //Admin Footer Text |
| 31 | add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
| 32 | //Register Course Widget |
| 33 | add_action( 'widgets_init', array($this, 'register_course_widget') ); |
| 34 | } |
| 35 | |
| 36 | public function register_menu(){ |
| 37 | $hasPro = tutor()->has_pro; |
| 38 | |
| 39 | $unanswered_questions = tutor_utils()->unanswered_question_count(); |
| 40 | $unanswered_bubble = ''; |
| 41 | if ($unanswered_questions){ |
| 42 | $unanswered_bubble = '<span class="update-plugins count-'.$unanswered_questions.'"><span class="plugin-count">'.$unanswered_questions.'</span></span>'; |
| 43 | } |
| 44 | |
| 45 | $course_post_type = tutor()->course_post_type; |
| 46 | |
| 47 | $pro_text = ''; |
| 48 | if ($hasPro){ |
| 49 | $pro_text = ' '.__('Pro', 'tutor'); |
| 50 | } |
| 51 | |
| 52 | $enable_course_marketplace = (bool) tutils()->get_option('enable_course_marketplace'); |
| 53 | |
| 54 | add_menu_page(__('Tutor LMS', 'tutor').$pro_text, __('Tutor LMS', 'tutor').$pro_text, 'manage_tutor_instructor', 'tutor', null, |
| 55 | '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>'), 2); |
| 56 | add_submenu_page('tutor', __('Categories', 'tutor'), __('Categories', 'tutor'), 'manage_tutor', 'edit-tags.php?taxonomy=course-category&post_type='.$course_post_type, null ); |
| 57 | |
| 58 | add_submenu_page('tutor', __('Tags', 'tutor'), __('Tags', 'tutor'), 'manage_tutor', 'edit-tags.php?taxonomy=course-tag&post_type='.$course_post_type, null ); |
| 59 | |
| 60 | add_submenu_page('tutor', __('Students', 'tutor'), __('Students', 'tutor'), 'manage_tutor', 'tutor-students', array($this, 'tutor_students') ); |
| 61 | |
| 62 | if ($enable_course_marketplace) { |
| 63 | add_submenu_page('tutor', __('Instructors', 'tutor'), __('Instructors', 'tutor'), 'manage_tutor', 'tutor-instructors', array($this, 'tutor_instructors')); |
| 64 | } |
| 65 | |
| 66 | add_submenu_page('tutor', __('Announcements', 'tutor'), __('Announcements', 'tutor'), 'manage_tutor_instructor', 'tutor_announcements', array($this, 'tutor_announcements')); |
| 67 | |
| 68 | add_submenu_page('tutor', __('Q & A', 'tutor'), __('Q & A '.$unanswered_bubble, 'tutor'), 'manage_tutor_instructor', 'question_answer', array($this, 'question_answer') ); |
| 69 | |
| 70 | add_submenu_page('tutor', __('Quiz Attempts', 'tutor'), __('Quiz Attempts', 'tutor'), 'manage_tutor_instructor', 'tutor_quiz_attempts',array($this, 'quiz_attempts') ); |
| 71 | |
| 72 | if ($enable_course_marketplace){ |
| 73 | add_submenu_page('tutor', __('Withdraw Requests', 'tutor'), __('Withdraw Requests', 'tutor'), 'manage_tutor_instructor', 'tutor_withdraw_requests', array($this, 'withdraw_requests') ); |
| 74 | } |
| 75 | |
| 76 | add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), __( 'Add-ons', 'tutor' ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) ); |
| 77 | |
| 78 | do_action('tutor_admin_register'); |
| 79 | |
| 80 | add_submenu_page('tutor', __('Settings', 'tutor'), __('Settings', 'tutor'), 'manage_tutor', 'tutor_settings', array($this, 'tutor_page') ); |
| 81 | |
| 82 | add_submenu_page('tutor', __('Tools', 'tutor'), __('Tools', 'tutor'), 'manage_tutor', 'tutor-tools', array($this, 'tutor_tools') ); |
| 83 | |
| 84 | if ( ! $hasPro){ |
| 85 | 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') ); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | public function tutor_page(){ |
| 90 | $tutor_option = new Options(); |
| 91 | echo apply_filters('tutor/options/generated-html', $tutor_option->generate()); |
| 92 | } |
| 93 | |
| 94 | public function tutor_students(){ |
| 95 | include tutor()->path.'views/pages/students.php'; |
| 96 | } |
| 97 | |
| 98 | public function tutor_instructors(){ |
| 99 | include tutor()->path.'views/pages/instructors.php'; |
| 100 | } |
| 101 | |
| 102 | public function tutor_announcements(){ |
| 103 | include tutor()->path.'views/pages/announcements.php'; |
| 104 | } |
| 105 | |
| 106 | public function question_answer(){ |
| 107 | include tutor()->path.'views/pages/question_answer.php'; |
| 108 | } |
| 109 | |
| 110 | public function quiz_attempts(){ |
| 111 | include tutor()->path.'views/pages/quiz_attempts.php'; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Show the withdraw requests table |
| 116 | * |
| 117 | * @since v.1.2.0 |
| 118 | */ |
| 119 | public function withdraw_requests(){ |
| 120 | include tutor()->path.'views/pages/withdraw_requests.php'; |
| 121 | } |
| 122 | |
| 123 | public function enable_disable_addons(){ |
| 124 | |
| 125 | if (defined('TUTOR_PRO_VERSION')) { |
| 126 | include tutor()->path.'views/pages/enable_disable_addons.php'; |
| 127 | }else{ |
| 128 | include tutor()->path.'views/pages/tutor-pro-addons.php'; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | public function tutor_tools(){ |
| 133 | $tutor_admin_tools_page = tutils()->array_get('tutor_admin_tools_page', $_GET); |
| 134 | if ($tutor_admin_tools_page){ |
| 135 | include apply_filters('tutor_admin_tools_page', tutor()->path."views/pages/{$tutor_admin_tools_page}.php", $tutor_admin_tools_page); |
| 136 | }else{ |
| 137 | $pages = apply_filters('tutor_tool_pages', array( |
| 138 | 'tutor_pages' => array('title' => __('Tutor Pages', 'tutor') ), |
| 139 | 'status' => __('Status', 'tutor'), |
| 140 | )); |
| 141 | |
| 142 | $current_page = 'tutor_pages'; |
| 143 | $requested_page = sanitize_text_field(tutils()->array_get('sub_page', $_GET)); |
| 144 | if ($requested_page){ |
| 145 | $current_page = $requested_page; |
| 146 | } |
| 147 | |
| 148 | $current_page = str_replace('/', '', $current_page); |
| 149 | $current_page = str_replace('.', '', $current_page); |
| 150 | $current_page = str_replace('\\', '', $current_page); |
| 151 | $current_page = trim($current_page); |
| 152 | |
| 153 | include tutor()->path.'views/pages/tools.php'; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | public function tutor_get_pro(){ |
| 158 | include tutor()->path.'views/pages/get-pro.php'; |
| 159 | } |
| 160 | |
| 161 | public function parent_menu_active( $parent_file ){ |
| 162 | $taxonomy = tutor_utils()->avalue_dot('taxonomy', $_GET); |
| 163 | if ($taxonomy === 'course-category' || $taxonomy === 'course-tag'){ |
| 164 | return 'tutor'; |
| 165 | } |
| 166 | |
| 167 | return $parent_file; |
| 168 | } |
| 169 | |
| 170 | public function submenu_file_active($submenu_file, $parent_file){ |
| 171 | $taxonomy = tutor_utils()->avalue_dot('taxonomy', $_GET); |
| 172 | $course_post_type = tutor()->course_post_type; |
| 173 | |
| 174 | if ($taxonomy === 'course-category'){ |
| 175 | return 'edit-tags.php?taxonomy=course-category&post_type='.$course_post_type; |
| 176 | } |
| 177 | if ($taxonomy === 'course-tag'){ |
| 178 | return 'edit-tags.php?taxonomy=course-tag&post_type='.$course_post_type; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | return $submenu_file; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Filter posts for instructor |
| 187 | */ |
| 188 | public function filter_posts_for_instructors(){ |
| 189 | if ( ! current_user_can('administrator') && current_user_can(tutor()->instructor_role)){ |
| 190 | @remove_menu_page( 'edit-comments.php' ); //Comments |
| 191 | add_filter( 'posts_clauses_request', array($this, 'posts_clauses_request') ); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | public function posts_clauses_request($clauses){ |
| 196 | |
| 197 | $user = wp_get_current_user(); |
| 198 | |
| 199 | if (in_array( 'administrator', $user->roles ) ) { |
| 200 | return $clauses; |
| 201 | } |
| 202 | |
| 203 | global $wpdb; |
| 204 | |
| 205 | $user_id = get_current_user_id(); |
| 206 | |
| 207 | $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)); |
| 208 | $own_courses = is_array($get_assigned_courses_ids) ? $get_assigned_courses_ids : array(); |
| 209 | $in_query_pre = implode(',', $own_courses); |
| 210 | |
| 211 | $custom_author_query = " AND ({$wpdb->posts}.post_type!='courses' OR {$wpdb->posts}.post_author = {$user_id} OR {$wpdb->posts}.ID IN({$in_query_pre})) "; |
| 212 | |
| 213 | $clauses['where'] .= $custom_author_query; |
| 214 | |
| 215 | return $clauses; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Prevent unauthorised course/lesson edit page by direct URL |
| 220 | * |
| 221 | * @since v.1.0.0 |
| 222 | */ |
| 223 | public function check_if_current_users_post(){ |
| 224 | if (current_user_can('administrator') || ! current_user_can(tutor()->instructor_role)) { |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | if (! empty($_GET['post']) ) { |
| 229 | $get_post_id = (int) sanitize_text_field($_GET['post']); |
| 230 | $get_post = get_post($get_post_id); |
| 231 | $tutor_post_types = array(tutor()->course_post_type, tutor()->lesson_post_type); |
| 232 | |
| 233 | $current_user = get_current_user_id(); |
| 234 | |
| 235 | if (in_array($get_post->post_type, $tutor_post_types) && $get_post->post_author != $current_user){ |
| 236 | global $wpdb; |
| 237 | |
| 238 | $get_assigned_courses_ids = (int) $wpdb->get_var($wpdb->prepare( |
| 239 | "SELECT user_id |
| 240 | from {$wpdb->usermeta} |
| 241 | WHERE user_id = %d AND meta_key = '_tutor_instructor_course_id' AND meta_value = %d ", $current_user, $get_post_id)); |
| 242 | |
| 243 | if ( ! $get_assigned_courses_ids){ |
| 244 | wp_die(__('Permission Denied', 'tutor')); |
| 245 | } |
| 246 | |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Status |
| 253 | */ |
| 254 | |
| 255 | public static function scan_template_files( $template_path = null ) { |
| 256 | if ( ! $template_path){ |
| 257 | $template_path = tutor()->path.'templates/'; |
| 258 | } |
| 259 | |
| 260 | $files = @scandir( $template_path ); // @codingStandardsIgnoreLine. |
| 261 | $result = array(); |
| 262 | |
| 263 | if ( ! empty( $files ) ) { |
| 264 | foreach ( $files as $key => $value ) { |
| 265 | if ( ! in_array( $value, array( '.', '..', '.DS_Store' ), true ) ) { |
| 266 | if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { |
| 267 | $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); |
| 268 | foreach ( $sub_files as $sub_file ) { |
| 269 | $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; |
| 270 | } |
| 271 | } else { |
| 272 | $result[] = $value; |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | return $result; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * @return array |
| 282 | * |
| 283 | * |
| 284 | */ |
| 285 | public static function template_overridden_files(){ |
| 286 | $template_files = self::scan_template_files(); |
| 287 | |
| 288 | $override_files = array(); |
| 289 | foreach ($template_files as $file){ |
| 290 | $file_path = null; |
| 291 | if (file_exists(trailingslashit(get_stylesheet_directory()).tutor()->template_path.$file)){ |
| 292 | $file_path = $file; |
| 293 | }elseif (file_exists(trailingslashit(get_template_directory()).tutor()->template_path.$file)){ |
| 294 | $file_path = $file; |
| 295 | } |
| 296 | |
| 297 | if ($file_path){ |
| 298 | $override_files[] = str_replace( WP_CONTENT_DIR.'/themes/', '', $file_path ); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | return $override_files; |
| 303 | } |
| 304 | |
| 305 | public static function get_environment_info(){ |
| 306 | |
| 307 | // Figure out cURL version, if installed. |
| 308 | $curl_version = ''; |
| 309 | if ( function_exists( 'curl_version' ) ) { |
| 310 | $curl_version = curl_version(); |
| 311 | $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | // WP memory limit. |
| 316 | $wp_memory_limit = tutor_utils()->let_to_num(WP_MEMORY_LIMIT); |
| 317 | if ( function_exists( 'memory_get_usage' ) ) { |
| 318 | $wp_memory_limit = max( $wp_memory_limit, tutor_utils()->let_to_num( @ini_get( 'memory_limit' ) ) ); |
| 319 | } |
| 320 | |
| 321 | $database_version = tutor_utils()->get_db_version(); |
| 322 | |
| 323 | return array( |
| 324 | 'home_url' => get_option( 'home' ), |
| 325 | 'site_url' => get_option( 'siteurl' ), |
| 326 | 'version' => tutor()->version, |
| 327 | 'wp_version' => get_bloginfo( 'version' ), |
| 328 | 'wp_multisite' => is_multisite(), |
| 329 | 'wp_memory_limit' => $wp_memory_limit, |
| 330 | 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
| 331 | 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), |
| 332 | 'language' => get_locale(), |
| 333 | 'external_object_cache' => wp_using_ext_object_cache(), |
| 334 | 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : '', |
| 335 | 'php_version' => phpversion(), |
| 336 | 'php_post_max_size' => tutor_utils()->let_to_num( ini_get( 'post_max_size' ) ), |
| 337 | 'php_max_execution_time' => ini_get( 'max_execution_time' ), |
| 338 | 'php_max_input_vars' => ini_get( 'max_input_vars' ), |
| 339 | 'curl_version' => $curl_version, |
| 340 | 'suhosin_installed' => extension_loaded( 'suhosin' ), |
| 341 | 'max_upload_size' => wp_max_upload_size(), |
| 342 | 'mysql_version' => $database_version['number'], |
| 343 | 'mysql_version_string' => $database_version['string'], |
| 344 | 'default_timezone' => date_default_timezone_get(), |
| 345 | 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), |
| 346 | 'soapclient_enabled' => class_exists( 'SoapClient' ), |
| 347 | 'domdocument_enabled' => class_exists( 'DOMDocument' ), |
| 348 | 'gzip_enabled' => is_callable( 'gzopen' ), |
| 349 | 'mbstring_enabled' => extension_loaded( 'mbstring' ), |
| 350 | ); |
| 351 | } |
| 352 | |
| 353 | |
| 354 | public function erase_tutor_data(){ |
| 355 | global $wpdb; |
| 356 | |
| 357 | $is_erase_data = tutor_utils()->get_option('delete_on_uninstall'); |
| 358 | //=> Deleting Data |
| 359 | |
| 360 | $plugin_file = tutor()->basename; |
| 361 | if ($is_erase_data && current_user_can( 'deactivate_plugin', $plugin_file )) { |
| 362 | /** |
| 363 | * Deleting Post Type, Meta Data, taxonomy |
| 364 | */ |
| 365 | $course_post_type = tutor()->course_post_type; |
| 366 | $lesson_post_type = tutor()->lesson_post_type; |
| 367 | |
| 368 | $post_types = array( |
| 369 | $course_post_type, |
| 370 | $lesson_post_type, |
| 371 | 'tutor_quiz', |
| 372 | 'tutor_enrolled', |
| 373 | 'topics', |
| 374 | 'tutor_enrolled', |
| 375 | 'tutor_announcements', |
| 376 | ); |
| 377 | |
| 378 | $post_type_strings = "'".implode("','", $post_types)."'"; |
| 379 | $tutor_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts} WHERE post_type in({$post_type_strings}) ;"); |
| 380 | |
| 381 | if (is_array($tutor_posts) && count($tutor_posts)){ |
| 382 | foreach ($tutor_posts as $post_id){ |
| 383 | //Delete categories |
| 384 | $terms = wp_get_object_terms( $post_id, 'course-category' ); |
| 385 | foreach( $terms as $term ){ |
| 386 | wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-category' ); |
| 387 | } |
| 388 | |
| 389 | //Delete tags if available |
| 390 | $terms = wp_get_object_terms( $post_id, 'course-tag' ); |
| 391 | foreach( $terms as $term ){ |
| 392 | wp_remove_object_terms( $post_id, array( $term->term_id ), 'course-tag' ); |
| 393 | } |
| 394 | |
| 395 | //Delete All Meta |
| 396 | $wpdb->delete($wpdb->postmeta, array('post_id' => $post_id) ); |
| 397 | $wpdb->delete($wpdb->posts, array('ID' => $post_id) ); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Deleting Comments (reviews, questions, quiz_answers, etc) |
| 403 | */ |
| 404 | $tutor_comments = $wpdb->get_col("SELECT comment_ID from {$wpdb->comments} WHERE comment_agent = 'comment_agent' ;"); |
| 405 | $comments_ids_strings = "'".implode("','", $tutor_comments)."'"; |
| 406 | if (is_array($tutor_comments) && count($tutor_comments)){ |
| 407 | $wpdb->query("DELETE from {$wpdb->commentmeta} WHERE comment_ID in({$comments_ids_strings}) "); |
| 408 | } |
| 409 | $wpdb->delete($wpdb->comments, array('comment_agent' => 'comment_agent')); |
| 410 | |
| 411 | /** |
| 412 | * Delete Options |
| 413 | */ |
| 414 | |
| 415 | delete_option('tutor_option'); |
| 416 | $wpdb->delete($wpdb->usermeta, array('meta_key' => '_is_tutor_student')); |
| 417 | $wpdb->delete($wpdb->usermeta, array('meta_key' => '_tutor_instructor_approved')); |
| 418 | $wpdb->delete($wpdb->usermeta, array('meta_key' => '_tutor_instructor_status')); |
| 419 | $wpdb->delete($wpdb->usermeta, array('meta_key' => '_is_tutor_instructor')); |
| 420 | $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_tutor_completed_lesson_id_%' "); |
| 421 | |
| 422 | //Deleting Table |
| 423 | $prefix = $wpdb->prefix; |
| 424 | $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 "); |
| 425 | |
| 426 | deactivate_plugins($plugin_file); |
| 427 | } |
| 428 | |
| 429 | wp_redirect('plugins.php'); |
| 430 | die(); |
| 431 | } |
| 432 | |
| 433 | public function plugin_action_links($actions){ |
| 434 | $hasPro = tutor()->has_pro; |
| 435 | |
| 436 | if(!$hasPro){ |
| 437 | $actions['tutor_pro_link'] = '<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"><span |
| 438 | style="color: #ff7742; font-weight: bold;">' . __('Upgrade to Pro', 'wp-megamenu') . '</span></a>'; |
| 439 | } |
| 440 | |
| 441 | $is_erase_data = tutor_utils()->get_option('delete_on_uninstall'); |
| 442 | |
| 443 | if ($is_erase_data) { |
| 444 | $plugin_file = tutor()->basename; |
| 445 | if ( current_user_can( 'deactivate_plugin', $plugin_file ) ) { |
| 446 | if ( isset( $actions['deactivate'] ) ) { |
| 447 | $actions['deactivate'] = '<a href="admin.php?page=tutor-tools&tutor_admin_tools_page=uninstall">' . __('Uninstall', 'tutor') . '</a>'; |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | $actions['settings'] = '<a href="admin.php?page=tutor_settings">' . __('Settings', 'tutor') . '</a>'; |
| 453 | return $actions; |
| 454 | } |
| 455 | |
| 456 | public function plugin_row_meta($plugin_meta, $plugin_file){ |
| 457 | |
| 458 | if ($plugin_file === tutor()->basename) { |
| 459 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', |
| 460 | esc_url( 'https://docs.themeum.com/tutor-lms/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ), |
| 461 | __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor' ) |
| 462 | ); |
| 463 | $plugin_meta[] = sprintf( '<a href="%s">%s</a>', |
| 464 | esc_url( 'https://www.themeum.com/contact-us/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ), |
| 465 | __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor' ) |
| 466 | ); |
| 467 | } |
| 468 | |
| 469 | return $plugin_meta; |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * @param $footer_text |
| 474 | * |
| 475 | * @return string |
| 476 | * |
| 477 | * Add footer text only on tutor pages |
| 478 | */ |
| 479 | public function admin_footer_text( $footer_text ) { |
| 480 | $current_screen = get_current_screen(); |
| 481 | |
| 482 | /** |
| 483 | * We are making sure that this message will be only on Tutor Admin page |
| 484 | */ |
| 485 | if ( apply_filters( 'tutor_display_admin_footer_text', (tutor_utils()->array_get('parent_base', $current_screen) === 'tutor' ) ) ) { |
| 486 | $footer_text = sprintf( |
| 487 | __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'tutor' ), |
| 488 | sprintf( '<strong>%s</strong>', esc_html__( 'Tutor LMS', 'tutor' ) ), |
| 489 | '<a href="https://wordpress.org/support/plugin/tutor/reviews?rate=5#new-post" target="_blank" class="tutor-rating-link">★★★★★</a>' |
| 490 | ); |
| 491 | } |
| 492 | |
| 493 | return $footer_text; |
| 494 | } |
| 495 | |
| 496 | |
| 497 | public function register_course_widget(){ |
| 498 | register_widget( 'Tutor\Course_Widget' ); |
| 499 | } |
| 500 | |
| 501 | |
| 502 | } |