block-patterns.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * Twenty Twenty-Two: Block Patterns
  4. *
  5. * @since Twenty Twenty-Two 1.0
  6. */
  7. /**
  8. * Registers block patterns and categories.
  9. *
  10. * @since Twenty Twenty-Two 1.0
  11. *
  12. * @return void
  13. */
  14. function twentytwentytwo_register_block_patterns() {
  15. $block_pattern_categories = array(
  16. 'featured' => array( 'label' => __( 'Featured', 'twentytwentytwo' ) ),
  17. 'footer' => array( 'label' => __( 'Footers', 'twentytwentytwo' ) ),
  18. 'header' => array( 'label' => __( 'Headers', 'twentytwentytwo' ) ),
  19. 'query' => array( 'label' => __( 'Query', 'twentytwentytwo' ) ),
  20. 'pages' => array( 'label' => __( 'Pages', 'twentytwentytwo' ) ),
  21. );
  22. /**
  23. * Filters the theme block pattern categories.
  24. *
  25. * @since Twenty Twenty-Two 1.0
  26. *
  27. * @param array[] $block_pattern_categories {
  28. * An associative array of block pattern categories, keyed by category name.
  29. *
  30. * @type array[] $properties {
  31. * An array of block category properties.
  32. *
  33. * @type string $label A human-readable label for the pattern category.
  34. * }
  35. * }
  36. */
  37. $block_pattern_categories = apply_filters( 'twentytwentytwo_block_pattern_categories', $block_pattern_categories );
  38. foreach ( $block_pattern_categories as $name => $properties ) {
  39. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  40. register_block_pattern_category( $name, $properties );
  41. }
  42. }
  43. $block_patterns = array(
  44. 'footer-default',
  45. 'footer-dark',
  46. 'footer-logo',
  47. 'footer-navigation',
  48. 'footer-title-tagline-social',
  49. 'footer-social-copyright',
  50. 'footer-navigation-copyright',
  51. 'footer-about-title-logo',
  52. 'footer-query-title-citation',
  53. 'footer-query-images-title-citation',
  54. 'footer-blog',
  55. 'general-subscribe',
  56. 'general-featured-posts',
  57. 'general-layered-images-with-duotone',
  58. 'general-wide-image-intro-buttons',
  59. 'general-large-list-names',
  60. 'general-video-header-details',
  61. 'general-list-events',
  62. 'general-two-images-text',
  63. 'general-image-with-caption',
  64. 'general-video-trailer',
  65. 'general-pricing-table',
  66. 'general-divider-light',
  67. 'general-divider-dark',
  68. 'header-default',
  69. 'header-large-dark',
  70. 'header-small-dark',
  71. 'header-image-background',
  72. 'header-image-background-overlay',
  73. 'header-with-tagline',
  74. 'header-text-only-green-background',
  75. 'header-text-only-salmon-background',
  76. 'header-title-and-button',
  77. 'header-text-only-with-tagline-black-background',
  78. 'header-logo-navigation-gray-background',
  79. 'header-logo-navigation-social-black-background',
  80. 'header-title-navigation-social',
  81. 'header-logo-navigation-offset-tagline',
  82. 'header-stacked',
  83. 'header-centered-logo',
  84. 'header-centered-logo-black-background',
  85. 'header-centered-title-navigation-social',
  86. 'header-title-and-button',
  87. 'hidden-404',
  88. 'hidden-bird',
  89. 'hidden-heading-and-bird',
  90. 'page-about-media-left',
  91. 'page-about-simple-dark',
  92. 'page-about-media-right',
  93. 'page-about-solid-color',
  94. 'page-about-links',
  95. 'page-about-links-dark',
  96. 'page-about-large-image-and-buttons',
  97. 'page-layout-image-and-text',
  98. 'page-layout-image-text-and-video',
  99. 'page-layout-two-columns',
  100. 'page-sidebar-poster',
  101. 'page-sidebar-grid-posts',
  102. 'page-sidebar-blog-posts',
  103. 'page-sidebar-blog-posts-right',
  104. 'query-default',
  105. 'query-simple-blog',
  106. 'query-grid',
  107. 'query-text-grid',
  108. 'query-image-grid',
  109. 'query-large-titles',
  110. 'query-irregular-grid',
  111. );
  112. /**
  113. * Filters the theme block patterns.
  114. *
  115. * @since Twenty Twenty-Two 1.0
  116. *
  117. * @param array $block_patterns List of block patterns by name.
  118. */
  119. $block_patterns = apply_filters( 'twentytwentytwo_block_patterns', $block_patterns );
  120. foreach ( $block_patterns as $block_pattern ) {
  121. $pattern_file = get_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' );
  122. register_block_pattern(
  123. 'twentytwentytwo/' . $block_pattern,
  124. require $pattern_file
  125. );
  126. }
  127. }
  128. add_action( 'init', 'twentytwentytwo_register_block_patterns', 9 );