diff --git a/block-finder.php b/block-finder.php index 6c1ef57..b13a9da 100644 --- a/block-finder.php +++ b/block-finder.php @@ -14,6 +14,9 @@ * @package block-finder */ +// Define plugin version +define('BLOCK_FINDER_VERSION', '1.0.0'); + // Setup autoloading require_once __DIR__ . '/vendor/autoload.php'; @@ -21,7 +24,7 @@ use BlockFinder\Functions; // Enqueue block editor assets -$loadAssets = new Functions(__FILE__); +$loadAssets = new Functions(__FILE__, BLOCK_FINDER_VERSION); add_action('admin_enqueue_scripts', [$loadAssets, 'enqueueAdminAssets']); add_action('wp_dashboard_setup', [$loadAssets, 'blockFinderDashboard']); add_action('wp_ajax_find_blocks', [$loadAssets, 'blockQuery']); diff --git a/readme.txt b/readme.txt index a068ccf..195d312 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: areziaal Tags: block, search, tools Requires at least: 6.3 Tested up to: 6.6.1 -Stable tag: 1.0 +Stable tag: 1.0.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/Functions.php b/src/Functions.php index fec2df7..4dadebf 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -6,14 +6,23 @@ class Functions { + protected $plugin_file; + protected $version; + + public function __construct($plugin_file, $version) + { + $this->plugin_file = $plugin_file; + $this->version = $version; + } + public function enqueueAdminAssets() { $script_path = 'build/block-finder.js'; $style_path = 'build/block-finder.css'; $asset_handle = 'block-finder'; - wp_enqueue_script($asset_handle . '-script', plugins_url($script_path, __DIR__), [], false, true); - wp_enqueue_style($asset_handle . '-style', plugins_url($style_path, __DIR__), [], false); + wp_enqueue_script($asset_handle . '-script', plugins_url($script_path, $this->plugin_file), [], $this->version, true); + wp_enqueue_style($asset_handle . '-style', plugins_url($style_path, $this->plugin_file), [], $this->version); wp_localize_script($asset_handle . '-script', 'blockFinderAjax', [ 'ajax_url' => admin_url('admin-ajax.php'),