Changeset 3446664
- Timestamp:
- 01/25/2026 08:01:15 PM (2 months ago)
- Location:
- modular-blocks-core/trunk
- Files:
-
- 3 edited
-
includes/class-block-registry.php (modified) (3 diffs)
-
modular-blocks-core.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modular-blocks-core/trunk/includes/class-block-registry.php
r3446638 r3446664 67 67 $locations = array(); 68 68 69 // 1. Add Primary Storage Location 69 // 1. Add Primary Storage Location (highest priority) 70 70 if ( defined( 'MBCORE_STORAGE_DIR' ) && defined( 'MBCORE_STORAGE_URL' ) ) { 71 71 $locations[] = array( … … 75 75 } 76 76 77 // 2. Add Theme Blocks Location (if not already added) 78 $theme_dir = trailingslashit( get_template_directory() ) . 'blocks/'; 79 $theme_url = trailingslashit( get_template_directory_uri() ) . 'blocks/'; 80 81 $is_duplicate = false; 77 // 2. Add Theme Blocks Location 78 $theme_dir = trailingslashit( get_template_directory() ) . 'blocks/'; 79 $theme_url = trailingslashit( get_template_directory_uri() ) . 'blocks/'; 80 $locations[] = array( 81 'dir' => $theme_dir, 82 'url' => $theme_url, 83 ); 84 85 // 3. Add Child Theme Blocks Location (if different) 86 if ( get_stylesheet_directory() !== get_template_directory() ) { 87 $child_dir = trailingslashit( get_stylesheet_directory() ) . 'blocks/'; 88 $child_url = trailingslashit( get_stylesheet_directory_uri() ) . 'blocks/'; 89 $locations[] = array( 90 'dir' => $child_dir, 91 'url' => $child_url, 92 ); 93 } 94 95 // 4. Add Uploads Storage Location (if not already covered) 96 $upload_dir = wp_upload_dir(); 97 if ( ! isset( $upload_dir['error'] ) || empty( $upload_dir['error'] ) ) { 98 $locations[] = array( 99 'dir' => $upload_dir['basedir'] . '/modular-blocks/', 100 'url' => $upload_dir['baseurl'] . '/modular-blocks/', 101 ); 102 } 103 104 // 5. Add Plugin Default Location 105 $locations[] = array( 106 'dir' => MBCORE_PATH . 'blocks/', 107 'url' => MBCORE_URL . 'blocks/', 108 ); 109 110 // Normalize paths and filter valid, unique directories. 111 $unique_locations = array(); 82 112 foreach ( $locations as $loc ) { 83 if ( trailingslashit( $loc['dir'] ) === $theme_dir ) { 84 $is_duplicate = true; 85 break; 86 } 87 } 88 89 if ( ! $is_duplicate && is_dir( $theme_dir ) ) { 90 $locations[] = array( 91 'dir' => $theme_dir, 92 'url' => $theme_url, 93 ); 94 } 95 96 // 3. Add Plugin Default Location (if not already added) 97 $plugin_dir = MBCORE_PATH . 'blocks/'; 98 $plugin_url = MBCORE_URL . 'blocks/'; 99 100 $is_duplicate = false; 101 foreach ( $locations as $loc ) { 102 if ( trailingslashit( $loc['dir'] ) === trailingslashit( $plugin_dir ) ) { 103 $is_duplicate = true; 104 break; 105 } 106 } 107 108 if ( ! $is_duplicate && is_dir( $plugin_dir ) ) { 109 $locations[] = array( 110 'dir' => $plugin_dir, 111 'url' => $plugin_url, 112 ); 113 // Normalize path to avoid issues with slashes. 114 $norm_path = wp_normalize_path( trailingslashit( $loc['dir'] ) ); 115 116 if ( ! isset( $unique_locations[ $norm_path ] ) && is_dir( $loc['dir'] ) ) { 117 $unique_locations[ $norm_path ] = $loc; 118 } 113 119 } 114 120 115 121 $registered_slugs = array(); 116 122 117 foreach ( $locations as $loc ) { 118 if ( ! is_dir( $loc['dir'] ) ) { 123 foreach ( $unique_locations as $loc ) { 124 $dirs = array_filter( glob( trailingslashit( $loc['dir'] ) . '*' ), 'is_dir' ); 125 126 if ( empty( $dirs ) ) { 119 127 continue; 120 128 } 121 122 $dirs = array_filter( glob( trailingslashit( $loc['dir'] ) . '*' ), 'is_dir' );123 129 124 130 foreach ( $dirs as $dir ) { … … 237 243 } 238 244 245 if ( \WP_Block_Type_Registry::get_instance()->is_registered( 'modular-blocks/' . $folder_name ) ) { 246 unregister_block_type( 'modular-blocks/' . $folder_name ); 247 } 248 239 249 $result = register_block_type( $dir_path, $args ); 240 250 return ! is_wp_error( $result ); -
modular-blocks-core/trunk/modular-blocks-core.php
r3446638 r3446664 3 3 * Plugin Name: Modular Blocks Core 4 4 * Description: A lightweight, custom framework for building dynamic, reusable Gutenberg blocks with minimal overhead. 5 * Version: 2.2. 55 * Version: 2.2.6 6 6 * Author: Akrit Singha 7 7 * Author URI: https://github.com/akritsingha -
modular-blocks-core/trunk/readme.txt
r3446638 r3446664 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 2.2. 57 Stable tag: 2.2.6 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.