functions.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /**
  3. * Assembler functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Assembler
  8. * @since Assembler 1.0
  9. */
  10. declare( strict_types = 1 );
  11. if ( ! function_exists( 'assembler_unregister_patterns' ) ) :
  12. /**
  13. * Unregister Jetpack patterns and core patterns bundled in WordPress.
  14. */
  15. function assembler_unregister_patterns() {
  16. $pattern_names = array(
  17. // Jetpack form patterns.
  18. 'contact-form',
  19. 'newsletter-form',
  20. 'rsvp-form',
  21. 'registration-form',
  22. 'appointment-form',
  23. 'feedback-form',
  24. // Patterns bundled in WordPress core.
  25. // These would be removed by remove_theme_support( 'core-block-patterns' )
  26. // if it's called on the init action with priority 9 from a plugin, not from a theme.
  27. 'core/query-standard-posts',
  28. 'core/query-medium-posts',
  29. 'core/query-small-posts',
  30. 'core/query-grid-posts',
  31. 'core/query-large-title-posts',
  32. 'core/query-offset-posts',
  33. 'core/social-links-shared-background-color',
  34. );
  35. foreach ( $pattern_names as $pattern_name ) {
  36. $pattern = \WP_Block_Patterns_Registry::get_instance()->get_registered( $pattern_name );
  37. if ( $pattern ) {
  38. unregister_block_pattern( $pattern_name );
  39. }
  40. }
  41. }
  42. endif;
  43. if ( ! function_exists( 'assembler_setup' ) ) :
  44. /**
  45. * Sets up theme defaults and registers support for various WordPress features.
  46. *
  47. * @since Assembler 1.0
  48. *
  49. * @return void
  50. */
  51. function assembler_setup() {
  52. // Enqueue editor styles.
  53. add_editor_style( 'style.css' );
  54. // Unregister Jetpack form patterns and core patterns bundled in WordPress.
  55. // Simple sites
  56. assembler_unregister_patterns();
  57. add_filter( 'wp_loaded', function () {
  58. // Atomic sites
  59. assembler_unregister_patterns();
  60. } );
  61. // Remove theme support for the core and featured patterns coming from the Dotorg pattern directory.
  62. remove_theme_support( 'core-block-patterns' );
  63. }
  64. endif;
  65. add_action( 'after_setup_theme', 'assembler_setup' );
  66. if ( ! function_exists( 'assembler_styles' ) ) :
  67. /**
  68. * Enqueue styles.
  69. *
  70. * @since Assembler 1.0
  71. *
  72. * @return void
  73. */
  74. function assembler_styles() {
  75. // Register theme stylesheet.
  76. wp_register_style(
  77. 'assembler-style',
  78. get_stylesheet_directory_uri() . '/style.css',
  79. array(),
  80. wp_get_theme()->get( 'Version' )
  81. );
  82. // Enqueue theme stylesheet.
  83. wp_enqueue_style( 'assembler-style' );
  84. }
  85. endif;
  86. add_action( 'wp_enqueue_scripts', 'assembler_styles' );
  87. gutenberg_register_block_style(
  88. array( 'core/group', 'core/columns' ),
  89. array(
  90. 'name' => '2',
  91. 'label' => __( 'Light', 'assembler' ),
  92. 'style_data' => array(
  93. 'color' => array(
  94. 'background' => 'var(--wp--preset--color--theme-2)',
  95. )
  96. ),
  97. )
  98. );
  99. gutenberg_register_block_style(
  100. array( 'core/group', 'core/columns' ),
  101. array(
  102. 'name' => '3',
  103. 'label' => __( 'Dark', 'assembler' ),
  104. 'style_data' => array(
  105. 'color' => array(
  106. 'background' => 'var(--wp--preset--color--theme-4)',
  107. 'text' => 'var(--wp--preset--color--theme-2)',
  108. ),
  109. 'elements' => array(
  110. 'button' => array(
  111. 'color' => array(
  112. 'background' => 'var(--wp--preset--color--theme-1)',
  113. 'text' => 'var(--wp--preset--color--theme-4)',
  114. ),
  115. ':hover' => array(
  116. 'color' => array(
  117. 'background' => 'var(--wp--preset--color--theme-2)',
  118. ),
  119. ),
  120. ),
  121. 'heading' => array(
  122. 'color' => array(
  123. 'text' => 'var(--wp--preset--color--theme-1)',
  124. )
  125. ),
  126. 'link' => array(
  127. 'color' => array(
  128. 'text' => 'currentColor',
  129. ),
  130. ':hover' => array(
  131. 'color' => array(
  132. 'text' => 'currentColor',
  133. ),
  134. ),
  135. ),
  136. ),
  137. ),
  138. )
  139. );
  140. gutenberg_register_block_style(
  141. array( 'core/group', 'core/columns' ),
  142. array(
  143. 'name' => '4',
  144. 'label' => __( 'Darkest', 'assembler' ),
  145. 'style_data' => array(
  146. 'color' => array(
  147. 'background' => 'var(--wp--preset--color--theme-5)',
  148. 'text' => 'var(--wp--preset--color--theme-2)',
  149. ),
  150. 'elements' => array(
  151. 'button' => array(
  152. 'color' => array(
  153. 'background' => 'var(--wp--preset--color--theme-1)',
  154. 'text' => 'var(--wp--preset--color--theme-4)',
  155. ),
  156. ':hover' => array(
  157. 'color' => array(
  158. 'background' => 'var(--wp--preset--color--theme-2)',
  159. ),
  160. ),
  161. ),
  162. 'heading' => array(
  163. 'color' => array(
  164. 'text' => 'var(--wp--preset--color--theme-1)',
  165. )
  166. ),
  167. 'link' => array(
  168. 'color' => array(
  169. 'text' => 'currentColor',
  170. ),
  171. ':hover' => array(
  172. 'color' => array(
  173. 'text' => 'currentColor',
  174. ),
  175. ),
  176. ),
  177. ),
  178. ),
  179. )
  180. );