functions.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /**
  3. * Olympique functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Olympique
  8. * @since Olympique 1.0
  9. */
  10. /**
  11. * Register block styles.
  12. */
  13. if ( ! function_exists( 'olympique_block_styles' ) ) :
  14. /**
  15. * Register custom block styles
  16. *
  17. * @since Olympique 1.0
  18. * @return void
  19. */
  20. function olympique_block_styles() {
  21. register_block_style(
  22. 'core/details',
  23. array(
  24. 'name' => 'arrow-icon-details',
  25. 'label' => __( 'Arrow icon', 'olympique' ),
  26. /*
  27. * Styles for the custom Arrow icon style of the Details block
  28. */
  29. 'inline_style' => '
  30. .is-style-arrow-icon-details {
  31. padding-top: var(--wp--preset--spacing--10);
  32. padding-bottom: var(--wp--preset--spacing--10);
  33. }
  34. .is-style-arrow-icon-details summary {
  35. list-style-type: "\2193\00a0\00a0\00a0";
  36. }
  37. .is-style-arrow-icon-details[open]>summary {
  38. list-style-type: "\2192\00a0\00a0\00a0";
  39. }',
  40. )
  41. );
  42. register_block_style(
  43. 'core/post-terms',
  44. array(
  45. 'name' => 'pill',
  46. 'label' => __( 'Pill', 'olympique' ),
  47. /*
  48. * Styles variation for post terms
  49. * https://github.com/WordPress/gutenberg/issues/24956
  50. */
  51. 'inline_style' => '
  52. .is-style-pill a,
  53. .is-style-pill span:not([class], [data-rich-text-placeholder]) {
  54. display: inline-block;
  55. background-color: var(--wp--preset--color--base-2);
  56. padding: 0.375rem 0.875rem;
  57. border-radius: var(--wp--preset--spacing--20);
  58. }
  59. .is-style-pill a:hover {
  60. background-color: var(--wp--preset--color--contrast-3);
  61. }',
  62. )
  63. );
  64. register_block_style(
  65. 'core/list',
  66. array(
  67. 'name' => 'checkmark-list',
  68. 'label' => __( 'Checkmark', 'olympique' ),
  69. /*
  70. * Styles for the custom checkmark list block style
  71. * https://github.com/WordPress/gutenberg/issues/51480
  72. */
  73. 'inline_style' => '
  74. ul.is-style-checkmark-list {
  75. list-style-type: "\2713";
  76. }
  77. ul.is-style-checkmark-list li {
  78. padding-inline-start: 1ch;
  79. }',
  80. )
  81. );
  82. register_block_style(
  83. 'core/navigation-link',
  84. array(
  85. 'name' => 'arrow-link',
  86. 'label' => __( 'With arrow', 'olympique' ),
  87. /*
  88. * Styles for the custom arrow nav link block style
  89. */
  90. 'inline_style' => '
  91. .is-style-arrow-link .wp-block-navigation-item__label:after {
  92. content: "\2197";
  93. padding-inline-start: 0.25rem;
  94. vertical-align: middle;
  95. text-decoration: none;
  96. display: inline-block;
  97. }',
  98. )
  99. );
  100. register_block_style(
  101. 'core/heading',
  102. array(
  103. 'name' => 'asterisk',
  104. 'label' => __( 'With asterisk', 'olympique' ),
  105. 'inline_style' => "
  106. .is-style-asterisk:before {
  107. content: '';
  108. width: 1.5rem;
  109. height: 3rem;
  110. background: var(--wp--preset--color--contrast-2, currentColor);
  111. clip-path: path('M11.93.684v8.039l5.633-5.633 1.216 1.23-5.66 5.66h8.04v1.737H13.2l5.701 5.701-1.23 1.23-5.742-5.742V21h-1.737v-8.094l-5.77 5.77-1.23-1.217 5.743-5.742H.842V9.98h8.162l-5.701-5.7 1.23-1.231 5.66 5.66V.684h1.737Z');
  112. display: block;
  113. }
  114. /* Hide the asterisk if the heading has no content, to avoid using empty headings to display the asterisk only, which is an A11Y issue */
  115. .is-style-asterisk:empty:before {
  116. content: none;
  117. }
  118. .is-style-asterisk:-moz-only-whitespace:before {
  119. content: none;
  120. }
  121. .is-style-asterisk.has-text-align-center:before {
  122. margin: 0 auto;
  123. }
  124. .is-style-asterisk.has-text-align-right:before {
  125. margin-left: auto;
  126. }
  127. .rtl .is-style-asterisk.has-text-align-left:before {
  128. margin-right: auto;
  129. }",
  130. )
  131. );
  132. }
  133. endif;
  134. add_action( 'init', 'olympique_block_styles' );
  135. /**
  136. * Enqueue block stylesheets.
  137. */
  138. if ( ! function_exists( 'olympique_block_stylesheets' ) ) :
  139. /**
  140. * Enqueue custom block stylesheets
  141. *
  142. * @since Olympique 1.0
  143. * @return void
  144. */
  145. function olympique_block_stylesheets() {
  146. /**
  147. * The wp_enqueue_block_style() function allows us to enqueue a stylesheet
  148. * for a specific block. These will only get loaded when the block is rendered
  149. * (both in the editor and on the front end), improving performance
  150. * and reducing the amount of data requested by visitors.
  151. *
  152. * See https://make.wordpress.org/core/2021/12/15/using-multiple-stylesheets-per-block/ for more info.
  153. */
  154. wp_enqueue_block_style(
  155. 'core/button',
  156. array(
  157. 'handle' => 'olympique-button-style-outline',
  158. 'src' => get_parent_theme_file_uri( 'assets/css/button-outline.css' ),
  159. 'ver' => wp_get_theme( get_template() )->get( 'Version' ),
  160. 'path' => get_parent_theme_file_path( 'assets/css/button-outline.css' ),
  161. )
  162. );
  163. }
  164. endif;
  165. add_action( 'init', 'olympique_block_stylesheets' );
  166. /**
  167. * Register pattern categories.
  168. */
  169. if ( ! function_exists( 'olympique_pattern_categories' ) ) :
  170. /**
  171. * Register pattern categories
  172. *
  173. * @since Olympique 1.0
  174. * @return void
  175. */
  176. function olympique_pattern_categories() {
  177. register_block_pattern_category(
  178. 'olympique_page',
  179. array(
  180. 'label' => _x( 'Pages', 'Block pattern category', 'olympique' ),
  181. 'description' => __( 'A collection of full page layouts.', 'olympique' ),
  182. )
  183. );
  184. }
  185. endif;
  186. add_action( 'init', 'olympique_pattern_categories' );