functions.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. // Make theme available for translation.
  20. load_theme_textdomain( 'livro' );
  21. // Add support for block styles.
  22. add_theme_support( 'wp-block-styles' );
  23. // Support the "Aside" post format.
  24. add_theme_support( 'post-formats', array( 'aside' ) );
  25. // Enqueue editor styles.
  26. add_editor_style( 'style.css' );
  27. }
  28. endif;
  29. add_action( 'after_setup_theme', 'livro_support' );
  30. if ( ! function_exists( 'livro_styles' ) ) :
  31. /**
  32. * Enqueue styles.
  33. *
  34. * @since Livro 1.0
  35. *
  36. * @return void
  37. */
  38. function livro_styles() {
  39. // Register theme stylesheet.
  40. wp_register_style(
  41. 'livro-style',
  42. get_template_directory_uri() . '/style.css',
  43. array(),
  44. wp_get_theme()->get( 'Version' )
  45. );
  46. // Enqueue theme stylesheet.
  47. wp_enqueue_style( 'livro-style' );
  48. }
  49. endif;
  50. add_action( 'wp_enqueue_scripts', 'livro_styles' );
  51. require get_template_directory() . '/inc/gutenberg-dependency-check.php';
  52. /**
  53. * Registers block patterns and categories.
  54. *
  55. * @since Livro 1.0
  56. *
  57. * @return void
  58. */
  59. function livro_register_block_pattern_categories() {
  60. //Needed until https://github.com/WordPress/gutenberg/issues/39500 is fixed.
  61. $block_pattern_categories = array(
  62. 'pages' => array( 'label' => __( 'Pages', 'livro' ) ),
  63. 'footer' => array( 'label' => __( 'Footers', 'livro' ) ),
  64. 'header' => array( 'label' => __( 'Headers', 'livro' ) ),
  65. );
  66. /**
  67. * Filters the theme block pattern categories.
  68. *
  69. * @since Livro 1.0
  70. *
  71. * @param array[] $block_pattern_categories {
  72. * An associative array of block pattern categories, keyed by category name.
  73. *
  74. * @type array[] $properties {
  75. * An array of block category properties.
  76. *
  77. * @type string $label A human-readable label for the pattern category.
  78. * }
  79. * }
  80. */
  81. $block_pattern_categories = apply_filters( 'livro_block_pattern_categories', $block_pattern_categories );
  82. foreach ( $block_pattern_categories as $name => $properties ) {
  83. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  84. register_block_pattern_category( $name, $properties );
  85. }
  86. }
  87. }
  88. add_action( 'init', 'livro_register_block_pattern_categories', 9 );