PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.0.10
Tutor LMS – eLearning and online course solution v2.0.10
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 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Assets.php
tutor / classes Last commit date
Addons.php 4 years ago Admin.php 4 years ago Ajax.php 3 years ago Announcements.php 4 years ago Assets.php 3 years ago Backend_Page_Trait.php 4 years ago Course.php 3 years ago Course_Embed.php 3 years ago Course_Filter.php 4 years ago Course_List.php 3 years ago Course_Settings_Tabs.php 4 years ago Course_Widget.php 4 years ago Custom_Validation.php 4 years ago Dashboard.php 3 years ago FormHandler.php 4 years ago Frontend.php 3 years ago Gutenberg.php 4 years ago Input.php 3 years ago Instructor.php 4 years ago Instructors_List.php 3 years ago Lesson.php 3 years ago Options_V2.php 3 years ago Post_types.php 4 years ago Private_Course_Access.php 4 years ago Q_and_A.php 3 years ago Question_Answers_List.php 4 years ago Quiz.php 3 years ago Quiz_Attempts_List.php 3 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 3 years ago Theme_Compatibility.php 5 years ago Tools.php 3 years ago Tools_V2.php 4 years ago Tutor.php 3 years ago TutorEDD.php 4 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 3 years ago Upgrader.php 4 years ago User.php 4 years ago Utils.php 3 years ago Video_Stream.php 4 years ago Withdraw.php 3 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 3 years ago
Assets.php
534 lines
1 <?php
2
3 namespace TUTOR;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class Assets {
10
11 public function __construct() {
12 /**
13 * Common scripts loading
14 */
15 add_action( 'admin_enqueue_scripts', array( $this, 'common_scripts' ) );
16 add_action( 'wp_enqueue_scripts', array( $this, 'common_scripts' ) );
17 /**
18 * Front and backend script enqueue
19 */
20 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
21 add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
22
23 add_action( 'admin_enqueue_scripts', array( $this, 'load_meta_data' ) );
24 add_action( 'wp_enqueue_scripts', array( $this, 'load_meta_data' ) );
25
26 /**
27 * Text domain loading
28 */
29 add_action( 'admin_enqueue_scripts', array( $this, 'tutor_script_text_domain' ), 100 );
30 add_action( 'wp_enqueue_scripts', array( $this, 'tutor_script_text_domain' ), 100 );
31 add_filter( 'tutor_localize_data', array( $this, 'modify_localize_data' ) );
32
33 /**
34 * register translatable function to load
35 * handled script with text domain attached to
36 *
37 * @since 1.9.0
38 */
39 add_action( 'admin_head', array( $this, 'tutor_add_mce_button' ) );
40 add_filter( 'get_the_generator_html', array( $this, 'tutor_generator_tag' ), 10, 2 );
41 add_filter( 'get_the_generator_xhtml', array( $this, 'tutor_generator_tag' ), 10, 2 );
42
43 /**
44 * Add translation support for external tinyMCE button
45 *
46 * @since 1.9.7
47 */
48 add_filter( 'mce_external_languages', array( $this, 'tutor_tinymce_translate' ) );
49
50 /**
51 * Identifier class to body tag
52 *
53 * @since v1.9.9
54 */
55 add_filter( 'body_class', array( $this, 'add_identifier_class_to_body' ) );
56 add_filter( 'admin_body_class', array( $this, 'add_identifier_class_to_body' ) );
57
58 /**
59 * Add edit with front end builder button on Gutenberg editor
60 *
61 * @since v2.0.5
62 */
63 add_action( 'enqueue_block_editor_assets', __CLASS__ . '::add_frontend_editor_button' );
64 }
65
66 private function get_default_localized_data() {
67 global $wp_version, $wp_query;
68
69 $home_url = get_home_url();
70 $parsed = parse_url( $home_url );
71
72 $base_path = ( is_array( $parsed ) && isset( $parsed['path'] ) ) ? $parsed['path'] : '/';
73 $base_path = rtrim( $base_path, '/' ) . '/';
74
75 $post_id = get_the_ID();
76 $post_type = get_post_type( $post_id );
77
78 $query_vars = $wp_query->query_vars;
79 if ( is_admin() && isset( $_GET['page'] ) ) {
80 $current_page = $_GET['page'];
81 } else {
82 $current_page = isset( $query_vars['tutor_dashboard_page'] ) ? $query_vars['tutor_dashboard_page'] : '';
83 }
84 return array(
85 'ajaxurl' => admin_url( 'admin-ajax.php' ),
86 'home_url' => get_home_url(),
87 'site_title' => get_bloginfo( 'title' ),
88 'base_path' => tutor()->basepath,
89 'tutor_url' => tutor()->url,
90 'tutor_pro_url' => function_exists( 'tutor_pro' ) ? tutor_pro()->url : null,
91 'nonce_key' => tutor()->nonce,
92 tutor()->nonce => wp_create_nonce( tutor()->nonce_action ),
93 'loading_icon_url' => get_admin_url() . 'images/wpspin_light.gif',
94 'placeholder_img_src' => tutor_placeholder_img_src(),
95 'enable_lesson_classic_editor' => get_tutor_option( 'enable_lesson_classic_editor' ),
96 'tutor_frontend_dashboard_url' => tutor_utils()->get_tutor_dashboard_page_permalink(),
97 'wp_date_format' => tutor_js_date_format_against_wp(),
98 'is_admin' => is_admin(),
99 'is_admin_bar_showing' => is_admin_bar_showing(),
100 'addons_data' => tutor_utils()->prepare_free_addons_data(),
101 'current_user' => wp_get_current_user(),
102 'content_change_event' => 'tutor_content_changed_event',
103 'is_tutor_course_edit' => isset( $_GET['action'] ) && 'edit' === $_GET['action'] && tutor()->course_post_type === get_post_type( get_the_ID() ) ? true : false,
104 'assignment_max_file_allowed' => 'tutor_assignments' === $post_type ? (int) tutor_utils()->get_assignment_option( $post_id, 'upload_files_limit' ) : 0,
105 'current_page' => $current_page,
106 'quiz_answer_display_time' => 1000 * (int) tutor_utils()->get_option( 'quiz_answer_display_time' ),
107 );
108 }
109
110 public function admin_scripts() {
111 wp_enqueue_style( 'tutor-select2', tutor()->url . 'assets/packages/select2/select2.min.css', array(), TUTOR_VERSION );
112 wp_enqueue_style( 'tutor-admin', tutor()->url . 'assets/css/tutor-admin.min.css', array(), TUTOR_VERSION );
113 /**
114 * Scripts
115 */
116 wp_enqueue_media();
117
118 wp_enqueue_script( 'wp-color-picker' );
119 wp_enqueue_style( 'wp-color-picker' );
120
121 wp_enqueue_script( 'jquery-ui-slider' );
122 wp_enqueue_script( 'jquery-ui-datepicker' );
123
124 wp_enqueue_script( 'tutor-select2', tutor()->url . 'assets/packages/select2/select2.full.min.js', array( 'jquery' ), TUTOR_VERSION, true );
125 wp_enqueue_script( 'tutor-admin', tutor()->url . 'assets/js/tutor-admin.min.js', array( 'jquery', 'wp-color-picker', 'wp-i18n' ), TUTOR_VERSION, true );
126 }
127
128 /**
129 * Load frontend scripts
130 */
131 public function frontend_scripts() {
132 global $post, $wp_query;
133
134 /**
135 * We checked wp_enqueue_editor() in condition because it conflicting with Divi Builder
136 * condition updated @since v.1.7.4
137 */
138
139 if ( is_single() ) {
140 if ( function_exists( 'et_pb_is_pagebuilder_used' ) ) {
141 $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
142 if ( ! $is_page_builder_used ) {
143 wp_enqueue_editor();
144 }
145 } else {
146 wp_enqueue_editor();
147 }
148 }
149
150 /**
151 * Initializing quicktags script to use in wp_editor();
152 */
153 wp_enqueue_script( 'quicktags' );
154
155 $tutor_dashboard_page_id = (int) tutor_utils()->get_option( 'tutor_dashboard_page_id' );
156 if ( $tutor_dashboard_page_id === get_the_ID() ) {
157 wp_enqueue_media();
158 }
159
160 /**
161 * Enabling Sorting, draggable, droppable...
162 */
163 wp_enqueue_script( 'jquery-ui-sortable' );
164 wp_enqueue_script( 'jquery-touch-punch', array( 'jquery-ui-sortable' ) );
165
166 // Plyr
167 if ( is_single_course( true ) ) {
168 wp_enqueue_style( 'tutor-plyr', tutor()->url . 'assets/packages/plyr/plyr.css', array(), TUTOR_VERSION );
169 wp_enqueue_script( 'tutor-plyr', tutor()->url . 'assets/packages/plyr/plyr.polyfilled.min.js', array( 'jquery' ), TUTOR_VERSION, true );
170 }
171
172 // Social Share
173 wp_enqueue_script( 'tutor-social-share', tutor()->url . 'assets/packages/SocialShare/SocialShare.min.js', array( 'jquery' ), TUTOR_VERSION, true );
174
175 /**
176 * Chart Data
177 */
178 if ( ! empty( $wp_query->query_vars['tutor_dashboard_page'] ) ) {
179 wp_enqueue_script( 'jquery-ui-slider' );
180
181 wp_enqueue_style( 'tutor-select2', tutor()->url . 'assets/packages/select2/select2.min.css', array(), TUTOR_VERSION );
182 wp_enqueue_script( 'tutor-select2', tutor()->url . 'assets/packages/select2/select2.full.min.js', array( 'jquery' ), TUTOR_VERSION, true );
183
184 if ( $wp_query->query_vars['tutor_dashboard_page'] === 'earning' ) {
185 wp_enqueue_script( 'tutor-front-chart-js', tutor()->url . 'assets/js/lib/Chart.bundle.min.js', array(), TUTOR_VERSION );
186 wp_enqueue_script( 'jquery-ui-datepicker' );
187 }
188 }
189 /**
190 * dependency wp-i18n added for
191 * translate js file
192 *
193 * @since 1.9.0
194 */
195 wp_enqueue_style( 'tutor-frontend', tutor()->url . 'assets/css/tutor-front.min.css', array(), TUTOR_VERSION );
196 wp_enqueue_script( 'tutor-frontend', tutor()->url . 'assets/js/tutor-front.min.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
197
198 /**
199 * Load frontend dashboard style
200 *
201 * @since v1.9.8
202 */
203 if ( tutor_utils()->is_tutor_frontend_dashboard() ) {
204 wp_enqueue_style( 'tutor-frontend-dashboard-css', tutor()->url . 'assets/css/tutor-frontend-dashboard.min.css', TUTOR_VERSION );
205 }
206
207 // Load date picker for announcement at frontend.
208 wp_enqueue_script( 'jquery-ui-datepicker' );
209 $css = ".mce-notification.mce-notification-error{display: none !important;}";
210 wp_add_inline_style( 'tutor-frontend', $css );
211 }
212
213 public function modify_localize_data( $localize_data ) {
214 global $post;
215
216 if ( is_admin() ) {
217 if ( ! empty( $_GET['taxonomy'] ) && ( $_GET['taxonomy'] === 'course-category' || $_GET['taxonomy'] === 'course-tag' ) ) {
218 $localize_data['open_tutor_admin_menu'] = true;
219 }
220 } else {
221
222 // Assign quiz option
223 if ( ! empty( $post->post_type ) && $post->post_type === 'tutor_quiz' ) {
224 $single_quiz_options = (array) tutor_utils()->get_quiz_option( $post->ID );
225 $saved_quiz_options = array(
226 'quiz_when_time_expires' => tutor_utils()->get_option( 'quiz_when_time_expires' ),
227 );
228
229 $quiz_options = array_merge( $single_quiz_options, $saved_quiz_options );
230
231 $previous_attempts = tutor_utils()->quiz_attempts();
232
233 if ( $previous_attempts && count( $previous_attempts ) ) {
234 $quiz_options['quiz_auto_start'] = 0;
235 }
236
237 $localize_data['quiz_options'] = $quiz_options;
238 }
239
240 // Including player assets if video exists
241 if ( tutor_utils()->has_video_in_single() ) {
242 $localize_data['post_id'] = get_the_ID();
243 $localize_data['best_watch_time'] = 0;
244
245 $best_watch_time = tutor_utils()->get_lesson_reading_info( get_the_ID(), 0, 'video_best_watched_time' );
246 if ( $best_watch_time > 0 ) {
247 $localize_data['best_watch_time'] = $best_watch_time;
248 }
249 }
250 }
251
252 return $localize_data;
253 }
254
255 /**
256 * Load common scripts
257 *
258 * @return void
259 */
260 public function common_scripts() {
261
262 /**
263 * Load TinyMCE for tutor settings page if
264 * tutor pro is not available.
265 *
266 * @since v2.0.8
267 */
268 $baseurl = includes_url( 'js/tinymce' );
269 $current_page = Input::get( 'page' );
270
271 // If it is settings page & tutor pro not activated.
272 if ( 'tutor_settings' === $current_page && ! wp_script_is( 'wp-tinymce-root' ) ) {
273 wp_enqueue_script( 'tutor-tiny', $baseurl . '/tinymce.min.js', array( 'jquery' ), TUTOR_VERSION, true );
274 }
275 wp_enqueue_style( 'tutor-icon', tutor()->url . 'assets/css/tutor-icon.min.css', array(), TUTOR_VERSION );
276
277 // Common css library.
278 if ( is_rtl() ) {
279 wp_enqueue_style( 'tutor', tutor()->url . 'assets/css/tutor.rtl.min.css', array(), TUTOR_VERSION );
280 } else {
281 wp_enqueue_style( 'tutor', tutor()->url . 'assets/css/tutor.min.css', array(), TUTOR_VERSION );
282 }
283
284 // Load course builder resources
285 if ( tutor_utils()->get_course_builder_screen() ) {
286 wp_enqueue_script( 'tutor-course-builder', tutor()->url . 'assets/js/tutor-course-builder.min.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
287 wp_enqueue_style( 'tutor-course-builder-css', tutor()->url . 'assets/css/tutor-course-builder.min.css', array(), TUTOR_VERSION );
288 }
289 /**
290 * Load tutor common scripts both backend and frontend
291 *
292 * @since v2.0.0
293 */
294 wp_enqueue_script( 'tutor-script', tutor()->url . 'assets/js/tutor.min.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
295 }
296
297 public function load_meta_data() {
298 // Localize scripts
299 $localize_data = apply_filters( 'tutor_localize_data', $this->get_default_localized_data() );
300 wp_localize_script( 'tutor-frontend', '_tutorobject', $localize_data );
301 wp_localize_script( 'tutor-admin', '_tutorobject', $localize_data );
302 wp_localize_script( 'tutor-course-builder', '_tutorobject', $localize_data );
303 wp_localize_script( 'tutor-script', '_tutorobject', $localize_data );
304
305 // Inline styles
306 wp_add_inline_style( 'tutor-frontend', $this->load_color_palette() );
307 wp_add_inline_style( 'tutor-admin', $this->load_color_palette() );
308 }
309
310 private function load_color_palette() {
311 $colors = array(
312 'tutor_primary_color' => '--tutor-color-primary',
313 'tutor_primary_hover_color' => '--tutor-color-primary-hover',
314 'tutor_text_color' => '--tutor-body-color',
315 'tutor_border_color' => '--tutor-border-color',
316 'tutor_gray_color' => '--tutor-color-gray',
317 );
318
319 // admin colors
320 $admin_colors = array();
321 if ( is_admin() ) {
322 $admin_color = get_user_option( 'admin_color' );
323
324 switch ( $admin_color ) {
325 case 'light':
326 $admin_color_codes = array( '#04a4cc', '#04b0db' );
327 break;
328
329 case 'modern':
330 $admin_color_codes = array( '#3858e9', '#4664eb' );
331 break;
332
333 case 'blue':
334 $admin_color_codes = array( '#e1a948', '#e3af55' );
335 break;
336
337 case 'coffee':
338 $admin_color_codes = array( '#c7a589', '#ccad93' );
339 break;
340
341 case 'ectoplasm':
342 $admin_color_codes = array( '#a3b745', '#a9bd4f' );
343 break;
344
345 case 'midnight':
346 $admin_color_codes = array( '#e14d43', '#e35950' );
347 break;
348
349 case 'ocean':
350 $admin_color_codes = array( '#9ebaa0', '#a7c0a9' );
351 break;
352
353 case 'sunrise':
354 $admin_color_codes = array( '#dd823b', '#df8a48' );
355 break;
356
357 default:
358 $admin_color_codes = array( '#007cba', '#006ba1' );
359 break;
360 }
361
362 $admin_colors = array(
363 '--tutor-color-primary' => $admin_color_codes[0],
364 '--tutor-color-primary-hover' => $admin_color_codes[1],
365 );
366 }
367
368 $fallback_colors = array(
369 'tutor_primary_color' => '#3E64DE',
370 'tutor_primary_hover_color' => '#395BCA',
371 'tutor_text_color' => '#212327',
372 'tutor_border_color' => '#E3E5EB',
373 'tutor_gray_color' => '#CDCFD5',
374 );
375
376 $color_string = '';
377 foreach ( $colors as $key => $property ) {
378 $fallback_color = isset( $fallback_colors[ $key ] ) ? $fallback_colors[ $key ] : '#212327';
379 $color = tutor_utils()->get_option( $key, $fallback_color );
380 $color_rgb = tutor_utils()->hex2rgb( $color );
381
382 if ( is_admin() && isset( $admin_colors[ $property ] ) ) {
383 $color = $admin_colors[ $property ];
384 $color_rgb = tutor_utils()->hex2rgb( $admin_colors[ $property ] );
385 }
386
387 if ( $color ) {
388 $color_string .= $property . ':' . $color . ';';
389 }
390
391 if ( $color_rgb ) {
392 $color_string .= $property . '-rgb:' . $color_rgb . ';';
393 }
394 }
395
396 return ':root{' . $color_string . '}';
397 }
398
399 /**
400 * Add Tinymce button for placing shortcode
401 */
402 function tutor_add_mce_button() {
403 // check user permissions
404 if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
405 return;
406 }
407 // check if WYSIWYG is enabled
408 if ( 'true' == get_user_option( 'rich_editing' ) ) {
409 add_filter( 'mce_external_plugins', array( $this, 'tutor_add_tinymce_js' ) );
410 add_filter( 'mce_buttons', array( $this, 'tutor_register_mce_button' ) );
411 }
412 }
413 // Declare script for new button
414 function tutor_add_tinymce_js( $plugin_array ) {
415 $plugin_array['tutor_button'] = tutor()->url . 'assets/js/lib/mce-button.js';
416 return $plugin_array;
417 }
418 // Register new button in the editor
419 function tutor_register_mce_button( $buttons ) {
420 array_push( $buttons, 'tutor_button' );
421 return $buttons;
422 }
423
424 /**
425 * Output generator tag to aid debugging.
426 *
427 * @param string $gen Generator.
428 * @param string $type Type.
429 * @return string
430 */
431 function tutor_generator_tag( $gen, $type ) {
432 switch ( $type ) {
433 case 'html':
434 $gen .= "\n" . '<meta name="generator" content="TutorLMS ' . TUTOR_VERSION . '">';
435 break;
436 case 'xhtml':
437 $gen .= "\n" . '<meta name="generator" content="TutorLMS ' . TUTOR_VERSION . '" />';
438 break;
439 }
440 return $gen;
441 }
442
443 /**
444 * load text domain handled script after all enqueue_scripts
445 * registered functions
446 *
447 * @since 1.9.0
448 */
449 function tutor_script_text_domain() {
450 wp_set_script_translations( 'tutor-frontend', 'tutor', tutor()->path . 'languages/' );
451 wp_set_script_translations( 'tutor-admin', 'tutor', tutor()->path . 'languages/' );
452 wp_set_script_translations( 'tutor-course-builder', 'tutor', tutor()->path . 'languages/' );
453 }
454
455 /**
456 * Add translation support for external tinyMCE button
457 *
458 * @since 1.9.7
459 */
460 function tutor_tinymce_translate() {
461 $locales['tutor_button'] = tutor()->path . 'includes/tinymce_translate.php';
462 return $locales;
463 }
464
465 public function add_identifier_class_to_body( $classes ) {
466 $course_builder_screen = tutor_utils()->get_course_builder_screen();
467 $to_add = array( 'tutor-lms' );
468
469 // Add backend course editor identifier class to body
470 if ( $course_builder_screen ) {
471 $to_add[] = is_admin() ? 'tutor-backend' : '';
472 $to_add[] = ' tutor-screen-course-builder tutor-screen-course-builder-' . $course_builder_screen . ' ';
473 }
474
475 // Add frontend course builder identifier class
476 if ( ! $course_builder_screen && tutor_utils()->is_tutor_frontend_dashboard() ) {
477 $to_add[] = 'tutor-screen-frontend-dashboard';
478 }
479
480 if ( is_admin() ) {
481 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
482 $base = ( $screen && is_object( $screen ) && property_exists( $screen, 'base' ) ) ? $screen->base : '';
483 $index = strpos( $base, 'tutor' );
484
485 if ( $index === 0 || $index > 0 ) {
486 $to_add[] = 'tutor-backend';
487
488 if ( isset( $_GET['page'] ) && $_GET['page'] == 'tutor_settings' ) {
489 $to_add[] = 'tutor-screen-backend-settings ';
490 }
491 if ( isset( $_GET['page'] ) ) {
492 $to_add[] = 'tutor-backend-' . $_GET['page'];
493 }
494 }
495 }
496
497 // Remove duplicate classes if any
498 $to_add = array_unique( $to_add );
499
500 if ( is_array( $classes ) ) {
501 $classes = array_merge( $classes, $to_add );
502 } else {
503 $classes .= implode( ' ', $to_add );
504 }
505
506 return $classes;
507 }
508
509 /**
510 * Enqueue script for adding edit with frontend course builder button
511 * on the Gutenberg editor
512 *
513 * @since v2.0.5
514 *
515 * @return void
516 */
517 public static function add_frontend_editor_button() {
518 $wp_screen = get_current_screen();
519
520 if ( is_a( $wp_screen, 'WP_Screen' ) && tutor()->course_post_type === $wp_screen->post_type ) {
521 wp_enqueue_script( 'tutor-gutenberg', tutor()->url . 'assets/js/tutor-gutenberg.min.js', array(), TUTOR_VERSION, true );
522 $data = array(
523 'frontend_dashboard_url' => esc_url( trailingslashit( tutor_utils()->tutor_dashboard_url( 'create-course' ) ) ) . '?course_ID=' . get_the_ID(),
524 );
525
526 wp_add_inline_script(
527 'tutor-gutenberg',
528 'const tutorInlineData =' . json_encode( $data ),
529 'before'
530 );
531 }
532 }
533 }
534