Skip to content

Commit

Permalink
Testing/pre release (#3)
Browse files Browse the repository at this point in the history
* fix: version based on plugin check issue

* change: results wrapper
  • Loading branch information
troychaplin authored Aug 4, 2024
1 parent 2c79aef commit 8802b47
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 47 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 build/block-finder-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/block-finder.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '677f28795b4f66f7d30f');
<?php return array('dependencies' => array(), 'version' => '8ba02d3ad6c07bef19ba');
2 changes: 1 addition & 1 deletion build/block-finder.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/block-finder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
21 changes: 15 additions & 6 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 Expand Up @@ -52,17 +61,17 @@ public function findBlockForm()
});

echo '<form id="block-finder-form">';
echo '<label for="post-type-selector">Select a post type:</label>';
echo '<label for="post-type-selector">Select a post type you wish to search in</label>';
echo '<select id="post-type-selector" name="post_type">';
echo '<option value="">Select a post type</option>'; // Default option
echo '<option value="">-- Select post type --</option>';
foreach ($gutenberg_post_types as $post_type) {
echo '<option value="' . esc_attr($post_type->name) . '">' . esc_html($post_type->label) . '</option>';
}
echo '</select>';

echo '<label for="block-finder-selector">Select a block to return a list of where it is being used on your site.</label>';
echo '<label for="block-finder-selector">Select a block you would like to search for</label>';
echo '<select id="block-finder-selector" name="block">';
echo '<option value="">Select a block to find</option>'; // Default option
echo '<option value="">-- Select block --</option>';
foreach ($inserter_blocks as $block_name => $block_type) {
if (!empty($block_type->title)) {
echo '<option value="' . esc_attr($block_name) . '">' . esc_html($block_type->title) . '</option>';
Expand Down
3 changes: 2 additions & 1 deletion src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ document.addEventListener('DOMContentLoaded', () => {
// Show loading indicator
submitButton.disabled = true;
submitButton.textContent = 'Finding blocks...';
resultsContainer.innerHTML = '<p>Loading results...</p>';
resultsContainer.innerHTML =
'<p id="block-results-loading">Loading results...</p>';

if (postType === '' || block === '') {
resultsContainer.innerHTML =
Expand Down
69 changes: 37 additions & 32 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
#block-finder-form label {
padding-bottom: 16px;
padding-bottom: 16px;
}

#block-finder-selector, #post-type-selector {
display: block;
margin-bottom: 10px;
padding: 5px;
width: 100%;
max-width: 400px;
#block-finder-selector,
#post-type-selector {
display: block;
margin-bottom: 10px;
padding: 2px 8px;
width: 100%;
max-width: 400px;
}

#block-results-loading {
padding: 14px 12px;
}

#block-finder-results {
background-color: #f2f2f2;
margin-top: 15px;
background-color: #f2f2f2;
margin-top: 15px;
}

#block-finder-results h3 {
font-weight: 700;
border-bottom: 1px solid #b9b9b9;
padding: 14px 12px;
margin: 0;
font-weight: 700;
border-bottom: 1px solid #b9b9b9;
padding: 14px 12px;
margin: 0;
}

#block-finder-results ul {
list-style-type: none;
padding: 0;
margin: 0;
list-style-type: none;
padding: 0;
margin: 0;
}

#block-finder-results li {
display: flex;
gap: 8px;
padding: 14px 12px;
margin-bottom: 0;
border-bottom: 1px dotted #b9b9b9;
display: flex;
gap: 8px;
padding: 14px 12px;
margin-bottom: 0;
border-bottom: 1px dotted #b9b9b9;
}

#block-finder-results li:last-child {
border-bottom: none;
border-bottom: none;
}

#block-finder-results span {
margin-left: auto;
display: flex;
gap: 8px;
align-items: center;
margin-left: auto;
display: flex;
gap: 8px;
align-items: center;
}

#block-finder-results a {
font-weight: 500;
color: #0073aa;
text-decoration: none;
font-weight: 500;
color: #0073aa;
text-decoration: none;
}

#block-finder-results a:last-child {
border-left: 1px solid #b9b9b9;
padding-left: 8px;
border-left: 1px solid #b9b9b9;
padding-left: 8px;
}

#block-finder-results a:hover {
text-decoration: underline;
text-decoration: underline;
}

0 comments on commit 8802b47

Please sign in to comment.