Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip loading the Learning Mode styles when Sensei is not available #7031

Merged
merged 7 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions course/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* @return void
*/
function course_support() {

add_theme_support( 'sensei-learning-mode' );

// Enqueue editor styles.
Expand All @@ -32,7 +31,7 @@ function course_support() {

add_action( 'after_setup_theme', 'course_support' );

if (!function_exists( 'course_scripts' )) :
if ( ! function_exists( 'course_scripts' ) ) :

/**
* Enqueue scripts and styles.
Expand All @@ -42,33 +41,21 @@ function course_support() {
* @return void
*/
function course_scripts() {

// Register theme stylesheet.
wp_register_style(
'course-style',
get_stylesheet_directory_uri() . '/style.css',
array(),
wp_get_theme()->get( 'Version' )
);

wp_register_style(
'course-sensei-learning-mode',
get_stylesheet_directory_uri() . '/learning-mode.css',
array(),
wp_get_theme()->get(
'Version'
)
);

// Enqueue theme stylesheet.
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_style( 'course-style' );

// TODO: Only Load it if the the page is using learning mode
wp_enqueue_style( 'course-sensei-learning-mode' );
/**
* 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.
*/
$use_style_from_sensei = apply_filters( 'course_learning_mode_load_styles', false );

// Enqueque theme scripts.
wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', [], wp_get_theme()->get( 'Version' ), true );
}
if ( class_exists( 'Sensei_Main' ) && empty( $use_style_from_sensei ) ) {
wp_register_style( 'course-sensei-learning-mode', get_stylesheet_directory_uri() . '/learning-mode.css', array(), wp_get_theme()->get( 'Version' ) );
wp_enqueue_style( 'course-sensei-learning-mode' );
}
}

endif;

Expand Down Expand Up @@ -96,4 +83,4 @@ function course_register_block_patterns_category() {
);
}

add_action( 'init', 'course_register_block_patterns_category' );
add_action( 'init', 'course_register_block_patterns_category' );
5 changes: 5 additions & 0 deletions course/learning-mode.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
### DEPRECATED FILE ###
Please don't update it, this file will be moved to the Sensei plugin to better Maintainability.

**/
:root, .sensei-course-theme {
--sensei-lm-header-height: 116px;
}
Expand Down