123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /**
- * Course functions and definitions
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package Course
- * @since Course 1.0
- */
- if ( ! function_exists( 'course_support' ) ) :
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * @since Course 1.0
- *
- * @return void
- */
- function course_support() {
- add_theme_support( 'sensei-learning-mode' );
- // Enqueue editor styles.
- add_editor_style( 'style.css' );
- }
- endif;
- add_action( 'after_setup_theme', 'course_support' );
- if ( ! function_exists( 'course_scripts' ) ) :
- /**
- * Enqueue scripts and styles.
- *
- * @since Course 1.0
- *
- * @return void
- */
- 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_style( 'course-style' );
- /**
- * 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' );
- }
- }
- endif;
- add_action( 'wp_enqueue_scripts', 'course_scripts' );
- function course_theme_init() {
- register_block_style(
- 'core/navigation-link',
- array(
- 'name' => 'navigation-link-button',
- 'label' => __( 'Button', 'course' ),
- )
- );
- }
- add_action( 'init', 'course_theme_init' );
- /**
- * Register Sensei LMS block patterns category.
- */
- function course_register_block_patterns_category() {
- register_block_pattern_category(
- 'sensei-lms',
- [ 'label' => 'Sensei LMS' ]
- );
- }
- add_action( 'init', 'course_register_block_patterns_category' );
- add_filter(
- 'theme_lesson_templates',
- 'course_theme_filter_single_lesson_template_for_sensei_learning_mode',
- 11,
- 3
- );
- /**
- * Filter the list of templates for the single lesson page.
- *
- * @param array $page_templates Array of page templates.
- * @param string $theme The current theme.
- * @param WP_Post $post The post being edited, provided for context, or null.
- *
- * @since Course 1.3.2
- *
- * @return array Array of page templates.
- */
- function course_theme_filter_single_lesson_template_for_sensei_learning_mode( $page_templates, $theme, $post ) {
- // In case some other plugin has a post type called lesson.
- if ( ! $post || ! class_exists( 'Sensei_Main' ) ) {
- return $page_templates;
- }
- $course_id = Sensei()->lesson->get_course_id( $post->ID );
- $is_learning_mode_enabled = Sensei_Course_Theme_Option::has_learning_mode_enabled( $course_id );
- if ( $is_learning_mode_enabled ) {
- unset( $page_templates['single-lesson'] );
- }
- return $page_templates;
- }
|