Skip to content

Commit

Permalink
Fix plugin constant based on #26
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubboucek committed Oct 13, 2019
1 parent 9de3202 commit 8536add
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/Gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ class Gutenberg {
* @var Access
*/
private $access;
/**
* @var string
*/
private $pluginDirUrl;

public function __construct( Admin $admin, Group $group, Access $access ) {
public function __construct( Admin $admin, Group $group, Access $access, $pluginMainFile ) {
add_action( 'init', array( $this, 'load_block_assets' ) );
add_action( 'admin_init', array( $this, 'load_products' ) );
add_filter( 'render_block', array( $this, 'maybe_hide_block' ), 10, 2 );

$this->admin = $admin;
$this->group = $group;
$this->access = $access;
$this->pluginDirUrl = plugin_dir_url($pluginMainFile);
}

function load_products() {
Expand All @@ -38,15 +43,15 @@ function load_block_assets() { // phpcs:ignore
// Register block styles for both frontend + backend.
wp_register_style(
'simpleshop-gutenberg-style-css', // Handle.
SIMPLESHOP_PLUGIN_URL . 'js/gutenberg/blocks.style.build.css', // Block style CSS.
$this->pluginDirUrl . 'js/gutenberg/blocks.style.build.css', // Block style CSS.
array( 'wp-editor' ), // Dependency to include the CSS after it.
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
);

// Register block editor script for backend.
wp_register_script(
'simpleshop-gutenberg-block-js', // Handle.
SIMPLESHOP_PLUGIN_URL . 'js/gutenberg/blocks.build.js', // Block.build.js: We register the block here. Built with Webpack.
$this->pluginDirUrl . 'js/gutenberg/blocks.build.js', // Block.build.js: We register the block here. Built with Webpack.
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), // Dependencies, defined above.
null, // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime — Gets file modification time.
true // Enqueue the script in the footer.
Expand All @@ -64,7 +69,7 @@ function load_block_assets() { // phpcs:ignore
// Register block editor styles for backend.
wp_register_style(
'simpleshop-gutenberg-block-editor-css', // Handle.
SIMPLESHOP_PLUGIN_URL . 'js/gutenberg/blocks.editor.build.css', // Block editor CSS.
$this->pluginDirUrl . 'js/gutenberg/blocks.editor.build.css', // Block editor CSS.
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function init() {
new Cron( $this );
new Metaboxes( $this );
new Shortcodes($this->access);
new Gutenberg($this->admin, $this->group, $this->access);
new Gutenberg($this->admin, $this->group, $this->access, $this->pluginMainFile);
}

public function generate_secure_key() {
Expand Down

0 comments on commit 8536add

Please sign in to comment.