Skip to content

Commit

Permalink
fix: version based on plugin check issue
Browse files Browse the repository at this point in the history
  • Loading branch information
troychaplin committed Aug 3, 2024
1 parent 2c79aef commit 6335a08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion block-finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
* @package block-finder
*/

// Define plugin version
define('BLOCK_FINDER_VERSION', '1.0.0');

// Setup autoloading
require_once __DIR__ . '/vendor/autoload.php';

// Include dependencies
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']);
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions src/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 6335a08

Please sign in to comment.