functions.php 2.0 KB

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