block-patterns.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Blockbase Theme: Block Patterns
  4. *
  5. * @package Blockbase
  6. */
  7. if ( ! function_exists( 'blockbase_register_block_patterns' ) ) :
  8. function blockbase_register_block_patterns() {
  9. if ( function_exists( 'register_block_pattern_category' ) ) {
  10. register_block_pattern_category(
  11. 'blockbase',
  12. array( 'label' => __( 'Blockbase', 'blockbase' ) )
  13. );
  14. }
  15. if ( function_exists( 'register_block_pattern' ) ) {
  16. $block_patterns = array(
  17. '404',
  18. 'footer-columns',
  19. 'footer-left',
  20. 'footer-primary',
  21. 'footer-search',
  22. 'footer-separator',
  23. 'footer-simple',
  24. 'footer-small',
  25. 'footer-with-site-title',
  26. );
  27. foreach ( $block_patterns as $block_pattern ) {
  28. register_block_pattern(
  29. 'blockbase/' . $block_pattern,
  30. require __DIR__ . '/patterns/' . $block_pattern . '.php'
  31. );
  32. }
  33. //register header templates also as patterns
  34. $header_patterns = array(
  35. 'centered',
  36. 'default',
  37. 'linear',
  38. 'minimal',
  39. 'rounded-logo',
  40. 'wide',
  41. );
  42. foreach ( $header_patterns as $header_pattern ) {
  43. register_block_pattern(
  44. 'blockbase/header-' . $header_pattern,
  45. array(
  46. 'title' => __( 'Blockbase Header (' . $header_pattern . ')', 'blockbase' ),
  47. 'categories' => array( 'header' ),
  48. 'blockTypes' => array( 'core/template-part/header' ),
  49. 'content' => file_get_contents (get_theme_file_path( '/parts/header-' . $header_pattern . '.html' )),
  50. )
  51. );
  52. }
  53. }
  54. }
  55. endif;
  56. add_action( 'init', 'blockbase_register_block_patterns', 9 );