PluginProbe
Tutor LMS – eLearning and online course solution / 1.2.13
Tutor LMS – eLearning and online course solution v1.2.13
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/Admin.php +74 -8 1.0.31.2.13 View file →
@@ -22,8 +22,14 @@
22 22 add_action('load-post.php', array($this, 'check_if_current_users_post') );
23 23
24 24 add_action('admin_action_uninstall_tutor_and_erase', array($this, 'erase_tutor_data'));
25 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 );
26 32 }
27 33
28 34 public function register_menu(){
29 35 $hasPro = tutor()->has_pro;
@@ -48,14 +54,14 @@
48 54
49 55 add_submenu_page('tutor', __('Q & A', 'tutor'), __('Q & A '.$unanswered_bubble, 'tutor'), 'manage_tutor_instructor', 'question_answer', array($this, 'question_answer') );
50 56
51 57 add_submenu_page('tutor', __('Quiz Attempts', 'tutor'), __('Quiz Attempts', 'tutor'), 'manage_tutor_instructor', 'tutor_quiz_attempts',array($this, 'quiz_attempts') );
58 + add_submenu_page('tutor', __('Withdraw Requests', 'tutor'), __('Withdraw Requests', 'tutor'), 'manage_tutor_instructor', 'tutor_withdraw_requests', array($this, 'withdraw_requests') );
52 59
53 60 //add_submenu_page('tutor', __('Add-ons', 'tutor'), __('Add-ons', 'tutor'), 'manage_tutor', 'tutor-addons', array(new Addons(),'addons_page') );
61 + add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), __( 'Add-ons', 'tutor' ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) );
54 62
55 63
56 - add_submenu_page('tutor', __('Add-ons', 'tutor'), __('Add-ons', 'tutor'), 'manage_tutor', 'tutor-addons', array($this, 'enable_disable_addons') );
57 -
58 64 add_submenu_page('tutor', __('Status', 'tutor'), __('Status', 'tutor'), 'manage_tutor', 'tutor-status', array($this, 'tutor_status') );
59 65
60 66 do_action('tutor_admin_register');
61 67
@@ -89,10 +95,24 @@
89 95 public function quiz_attempts(){
90 96 include tutor()->path.'views/pages/quiz_attempts.php';
91 97 }
92 98
99 + /**
100 + * Show the withdraw requests table
101 + *
102 + * @since v.1.2.0
103 + */
104 + public function withdraw_requests(){
105 + include tutor()->path.'views/pages/withdraw_requests.php';
106 + }
107 +
93 108 public function enable_disable_addons(){
94 - include tutor()->path.'views/pages/enable_disable_addons.php';
109 +
110 + if (defined('TUTOR_PRO_VERSION')) {
111 + include tutor()->path.'views/pages/enable_disable_addons.php';
112 + }else{
113 + include tutor()->path.'views/pages/tutor-pro-addons.php';
114 + }
95 115 }
96 116
97 117 public function tutor_status(){
98 118 include tutor()->path.'views/pages/status.php';
@@ -133,11 +153,11 @@
133 153 /**
134 154 * Filter posts for instructor
135 155 */
136 156 public function filter_posts_for_instructors(){
137 - if (current_user_can(tutor()->instructor_role)){
157 + if ( ! current_user_can('administrator') && current_user_can(tutor()->instructor_role)){
138 158 remove_menu_page( 'edit-comments.php' ); //Comments
139 - add_action( 'posts_clauses_request', array($this, 'posts_clauses_request') );
159 + add_filter( 'posts_clauses_request', array($this, 'posts_clauses_request') );
140 160 }
141 161 }
142 162
143 163 public function posts_clauses_request($clauses){
@@ -148,9 +168,9 @@
148 168 $get_assigned_courses_ids = $wpdb->get_col("SELECT meta_value from {$wpdb->usermeta} WHERE meta_key = '_tutor_instructor_course_id' AND user_id = {$user_id} ");
149 169
150 170 $custom_author_query = "AND {$wpdb->posts}.post_author = {$user_id}";
151 171 if (is_array($get_assigned_courses_ids) && count($get_assigned_courses_ids)){
152 - $in_query_pre = implode($get_assigned_courses_ids, ',');
172 + $in_query_pre = implode(',', $get_assigned_courses_ids);
153 173 $custom_author_query = " AND ( {$wpdb->posts}.post_author = {$user_id} OR {$wpdb->posts}.ID IN({$in_query_pre}) ) ";
154 174 }
155 175
156 176 $clauses['where'] .= $custom_author_query;
@@ -158,9 +178,9 @@
158 178 return $clauses;
159 179 }
160 180
161 181 /**
162 - * Prevent unauthorised post edit page by direct URL
182 + * Prevent unauthorised course/lesson edit page by direct URL
163 183 *
164 184 * @since v.1.0.0
165 185 */
166 186 public function check_if_current_users_post(){
@@ -170,11 +190,13 @@
170 190
171 191 if (! empty($_GET['post']) ) {
172 192 $get_post_id = (int) sanitize_text_field($_GET['post']);
173 193 $get_post = get_post($get_post_id);
194 + $tutor_post_types = array(tutor()->course_post_type, tutor()->lesson_post_type);
195 +
174 196 $current_user = get_current_user_id();
175 197
176 - if ($get_post->post_author != $current_user){
198 + if (in_array($get_post->post_type, $tutor_post_types) && $get_post->post_author != $current_user){
177 199 global $wpdb;
178 200
179 201 $get_assigned_courses_ids = (int) $wpdb->get_var("SELECT user_id from {$wpdb->usermeta} WHERE user_id = {$current_user} AND meta_key = '_tutor_instructor_course_id' AND meta_value = {$get_post_id} ");
180 202
@@ -359,8 +381,12 @@
359 381 /**D*/ $wpdb->delete($wpdb->usermeta, array('meta_key' => '_tutor_instructor_status'));
360 382 /**D*/ $wpdb->delete($wpdb->usermeta, array('meta_key' => '_is_tutor_instructor'));
361 383 /**D*/ $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_tutor_completed_lesson_id_%' ");
362 384
385 + //Deleting Table
386 + $prefix = $wpdb->prefix;
387 + /**D*/ $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 ");
388 +
363 389 deactivate_plugins($plugin_file);
364 390 }
365 391
366 392 wp_redirect('plugins.php');
@@ -389,7 +415,47 @@
389 415 $actions['settings'] = '<a href="admin.php?page=tutor_settings">' . __('Settings', 'tutor') . '</a>';
390 416 return $actions;
391 417 }
392 418
419 + public function plugin_row_meta($plugin_meta, $plugin_file){
420 +
421 + if ($plugin_file === tutor()->basename) {
422 + $plugin_meta[] = sprintf( '<a href="%s">%s</a>',
423 + esc_url( 'https://www.themeum.com/docs/tutor-introduction/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ),
424 + __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor' )
425 + );
426 + $plugin_meta[] = sprintf( '<a href="%s">%s</a>',
427 + esc_url( 'https://www.themeum.com/support-forums/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ),
428 + __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor' )
429 + );
430 + }
431 +
432 + return $plugin_meta;
433 + }
434 +
435 + /**
436 + * @param $footer_text
437 + *
438 + * @return string
439 + *
440 + * Add footer text only on tutor pages
441 + */
442 + public function admin_footer_text( $footer_text ) {
443 + $current_screen = get_current_screen();
444 + $tutor_pages = tutor_utils()->tutor_get_screen_ids();
445 +
446 + /**
447 + * We are making sure that this message will be only on Tutor Admin page
448 + */
449 + if ( isset( $current_screen->id ) && apply_filters( 'tutor_display_admin_footer_text', in_array( $current_screen->id, $tutor_pages ) ) ) {
450 + $footer_text = sprintf(
451 + __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'tutor' ),
452 + sprintf( '<strong>%s</strong>', esc_html__( 'Tutor LMS', 'tutor' ) ),
453 + '<a href="https://wordpress.org/support/plugin/tutor/reviews?rate=5#new-post" target="_blank" class="tutor-rating-link">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
454 + );
455 + }
456 +
457 + return $footer_text;
458 + }
393 459
394 460
395 461 }