Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Simple module registration #79

Merged
merged 2 commits into from
Apr 4, 2018
Merged

Conversation

stian-overasen
Copy link
Member

  • Register modules directly into core instead of using helper function hogan_register_module() and temporary array hogan/modules.
  • Deprecate the old helper function without breaking everything.

The current way of registering modules with global helper function.

add_action( 'hogan/include_modules' 'hogan_text_register_module' );

function hogan_text_register_module() {
    require_once 'class-text.php';
    \hogan_register_module( new \Dekode\Hogan\Text() );
}

The new way with direct access to the core object.

add_action( 'hogan/include_modules', 'hogan_text_register_module', 10, 1 );

function hogan_text_register_module( \Dekode\Hogan\Core $core ) {
    require_once 'class-text.php';
    $core->register_module( new \Dekode\Hogan\Text() );
}

trinef
trinef previously approved these changes Apr 4, 2018
README.md Outdated
add_action( 'hogan/include_modules', function( \Dekode\Hogan\Core $core ) {
require_once 'class-demomodule.php';
$core->register_module( new DemoModule() );
}, 10, 1 );
```

See the [Text Module](https://github.com/DekodeInteraktiv/hogan-text) for a complete example.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er texmodulen oppdatert med den nye måten å registrere modulen på?

@stian-overasen stian-overasen merged commit 4663e5c into master Apr 4, 2018
@stian-overasen stian-overasen deleted the simplified-module-registration2 branch April 4, 2018 09:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants