Addons.php
2 years ago
Admin.php
2 years ago
Ajax.php
2 years ago
Announcements.php
3 years ago
Assets.php
2 years ago
Backend_Page_Trait.php
3 years ago
Course.php
1 year ago
Course_Embed.php
3 years ago
Course_Filter.php
1 year ago
Course_List.php
1 year ago
Course_Settings_Tabs.php
3 years ago
Course_Widget.php
3 years ago
Custom_Validation.php
3 years ago
Dashboard.php
3 years ago
FormHandler.php
2 years ago
Frontend.php
2 years ago
Gutenberg.php
3 years ago
Input.php
3 years ago
Instructor.php
2 years ago
Instructors_List.php
1 year ago
Lesson.php
2 years ago
Options_V2.php
1 year ago
Permalink.php
2 years ago
Post_types.php
2 years ago
Private_Course_Access.php
3 years ago
Q_And_A.php
1 year ago
Question_Answers_List.php
3 years ago
Quiz.php
2 years ago
Quiz_Attempts_List.php
2 years ago
RestAPI.php
2 years ago
Reviews.php
3 years ago
Rewrite_Rules.php
2 years ago
Shortcode.php
1 year ago
Student.php
2 years ago
Students_List.php
3 years ago
Taxonomies.php
3 years ago
Template.php
2 years ago
Theme_Compatibility.php
3 years ago
Tools.php
3 years ago
Tools_V2.php
2 years ago
Tutor.php
2 years ago
TutorEDD.php
2 years ago
Tutor_Base.php
2 years ago
Tutor_Setup.php
2 years ago
Upgrader.php
2 years ago
User.php
2 years ago
Utils.php
1 year ago
Video_Stream.php
3 years ago
WhatsNew.php
2 years ago
Withdraw.php
2 years ago
Withdraw_Requests_List.php
3 years ago
WooCommerce.php
2 years ago
Admin.php
569 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Manage admin menu and plugin related logic |
| 4 | * |
| 5 | * @package Tutor |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | namespace TUTOR; |
| 12 | |
| 13 | use TUTOR\Input; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Admin Class |
| 21 | * |
| 22 | * @since 1.0.0 |
| 23 | */ |
| 24 | class Admin { |
| 25 | /** |
| 26 | * Constructor |
| 27 | * |
| 28 | * @since 1.0.0 |
| 29 | * @return void |
| 30 | */ |
| 31 | public function __construct() { |
| 32 | add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
| 33 | // Force activate menu for necessary. |
| 34 | add_filter( 'parent_file', array( $this, 'parent_menu_active' ) ); |
| 35 | add_filter( 'submenu_file', array( $this, 'submenu_file_active' ), 10, 2 ); |
| 36 | |
| 37 | add_action( 'admin_init', array( $this, 'filter_posts_for_instructors' ) ); |
| 38 | add_action( 'load-post.php', array( $this, 'check_if_current_users_post' ) ); |
| 39 | |
| 40 | add_filter( 'plugin_action_links_' . plugin_basename( TUTOR_FILE ), array( $this, 'plugin_action_links' ) ); |
| 41 | |
| 42 | // Plugin Row Meta. |
| 43 | add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); |
| 44 | |
| 45 | // Admin Footer Text. |
| 46 | add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
| 47 | // Register Course Widget. |
| 48 | add_action( 'widgets_init', array( $this, 'register_course_widget' ) ); |
| 49 | |
| 50 | // Handle flash toast message for redirect_to util helper. |
| 51 | add_action( 'admin_head', array( new Utils(), 'handle_flash_message' ), 999 ); |
| 52 | add_action( 'tutor_after_settings_menu', '\TUTOR\WhatsNew::whats_new_menu', 11 ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Register admin menus |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | * @return void |
| 60 | */ |
| 61 | public function register_menu() { |
| 62 | $has_pro = tutor()->has_pro; |
| 63 | |
| 64 | $unanswered_questions = tutor_utils()->unanswered_question_count(); |
| 65 | $unanswered_bubble = ''; |
| 66 | if ( $unanswered_questions ) { |
| 67 | $unanswered_bubble = '<span class="update-plugins count-' . $unanswered_questions . '"><span class="plugin-count">' . $unanswered_questions . '</span></span>'; |
| 68 | } |
| 69 | |
| 70 | $course_post_type = tutor()->course_post_type; |
| 71 | |
| 72 | $pro_text = ''; |
| 73 | if ( $has_pro ) { |
| 74 | $pro_text = ' ' . __( 'Pro', 'tutor' ); |
| 75 | } |
| 76 | |
| 77 | $enable_course_marketplace = (bool) tutor_utils()->get_option( 'enable_course_marketplace' ); |
| 78 | |
| 79 | $welcome = Tutor_Setup::is_welcome_page_visited(); |
| 80 | |
| 81 | $root_page = array( $this, 'tutor_course_list' ); |
| 82 | if ( false === $welcome && Input::has( 'page' ) && 'tutor' === Input::get( 'page' ) && Input::has( 'welcome' ) ) { |
| 83 | $root_page = array( $this, 'welcome_page' ); |
| 84 | } |
| 85 | |
| 86 | $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>' ); |
| 87 | $menu_position = 2; |
| 88 | |
| 89 | add_menu_page( |
| 90 | __( 'Tutor LMS', 'tutor' ) . $pro_text, |
| 91 | __( 'Tutor LMS', 'tutor' ) . $pro_text, |
| 92 | 'manage_tutor_instructor', |
| 93 | 'tutor', |
| 94 | $root_page, |
| 95 | $icon_base64_uri, |
| 96 | $menu_position |
| 97 | ); |
| 98 | |
| 99 | // Added @since v2.0.0. |
| 100 | add_submenu_page( 'tutor', __( 'Courses', 'tutor' ), __( 'Courses', 'tutor' ), 'manage_tutor_instructor', 'tutor', array( $this, 'tutor_course_list' ) ); |
| 101 | |
| 102 | // Extendable action hook @since 2.2.0. |
| 103 | do_action( 'tutor_after_courses_menu' ); |
| 104 | |
| 105 | if ( ! $has_pro ) { |
| 106 | add_submenu_page( 'tutor', __( 'Email', 'tutor' ), __( 'Email <span class="tutor-pro-badge">Hot</span>', 'tutor' ), 'manage_tutor', 'new-key-feature', array( $this, 'feature_promotion_page' ) ); |
| 107 | } |
| 108 | |
| 109 | add_submenu_page( 'tutor', __( 'Categories', 'tutor' ), __( 'Categories', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type, null ); |
| 110 | |
| 111 | add_submenu_page( 'tutor', __( 'Tags', 'tutor' ), __( 'Tags', 'tutor' ), 'manage_tutor', 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type, null ); |
| 112 | |
| 113 | add_submenu_page( 'tutor', __( 'Students', 'tutor' ), __( 'Students', 'tutor' ), 'manage_tutor', Students_List::STUDENTS_LIST_PAGE, array( $this, 'tutor_students' ) ); |
| 114 | |
| 115 | if ( $enable_course_marketplace ) { |
| 116 | add_submenu_page( 'tutor', __( 'Instructors', 'tutor' ), __( 'Instructors', 'tutor' ), 'manage_tutor', Instructors_List::INSTRUCTOR_LIST_PAGE, array( $this, 'tutor_instructors' ) ); |
| 117 | } |
| 118 | |
| 119 | add_submenu_page( 'tutor', __( 'Announcements', 'tutor' ), __( 'Announcements', 'tutor' ), 'manage_tutor_instructor', 'tutor_announcements', array( $this, 'tutor_announcements' ) ); |
| 120 | |
| 121 | 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' ) ); |
| 122 | |
| 123 | add_submenu_page( 'tutor', __( 'Quiz Attempts', 'tutor' ), __( 'Quiz Attempts', 'tutor' ), 'manage_tutor_instructor', Quiz_Attempts_List::QUIZ_ATTEMPT_PAGE, array( $this, 'quiz_attempts' ) ); |
| 124 | |
| 125 | if ( $enable_course_marketplace ) { |
| 126 | add_submenu_page( 'tutor', __( 'Withdraw Requests', 'tutor' ), __( 'Withdraw Requests', 'tutor' ), 'manage_tutor', Withdraw_Requests_List::WITHDRAW_REQUEST_LIST_PAGE, array( $this, 'withdraw_requests' ) ); |
| 127 | } |
| 128 | |
| 129 | add_submenu_page( 'tutor', __( 'Add-ons', 'tutor' ), sprintf( '<span class="tutor-addons-text">%s</span>', __( 'Add-ons', 'tutor' ) ), 'manage_tutor', 'tutor-addons', array( $this, 'enable_disable_addons' ) ); |
| 130 | |
| 131 | do_action( 'tutor_admin_register' ); |
| 132 | |
| 133 | add_submenu_page( 'tutor', __( 'Tools', 'tutor' ), __( 'Tools', 'tutor' ), 'manage_tutor', 'tutor-tools', array( new \TUTOR\Tools_V2(), 'load_tools_page' ) ); |
| 134 | |
| 135 | add_submenu_page( 'tutor', __( 'Settings', 'tutor' ), __( 'Settings', 'tutor' ), 'manage_tutor', 'tutor_settings', array( new \TUTOR\Options_V2(), 'load_settings_page' ) ); |
| 136 | |
| 137 | do_action( 'tutor_after_settings_menu' ); |
| 138 | |
| 139 | if ( ! $has_pro ) { |
| 140 | add_submenu_page( 'tutor', __( 'Upgrade to Pro', 'tutor' ), sprintf( '<span class="tutor-get-pro-text">%s</span>', __( 'Upgrade to Pro', 'tutor' ) ), 'manage_options', 'tutor-get-pro', array( $this, 'tutor_get_pro' ) ); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Show Feature Promotion Page for Free User. |
| 146 | * |
| 147 | * @since 2.2.0 |
| 148 | * |
| 149 | * @return void |
| 150 | */ |
| 151 | public function feature_promotion_page() { |
| 152 | include tutor()->path . 'views/pages/feature-promotion.php'; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Show students page |
| 157 | * |
| 158 | * @since 1.0.0 |
| 159 | * @return void |
| 160 | */ |
| 161 | public function tutor_students() { |
| 162 | include tutor()->path . 'views/pages/students.php'; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Show instructor page |
| 167 | * |
| 168 | * @since 1.0.0 |
| 169 | * @return void |
| 170 | */ |
| 171 | public function tutor_instructors() { |
| 172 | include tutor()->path . 'views/pages/instructors.php'; |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Show announcements page |
| 177 | * |
| 178 | * @since 1.0.0 |
| 179 | * @return void |
| 180 | */ |
| 181 | public function tutor_announcements() { |
| 182 | include tutor()->path . 'views/pages/announcements.php'; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Show Q&A page |
| 187 | * |
| 188 | * @since 1.0.0 |
| 189 | * @return void |
| 190 | */ |
| 191 | public function question_answer() { |
| 192 | include tutor()->path . 'views/pages/question_answer.php'; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Show quiz attempts page |
| 197 | * |
| 198 | * @since 1.0.0 |
| 199 | * @return void |
| 200 | */ |
| 201 | public function quiz_attempts() { |
| 202 | include tutor()->path . 'views/pages/quiz_attempts.php'; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Show the withdraw requests table |
| 207 | * |
| 208 | * @since 1.2.0 |
| 209 | * @return void |
| 210 | */ |
| 211 | public function withdraw_requests() { |
| 212 | include tutor()->path . 'views/pages/withdraw_requests.php'; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Enable or disable addons |
| 217 | * |
| 218 | * @since 1.0.0 |
| 219 | * @return void |
| 220 | */ |
| 221 | public function enable_disable_addons() { |
| 222 | |
| 223 | if ( defined( 'TUTOR_PRO_VERSION' ) ) { |
| 224 | include tutor()->path . 'views/pages/enable_disable_addons.php'; |
| 225 | } else { |
| 226 | include tutor()->path . 'views/pages/tutor-pro-addons.php'; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Tutor tools page (OLD) |
| 232 | * |
| 233 | * @since 1.0.0 |
| 234 | * @return void |
| 235 | */ |
| 236 | public function tutor_tools_old() { |
| 237 | $tutor_admin_tools_page = Input::get( 'tutor_admin_tools_page' ); |
| 238 | if ( $tutor_admin_tools_page ) { |
| 239 | include apply_filters( 'tutor_admin_tools_page', tutor()->path . "views/pages/{$tutor_admin_tools_page}.php", $tutor_admin_tools_page ); |
| 240 | } else { |
| 241 | $pages = apply_filters( |
| 242 | 'tutor_tool_pages', |
| 243 | array( |
| 244 | 'tutor_pages' => array( 'title' => __( 'Tutor Pages', 'tutor' ) ), |
| 245 | 'status' => __( 'Status', 'tutor' ), |
| 246 | ) |
| 247 | ); |
| 248 | |
| 249 | $current_page = 'tutor_pages'; |
| 250 | $requested_page = Input::get( 'sub_page' ); |
| 251 | if ( $requested_page ) { |
| 252 | $current_page = $requested_page; |
| 253 | } |
| 254 | |
| 255 | $current_page = str_replace( '/', '', $current_page ); |
| 256 | $current_page = str_replace( '.', '', $current_page ); |
| 257 | $current_page = str_replace( '\\', '', $current_page ); |
| 258 | $current_page = trim( $current_page ); |
| 259 | |
| 260 | include tutor()->path . 'views/pages/tools.php'; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Show pro upgrade page |
| 266 | * |
| 267 | * @since 1.0.0 |
| 268 | * @return void |
| 269 | */ |
| 270 | public function tutor_get_pro() { |
| 271 | include tutor()->path . 'views/pages/get-pro.php'; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Parent menu active |
| 276 | * |
| 277 | * @since 1.0.0 |
| 278 | * |
| 279 | * @param string $parent_file parent file. |
| 280 | * @return string |
| 281 | */ |
| 282 | public function parent_menu_active( $parent_file ) { |
| 283 | $taxonomy = Input::get( 'taxonomy' ); |
| 284 | if ( 'course-category' === $taxonomy || 'course-tag' === $taxonomy ) { |
| 285 | return 'tutor'; |
| 286 | } |
| 287 | |
| 288 | return $parent_file; |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Sub-menu active |
| 293 | * |
| 294 | * @since 1.0.0 |
| 295 | * |
| 296 | * @param string $submenu_file submenu file. |
| 297 | * @param string $parent_file parent file. |
| 298 | * |
| 299 | * @return string |
| 300 | */ |
| 301 | public function submenu_file_active( $submenu_file, $parent_file ) { |
| 302 | $taxonomy = Input::get( 'taxonomy' ); |
| 303 | $course_post_type = tutor()->course_post_type; |
| 304 | |
| 305 | if ( 'course-category' === $taxonomy ) { |
| 306 | return 'edit-tags.php?taxonomy=course-category&post_type=' . $course_post_type; |
| 307 | } |
| 308 | if ( 'course-tag' === $taxonomy ) { |
| 309 | return 'edit-tags.php?taxonomy=course-tag&post_type=' . $course_post_type; |
| 310 | } |
| 311 | |
| 312 | return $submenu_file; |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Filter posts for instructor |
| 317 | * |
| 318 | * @since 1.0.0 |
| 319 | * @return void |
| 320 | */ |
| 321 | public function filter_posts_for_instructors() { |
| 322 | if ( ! current_user_can( 'administrator' ) && current_user_can( tutor()->instructor_role ) ) { |
| 323 | @remove_menu_page( 'edit-comments.php' ); // Comments. |
| 324 | add_filter( 'posts_clauses_request', array( $this, 'posts_clauses_request' ) ); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Request for posts clauses |
| 330 | * |
| 331 | * @since 1.0.0 |
| 332 | * |
| 333 | * @param mixed $clauses clauses. |
| 334 | * @return mixed |
| 335 | */ |
| 336 | public function posts_clauses_request( $clauses ) { |
| 337 | |
| 338 | if ( ! is_admin() || ( ! Input::has( 'post_type' ) || Input::get( 'post_type' ) != tutor()->course_post_type ) || tutor_utils()->has_user_role( array( 'administrator', 'editor' ) ) ) { |
| 339 | return $clauses; |
| 340 | } |
| 341 | |
| 342 | // Need multi instructor check. |
| 343 | global $wpdb; |
| 344 | |
| 345 | $user_id = get_current_user_id(); |
| 346 | |
| 347 | $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 ) ); |
| 348 | $own_courses = is_array( $get_assigned_courses_ids ) ? $get_assigned_courses_ids : array(); |
| 349 | |
| 350 | $in_query_pre = count( $own_courses ) ? implode( ',', $own_courses ) : null; |
| 351 | $in_query_where = $in_query_pre ? " OR {$wpdb->posts}.ID IN({$in_query_pre})" : ''; |
| 352 | |
| 353 | $course_post_type = tutor()->course_post_type; |
| 354 | $custom_author_query = " AND ({$wpdb->posts}.post_type!='{$course_post_type}' OR {$wpdb->posts}.post_author = {$user_id}) {$in_query_where}"; |
| 355 | |
| 356 | $clauses['where'] .= $custom_author_query; |
| 357 | |
| 358 | return $clauses; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * Prevent unauthorised course/lesson edit page by direct URL |
| 363 | * |
| 364 | * @since 1.0.0 |
| 365 | * @return void |
| 366 | */ |
| 367 | public function check_if_current_users_post() { |
| 368 | if ( current_user_can( 'administrator' ) || ! current_user_can( tutor()->instructor_role ) ) { |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | if ( ! empty( Input::get( 'post' ) ) ) { |
| 373 | $get_post_id = Input::get( 'post', Input::TYPE_INT ); |
| 374 | $get_post = get_post( $get_post_id ); |
| 375 | $tutor_post_types = array( tutor()->course_post_type, tutor()->lesson_post_type ); |
| 376 | |
| 377 | $current_user = get_current_user_id(); |
| 378 | |
| 379 | if ( in_array( $get_post->post_type, $tutor_post_types ) && $get_post->post_author != $current_user ) { |
| 380 | global $wpdb; |
| 381 | |
| 382 | $get_assigned_courses_ids = (int) $wpdb->get_var( |
| 383 | $wpdb->prepare( |
| 384 | "SELECT user_id |
| 385 | from {$wpdb->usermeta} |
| 386 | WHERE user_id = %d AND meta_key = '_tutor_instructor_course_id' AND meta_value = %d ", |
| 387 | $current_user, |
| 388 | $get_post_id |
| 389 | ) |
| 390 | ); |
| 391 | |
| 392 | if ( ! $get_assigned_courses_ids ) { |
| 393 | wp_die( esc_html__( 'Permission Denied', 'tutor' ) ); |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Scan template files |
| 401 | * |
| 402 | * @since 1.0.0 |
| 403 | * |
| 404 | * @param string $template_path template file path. |
| 405 | * @return array |
| 406 | */ |
| 407 | public static function scan_template_files( $template_path = null ) { |
| 408 | if ( ! $template_path ) { |
| 409 | $template_path = tutor()->path . 'templates/'; |
| 410 | } |
| 411 | |
| 412 | $files = @scandir($template_path); // @codingStandardsIgnoreLine. |
| 413 | $result = array(); |
| 414 | |
| 415 | if ( ! empty( $files ) ) { |
| 416 | foreach ( $files as $key => $value ) { |
| 417 | if ( ! in_array( $value, array( '.', '..', '.DS_Store' ), true ) ) { |
| 418 | if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { |
| 419 | $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); |
| 420 | foreach ( $sub_files as $sub_file ) { |
| 421 | $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; |
| 422 | } |
| 423 | } else { |
| 424 | $result[] = $value; |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | return $result; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Get Template overridden files |
| 434 | * |
| 435 | * @since 1.0.0 |
| 436 | * @return array |
| 437 | */ |
| 438 | public static function template_overridden_files() { |
| 439 | $template_files = self::scan_template_files(); |
| 440 | |
| 441 | $override_files = array(); |
| 442 | foreach ( $template_files as $file ) { |
| 443 | $file_path = null; |
| 444 | if ( file_exists( trailingslashit( get_stylesheet_directory() ) . tutor()->template_path . $file ) ) { |
| 445 | $file_path = $file; |
| 446 | } elseif ( file_exists( trailingslashit( get_template_directory() ) . tutor()->template_path . $file ) ) { |
| 447 | $file_path = $file; |
| 448 | } |
| 449 | |
| 450 | if ( $file_path ) { |
| 451 | $override_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $file_path ); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | return $override_files; |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Plugin activation link |
| 460 | * |
| 461 | * @since 1.0.0 |
| 462 | * |
| 463 | * @param array $actions action list. |
| 464 | * @return array |
| 465 | */ |
| 466 | public function plugin_action_links( $actions ) { |
| 467 | $has_pro = tutor()->has_pro; |
| 468 | |
| 469 | if ( ! $has_pro ) { |
| 470 | $actions['tutor_pro_link'] = |
| 471 | '<a href="https://tutorlms.com/pricing?utm_source=tutor_plugin_action_link&utm_medium=wordpress_dashboard&utm_campaign=go_premium" target="_blank"> |
| 472 | <span style="color: #ff7742; font-weight: bold;">' . |
| 473 | __( 'Upgrade to Pro', 'wp-megamenu' ) . |
| 474 | '</span> |
| 475 | </a>'; |
| 476 | } |
| 477 | |
| 478 | $actions['settings'] = '<a href="admin.php?page=tutor_settings">' . __( 'Settings', 'tutor' ) . '</a>'; |
| 479 | |
| 480 | return $actions; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Add plugin meta data in WP plugins list page |
| 485 | * |
| 486 | * @since 1.0.0 |
| 487 | * |
| 488 | * @param array $plugin_meta plugin meta data. |
| 489 | * @param string $plugin_file plugin file. |
| 490 | * |
| 491 | * @return array |
| 492 | */ |
| 493 | public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 494 | |
| 495 | if ( tutor()->basename === $plugin_file ) { |
| 496 | $plugin_meta[] = sprintf( |
| 497 | '<a href="%s">%s</a>', |
| 498 | esc_url( 'https://docs.themeum.com/tutor-lms/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_docs_link' ), |
| 499 | __( '<strong style="color: #03bd24">Documentation</strong>', 'tutor' ) |
| 500 | ); |
| 501 | $plugin_meta[] = sprintf( |
| 502 | '<a href="%s">%s</a>', |
| 503 | esc_url( 'https://www.themeum.com/contact-us/?utm_source=tutor&utm_medium=plugins_installation_list&utm_campaign=plugin_support_link' ), |
| 504 | __( '<strong style="color: #03bd24">Get Support</strong>', 'tutor' ) |
| 505 | ); |
| 506 | } |
| 507 | |
| 508 | return $plugin_meta; |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * Add footer text only on tutor pages |
| 513 | * |
| 514 | * @since 1.0.0 |
| 515 | * |
| 516 | * @param string $footer_text footer text. |
| 517 | * @return string |
| 518 | */ |
| 519 | public function admin_footer_text( $footer_text ) { |
| 520 | $current_screen = get_current_screen(); |
| 521 | |
| 522 | /** |
| 523 | * We are making sure that this message will be only on Tutor Admin page |
| 524 | */ |
| 525 | if ( apply_filters( 'tutor_display_admin_footer_text', ( tutor_utils()->array_get( 'parent_base', $current_screen ) === 'tutor' ) ) ) { |
| 526 | $footer_text = sprintf( |
| 527 | /* translators: %s: plugin name */ |
| 528 | __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'tutor' ), |
| 529 | sprintf( '<strong>%s</strong>', esc_html__( 'Tutor LMS', 'tutor' ) ), |
| 530 | '<a href="https://wordpress.org/support/plugin/tutor/reviews?rate=5#new-post" target="_blank" class="tutor-rating-link">★★★★★</a>' |
| 531 | ); |
| 532 | } |
| 533 | |
| 534 | return $footer_text; |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * Register course widget |
| 539 | * |
| 540 | * @since 1.0.0 |
| 541 | * @return void |
| 542 | */ |
| 543 | public function register_course_widget() { |
| 544 | register_widget( 'Tutor\Course_Widget' ); |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * Tutor Course List |
| 549 | * |
| 550 | * @since 2.0.0 |
| 551 | * @return void |
| 552 | */ |
| 553 | public function tutor_course_list() { |
| 554 | include tutor()->path . 'views/pages/course-list.php'; |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Show welcome page |
| 559 | * |
| 560 | * @since 1.0.0 |
| 561 | * @return void |
| 562 | */ |
| 563 | public function welcome_page() { |
| 564 | Tutor_Setup::mark_as_visited(); |
| 565 | include tutor()->path . 'views/pages/welcome.php'; |
| 566 | exit; |
| 567 | } |
| 568 | } |
| 569 |