functions.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Archeo functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Archeo
  8. * @since Archeo 1.0
  9. */
  10. if ( ! function_exists( 'archeo_support' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * @since Archeo 1.0
  15. *
  16. * @return void
  17. */
  18. function archeo_support() {
  19. // Add support for block styles.
  20. add_theme_support( 'wp-block-styles' );
  21. // Enqueue editor styles.
  22. add_editor_style( 'style.css' );
  23. }
  24. endif;
  25. add_action( 'after_setup_theme', 'archeo_support' );
  26. if ( ! function_exists( 'archeo_styles' ) ) :
  27. /**
  28. * Enqueue styles.
  29. *
  30. * @since Archeo 1.0
  31. *
  32. * @return void
  33. */
  34. function archeo_styles() {
  35. // Register theme stylesheet.
  36. wp_register_style(
  37. 'archeo-style',
  38. get_template_directory_uri() . '/style.css',
  39. array(),
  40. wp_get_theme()->get( 'Version' )
  41. );
  42. // Enqueue theme stylesheet.
  43. wp_enqueue_style( 'archeo-style' );
  44. }
  45. endif;
  46. add_action( 'wp_enqueue_scripts', 'archeo_styles' );
  47. /**
  48. * Registers block patterns and categories.
  49. *
  50. * @since Archeo 1.0
  51. *
  52. * @return void
  53. */
  54. function archeo_register_block_pattern_categories() {
  55. $block_pattern_categories = array(
  56. 'images' => array( 'label' => __( 'Images', 'archeo' ) ),
  57. 'featured' => array( 'label' => __( 'Featured', 'archeo' ) ),
  58. 'footer' => array( 'label' => __( 'Footers', 'archeo' ) ),
  59. 'query' => array( 'label' => __( 'Query', 'archeo' ) ),
  60. );
  61. /**
  62. * Filters the theme block pattern categories.
  63. *
  64. * @since archeo 1.0
  65. *
  66. * @param array[] $block_pattern_categories {
  67. * An associative array of block pattern categories, keyed by category name.
  68. *
  69. * @type array[] $properties {
  70. * An array of block category properties.
  71. *
  72. * @type string $label A human-readable label for the pattern category.
  73. * }
  74. * }
  75. */
  76. $block_pattern_categories = apply_filters( 'archeo_block_pattern_categories', $block_pattern_categories );
  77. foreach ( $block_pattern_categories as $name => $properties ) {
  78. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  79. register_block_pattern_category( $name, $properties );
  80. }
  81. }
  82. }
  83. add_action( 'init', 'archeo_register_block_pattern_categories', 9 );