-
Notifications
You must be signed in to change notification settings - Fork 1
File Structure
The location and structure of certain files are very important to how Willow works, so understanding the lookup process is equally important.
Data is gathered greedily, but merged logically - Willow out-of-the-box will search for configuration settings within itself, with the Q plugin, a parent or child theme - in that order and will merge all collected data, prioritizing the later over the former, while trying to ensure that all required configuration are present - from the simple base model found in the file library/view/context/global.php
@todo...
By default,
As Willow contexts can be extended, it is also required to allow plugins to extend the configuration lookup locations, this can be achieved by adding the lookup parameters to the context extension callback, as shown in the following example:
public static function __run() {
// check for willow ##
if( ! class_exists( 'q_willow' ) ){ return false; }
$class = new \ReflectionClass( __CLASS__ );
$methods = $class->getMethods( \ReflectionMethod::IS_PUBLIC );
foreach( $methods as $key ){ $public_methods[] = $key->name; } // match format returned by get_class_methods() ##
// register new class methods ##
\add_action( 'after_setup_theme', function() use ( $public_methods ) {
\q\willow\context\extend::register([
'context' => 'user',#str_replace( __NAMESPACE__.'\\', '', __CLASS__ ),
'lookup' => \q_user::get_plugin_path( 'library/view/context/' ), // allow for extended .willow lookups ##
'class' => __CLASS__,
'methods' => $public_methods // public only
]);
}, 2 );
}In this example, we are telling Willow to also look in the path library/view/context/ when running checks for willow configuration files.