From c82a701519fc36a80cb197c1a044027ccb973a7d Mon Sep 17 00:00:00 2001 From: Joshua Fredrickson Date: Sun, 13 Sep 2020 10:55:32 -0500 Subject: [PATCH 1/8] Add dependency micropackage/filesystem --- composer.json | 3 ++- composer.lock | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 07e8afe..312eb03 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "require": { "php": ">=5.6", "micropackage/singleton": "^1.1", - "micropackage/dochooks": "^1.0" + "micropackage/dochooks": "^1.0", + "micropackage/filesystem": "^1.1" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", diff --git a/composer.lock b/composer.lock index 1bcb03c..148f06f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bd32cd3e4cadf01d639c210d3ede7a5f", + "content-hash": "455452f00241e38e860abcac689f6a41", "packages": [ { "name": "micropackage/dochooks", @@ -47,6 +47,48 @@ "description": "DocHooks - annotated WordPress hooks", "time": "2020-01-28T12:33:02+00:00" }, + { + "name": "micropackage/filesystem", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/micropackage/filesystem.git", + "reference": "a686c7c2d7c7443c4cf6dc55dbd2283a6e219b06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/micropackage/filesystem/zipball/a686c7c2d7c7443c4cf6dc55dbd2283a6e219b06", + "reference": "a686c7c2d7c7443c4cf6dc55dbd2283a6e219b06", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/php-compatibility": "^9.1", + "phpunit/phpunit": "^6.5.5", + "wp-coding-standards/wpcs": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Micropackage\\Filesystem\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "Jakub Mikita", + "email": "jakub@bracketspace.com" + } + ], + "description": "Wrapper for WordPress' Filesystem for easier file manipulations.", + "time": "2020-06-15T11:06:50+00:00" + }, { "name": "micropackage/singleton", "version": "1.1.0", @@ -319,5 +361,6 @@ "platform": { "php": ">=5.6" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } From 43d4a4500ec5e76dfec442bc1f0fff94dfd30efe Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 16 Sep 2020 14:03:41 +0200 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0110956..37c9a42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [Next] + +* [Fixed] Missing Filesystem dependency, thanks to @joshuafredrickson + ## 1.0.3 * [Added] Filters for config From cb1615c618a30e26e4aa90e56201f8de0bfb5a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Sza=C5=82kiewicz?= Date: Thu, 8 Apr 2021 16:26:11 +0200 Subject: [PATCH 3/8] fix default blocks path --- src/BlockLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlockLoader.php b/src/BlockLoader.php index 049ceab..edc49b7 100644 --- a/src/BlockLoader.php +++ b/src/BlockLoader.php @@ -185,7 +185,7 @@ public function register_metabox_blocks( $meta_boxes ) { public function get_blocks() { $paths = apply_filters( 'micropackage/block-loader/paths', - [ wp_normalize_path( "$this->root_dir/blocks" ) ] + [ wp_normalize_path( "{$this->root_dir}/{$this->config['dir']}" ) ] ); $blocks = []; From 412ba115b39694e5dec3e18f9f48b7028cd335de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Sza=C5=82kiewicz?= Date: Thu, 8 Apr 2021 16:27:19 +0200 Subject: [PATCH 4/8] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37c9a42..d368a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## [Next] +* [Fixed] Hardcoded default blocks path * [Fixed] Missing Filesystem dependency, thanks to @joshuafredrickson ## 1.0.3 From 0b63280a6f3b4435fcad0301e1e58e2e9983df7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Sza=C5=82kiewicz?= Date: Fri, 9 Apr 2021 18:28:28 +0200 Subject: [PATCH 5/8] fix error --- src/BlockLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlockLoader.php b/src/BlockLoader.php index edc49b7..90e813c 100644 --- a/src/BlockLoader.php +++ b/src/BlockLoader.php @@ -214,7 +214,7 @@ private function get_blocks_from_path( $path ) { $data = $this->get_block_data( $filepath ); $slug = basename( $filepath, '.php' ); - if ( ! $data['title'] ) { + if ( ! isset( $data['title'] ) ) { continue; } From a5b7a5020ad9094945c9597cb265f843c0038e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Sza=C5=82kiewicz?= Date: Fri, 9 Apr 2021 18:29:06 +0200 Subject: [PATCH 6/8] add possibility to load blocks from subfolders - CU-fk2fev --- src/BlockLoader.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/BlockLoader.php b/src/BlockLoader.php index 90e813c..511d74c 100644 --- a/src/BlockLoader.php +++ b/src/BlockLoader.php @@ -210,9 +210,17 @@ private function get_blocks_from_path( $path ) { if ( $files ) { foreach ( $files as $file ) { - $filepath = $fs->path( $file['name'] ); + if ( $fs->is_file( $file['name'] ) ) { + $filename = $file['name']; + } elseif ( $fs->is_file( "{$file['name']}/template.php" ) ) { + $filename = "{$file['name']}/template.php"; + } else { + continue; + } + + $filepath = $fs->path( $filename ); $data = $this->get_block_data( $filepath ); - $slug = basename( $filepath, '.php' ); + $slug = basename( $file['name'], '.php' ); if ( ! isset( $data['title'] ) ) { continue; From 1c5b93ed90a9a1d82c95db7e58264c6b8fdba9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Sza=C5=82kiewicz?= Date: Fri, 9 Apr 2021 18:30:29 +0200 Subject: [PATCH 7/8] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d368a66..49cad93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. ## [Next] +* [Added] Possibility to load blocks from subfolders (block-name/template.php instead of the default block-name.php) +* [Fixed] Error with invalid array key if file didn't have a block header * [Fixed] Hardcoded default blocks path * [Fixed] Missing Filesystem dependency, thanks to @joshuafredrickson From d00733c34ef021284780fc60b500437c99c6b1a4 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Mon, 12 Apr 2021 11:14:12 +0200 Subject: [PATCH 8/8] bump version --- CHANGELOG.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49cad93..83d4ee8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog All notable changes to this project will be documented in this file. -## [Next] +## 1.0.4 * [Added] Possibility to load blocks from subfolders (block-name/template.php instead of the default block-name.php) * [Fixed] Error with invalid array key if file didn't have a block header diff --git a/composer.json b/composer.json index 312eb03..45f56d3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "micropackage/block-loader", - "version": "1.0.3", + "version": "1.0.4", "description": "Block Loader - automatic Gutenberg blocks from template files.", "license": "GPL-3.0-or-later", "authors": [