|
4 | 4 | * Do not edit anything in this file unless you know what you're doing
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +/** |
| 8 | + * Require Composer autoloader if installed on it's own |
| 9 | + */ |
| 10 | +if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) { |
| 11 | + require_once $composer; |
| 12 | +} |
| 13 | + |
7 | 14 | /**
|
8 | 15 | * Here's what's happening with these hooks:
|
9 | 16 | * 1. WordPress detects theme in themes/sage
|
|
20 | 27 | });
|
21 | 28 | add_action('after_switch_theme', function () {
|
22 | 29 | $stylesheet = get_option('stylesheet');
|
23 |
| - basename($stylesheet) == 'templates' || update_option('stylesheet', $stylesheet . '/templates'); |
| 30 | + if (basename($stylesheet) !== 'templates') { |
| 31 | + update_option('stylesheet', $stylesheet . '/templates'); |
| 32 | + } |
24 | 33 | });
|
25 | 34 |
|
26 | 35 | /**
|
|
30 | 39 | * Add or remove files to the array as needed. Supports child theme overrides.
|
31 | 40 | *
|
32 | 41 | * Please note that missing files will produce a fatal error.
|
33 |
| - * |
34 |
| - * @link https://github.com/roots/sage/pull/1042 |
35 | 42 | */
|
36 | 43 | $sage_includes = [
|
37 |
| - 'src/helpers.php', // Helper functions |
38 |
| - 'src/setup.php', // Theme setup |
39 |
| - 'src/filters.php', // Filters |
40 |
| - 'src/admin.php' // Admin |
| 44 | + 'src/helpers.php', // Helper functions |
| 45 | + 'src/setup.php', // Theme setup |
| 46 | + 'src/filters.php', // Filters |
| 47 | + 'src/admin.php' // Admin |
41 | 48 | ];
|
42 |
| - |
43 |
| -foreach ($sage_includes as $file) { |
44 |
| - if (!$filepath = locate_template($file)) { |
| 49 | +array_walk($sage_includes, function ($file) { |
| 50 | + if (!locate_template($file, true, true)) { |
45 | 51 | trigger_error(sprintf(__('Error locating %s for inclusion', 'sage'), $file), E_USER_ERROR);
|
46 | 52 | }
|
47 |
| - require_once $filepath; |
48 |
| -} |
49 |
| -unset($file, $filepath); |
50 |
| - |
51 |
| -/** |
52 |
| - * Require Composer autoloader if installed on it's own |
53 |
| - */ |
54 |
| -if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) { |
55 |
| - require_once $composer; |
56 |
| -} |
| 53 | +}); |
0 commit comments