Skip to content

Commit

Permalink
Add/documentation (#192)
Browse files Browse the repository at this point in the history
* Better describe requirements

* Update Theme.php
  • Loading branch information
Luehrsen authored Mar 24, 2023
1 parent 65e0ce3 commit f261f05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions theme/inc/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

/**
* Main class for the theme.
*
* This class takes care of initializing components.
* This is the main container for all theme components. It is used to access
* the components and to provide some basic information about the theme.
*/
class Theme {

Expand Down
13 changes: 13 additions & 0 deletions theme/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
*/
function lh_theme() {

/**
* Check if the requirements for the current theme are met.
* If the requirements are not met, we might get severe errors. Therefore, we
* return null and do not initialize the theme.
*/
if ( ! theme_requirements_are_met() ) {
return null;
}

static $theme = null;

if ( null === $theme ) {
$builder = new \DI\ContainerBuilder();
$container = $builder->build();

$theme = $container->get( Theme::class );
}

return $theme;
}

Expand All @@ -36,10 +43,16 @@ function lh_theme() {
* @return bool True if requirements are met, false otherwise.
*/
function theme_requirements_are_met() {
/**
* The accompanying plugin is required.
*/
if ( ! function_exists( '\WPMunich\lhpbpp\lh_plugin' ) || \WPMunich\lhpbpp\lh_plugin() === null ) {
return false;
}

/**
* The Advanced Custom Fields plugin is required.
*/
if ( ! function_exists( 'get_field' ) ) {
return false;
}
Expand Down

0 comments on commit f261f05

Please sign in to comment.