Skip to content

Commit

Permalink
Simplify boostrapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
justintadlock committed Oct 20, 2024
1 parent 6b53ce8 commit 6625512
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
}

# Bootstrap the theme.
add_action('after_setup_theme', __NAMESPACE__ . '\\boot', PHP_INT_MIN);
add_action('after_setup_theme', fn() => theme()->boot(), PHP_INT_MIN);
16 changes: 3 additions & 13 deletions src/functions-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,20 @@

namespace X3P0\Ideas;

/**
* Bootstraps the theme.
*
* @since 1.0.0
*/
function boot(): void
{
theme()->boot();
}

/**
* Stores the single instance of the theme in the static `$theme` variable. Devs
* can access any class/component by passing in its reference via the `$component`
* can access any class/component by passing in its reference via the `$abstract`
* parameter (useful for accessing hooks within classes).
*
* @since 1.0.0
*/
function theme(string $component = ''): mixed
function theme(string $abstract = ''): mixed
{
static $theme;

if (! $theme instanceof Theme) {
do_action('x3p0/ideas/init', $theme = new Theme());
}

return '' === $component ? $theme : $theme->get($component);
return '' === $abstract ? $theme : $theme->get($abstract);
}

0 comments on commit 6625512

Please sign in to comment.