From 5ec4ac5094af461fa60842549abac80405267ab4 Mon Sep 17 00:00:00 2001 From: Imran Hossain Date: Tue, 22 Aug 2023 06:44:15 +0600 Subject: [PATCH 1/6] Enqueue the styles and scripts --- course/functions.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/course/functions.php b/course/functions.php index 08be1b9363..1fa2c6bfaa 100644 --- a/course/functions.php +++ b/course/functions.php @@ -41,9 +41,14 @@ function course_support() { */ function course_scripts() { wp_register_style( 'course-style', get_stylesheet_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) ); - wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', [], wp_get_theme()->get( 'Version' ), true ); + wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', array(), wp_get_theme()->get( 'Version' ), true ); wp_enqueue_style( 'course-style' ); + // Load gravatar-hovercard related styles and scripts. + wp_enqueue_style( 'gravatar-hovercard-style', 'https://unpkg.com/@gravatar-com/hovercards@0.5.7/dist/style.css', array(), 'unversioned' ); + wp_register_script( 'gravatar-hovercard-js', 'https://unpkg.com/@gravatar-com/hovercards@0.5.7', array(), 'unversioned', false ); + wp_enqueue_script( 'gravatar-hovercard-setup-js', get_template_directory_uri() . '/assets/js/hovercard-setup.js', array( 'gravatar-hovercard-js' ), wp_get_theme()->get( 'Version' ), true ); + /** * Temporary Hook to skip the learning mode style when the Sensei LMS is able to provide it. * It is only used to continue loading the deprecated styles if a old sensei version is installed. @@ -79,7 +84,7 @@ function course_theme_init() { function course_register_block_patterns_category() { register_block_pattern_category( 'sensei-lms', - [ 'label' => 'Sensei LMS' ] + array( 'label' => 'Sensei LMS' ) ); } @@ -119,3 +124,28 @@ function course_theme_filter_single_lesson_template_for_sensei_learning_mode( $p return $page_templates; } +/** + * Defer the parsing of specific JS scripts. + * + * @param string $tag The