Skip to content

Commit

Permalink
Register Js
Browse files Browse the repository at this point in the history
  • Loading branch information
aulisius committed Dec 19, 2022
1 parent d98f44b commit 54a96d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function () {
'name' => 'help-center',
'label' => __( 'Help Center', 'newfold-help-center-module' ),
'callback' => function ( Container $container ) {
define( 'NFD_HELPCENTER_BUILD_DIR', __DIR__ . '/build/' );
define( 'NFD_HELPCENTER_PLUGIN_URL', $container->plugin()->url );
new HelpCenter( $container );
},
'isActive' => true,
Expand Down
17 changes: 16 additions & 1 deletion includes/HelpCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,24 @@ class HelpCenter {
public function __construct( Container $container ) {

$this->container = $container;

add_action( 'init' , array( $this, 'register_assets') );
// Module functionality goes here

}

/**
* Load WP dependencies into the page.
*/
public function register_assets() {
$asset_file = NFD_HELPCENTER_BUILD_DIR . 'index.asset.php';
if ( file_exists($asset_file) ) {
$asset = require_once $asset_file;
\wp_enqueue_script(
'nfd-helpcenter-dependency',
NFD_HELPCENTER_PLUGIN_URL . 'vendor/newfold-labs/wp-module-help-center/build/index.js',
array_merge( $asset['dependencies'], array() ),
$asset_file
);
}
}
}

0 comments on commit 54a96d3

Please sign in to comment.