zed_data() ); if ( $is_kids_mode ) { $google_font_url = 'https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700&display=swap'; wp_enqueue_style( 'tutor-kids', $kids_css_url, array( 'tutor-core' ), $version ); } // Core. wp_enqueue_style( 'tutor-google-fonts', $google_font_url, array(), $version ); wp_enqueue_style( 'tutor-core', $core_css_url, array( 'tutor-google-fonts' ), $version ); wp_enqueue_script( 'tutor-core', $core_js_url, array( 'wp-i18n', 'wp-date' ), $version, true ); wp_localize_script( 'tutor-core', '_tutorobject', $localize_data ); // Generate color palette from user selected brand color and add to the root. $brand_color = tutor_utils()->get_brand_color(); if ( Options_V2::DEFAULT_BRAND_COLOR !== $brand_color ) { wp_add_inline_style( 'tutor-core', $this->load_core_color_palette( $brand_color ) ); } if ( $is_dashboard ) { wp_enqueue_style( 'tutor-dashboard', $dashboard_css_url, array(), $version ); wp_enqueue_script( 'tutor-dashboard', $dashboard_js_url, array( 'tutor-core', 'wp-i18n', 'wp-date' ), $version, true ); } if ( $is_learning_area ) { wp_enqueue_style( 'tutor-learning', $learning_area_css_url, array(), $version ); wp_enqueue_script( 'tutor-learning', $learning_area_js_url, array( 'tutor-core', 'wp-i18n', 'wp-date' ), $version, true ); if ( is_single_course( true ) ) { wp_enqueue_style( 'tutor-plyr', tutor()->url . 'assets/lib/plyr/plyr.css', array(), $version ); wp_enqueue_script( 'tutor-plyr', tutor()->url . 'assets/lib/plyr/plyr.polyfilled.min.js', array( 'jquery' ), $version, true ); } } wp_enqueue_style( 'tutor-cart-button' ); } /** * Check if need to load legacy scripts * * If the current screen is dashboard or new learning area * then this method will return false to avoid loading legacy css & js files * * @since 4.0.0 * * @return boolean */ public static function should_load_legacy_scripts(): bool { // Always load in the admin panel. if ( is_admin() ) { return true; } $load = true; $post_id = get_the_ID(); $is_learning_area = tutor_utils()->is_learning_area(); $is_legacy_learning = tutor_utils()->is_legacy_learning_mode(); $is_dashboard = tutor_utils()->is_dashboard_page(); $page_ids = array( (int) tutor_utils()->get_option( 'student_register_page' ), (int) tutor_utils()->get_option( 'instructor_register_page' ), ); // Ignore loading legacy scripts on specific case. if ( $is_learning_area && ! $is_legacy_learning ) { $load = false; } elseif ( $is_dashboard ) { $load = false; } elseif ( in_array( $post_id, $page_ids, true ) ) { $load = false; } else { // Ignore loading legacy scripts for these shortcodes. $has_shortcode = false; $shortcdes = array( 'tutor_student_registration_form', 'tutor_instructor_registration_form', 'tutor_dashboard', 'tutor_login', ); $post_content = get_the_content(); foreach ( $shortcdes as $shortcde ) { $has_shortcode = has_shortcode( $post_content, $shortcde ); if ( $has_shortcode ) { $load = false; break; } } // Ignore loading legacy scripts for these blocks on frontend. if ( $load && function_exists( 'has_block' ) ) { $blocks = array( 'tutor-gutenberg/student-registration', 'tutor-gutenberg/instructor-registration', ); foreach ( $blocks as $block ) { if ( has_block( $block, $post_id ) ) { $load = false; break; } } } } return apply_filters( 'tutor_should_load_legacy_scripts', $load ); } /** * Add custom meta data to the head section. * * Outputs a viewport meta tag to improve mobile responsiveness. * * @since 4.0.0 * * @return void */ public function add_custom_data() { if ( tutor_utils()->is_dashboard_page() || tutor_utils()->is_learning_area() ) { echo '' . "\n"; } } /** * Add preload to CSS * * @param string $html HTML. * @param string $handle Handle. * * @since 4.0.0 * * @return string */ public function add_preload_to_css( $html, $handle ) { if ( 'tutor-google-fonts' === $handle ) { $html = str_replace( "rel='stylesheet'", "rel='preload' as='style' onload=\"this.onload=null;this.rel='stylesheet'\"", $html ); } return $html; } }