Plugin Directory

Changeset 3446664


Ignore:
Timestamp:
01/25/2026 08:01:15 PM (2 months ago)
Author:
akritsingha
Message:

Update version to 2.2.6

Location:
modular-blocks-core/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • modular-blocks-core/trunk/includes/class-block-registry.php

    r3446638 r3446664  
    6767        $locations = array();
    6868
    69         // 1. Add Primary Storage Location
     69        // 1. Add Primary Storage Location (highest priority)
    7070        if ( defined( 'MBCORE_STORAGE_DIR' ) && defined( 'MBCORE_STORAGE_URL' ) ) {
    7171            $locations[] = array(
     
    7575        }
    7676
    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();
    82112        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            }
    113119        }
    114120
    115121        $registered_slugs = array();
    116122
    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 ) ) {
    119127                continue;
    120128            }
    121 
    122             $dirs = array_filter( glob( trailingslashit( $loc['dir'] ) . '*' ), 'is_dir' );
    123129
    124130            foreach ( $dirs as $dir ) {
     
    237243        }
    238244
     245        if ( \WP_Block_Type_Registry::get_instance()->is_registered( 'modular-blocks/' . $folder_name ) ) {
     246            unregister_block_type( 'modular-blocks/' . $folder_name );
     247        }
     248
    239249        $result = register_block_type( $dir_path, $args );
    240250        return ! is_wp_error( $result );
  • modular-blocks-core/trunk/modular-blocks-core.php

    r3446638 r3446664  
    33 * Plugin Name: Modular Blocks Core
    44 * Description: A lightweight, custom framework for building dynamic, reusable Gutenberg blocks with minimal overhead.
    5  * Version: 2.2.5
     5 * Version: 2.2.6
    66 * Author: Akrit Singha
    77 * Author URI: https://github.com/akritsingha
  • modular-blocks-core/trunk/readme.txt

    r3446638 r3446664  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.2.5
     7Stable tag: 2.2.6
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.