functions.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Livro functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Livro
  8. * @since Livro 1.0
  9. */
  10. if ( ! function_exists( 'livro_support' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * @since Livro 1.0
  15. *
  16. * @return void
  17. */
  18. function livro_support() {
  19. // Add support for block styles.
  20. add_theme_support( 'wp-block-styles' );
  21. // Support the "Aside" post format.
  22. add_theme_support( 'post-formats', array( 'aside' ) );
  23. // Enqueue editor styles.
  24. add_editor_style( 'style.css' );
  25. }
  26. endif;
  27. add_action( 'after_setup_theme', 'livro_support' );
  28. if ( ! function_exists( 'livro_styles' ) ) :
  29. /**
  30. * Enqueue styles.
  31. *
  32. * @since Livro 1.0
  33. *
  34. * @return void
  35. */
  36. function livro_styles() {
  37. // Register theme stylesheet.
  38. wp_register_style(
  39. 'livro-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( 'livro-style' );
  46. }
  47. endif;
  48. add_action( 'wp_enqueue_scripts', 'livro_styles' );
  49. require get_template_directory() . '/inc/gutenberg-dependency-check.php';
  50. /**
  51. * Registers block patterns and categories.
  52. *
  53. * @since Livro 1.0
  54. *
  55. * @return void
  56. */
  57. function livro_register_block_pattern_categories() {
  58. //Needed until https://github.com/WordPress/gutenberg/issues/39500 is fixed.
  59. $block_pattern_categories = array(
  60. 'pages' => array( 'label' => __( 'Pages', 'livro' ) ),
  61. 'footer' => array( 'label' => __( 'Footers', 'livro' ) ),
  62. 'header' => array( 'label' => __( 'Headers', 'livro' ) )
  63. );
  64. /**
  65. * Filters the theme block pattern categories.
  66. *
  67. * @since Livro 1.0
  68. *
  69. * @param array[] $block_pattern_categories {
  70. * An associative array of block pattern categories, keyed by category name.
  71. *
  72. * @type array[] $properties {
  73. * An array of block category properties.
  74. *
  75. * @type string $label A human-readable label for the pattern category.
  76. * }
  77. * }
  78. */
  79. $block_pattern_categories = apply_filters( 'livro_block_pattern_categories', $block_pattern_categories );
  80. foreach ( $block_pattern_categories as $name => $properties ) {
  81. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  82. register_block_pattern_category( $name, $properties );
  83. }
  84. }
  85. }
  86. add_action( 'init', 'livro_register_block_pattern_categories', 9 );