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 3 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
45 changes: 18 additions & 27 deletions course/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/


// require 'wp-admin/includes/plugin.php';
m1r0 marked this conversation as resolved.
Show resolved Hide resolved
if ( ! function_exists( 'course_support' ) ) :

/**
Expand All @@ -20,7 +21,6 @@
* @return void
*/
function course_support() {

add_theme_support( 'sensei-learning-mode' );

// Enqueue editor styles.
Expand All @@ -32,7 +32,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 +42,24 @@ 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' );
$has_sensei = function_exists( 'Sensei' );
donnapep marked this conversation as resolved.
Show resolved Hide resolved

/**
* Temporary Hook to skip the learning mode style when the Sensei LMS is able to provide it.
* It only use the deprecated style if an old sensei version is installed.
*/
$use_style_from_sensei = apply_filters( 'internal_course_theme_use_learning_mode_style_from_sensei', false );
donnapep marked this conversation as resolved.
Show resolved Hide resolved

// Enqueque theme scripts.
wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', [], wp_get_theme()->get( 'Version' ), true );
}
if ( $has_sensei && empty($use_style_from_sensei) ) {
donnapep marked this conversation as resolved.
Show resolved Hide resolved
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 +87,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