functions.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Remote functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Remote
  8. * @since Remote 1.0
  9. */
  10. if ( ! function_exists( 'remote_support' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * @since Remote 1.0
  15. *
  16. * @return void
  17. */
  18. function remote_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', 'remote_support' );
  26. if ( ! function_exists( 'remote_styles' ) ) :
  27. /**
  28. * Enqueue styles.
  29. *
  30. * @since Remote 1.0
  31. *
  32. * @return void
  33. */
  34. function remote_styles() {
  35. // Register theme stylesheet.
  36. wp_register_style(
  37. 'remote-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( 'remote-style' );
  44. }
  45. endif;
  46. add_action( 'wp_enqueue_scripts', 'remote_styles' );
  47. /**
  48. * Registers block patterns and categories.
  49. *
  50. * @since Remote 1.0
  51. *
  52. * @return void
  53. */
  54. function remote_register_block_pattern_categories() {
  55. //Needed until https://github.com/WordPress/gutenberg/issues/39500 is fixed.
  56. $block_pattern_categories = array(
  57. 'featured' => array( 'label' => __( 'Featured', 'remote' ) ),
  58. 'columns' => array( 'label' => __( 'Columns', 'remote' ) ),
  59. 'text' => array( 'label' => __( 'Text', 'remote' ) ),
  60. 'query' => array( 'label' => __( 'Query', 'remote' ) ),
  61. );
  62. /**
  63. * Filters the theme block pattern categories.
  64. *
  65. * @since remote 1.0
  66. *
  67. * @param array[] $block_pattern_categories {
  68. * An associative array of block pattern categories, keyed by category name.
  69. *
  70. * @type array[] $properties {
  71. * An array of block category properties.
  72. *
  73. * @type string $label A human-readable label for the pattern category.
  74. * }
  75. * }
  76. */
  77. $block_pattern_categories = apply_filters( 'remote_block_pattern_categories', $block_pattern_categories );
  78. foreach ( $block_pattern_categories as $name => $properties ) {
  79. if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) {
  80. register_block_pattern_category( $name, $properties );
  81. }
  82. }
  83. }
  84. add_action( 'init', 'remote_register_block_pattern_categories', 9 );