functions.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Register The Auto Loader
  5. |--------------------------------------------------------------------------
  6. |
  7. | Composer provides a convenient, automatically generated class loader for
  8. | our theme. We will simply require it into the script here so that we
  9. | don't have to worry about manually loading any of our classes later on.
  10. |
  11. */
  12. if (! file_exists($composer = __DIR__.'/vendor/autoload.php')) {
  13. wp_die(__('Error locating autoloader. Please run <code>composer install</code>.', 'sage'));
  14. }
  15. require $composer;
  16. /*
  17. |--------------------------------------------------------------------------
  18. | Register The Bootloader
  19. |--------------------------------------------------------------------------
  20. |
  21. | The first thing we will do is schedule a new Acorn application container
  22. | to boot when WordPress is finished loading the theme. The application
  23. | serves as the "glue" for all the components of Laravel and is
  24. | the IoC container for the system binding all of the various parts.
  25. |
  26. */
  27. if (! function_exists('\Roots\bootloader')) {
  28. wp_die(
  29. __('You need to install Acorn to use this theme.', 'sage'),
  30. '',
  31. [
  32. 'link_url' => 'https://roots.io/acorn/docs/installation/',
  33. 'link_text' => __('Acorn Docs: Installation', 'sage'),
  34. ]
  35. );
  36. }
  37. \Roots\bootloader()->boot();
  38. /*
  39. |--------------------------------------------------------------------------
  40. | Register Sage Theme Files
  41. |--------------------------------------------------------------------------
  42. |
  43. | Out of the box, Sage ships with categorically named theme files
  44. | containing common functionality and setup to be bootstrapped with your
  45. | theme. Simply add (or remove) files from the array below to change what
  46. | is registered alongside Sage.
  47. |
  48. */
  49. collect(['setup', 'filters'])
  50. ->each(function ($file) {
  51. if (! locate_template($file = "app/{$file}.php", true, true)) {
  52. wp_die(
  53. /* translators: %s is replaced with the relative file path */
  54. sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file)
  55. );
  56. }
  57. });