From 1afb3503906058d837e48011635b47f561682c39 Mon Sep 17 00:00:00 2001 From: Warwick Date: Fri, 9 Jan 2026 14:54:17 +0200 Subject: [PATCH 01/56] fix: correct namespace escaping in plugin initialization comments and function --- {{slug}}.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{slug}}.php b/{{slug}}.php index f56ae5b..6d5edb4 100644 --- a/{{slug}}.php +++ b/{{slug}}.php @@ -56,12 +56,12 @@ function () { /** * Initialise the plugin and return the main instance. * - * @return \\{{namespace}}\\classes\\Core Main plugin instance. + * @return \{{namespace}}\classes\Core Main plugin instance. */ function {{namespace}}_plugin() { global ${{namespace}}_plugin; if ( null === ${{namespace}}_plugin ) { - ${{namespace}}_plugin = new \\{{namespace}}\\classes\\Core(); + ${{namespace}}_plugin = new \{{namespace}}\classes\Core(); } return ${{namespace}}_plugin; } From f737c7fd01d59a4ab47930bb040180f9249c7614 Mon Sep 17 00:00:00 2001 From: Warwick Date: Fri, 9 Jan 2026 14:54:41 +0200 Subject: [PATCH 02/56] fix: remove unnecessary blank lines at the beginning of class files --- inc/class-post-types.php | 1 - inc/class-scf-json.php | 1 - inc/class-taxonomies.php | 1 - 3 files changed, 3 deletions(-) diff --git a/inc/class-post-types.php b/inc/class-post-types.php index 8acddc6..7773d58 100644 --- a/inc/class-post-types.php +++ b/inc/class-post-types.php @@ -1,4 +1,3 @@ - Date: Fri, 9 Jan 2026 14:58:58 +0200 Subject: [PATCH 03/56] refactor: standardize class names by removing namespace prefixes in multiple files --- inc/class-block-bindings.php | 2 +- inc/class-block-styles.php | 2 +- inc/class-block-templates.php | 4 +--- inc/class-fields.php | 6 +++--- inc/class-options.php | 2 +- inc/class-patterns.php | 2 +- inc/class-post-types.php | 2 +- inc/class-repeater-fields.php | 6 +----- inc/class-scf-json-validator.php | 9 +-------- inc/class-scf-json.php | 2 +- inc/class-taxonomies.php | 4 ++-- 11 files changed, 14 insertions(+), 27 deletions(-) diff --git a/inc/class-block-bindings.php b/inc/class-block-bindings.php index 7053af8..186ded5 100644 --- a/inc/class-block-bindings.php +++ b/inc/class-block-bindings.php @@ -7,7 +7,7 @@ * @package {{namespace}} * @since 6.5.0 Block Bindings API */ -class {{namespace|pascalCase}}_Block_Bindings { +class Block_Bindings { /** * Binding source name. diff --git a/inc/class-block-styles.php b/inc/class-block-styles.php index 63ea193..b0756eb 100644 --- a/inc/class-block-styles.php +++ b/inc/class-block-styles.php @@ -16,7 +16,7 @@ * * @since 1.0.0 */ -class {{namespace|pascalCase}}_Block_Styles { +class Block_Styles { /** * Constructor. diff --git a/inc/class-block-templates.php b/inc/class-block-templates.php index f550bec..28494f7 100644 --- a/inc/class-block-templates.php +++ b/inc/class-block-templates.php @@ -14,9 +14,7 @@ /** * Plugin block templates registration. */ -class {{namespace|pascalCase}}_Block_Templates { - */ -class ExamplePlugin_Block_Templates { +class Block_Templates { /** * Constructor. diff --git a/inc/class-fields.php b/inc/class-fields.php index 54ff285..1807b5f 100644 --- a/inc/class-fields.php +++ b/inc/class-fields.php @@ -19,7 +19,7 @@ * * @since 1.0.0 */ -class {{namespace|pascalCase}}_Fields { +class Fields { /** * Field group key. @@ -119,7 +119,7 @@ public function register_fields() { 'label' => __( 'Related Items', '{{textdomain}}' ), 'name' => '{{namespace}}_related', 'type' => 'relationship', - 'post_type' => array( {{namespace|pascalCase}}_Post_Types::POST_TYPE ), + 'post_type' => array( Post_Types::POST_TYPE ), 'filters' => array( 'search', 'taxonomy' ), 'return_format' => 'object', 'instructions' => __( 'Select related items.', '{{textdomain}}' ), @@ -130,7 +130,7 @@ public function register_fields() { array( 'param' => 'post_type', 'operator' => '==', - 'value' => ExamplePlugin_Post_Types::POST_TYPE, + 'value' => Post_Types::POST_TYPE, ), ), ), diff --git a/inc/class-options.php b/inc/class-options.php index a6cf333..ad6d3d0 100644 --- a/inc/class-options.php +++ b/inc/class-options.php @@ -22,7 +22,7 @@ * * Registers options pages and their associated field groups using SCF. */ -class {{namespace|pascalCase}}_Options { +class Options { /** * Main options page slug. diff --git a/inc/class-patterns.php b/inc/class-patterns.php index 027b04d..d0c7977 100644 --- a/inc/class-patterns.php +++ b/inc/class-patterns.php @@ -16,7 +16,7 @@ * * @since 1.0.0 */ -class {{namespace|pascalCase}}_Patterns { +class Patterns { /** * Constructor. diff --git a/inc/class-post-types.php b/inc/class-post-types.php index 7773d58..850637e 100644 --- a/inc/class-post-types.php +++ b/inc/class-post-types.php @@ -15,7 +15,7 @@ /** * Post Types class. */ -class {{namespace|pascalCase}}_Post_Types { +class Post_Types { /** * Post type slug. diff --git a/inc/class-repeater-fields.php b/inc/class-repeater-fields.php index e02e51c..84db08f 100644 --- a/inc/class-repeater-fields.php +++ b/inc/class-repeater-fields.php @@ -1,6 +1,3 @@ - Date: Fri, 9 Jan 2026 15:02:56 +0200 Subject: [PATCH 04/56] refactor: update constructor and class references to remove namespace prefixes in multiple files --- inc/class-block-bindings.php | 1 - inc/class-block-styles.php | 216 +++++++++++++++---------------- inc/class-core.php | 22 ++-- inc/class-patterns.php | 42 +++--- inc/class-scf-json-validator.php | 7 +- 5 files changed, 143 insertions(+), 145 deletions(-) diff --git a/inc/class-block-bindings.php b/inc/class-block-bindings.php index 186ded5..235a0f0 100644 --- a/inc/class-block-bindings.php +++ b/inc/class-block-bindings.php @@ -13,7 +13,6 @@ class Block_Bindings { * Binding source name. * * @since 1.0.0 - public function __construct() { */ const SOURCE = 'example_plugin/fields'; diff --git a/inc/class-block-styles.php b/inc/class-block-styles.php index b0756eb..47d771b 100644 --- a/inc/class-block-styles.php +++ b/inc/class-block-styles.php @@ -19,144 +19,144 @@ class Block_Styles { /** - * Constructor. - * - * @since 1.0.0 - */ -public function __construct() { - add_action( 'init', array( $this, 'register_block_styles' ) ); -} - -/** - * Register block style variations. - * - * @since 1.0.0 - * @return void - */ -public function register_block_styles() { - if ( ! function_exists( 'register_block_style' ) ) { - return; + * Constructor. + * + * @since 1.0.0 + */ + public function __construct() { + add_action( 'init', array( $this, 'register_block_styles' ) ); } - $style_files = $this->get_style_files(); + /** + * Register block style variations. + * + * @since 1.0.0 + * @return void + */ + public function register_block_styles() { + if ( ! function_exists( 'register_block_style' ) ) { + return; + } - foreach ( $style_files as $file_path ) { - $definitions = $this->load_style_definitions( $file_path ); + $style_files = $this->get_style_files(); - foreach ( $definitions as $definition ) { - $this->register_block_style_definition( $definition ); + foreach ( $style_files as $file_path ) { + $definitions = $this->load_style_definitions( $file_path ); + + foreach ( $definitions as $definition ) { + $this->register_block_style_definition( $definition ); + } } } -} -/** - * Retrieve all JSON files from the styles directory. - * - * @since 1.0.0 - * - * @return array Absolute file paths. - */ -private function get_style_files() { - $directory = {{namespace|upper}}_PLUGIN_DIR . 'styles'; + /** + * Retrieve all JSON files from the styles directory. + * + * @since 1.0.0 + * + * @return array Absolute file paths. + */ + private function get_style_files() { + $directory = {{namespace|upper}}_PLUGIN_DIR . 'styles'; + + if ( ! is_dir( $directory ) ) { + return array(); + } - if ( ! is_dir( $directory ) ) { - return array(); - } + $files = array(); + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator( $directory, \FilesystemIterator::SKIP_DOTS ) + ); - $files = array(); - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator( $directory, \FilesystemIterator::SKIP_DOTS ) - ); + foreach ( $iterator as $file ) { + if ( 'json' !== strtolower( $file->getExtension() ) ) { + continue; + } - foreach ( $iterator as $file ) { - if ( 'json' !== strtolower( $file->getExtension() ) ) { - continue; + $files[] = $file->getPathname(); } - $files[] = $file->getPathname(); + return $files; } - return $files; -} - -/** - * Load style definitions from a JSON file. - * - * Supports files containing a single definition, a `styles` array, or a list of definitions. - * - * @param string $file_path JSON file path. - * @return array> List of style definitions. - */ -private function load_style_definitions( $file_path ) { - $content = file_get_contents( $file_path ); + /** + * Load style definitions from a JSON file. + * + * Supports files containing a single definition, a `styles` array, or a list of definitions. + * + * @param string $file_path JSON file path. + * @return array> List of style definitions. + */ + private function load_style_definitions( $file_path ) { + $content = file_get_contents( $file_path ); + + if ( false === $content ) { + return array(); + } - if ( false === $content ) { - return array(); - } + $data = json_decode( $content, true ); - $data = json_decode( $content, true ); + if ( ! is_array( $data ) || empty( $data ) ) { + return array(); + } - if ( ! is_array( $data ) || empty( $data ) ) { - return array(); - } + if ( isset( $data['styles'] ) && is_array( $data['styles'] ) ) { + return $data['styles']; + } - if ( isset( $data['styles'] ) && is_array( $data['styles'] ) ) { - return $data['styles']; - } + if ( array_keys( $data ) === range( 0, count( $data ) - 1 ) ) { + return $data; + } - if ( array_keys( $data ) === range( 0, count( $data ) - 1 ) ) { - return $data; + return array( $data ); } - return array( $data ); -} + /** + * Register a single block style definition. + * + * @param array $definition Style definition parsed from JSON. + * @return void + */ + private function register_block_style_definition( $definition ) { + if ( empty( $definition['blocks'] ) ) { + return; + } -/** - * Register a single block style definition. - * - * @param array $definition Style definition parsed from JSON. - * @return void - */ -private function register_block_style_definition( $definition ) { - if ( empty( $definition['blocks'] ) ) { - return; - } + if ( isset( $definition['scope'] ) && 'block' !== $definition['scope'] ) { + return; + } - if ( isset( $definition['scope'] ) && 'block' !== $definition['scope'] ) { - return; - } + $blocks = is_array( $definition['blocks'] ) ? $definition['blocks'] : array( $definition['blocks'] ); + $blocks = array_filter( array_map( 'strval', $blocks ) ); - $blocks = is_array( $definition['blocks'] ) ? $definition['blocks'] : array( $definition['blocks'] ); - $blocks = array_filter( array_map( 'strval', $blocks ) ); + if ( empty( $blocks ) ) { + return; + } - if ( empty( $blocks ) ) { - return; - } + $name = isset( $definition['name'] ) ? $definition['name'] : ''; + $label = isset( $definition['label'] ) ? $definition['label'] : ''; - $name = isset( $definition['name'] ) ? $definition['name'] : ''; - $label = isset( $definition['label'] ) ? $definition['label'] : ''; + if ( empty( $name ) || empty( $label ) ) { + return; + } - if ( empty( $name ) || empty( $label ) ) { - return; - } + $args = array( + 'name' => $name, + 'label' => __( $label, '{{textdomain}}' ), + ); - $args = array( - 'name' => $name, - 'label' => __( $label, '{{textdomain}}' ), - ); + if ( ! empty( $definition['class_name'] ) ) { + $args['class_name'] = $definition['class_name']; + } - if ( ! empty( $definition['class_name'] ) ) { - $args['class_name'] = $definition['class_name']; - } + if ( isset( $definition['style_data'] ) && is_array( $definition['style_data'] ) ) { + $args['style_data'] = $definition['style_data']; + } - if ( isset( $definition['style_data'] ) && is_array( $definition['style_data'] ) ) { - $args['style_data'] = $definition['style_data']; - } + if ( isset( $definition['style_handle'] ) && is_string( $definition['style_handle'] ) ) { + $args['style_handle'] = $definition['style_handle']; + } - if ( isset( $definition['style_handle'] ) && is_string( $definition['style_handle'] ) ) { - $args['style_handle'] = $definition['style_handle']; + register_block_style( $blocks, $args ); } - - register_block_style( $blocks, $args ); -} } diff --git a/inc/class-core.php b/inc/class-core.php index d652b90..cbb63a4 100644 --- a/inc/class-core.php +++ b/inc/class-core.php @@ -31,17 +31,17 @@ public function __construct() { add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); // Initialize components. - new {{namespace|pascalCase}}_Post_Types(); - new {{namespace|pascalCase}}_Taxonomies(); - new {{namespace|pascalCase}}_Fields(); - new {{namespace|pascalCase}}_Repeater_Fields(); - new {{namespace|pascalCase}}_Options(); - new {{namespace|pascalCase}}_SCF_JSON(); - new {{namespace|pascalCase}}_SCF_JSON_Validator(); - new {{namespace|pascalCase}}_Block_Templates(); - new {{namespace|pascalCase}}_Block_Bindings(); - new {{namespace|pascalCase}}_Block_Styles(); - new {{namespace|pascalCase}}_Patterns(); + new Post_Types(); + new Taxonomies(); + new Fields(); + new Repeater_Fields(); + new Options(); + new SCF_JSON(); + new SCF_JSON_Validator(); + new Block_Templates(); + new Block_Bindings(); + new Block_Styles(); + new Patterns(); } /** diff --git a/inc/class-patterns.php b/inc/class-patterns.php index d0c7977..b8cb210 100644 --- a/inc/class-patterns.php +++ b/inc/class-patterns.php @@ -91,25 +91,25 @@ public function register_patterns() { } /** - * Derive pattern slug from filename. - * - * Converts 'patterns/{{slug}}-tour-card.php' to '{{slug}}/tour-card' - * - * @since 1.0.0 - * @param string $pattern_file Full path to pattern file. - * @return string Pattern slug. - */ - private function get_pattern_slug_from_file( $pattern_file ) { - $filename = basename( $pattern_file, '.php' ); - - // Remove '{{slug}}-' prefix if present, preserving post type and pattern purpose. - if ( strpos( $filename, '{{slug}}-' ) === 0 ) { - $pattern_name = substr( $filename, strlen( '{{slug}}-' ) ); - } else { - $pattern_name = $filename; - } - - // Return namespaced slug in the format '{{slug}}/{post_type}-{pattern}'. - return '{{slug}}/' . $pattern_name; - } + * Derive pattern slug from filename. + * + * Converts 'patterns/{{slug}}-tour-card.php' to '{{slug}}/tour-card' + * + * @since 1.0.0 + * @param string $pattern_file Full path to pattern file. + * @return string Pattern slug. + */ + private function get_pattern_slug_from_file( $pattern_file ) { + $filename = basename( $pattern_file, '.php' ); + + // Remove '{{slug}}-' prefix if present, preserving post type and pattern purpose. + if ( strpos( $filename, '{{slug}}-' ) === 0 ) { + $pattern_name = substr( $filename, strlen( '{{slug}}-' ) ); + } else { + $pattern_name = $filename; + } + + // Return namespaced slug in the format '{{slug}}/{post_type}-{pattern}'. + return '{{slug}}/' . $pattern_name; + } } diff --git a/inc/class-scf-json-validator.php b/inc/class-scf-json-validator.php index 9028774..226da82 100644 --- a/inc/class-scf-json-validator.php +++ b/inc/class-scf-json-validator.php @@ -43,7 +43,7 @@ class SCF_JSON_Validator { /** * SCF JSON handler instance. * - * @var ExamplePlugin_SCF_JSON + * @var SCF_JSON */ private $scf_json; @@ -89,9 +89,8 @@ public function __construct() { $this->schema_path = EXAMPLE_PLUGIN_PLUGIN_DIR . 'scf-json/schema/scf-field-group.schema.json'; $this->schema_path = {{namespace|upper}}_PLUGIN_DIR . 'scf-json/schema/scf-field-group.schema.json'; - if ( class_exists( 'example_plugin\classes\ExamplePlugin_SCF_JSON' ) ) { - $this->scf_json = new ExamplePlugin_SCF_JSON(); - if ( class_exists( '{{namespace}}\\classes\\{{namespace|pascalCase}}_SCF_JSON' ) ) { + if ( class_exists( '{{namespace}}\\classes\\SCF_JSON' ) ) { + $this->scf_json = new SCF_JSON(); } $this->load_schema(); From 5dc226bfe8e02110909d4ec8f18137aaf77214c4 Mon Sep 17 00:00:00 2001 From: Warwick Date: Fri, 9 Jan 2026 15:17:23 +0200 Subject: [PATCH 05/56] fix: remove unnecessary namespace declaration and update schema path in multiple files --- inc/class-core.php | 1 - inc/class-fields.php | 1 - inc/class-scf-json-validator.php | 1 - 3 files changed, 3 deletions(-) diff --git a/inc/class-core.php b/inc/class-core.php index cbb63a4..173a6ae 100644 --- a/inc/class-core.php +++ b/inc/class-core.php @@ -1,5 +1,4 @@ schema_path = EXAMPLE_PLUGIN_PLUGIN_DIR . 'scf-json/schema/scf-field-group.schema.json'; $this->schema_path = {{namespace|upper}}_PLUGIN_DIR . 'scf-json/schema/scf-field-group.schema.json'; if ( class_exists( '{{namespace}}\\classes\\SCF_JSON' ) ) { From 5951e7537c099268520515553d1e59082d6838f7 Mon Sep 17 00:00:00 2001 From: Warwick Date: Fri, 9 Jan 2026 15:34:07 +0200 Subject: [PATCH 06/56] fix: ensure supports property is an array in post type registration and improve variable replacement handling in generator script --- inc/class-post-types.php | 2 +- scripts/generate-plugin.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/class-post-types.php b/inc/class-post-types.php index 850637e..88d4dfa 100644 --- a/inc/class-post-types.php +++ b/inc/class-post-types.php @@ -78,7 +78,7 @@ public function register_post_types() { 'hierarchical' => false, 'menu_position' => 20, 'menu_icon' => '{{cpt_icon}}', - 'supports' => {{cpt_supports}}, + 'supports' => array( {{cpt_supports}} ), 'template' => array( array( '{{namespace}}/{{slug}}-single' ), ), diff --git a/scripts/generate-plugin.js b/scripts/generate-plugin.js index 410c5b5..15af426 100644 --- a/scripts/generate-plugin.js +++ b/scripts/generate-plugin.js @@ -416,7 +416,14 @@ function replaceMustacheVars(content, config) { // Replace simple variables (e.g., example-plugin) result = result.replace(/\{\{([a-z_]+)\}\}/gi, (match, varName) => { const value = config[varName]; - return value !== undefined ? String(value) : ''; // Return empty string for undefined + if (value === undefined) { + return ''; // Return empty string for undefined + } + // Handle arrays by converting to quoted, comma-separated strings for PHP + if (Array.isArray(value)) { + return value.map(item => `'${item}'`).join(', '); + } + return String(value); }); return result; From 18502c90922c3ac03d35a6ba57f0e405fd0326c5 Mon Sep 17 00:00:00 2001 From: Warwick Date: Fri, 9 Jan 2026 15:35:02 +0200 Subject: [PATCH 07/56] refactor: remove unused HTML markup and improve structure in multiple pattern files --- patterns/{{slug}}-archive.php | 32 ------------------------------- patterns/{{slug}}-card.php | 36 ----------------------------------- patterns/{{slug}}-meta.php | 12 ------------ patterns/{{slug}}-single.php | 25 ------------------------ 4 files changed, 105 deletions(-) diff --git a/patterns/{{slug}}-archive.php b/patterns/{{slug}}-archive.php index 05fe0eb..44e15f5 100644 --- a/patterns/{{slug}}-archive.php +++ b/patterns/{{slug}}-archive.php @@ -10,38 +10,6 @@ exit; } -
- - - - - - - - - - - - -

' . esc_html__( 'No items found.', '{{textdomain}}' ) . '

-
- - - - - - - - - - - - -

' . esc_html__( 'No items found.', 'example-plugin' ) . '

- - -
-', return array( 'title' => __( '{{name}} Archive', '{{textdomain}}' ), 'slug' => '{{slug}}/item-archive', diff --git a/patterns/{{slug}}-card.php b/patterns/{{slug}}-card.php index 6347bdc..ceead3c 100644 --- a/patterns/{{slug}}-card.php +++ b/patterns/{{slug}}-card.php @@ -10,24 +10,6 @@ exit; } -
- - - -
- - - -

- - - - - -
- -
-', return array( 'title' => __( '{{name}} Card', '{{textdomain}}' ), 'slug' => '{{slug}}/item-card', @@ -42,22 +24,4 @@ 'postTypes' => array( 'item' ), 'viewportWidth' => 400, 'content' => '\n
\n\t\n\n\t\n\t
\n\t\t\n\n\t\t\n\t\t

\n\t\t\n\n\t\t\n\n\t\t\n\t
\n\t\n
\n', -
- - - -
- - - -

- - - - - -
- -
-', ); diff --git a/patterns/{{slug}}-meta.php b/patterns/{{slug}}-meta.php index da80c21..c3659d1 100644 --- a/patterns/{{slug}}-meta.php +++ b/patterns/{{slug}}-meta.php @@ -10,18 +10,6 @@ exit; } -
- -

' . esc_html__( 'Details', 'example-plugin' ) . '

- - - -
- -
- -
-', return array( 'title' => __( '{{name}} Meta', '{{textdomain}}' ), 'slug' => '{{slug}}/item-meta', diff --git a/patterns/{{slug}}-single.php b/patterns/{{slug}}-single.php index ca8e82e..26b1877 100644 --- a/patterns/{{slug}}-single.php +++ b/patterns/{{slug}}-single.php @@ -25,29 +25,4 @@ 'templateTypes' => array( 'single', 'single-example-plugin' ), 'viewportWidth' => 1200, 'content' => '\n
\n\t\n\n\t\n\t
\n\t\t\n\n\t\t\n\t\t

\n\t\t\n\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t\n\n\t\t\n\t
\n\t\n\n\t\n
\n', -
- - - -
- - - -

- - - -
- - -
- - - -
- - - -
-', ); From 7ca7c1f6ebf03d338eaa31b6b829edcc229e7f49 Mon Sep 17 00:00:00 2001 From: Warwick Date: Mon, 19 Jan 2026 10:57:39 +0200 Subject: [PATCH 08/56] refactor: remove unnecessary comments from block.json files for card, collection, featured, and slider blocks --- src/blocks/{{slug}}-card/block.json | 1 - src/blocks/{{slug}}-collection/block.json | 1 - src/blocks/{{slug}}-featured/block.json | 1 - src/blocks/{{slug}}-slider/block.json | 1 - 4 files changed, 4 deletions(-) diff --git a/src/blocks/{{slug}}-card/block.json b/src/blocks/{{slug}}-card/block.json index dea9cb4..d82c02d 100644 --- a/src/blocks/{{slug}}-card/block.json +++ b/src/blocks/{{slug}}-card/block.json @@ -86,4 +86,3 @@ "style": "file:./style.css", "render": "file:./render.php" } -// ...existing code from block.json for card block... diff --git a/src/blocks/{{slug}}-collection/block.json b/src/blocks/{{slug}}-collection/block.json index cf154ad..792d533 100644 --- a/src/blocks/{{slug}}-collection/block.json +++ b/src/blocks/{{slug}}-collection/block.json @@ -103,4 +103,3 @@ "render": "file:./render.php", "viewScript": "file:./view.js" } -// ...existing code from block.json for collection block... diff --git a/src/blocks/{{slug}}-featured/block.json b/src/blocks/{{slug}}-featured/block.json index c53c5a7..2b4b91b 100644 --- a/src/blocks/{{slug}}-featured/block.json +++ b/src/blocks/{{slug}}-featured/block.json @@ -100,4 +100,3 @@ "style": "file:./style.css", "render": "file:./render.php" } -// ...existing code from block.json for featured block... diff --git a/src/blocks/{{slug}}-slider/block.json b/src/blocks/{{slug}}-slider/block.json index 8698e9a..1483954 100644 --- a/src/blocks/{{slug}}-slider/block.json +++ b/src/blocks/{{slug}}-slider/block.json @@ -99,4 +99,3 @@ "render": "file:./render.php", "viewScript": "file:./view.js" } -// ...existing code from block.json for slider block... From 226cce65c9f620c0706f21e5d1f9bc08aa00a692 Mon Sep 17 00:00:00 2001 From: Warwick Date: Mon, 19 Jan 2026 11:05:55 +0200 Subject: [PATCH 09/56] fix: update post type slug and template references to use correct placeholders --- inc/class-post-types.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/class-post-types.php b/inc/class-post-types.php index 88d4dfa..501d248 100644 --- a/inc/class-post-types.php +++ b/inc/class-post-types.php @@ -23,7 +23,7 @@ class Post_Types { * @since 1.0.0 * @var string */ - const POST_TYPE = '{{slug}}'; + const POST_TYPE = '{{cpt_slug}}'; /** * Constructor. @@ -80,7 +80,7 @@ public function register_post_types() { 'menu_icon' => '{{cpt_icon}}', 'supports' => array( {{cpt_supports}} ), 'template' => array( - array( '{{namespace}}/{{slug}}-single' ), + array( '{{namespace}}/{{cpt_slug}}-single' ), ), 'template_lock' => false, ); From 6ec4c26851c0a9ba637ee8a8dc95c34d3d39babe Mon Sep 17 00:00:00 2001 From: Warwick Date: Mon, 19 Jan 2026 11:29:12 +0200 Subject: [PATCH 10/56] Refactor {{cpt1_slug}} Collection Block - Removed old {{cpt1_slug}}-collection block files (editor.scss, index.js, render.php, style.css, style.scss, view.js). - Created new {{cpt_slug}}-collection block files with updated structure and naming conventions. - Implemented editor and frontend styles using BEM methodology for better maintainability. - Added extensibility features for filtering and sorting collections via JavaScript events. - Updated block.json to reflect new attributes and context usage. - Enhanced accessibility features including focus states and ARIA attributes. --- .../generate-plugin.instructions.md | 2 +- docs/GENERATE_PLUGIN.md | 6 +++--- ...-changes-2025-12-18-2025-12-18T09-59-10.md | 2 +- src/blocks/{{block_slug}}-collection/edit.js | 20 +++++++++---------- .../README.md | 2 +- .../block.json | 6 +++--- .../edit.js | 20 +++++++++---------- .../editor.css | 10 +++++----- .../editor.scss | 4 ++-- .../index.js | 2 +- .../render.php | 6 +++--- .../style.css | 10 +++++----- .../style.scss | 6 +++--- .../view.js | 4 ++-- src/blocks/{{slug}}-card/block.json | 14 ++++++------- src/blocks/{{slug}}-card/edit.js | 18 ++++++++--------- src/blocks/{{slug}}-card/render.php | 16 +++++++-------- src/blocks/{{slug}}-collection/edit.js | 18 ++++++++--------- 18 files changed, 83 insertions(+), 83 deletions(-) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/README.md (80%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/block.json (88%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/edit.js (83%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/editor.css (62%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/editor.scss (94%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/index.js (67%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/render.php (51%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/style.css (68%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/style.scss (92%) rename src/blocks/{{{cpt1_slug}}-collection => {{cpt_slug}}-collection}/view.js (86%) diff --git a/.github/instructions/generate-plugin.instructions.md b/.github/instructions/generate-plugin.instructions.md index ff24e9f..d900210 100644 --- a/.github/instructions/generate-plugin.instructions.md +++ b/.github/instructions/generate-plugin.instructions.md @@ -1,6 +1,6 @@ # ⚠️ WARNING: Strict Mustache Placeholder Enforcement -All contributors must use the correct mustache placeholders in all template files, folders, and code. Do not use generic placeholders (like `{{slug}}`) where a more specific one is required (e.g., `{{cpt1_slug}}`, `{{taxonomy1_slug}}`). +All contributors must use the correct mustache placeholders in all template files, folders, and code. Do not use generic placeholders (like `{{slug}}`) where a more specific one is required (e.g., `{{cpt_slug}}`, `{{taxonomy1_slug}}`). **Never hard-code plugin-specific values** in the scaffold. All identifiers, class names, translation domains, and meta keys must use the appropriate placeholder as defined in `scripts/mustache-variables-registry.json`. diff --git a/docs/GENERATE_PLUGIN.md b/docs/GENERATE_PLUGIN.md index 4004243..f3cb276 100644 --- a/docs/GENERATE_PLUGIN.md +++ b/docs/GENERATE_PLUGIN.md @@ -1,6 +1,6 @@ # ⚠️ WARNING: Strict Mustache Placeholder Enforcement -All template files, folders, and code **must** use the correct mustache placeholders as defined in `scripts/mustache-variables-registry.json`. Do not use generic placeholders (like `{{slug}}`) where a more specific one is required (e.g., `{{cpt1_slug}}`, `{{taxonomy1_slug}}`). +All template files, folders, and code **must** use the correct mustache placeholders as defined in `scripts/mustache-variables-registry.json`. Do not use generic placeholders (like `{{slug}}`) where a more specific one is required (e.g., `{{cpt_slug}}`, `{{taxonomy1_slug}}`). **Do not hard-code any plugin-specific values** in the scaffold. All identifiers, class names, translation domains, and meta keys must use the appropriate placeholder. This ensures the generator can produce multi-entity plugins without manual intervention. @@ -153,7 +153,7 @@ Author: LightSpeed ### CRITICAL: Use Specific Placeholders for Multiple CPTs/Taxonomies/Fields -**WARNING:** When building plugins that support multiple custom post types (CPTs), taxonomies, or custom fields, you MUST use specific mustache placeholders for each entity. Do NOT use generic placeholders like `{{slug}}`, `{{cpt_slug}}`, or `{{taxonomy_slug}}` in your templates or code. Instead, use numbered or uniquely named placeholders for each entity, such as `{{cpt1_slug}}`, `{{cpt2_slug}}`, `{{taxonomy1_slug}}`, `{{taxonomy2_slug}}`, `{{field1_name}}`, etc. +**WARNING:** When building plugins that support multiple custom post types (CPTs), taxonomies, or custom fields, you MUST use specific mustache placeholders for each entity. Do NOT use generic placeholders like `{{slug}}`, `{{cpt_slug}}`, or `{{taxonomy_slug}}` in your templates or code. Instead, use numbered or uniquely named placeholders for each entity, such as `{{cpt_slug}}`, `{{cpt2_slug}}`, `{{taxonomy1_slug}}`, `{{taxonomy2_slug}}`, `{{field1_name}}`, etc. **Why?** @@ -183,7 +183,7 @@ Author: LightSpeed register_post_type( '{{cpt_slug}}', ... ); // GOOD (use specific): -register_post_type( '{{cpt1_slug}}', ... ); +register_post_type( '{{cpt_slug}}', ... ); register_post_type( '{{cpt2_slug}}', ... ); // BAD: diff --git a/scripts/reports/registry-changes-2025-12-18-2025-12-18T09-59-10.md b/scripts/reports/registry-changes-2025-12-18-2025-12-18T09-59-10.md index 481263a..5d7cd83 100644 --- a/scripts/reports/registry-changes-2025-12-18-2025-12-18T09-59-10.md +++ b/scripts/reports/registry-changes-2025-12-18-2025-12-18T09-59-10.md @@ -5,7 +5,7 @@ ## Added (2) - `{{author_username}}` -- `{{cpt1_slug}}` +- `{{cpt_slug}}` ## Removed (1) diff --git a/src/blocks/{{block_slug}}-collection/edit.js b/src/blocks/{{block_slug}}-collection/edit.js index 1c9a3c7..4f5eedb 100644 --- a/src/blocks/{{block_slug}}-collection/edit.js +++ b/src/blocks/{{block_slug}}-collection/edit.js @@ -58,7 +58,7 @@ export default function Edit({ attributes, setAttributes }) { return select('core').getEntityRecords( 'postType', - '{{cpt1_slug}}', + '{{cpt_slug}}', queryArgs ); }, @@ -66,7 +66,7 @@ export default function Edit({ attributes, setAttributes }) { ); const blockProps = useBlockProps({ - className: `wp-block-{{namespace}}-{{cpt1_slug}}-collection is-layout-${layout}`, + className: `wp-block-{{namespace}}-{{cpt_slug}}-collection is-layout-${layout}`, }); const gridStyle = useMemo(() => { @@ -217,19 +217,19 @@ export default function Edit({ attributes, setAttributes }) { {posts && posts.length > 0 && (
{posts.map((post) => (
{displayFeaturedImage && post._embedded?.[ 'wp:featuredmedia' ]?.[0] && ( -
+
)} -
+
{displayTitle && ( -

+

{post.title.rendered}

)} {displayExcerpt && (
)} {displayMeta && ( -
+