setup.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Theme setup.
  4. */
  5. namespace App;
  6. use function Roots\bundle;
  7. /**
  8. * Register the theme assets.
  9. *
  10. * @return void
  11. */
  12. add_action('wp_enqueue_scripts', function () {
  13. bundle('app')->enqueue();
  14. }, 100);
  15. /**
  16. * Register the theme assets with the block editor.
  17. *
  18. * @return void
  19. */
  20. add_action('enqueue_block_editor_assets', function () {
  21. bundle('editor')->enqueue();
  22. }, 100);
  23. /**
  24. * Register the initial theme setup.
  25. *
  26. * @return void
  27. */
  28. add_action('after_setup_theme', function () {
  29. /**
  30. * Enable features from the Soil plugin if activated.
  31. *
  32. * @link https://roots.io/plugins/soil/
  33. */
  34. add_theme_support('soil', [
  35. 'clean-up',
  36. 'nav-walker',
  37. 'nice-search',
  38. 'relative-urls',
  39. ]);
  40. /**
  41. * Disable full-site editing support.
  42. *
  43. * @link https://wptavern.com/gutenberg-10-5-embeds-pdfs-adds-verse-block-color-options-and-introduces-new-patterns
  44. */
  45. remove_theme_support('block-templates');
  46. /**
  47. * Register the navigation menus.
  48. *
  49. * @link https://developer.wordpress.org/reference/functions/register_nav_menus/
  50. */
  51. register_nav_menus([
  52. 'primary_navigation' => __('Primary Navigation', 'sage'),
  53. ]);
  54. /**
  55. * Disable the default block patterns.
  56. *
  57. * @link https://developer.wordpress.org/block-editor/developers/themes/theme-support/#disabling-the-default-block-patterns
  58. */
  59. remove_theme_support('core-block-patterns');
  60. /**
  61. * Enable plugins to manage the document title.
  62. *
  63. * @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag
  64. */
  65. add_theme_support('title-tag');
  66. /**
  67. * Enable post thumbnail support.
  68. *
  69. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  70. */
  71. add_theme_support('post-thumbnails');
  72. /**
  73. * Enable responsive embed support.
  74. *
  75. * @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content
  76. */
  77. add_theme_support('responsive-embeds');
  78. /**
  79. * Enable HTML5 markup support.
  80. *
  81. * @link https://developer.wordpress.org/reference/functions/add_theme_support/#html5
  82. */
  83. add_theme_support('html5', [
  84. 'caption',
  85. 'comment-form',
  86. 'comment-list',
  87. 'gallery',
  88. 'search-form',
  89. 'script',
  90. 'style',
  91. ]);
  92. /**
  93. * Enable selective refresh for widgets in customizer.
  94. *
  95. * @link https://developer.wordpress.org/reference/functions/add_theme_support/#customize-selective-refresh-widgets
  96. */
  97. add_theme_support('customize-selective-refresh-widgets');
  98. }, 20);
  99. /**
  100. * Register the theme sidebars.
  101. *
  102. * @return void
  103. */
  104. add_action('widgets_init', function () {
  105. $config = [
  106. 'before_widget' => '<section class="widget %1$s %2$s">',
  107. 'after_widget' => '</section>',
  108. 'before_title' => '<h3>',
  109. 'after_title' => '</h3>',
  110. ];
  111. register_sidebar([
  112. 'name' => __('Primary', 'sage'),
  113. 'id' => 'sidebar-primary',
  114. ] + $config);
  115. register_sidebar([
  116. 'name' => __('Footer', 'sage'),
  117. 'id' => 'sidebar-footer',
  118. ] + $config);
  119. });