block-patterns.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Spearhead Theme: Block Patterns
  4. *
  5. * @package Spearhead
  6. * @since 1.0.0
  7. */
  8. if ( ! function_exists( 'spearhead_register_block_patterns' ) ) :
  9. /**
  10. * Sets up support for block patterns and unregisters Seedlet's.
  11. */
  12. function spearhead_register_block_patterns() {
  13. /**
  14. * Register Block Pattern Category.
  15. */
  16. if ( function_exists( 'register_block_pattern_category' ) ) {
  17. register_block_pattern_category(
  18. 'spearhead',
  19. array( 'label' => __( 'Spearhead', 'spearhead' ) )
  20. );
  21. }
  22. /**
  23. * Register Block Patterns.
  24. */
  25. if ( function_exists( 'register_block_pattern' ) ) {
  26. register_block_pattern(
  27. 'spearhead/related-posts',
  28. array(
  29. 'title' => __( 'Related Posts', 'spearhead' ),
  30. 'categories' => array( 'spearhead' ),
  31. 'content' => '<!-- wp:separator {"className":"is-style-wide"} --><hr class="wp-block-separator is-style-wide"/><!-- /wp:separator --><!-- wp:paragraph {"fontSize":"medium"} --><p class="has-medium-font-size">Related</p><!-- /wp:paragraph --><!-- wp:jetpack/related-posts /-->',
  32. )
  33. );
  34. register_block_pattern(
  35. 'spearhead/archive-page',
  36. array(
  37. 'title' => __( 'Archive page', 'spearhead' ),
  38. 'categories' => array( 'spearhead' ),
  39. 'content' => '<!-- wp:search {"label":"Search","showLabel":false,"placeholder":"Search...","buttonText":"Search","buttonPosition":"button-inside","buttonUseIcon":true} /-->
  40. <!-- wp:spacer {"height":30} --><div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer -->
  41. <!-- wp:paragraph --><p>' . __( 'Latest Posts', 'spearhead' ) . '</p><!-- /wp:paragraph -->
  42. <!-- wp:latest-posts /-->
  43. <!-- wp:spacer {"height":10} --><div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div><!-- /wp:spacer -->
  44. <!-- wp:paragraph --><p>' . __( 'Categories', 'spearhead' ) . '</p><!-- /wp:paragraph -->
  45. <!-- wp:categories /-->',
  46. )
  47. );
  48. }
  49. /**
  50. * Unregister SeedletBlock Pattern Category.
  51. */
  52. if ( function_exists( 'unregister_block_pattern_category' ) ) {
  53. unregister_block_pattern_category( 'seedlet' );
  54. }
  55. /**
  56. * Unregister Block Patterns from Seedlet.
  57. */
  58. if ( function_exists( 'unregister_block_pattern' ) ) {
  59. unregister_block_pattern( 'seedlet/group-split-background' );
  60. unregister_block_pattern( 'seedlet/group-image-overlap' );
  61. unregister_block_pattern( 'seedlet/latest-posts-alternating-grid' );
  62. }
  63. }
  64. endif;
  65. add_action( 'after_setup_theme', 'spearhead_register_block_patterns', 12 );