functions.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. // Make theme available for translation.
  20. load_theme_textdomain( 'archeo' );
  21. // Add support for block styles.
  22. add_theme_support( 'wp-block-styles' );
  23. // Enqueue editor styles.
  24. add_editor_style( 'style.css' );
  25. }
  26. endif;
  27. add_action( 'after_setup_theme', 'archeo_support' );
  28. if ( ! function_exists( 'archeo_styles' ) ) :
  29. /**
  30. * Enqueue styles.
  31. *
  32. * @since Archeo 1.0
  33. *
  34. * @return void
  35. */
  36. function archeo_styles() {
  37. // Register theme stylesheet.
  38. wp_register_style(
  39. 'archeo-style',
  40. get_template_directory_uri() . '/style.css',
  41. array(),
  42. wp_get_theme()->get( 'Version' )
  43. );
  44. // Enqueue theme stylesheet.
  45. wp_enqueue_style( 'archeo-style' );
  46. }
  47. endif;
  48. add_action( 'wp_enqueue_scripts', 'archeo_styles' );
  49. /**
  50. * Registers block patterns and categories.
  51. *
  52. * @since Archeo 1.0
  53. *
  54. * @return void
  55. */
  56. function archeo_register_block_pattern_categories() {
  57. $block_pattern_categories = array(
  58. 'images' => array( 'label' => __( 'Images', 'archeo' ) ),
  59. 'featured' => array( 'label' => __( 'Featured', 'archeo' ) ),
  60. 'footer' => array( 'label' => __( 'Footers', 'archeo' ) ),
  61. 'query' => array( 'label' => __( 'Query', 'archeo' ) ),
  62. );
  63. /**
  64. * Filters the theme block pattern categories.
  65. *
  66. * @since archeo 1.0
  67. *
  68. * @param array[] $block_pattern_categories {
  69. * An associative array of block pattern categories, keyed by category name.
  70. *
  71. * @type array[] $properties {
  72. * An array of block category properties.
  73. *
  74. * @type string $label A human-readable label for the pattern category.
  75. * }
  76. * }
  77. */
  78. $block_pattern_categories = apply_filters( 'archeo_block_pattern_categories', $block_pattern_categories );
  79. foreach ( $block_pattern_categories as $name => $properties ) {
  80. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  81. register_block_pattern_category( $name, $properties );
  82. }
  83. }
  84. }
  85. add_action( 'init', 'archeo_register_block_pattern_categories', 9 );