functions.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Twenty Twenty-Two functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package WordPress
  8. * @subpackage Twenty_Twenty_Two
  9. * @since Twenty Twenty-Two 1.0
  10. */
  11. if ( ! function_exists( 'twentytwentytwo_support' ) ) :
  12. /**
  13. * Sets up theme defaults and registers support for various WordPress features.
  14. *
  15. * @since Twenty Twenty-Two 1.0
  16. *
  17. * @return void
  18. */
  19. function twentytwentytwo_support() {
  20. // Add support for block styles.
  21. add_theme_support( 'wp-block-styles' );
  22. // Enqueue editor styles.
  23. add_editor_style( 'style.css' );
  24. }
  25. endif;
  26. add_action( 'after_setup_theme', 'twentytwentytwo_support' );
  27. if ( ! function_exists( 'twentytwentytwo_styles' ) ) :
  28. /**
  29. * Enqueue styles.
  30. *
  31. * @since Twenty Twenty-Two 1.0
  32. *
  33. * @return void
  34. */
  35. function twentytwentytwo_styles() {
  36. // Register theme stylesheet.
  37. $theme_version = wp_get_theme()->get( 'Version' );
  38. $version_string = is_string( $theme_version ) ? $theme_version : false;
  39. wp_register_style(
  40. 'twentytwentytwo-style',
  41. get_template_directory_uri() . '/style.css',
  42. array(),
  43. $version_string
  44. );
  45. // Enqueue theme stylesheet.
  46. wp_enqueue_style( 'twentytwentytwo-style' );
  47. }
  48. endif;
  49. add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' );
  50. // Add block patterns
  51. require get_template_directory() . '/inc/block-patterns.php';