Skip to content

Commit

Permalink
Course: Skip the learning mode style when sensei is not available (#7031
Browse files Browse the repository at this point in the history
)

* Skip the learning mode style when sensei is not available
  • Loading branch information
gabrielcaires committed May 3, 2023
1 parent 679c457 commit e342cf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
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,22 @@ 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_deprecated_style = apply_filters( 'course_learning_mode_load_styles', true );

if ( class_exists( 'Sensei_Main' ) && $use_deprecated_style ) {
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' );
}

// Enqueque theme scripts.
wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', [], wp_get_theme()->get( 'Version' ), true );
}
}

endif;

Expand Down Expand Up @@ -99,7 +87,6 @@ function course_register_block_patterns_category() {
}

add_action( 'init', 'course_register_block_patterns_category' );

/**
* Determine the theme variation and save in option.
*
Expand Down
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

0 comments on commit e342cf0

Please sign in to comment.