functions.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. // Make theme available for translation.
  20. load_theme_textdomain( 'remote' );
  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', 'remote_support' );
  28. if ( ! function_exists( 'remote_styles' ) ) :
  29. /**
  30. * Enqueue styles.
  31. *
  32. * @since Remote 1.0
  33. *
  34. * @return void
  35. */
  36. function remote_styles() {
  37. // Register theme stylesheet.
  38. wp_register_style(
  39. 'remote-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( 'remote-style' );
  46. }
  47. endif;
  48. add_action( 'wp_enqueue_scripts', 'remote_styles' );
  49. /**
  50. * Registers block patterns and categories.
  51. *
  52. * @since Remote 1.0
  53. *
  54. * @return void
  55. */
  56. function remote_register_block_pattern_categories() {
  57. //Needed until https://github.com/WordPress/gutenberg/issues/39500 is fixed.
  58. $block_pattern_categories = array(
  59. 'featured' => array( 'label' => __( 'Featured', 'remote' ) ),
  60. 'columns' => array( 'label' => __( 'Columns', 'remote' ) ),
  61. 'text' => array( 'label' => __( 'Text', 'remote' ) ),
  62. 'query' => array( 'label' => __( 'Query', 'remote' ) ),
  63. );
  64. /**
  65. * Filters the theme block pattern categories.
  66. *
  67. * @since remote 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( 'remote_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', 'remote_register_block_pattern_categories', 9 );