functions.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Sets up theme defaults and registers support for various WordPress features.
  4. */
  5. function stewart_support() {
  6. // Add support for block styles.
  7. add_theme_support( 'wp-block-styles' );
  8. }
  9. add_action( 'after_setup_theme', 'stewart_support' );
  10. /**
  11. * Enqueue styles.
  12. */
  13. function stewart_styles() {
  14. // Register theme stylesheet.
  15. wp_register_style(
  16. 'stewart-style',
  17. get_stylesheet_directory_uri() . '/style.css',
  18. array(),
  19. wp_get_theme()->get( 'Version' )
  20. );
  21. // Enqueue theme stylesheet.
  22. wp_enqueue_style( 'stewart-style' );
  23. }
  24. add_action( 'wp_enqueue_scripts', 'stewart_styles' );
  25. /**
  26. * Registers block patterns and categories.
  27. *
  28. * @since Stewart 1.7
  29. *
  30. * @return void
  31. */
  32. function stewart_register_block_pattern_categories() {
  33. $block_pattern_categories = array(
  34. 'images' => array( 'label' => __( 'Images', 'stewart' ) ),
  35. 'featured' => array( 'label' => __( 'Featured', 'stewart' ) ),
  36. 'footer' => array( 'label' => __( 'Footers', 'stewart' ) ),
  37. 'pages' => array( 'label' => __( 'Pages', 'stewart' ) ),
  38. 'sidebar' => array( 'label' => __( 'Sidebar', 'stewart' ) ),
  39. 'query' => array( 'label' => __( 'Query', 'stewart' ) ),
  40. );
  41. /**
  42. * Filters the theme block pattern categories.
  43. *
  44. * @since stewart 1.7
  45. *
  46. * @param array[] $block_pattern_categories {
  47. * An associative array of block pattern categories, keyed by category name.
  48. *
  49. * @type array[] $properties {
  50. * An array of block category properties.
  51. *
  52. * @type string $label A human-readable label for the pattern category.
  53. * }
  54. * }
  55. */
  56. $block_pattern_categories = apply_filters( 'stewart_block_pattern_categories', $block_pattern_categories );
  57. foreach ( $block_pattern_categories as $name => $properties ) {
  58. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  59. register_block_pattern_category( $name, $properties );
  60. }
  61. }
  62. }
  63. add_action( 'init', 'stewart_register_block_pattern_categories', 9 );