functions.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Course functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Course
  8. * @since Course 1.0
  9. */
  10. if ( ! function_exists( 'course_support' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * @since Course 1.0
  15. *
  16. * @return void
  17. */
  18. function course_support() {
  19. add_theme_support( 'sensei-learning-mode' );
  20. // Enqueue editor styles.
  21. add_editor_style( 'style.css' );
  22. add_editor_style( 'learning-mode.css' );
  23. }
  24. endif;
  25. add_action( 'after_setup_theme', 'course_support' );
  26. if (!function_exists( 'course_scripts' )) :
  27. /**
  28. * Enqueue scripts and styles.
  29. *
  30. * @since Course 1.0
  31. *
  32. * @return void
  33. */
  34. function course_scripts() {
  35. // Register theme stylesheet.
  36. wp_register_style(
  37. 'course-style',
  38. get_stylesheet_directory_uri() . '/style.css',
  39. array(),
  40. wp_get_theme()->get( 'Version' )
  41. );
  42. wp_register_style(
  43. 'course-sensei-learning-mode',
  44. get_stylesheet_directory_uri() . '/learning-mode.css',
  45. array(),
  46. wp_get_theme()->get(
  47. 'Version'
  48. )
  49. );
  50. // Enqueue theme stylesheet.
  51. wp_enqueue_style( 'course-style' );
  52. // TODO: Only Load it if the the page is using learning mode
  53. wp_enqueue_style( 'course-sensei-learning-mode' );
  54. // Enqueque theme scripts.
  55. wp_enqueue_script( 'course-header', get_template_directory_uri() . '/assets/js/header.js', [], wp_get_theme()->get( 'Version' ), true );
  56. }
  57. endif;
  58. add_action( 'wp_enqueue_scripts', 'course_scripts' );
  59. function course_theme_init() {
  60. register_block_style(
  61. 'core/navigation-link',
  62. array(
  63. 'name' => 'navigation-link-button',
  64. 'label' => __( 'Button', 'course' ),
  65. )
  66. );
  67. }
  68. add_action( 'init', 'course_theme_init' );
  69. /**
  70. * Register Sensei LMS block patterns category.
  71. */
  72. function course_register_block_patterns_category() {
  73. register_block_pattern_category(
  74. 'sensei-lms',
  75. [ 'label' => 'Sensei LMS' ]
  76. );
  77. }
  78. add_action( 'init', 'course_register_block_patterns_category' );