From 8802b4784d1e336fbc0d0986d63e15595f064c19 Mon Sep 17 00:00:00 2001 From: Troy Chaplin <15524465+troychaplin@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:01:51 -0400 Subject: [PATCH] Testing/pre release (#3) * fix: version based on plugin check issue * change: results wrapper --- block-finder.php | 5 ++- build/block-finder-rtl.css | 2 +- build/block-finder.asset.php | 2 +- build/block-finder.css | 2 +- build/block-finder.js | 2 +- package-lock.json | 4 +-- readme.txt | 2 +- src/Functions.php | 21 +++++++---- src/script.js | 3 +- src/styles.css | 69 +++++++++++++++++++----------------- 10 files changed, 65 insertions(+), 47 deletions(-) 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/build/block-finder-rtl.css b/build/block-finder-rtl.css index df5d575..d18d41e 100644 --- a/build/block-finder-rtl.css +++ b/build/block-finder-rtl.css @@ -1 +1 @@ -#block-finder-form label{padding-bottom:16px}#block-finder-selector,#post-type-selector{display:block;margin-bottom:10px;max-width:400px;padding:5px;width:100%}#block-finder-results{background-color:#f2f2f2;margin-top:15px}#block-finder-results h3{border-bottom:1px solid #b9b9b9;font-weight:700;margin:0;padding:14px 12px}#block-finder-results ul{list-style-type:none;margin:0;padding:0}#block-finder-results li{border-bottom:1px dotted #b9b9b9;display:flex;gap:8px;margin-bottom:0;padding:14px 12px}#block-finder-results li:last-child{border-bottom:none}#block-finder-results span{align-items:center;display:flex;gap:8px;margin-right:auto}#block-finder-results a{color:#0073aa;font-weight:500;text-decoration:none}#block-finder-results a:last-child{border-right:1px solid #b9b9b9;padding-right:8px}#block-finder-results a:hover{text-decoration:underline} +#block-finder-form label{padding-bottom:16px}#block-finder-selector,#post-type-selector{display:block;margin-bottom:10px;max-width:400px;padding:2px 8px;width:100%}#block-results-loading{padding:14px 12px}#block-finder-results{background-color:#f2f2f2;margin-top:15px}#block-finder-results h3{border-bottom:1px solid #b9b9b9;font-weight:700;margin:0;padding:14px 12px}#block-finder-results ul{list-style-type:none;margin:0;padding:0}#block-finder-results li{border-bottom:1px dotted #b9b9b9;display:flex;gap:8px;margin-bottom:0;padding:14px 12px}#block-finder-results li:last-child{border-bottom:none}#block-finder-results span{align-items:center;display:flex;gap:8px;margin-right:auto}#block-finder-results a{color:#0073aa;font-weight:500;text-decoration:none}#block-finder-results a:last-child{border-right:1px solid #b9b9b9;padding-right:8px}#block-finder-results a:hover{text-decoration:underline} diff --git a/build/block-finder.asset.php b/build/block-finder.asset.php index 8f4900d..5c3ca5f 100644 --- a/build/block-finder.asset.php +++ b/build/block-finder.asset.php @@ -1 +1 @@ - array(), 'version' => '677f28795b4f66f7d30f'); + array(), 'version' => '8ba02d3ad6c07bef19ba'); diff --git a/build/block-finder.css b/build/block-finder.css index 7bce2ce..ecb94cf 100644 --- a/build/block-finder.css +++ b/build/block-finder.css @@ -1 +1 @@ -#block-finder-form label{padding-bottom:16px}#block-finder-selector,#post-type-selector{display:block;margin-bottom:10px;max-width:400px;padding:5px;width:100%}#block-finder-results{background-color:#f2f2f2;margin-top:15px}#block-finder-results h3{border-bottom:1px solid #b9b9b9;font-weight:700;margin:0;padding:14px 12px}#block-finder-results ul{list-style-type:none;margin:0;padding:0}#block-finder-results li{border-bottom:1px dotted #b9b9b9;display:flex;gap:8px;margin-bottom:0;padding:14px 12px}#block-finder-results li:last-child{border-bottom:none}#block-finder-results span{align-items:center;display:flex;gap:8px;margin-left:auto}#block-finder-results a{color:#0073aa;font-weight:500;text-decoration:none}#block-finder-results a:last-child{border-left:1px solid #b9b9b9;padding-left:8px}#block-finder-results a:hover{text-decoration:underline} +#block-finder-form label{padding-bottom:16px}#block-finder-selector,#post-type-selector{display:block;margin-bottom:10px;max-width:400px;padding:2px 8px;width:100%}#block-results-loading{padding:14px 12px}#block-finder-results{background-color:#f2f2f2;margin-top:15px}#block-finder-results h3{border-bottom:1px solid #b9b9b9;font-weight:700;margin:0;padding:14px 12px}#block-finder-results ul{list-style-type:none;margin:0;padding:0}#block-finder-results li{border-bottom:1px dotted #b9b9b9;display:flex;gap:8px;margin-bottom:0;padding:14px 12px}#block-finder-results li:last-child{border-bottom:none}#block-finder-results span{align-items:center;display:flex;gap:8px;margin-left:auto}#block-finder-results a{color:#0073aa;font-weight:500;text-decoration:none}#block-finder-results a:last-child{border-left:1px solid #b9b9b9;padding-left:8px}#block-finder-results a:hover{text-decoration:underline} diff --git a/build/block-finder.js b/build/block-finder.js index 94e3d04..d55bd9f 100644 --- a/build/block-finder.js +++ b/build/block-finder.js @@ -1 +1 @@ -(()=>{"use strict";document.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("block-finder-form");e.addEventListener("submit",(async t=>{t.preventDefault();const n=document.getElementById("post-type-selector"),o=document.getElementById("block-finder-selector"),d=n.value,r=o.value,c=document.getElementById("block-finder-results"),a=e.querySelector('button[type="submit"]');if(a.disabled=!0,a.textContent="Finding blocks...",c.innerHTML="

Loading results...

",""===d||""===r)return void(c.innerHTML="

Please select both a post type and a block to find.

");const s=new URLSearchParams;s.append("action","find_blocks"),s.append("post_type",d),s.append("block",r),s.append("nonce",blockFinderAjax.nonce);try{const e=await fetch(blockFinderAjax.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:s.toString()});if(e.ok){const t=await e.text();c.innerHTML=t}else{const t=await e.json();c.innerHTML=`

An error occurred: ${t.message}

`}}catch(e){c.innerHTML=`

An error occurred: ${e.message}

`}finally{a.disabled=!1,a.textContent="Find Block"}}))}))})(); \ No newline at end of file +(()=>{"use strict";document.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("block-finder-form");e.addEventListener("submit",(async t=>{t.preventDefault();const n=document.getElementById("post-type-selector"),o=document.getElementById("block-finder-selector"),d=n.value,r=o.value,c=document.getElementById("block-finder-results"),a=e.querySelector('button[type="submit"]');if(a.disabled=!0,a.textContent="Finding blocks...",c.innerHTML='

Loading results...

',""===d||""===r)return void(c.innerHTML="

Please select both a post type and a block to find.

");const s=new URLSearchParams;s.append("action","find_blocks"),s.append("post_type",d),s.append("block",r),s.append("nonce",blockFinderAjax.nonce);try{const e=await fetch(blockFinderAjax.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},body:s.toString()});if(e.ok){const t=await e.text();c.innerHTML=t}else{const t=await e.json();c.innerHTML=`

An error occurred: ${t.message}

`}}catch(e){c.innerHTML=`

An error occurred: ${e.message}

`}finally{a.disabled=!1,a.textContent="Find Block"}}))}))})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 95abf1e..5c89d3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "block-finder", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "block-finder", - "version": "0.1.0", + "version": "1.0.0", "license": "GPL-2.0-or-later", "devDependencies": { "@commitlint/cli": "^19.3.0", 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..8c79c62 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'), @@ -52,17 +61,17 @@ public function findBlockForm() }); echo '
'; - echo ''; + echo ''; echo ''; - echo ''; + echo ''; echo '