block-patterns.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. register_block_pattern(
  49. 'spearhead/podcast-links',
  50. array(
  51. 'title' => __( 'Podcast links', 'spearhead' ),
  52. 'categories' => array( 'spearhead' ),
  53. 'content' => '
  54. <!-- wp:navigation {"orientation":"horizontal"} -->
  55. <!-- wp:paragraph --><p>' . __( 'Podcast available on:', 'spearhead' ) . '</p><!-- /wp:paragraph -->
  56. <!-- wp:navigation-link {"label":"Apple","url":"https://www.apple.com/"} /-->
  57. <!-- wp:navigation-link {"label":"Breaker","url":"https://www.breaker.audio/"} /-->
  58. <!-- wp:navigation-link {"label":"Google","url":"https://www.google.com/"} /-->
  59. <!-- wp:navigation-link {"label":"LinkedIn","url":"https://www.linkedin.com/"} /-->
  60. <!-- wp:navigation-link {"label":"Overcast","url":"https://overcast.fm/"} /-->
  61. <!-- wp:navigation-link {"label":"Spotify","url":"https://spotify.com/"} /-->
  62. <!-- wp:navigation-link {"label":"Twitter","url":"https://twitter.com/"} /-->
  63. <!-- wp:navigation-link {"label":"YouTube","url":"https://youtube.com/"} /-->
  64. <!-- /wp:navigation -->',
  65. )
  66. );
  67. register_block_pattern(
  68. 'spearhead/podcast-links-list',
  69. array(
  70. 'title' => __( 'Podcast links list', 'spearhead' ),
  71. 'categories' => array( 'spearhead' ),
  72. 'content' => '<!-- wp:paragraph {"className":"podcast-links-list-block","style":{"typography":{"fontSize":18}}} --><p class="podcast-links-list-block" style="font-size:18px"><a rel="noreferrer noopener" target="_blank" href="https://www.apple.com/">Apple </a>•<a rel="noreferrer noopener" target="_blank" href="https://www.breaker.audio/">Breaker </a>•<a rel="noreferrer noopener" target="_blank" href="https://www.google.com/">Google </a>•<a rel="noreferrer noopener" target="_blank" href="https://www.linkedin.com/">LinkedIn </a>•<a rel="noreferrer noopener" target="_blank" href="https://overcast.fm/">Overcast </a>•<a rel="noreferrer noopener" target="_blank" href="https://www.spotify.com/">Spotify </a>•<a rel="noreferrer noopener" target="_blank" href="https://twitter.com/">Twitter </a>•<a href="https://www.youtube.com/" target="_blank" rel="noreferrer noopener">YouTube</a></p><!-- /wp:paragraph -->',
  73. )
  74. );
  75. }
  76. /**
  77. * Unregister SeedletBlock Pattern Category.
  78. */
  79. if ( function_exists( 'unregister_block_pattern_category' ) ) {
  80. unregister_block_pattern_category( 'seedlet' );
  81. }
  82. /**
  83. * Unregister Block Patterns from Seedlet.
  84. */
  85. if ( function_exists( 'unregister_block_pattern' ) ) {
  86. unregister_block_pattern( 'seedlet/group-split-background' );
  87. unregister_block_pattern( 'seedlet/group-image-overlap' );
  88. unregister_block_pattern( 'seedlet/latest-posts-alternating-grid' );
  89. }
  90. }
  91. endif;
  92. add_action( 'after_setup_theme', 'spearhead_register_block_patterns', 12 );