Plugin Directory

Changeset 3360754


Ignore:
Timestamp:
09/12/2025 08:10:51 PM (7 months ago)
Author:
mrboydwp
Message:

Fix block registration: use root block.json instead of build/ directory

Location:
bcodecraft-blocks
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bcodecraft-blocks/tags/1.2.3/includes/class-snippy-blocks-editor.php

    r3360751 r3360754  
    1616
    1717    public function registerBlock() {
    18         // WordPress 6.0+ compatible block registration with explicit namespace
    19         $block_json_path = SNIPPY_BLOCKS_PLUGIN_DIR . 'build';
     18        // WordPress 6.0+ compatible block registration
     19        $block_json_file = SNIPPY_BLOCKS_PLUGIN_DIR . 'block.json';
    2020       
    21         // First check if build version exists (production)
    22         if (file_exists($block_json_path . '/block.json')) {
    23             register_block_type($block_json_path . '/block.json', [
     21        if (file_exists($block_json_file)) {
     22            register_block_type($block_json_file, [
    2423                'render_callback' => [$this, 'renderBlockCallback'],
    2524            ]);
    26         }
    27         // Fallback to source version (development) 
    28         else if (file_exists(SNIPPY_BLOCKS_PLUGIN_DIR . 'src/block.json')) {
    29             register_block_type(SNIPPY_BLOCKS_PLUGIN_DIR . 'src/block.json', [
    30                 'render_callback' => [$this, 'renderBlockCallback'],
    31             ]);
    32         }
    33         // Manual registration as fallback (should not happen if files exist)
    34         else {
     25        } else {
     26            // Manual registration as fallback
    3527            register_block_type('bccb-blocks/snippet', [
    3628                'render_callback' => [$this, 'renderBlockCallback'],
  • bcodecraft-blocks/trunk/includes/class-snippy-blocks-editor.php

    r3360751 r3360754  
    1616
    1717    public function registerBlock() {
    18         // WordPress 6.0+ compatible block registration with explicit namespace
    19         $block_json_path = SNIPPY_BLOCKS_PLUGIN_DIR . 'build';
     18        // WordPress 6.0+ compatible block registration
     19        $block_json_file = SNIPPY_BLOCKS_PLUGIN_DIR . 'block.json';
    2020       
    21         // First check if build version exists (production)
    22         if (file_exists($block_json_path . '/block.json')) {
    23             register_block_type($block_json_path . '/block.json', [
     21        if (file_exists($block_json_file)) {
     22            register_block_type($block_json_file, [
    2423                'render_callback' => [$this, 'renderBlockCallback'],
    2524            ]);
    26         }
    27         // Fallback to source version (development) 
    28         else if (file_exists(SNIPPY_BLOCKS_PLUGIN_DIR . 'src/block.json')) {
    29             register_block_type(SNIPPY_BLOCKS_PLUGIN_DIR . 'src/block.json', [
    30                 'render_callback' => [$this, 'renderBlockCallback'],
    31             ]);
    32         }
    33         // Manual registration as fallback (should not happen if files exist)
    34         else {
     25        } else {
     26            // Manual registration as fallback
    3527            register_block_type('bccb-blocks/snippet', [
    3628                'render_callback' => [$this, 'renderBlockCallback'],
Note: See TracChangeset for help on using the changeset viewer.