Plugin Directory

Changeset 3333677


Ignore:
Timestamp:
07/24/2025 01:34:50 PM (8 months ago)
Author:
dplugins
Message:

Update to version 1.0.7 from GitHub

Location:
dblocks-finder
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dblocks-finder/tags/1.0.7/app/App.php

    r3250593 r3333677  
    9595        }
    9696   
    97         // Search for pattern usage in post content
     97        // Search for pattern usage in post content - improved method
    9898        foreach ($posts as $post) {
    99             // Look for patterns in the content (using LIKE to find pattern references)
    100             // Modify the loop that adds pattern usage to ensure each pattern is added only once per post
    101                 foreach ($patterns as $pattern) {
    102                     $pattern_id = $pattern['id'];
    103                     // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    104                     $pattern_usage_results = $wpdb->get_results($wpdb->prepare(
    105                         "SELECT p.ID, p.post_title, p.post_type
    106                         FROM {$wpdb->posts} p
    107                         WHERE p.post_content LIKE %s
    108                         AND (p.post_type = %s OR p.post_type = %s)",
    109                         '%' . $wpdb->esc_like('<!-- wp:block {"ref":' . $pattern_id . '} /-->') . '%',
    110                         'page',
    111                         'post'
    112                     ));
    113 
    114                     // If pattern is used, add it to the usage array
    115                     if (!empty($pattern_usage_results)) {
    116                         foreach ($pattern_usage_results as $usage) {
    117                             // Ensure the pattern is only added once per post by checking if it's already in the array
    118                             if (!in_array($usage->ID, array_column($pattern_usage[$pattern['title']], 'post_id'))) {
    119                                 $pattern_usage[$pattern['title']][] = [
    120                                     'post_title' => $usage->post_title,
    121                                     'post_type'  => $usage->post_type,
    122                                     'post_id'    => $usage->ID
    123                                 ];
    124                             }
     99            // Check for blocks in posts and detect patterns
     100            if (has_blocks($post->post_content)) {
     101                $post_blocks = parse_blocks($post->post_content);
     102                // Use the same logic as our debug method to find patterns
     103                foreach ($patterns as $pattern_title => $pattern_data) {
     104                    if ($this->find_pattern_in_blocks($post_blocks, $pattern_data['id'], $pattern_title)) {
     105                        // Ensure the pattern is only added once per post by checking if it's already in the array
     106                        if (!in_array($post->ID, array_column($pattern_usage[$pattern_title], 'post_id'))) {
     107                            $pattern_usage[$pattern_title][] = [
     108                                'post_title' => $post->post_title,
     109                                'post_type'  => $post->post_type,
     110                                'post_id'    => $post->ID
     111                            ];
    125112                        }
    126113                    }
    127114                }
    128 
    129    
     115            }
     116        }
     117
     118        // Now check for blocks in all posts for regular block detection
     119        foreach ($posts as $post) {
    130120            // Check for blocks in posts
    131121            if (has_blocks($post->post_content)) {
     
    203193   
    204194        return ['blocks' => $blocks, 'usage' => $used_blocks, 'patterns' => $patterns, 'pattern_usage' => $pattern_usage];
     195    }
     196
     197
     198
     199    // Helper method to recursively find patterns in blocks
     200    private function find_pattern_in_blocks($blocks, $pattern_id, $pattern_title) {
     201        foreach ($blocks as $block) {
     202            // Check if this is a pattern block
     203            if (isset($block['blockName'])) {
     204                // Check for wp:block with ref
     205                if ($block['blockName'] === 'core/block' &&
     206                    isset($block['attrs']['ref']) &&
     207                    $block['attrs']['ref'] == $pattern_id) {
     208                    return true;
     209                }
     210               
     211                // Check for wp:pattern with slug
     212                if (strpos($block['blockName'], 'core/pattern') === 0 &&
     213                    isset($block['attrs']['slug']) &&
     214                    $block['attrs']['slug'] === $pattern_title) {
     215                    return true;
     216                }
     217            }
     218           
     219            // Recurse into inner blocks
     220            if (isset($block['innerBlocks']) && !empty($block['innerBlocks'])) {
     221                if ($this->find_pattern_in_blocks($block['innerBlocks'], $pattern_id, $pattern_title)) {
     222                    return true;
     223                }
     224            }
     225        }
     226        return false;
    205227    }
    206228
     
    262284    }
    263285}
     286
  • dblocks-finder/tags/1.0.7/dblocks-finder.php

    r3291512 r3333677  
    55 * Requires at least: 6.1
    66 * Requires PHP:      7.4
    7  * Version:           1.0.6
     7 * Version:           1.0.7
    88 * Author:            DPlugins
    99 * Author URI:        https://dplugins.com/
  • dblocks-finder/tags/1.0.7/readme.txt

    r3291512 r3333677  
    44Requires at least: 6.6.0
    55Tested up to: 6.8.1
    6 Stable tag: 1.0.6
     6Stable tag: 1.0.7
    77Requires PHP: 7.4
    88License: GPL-2.0-or-later
     
    46462. Preview
    4747
     48== Changelog ==
     49= 1.0.7 =
     50* Fixed: Sync patterns was not scanned in child pages
    4851
    4952== Changelog ==
  • dblocks-finder/tags/1.0.7/vendor/composer/installed.php

    r3215751 r3333677  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '52aacd5ee7ff82ab19733f0eff0ad5dfc872c61e',
     6        'reference' => '48bcea822d3241fa3d05ca944f37f9864de67fd7',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '52aacd5ee7ff82ab19733f0eff0ad5dfc872c61e',
     16            'reference' => '48bcea822d3241fa3d05ca944f37f9864de67fd7',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • dblocks-finder/trunk/app/App.php

    r3250593 r3333677  
    9595        }
    9696   
    97         // Search for pattern usage in post content
     97        // Search for pattern usage in post content - improved method
    9898        foreach ($posts as $post) {
    99             // Look for patterns in the content (using LIKE to find pattern references)
    100             // Modify the loop that adds pattern usage to ensure each pattern is added only once per post
    101                 foreach ($patterns as $pattern) {
    102                     $pattern_id = $pattern['id'];
    103                     // phpcs:ignore WordPress.DB.DirectDatabaseQuery
    104                     $pattern_usage_results = $wpdb->get_results($wpdb->prepare(
    105                         "SELECT p.ID, p.post_title, p.post_type
    106                         FROM {$wpdb->posts} p
    107                         WHERE p.post_content LIKE %s
    108                         AND (p.post_type = %s OR p.post_type = %s)",
    109                         '%' . $wpdb->esc_like('<!-- wp:block {"ref":' . $pattern_id . '} /-->') . '%',
    110                         'page',
    111                         'post'
    112                     ));
    113 
    114                     // If pattern is used, add it to the usage array
    115                     if (!empty($pattern_usage_results)) {
    116                         foreach ($pattern_usage_results as $usage) {
    117                             // Ensure the pattern is only added once per post by checking if it's already in the array
    118                             if (!in_array($usage->ID, array_column($pattern_usage[$pattern['title']], 'post_id'))) {
    119                                 $pattern_usage[$pattern['title']][] = [
    120                                     'post_title' => $usage->post_title,
    121                                     'post_type'  => $usage->post_type,
    122                                     'post_id'    => $usage->ID
    123                                 ];
    124                             }
     99            // Check for blocks in posts and detect patterns
     100            if (has_blocks($post->post_content)) {
     101                $post_blocks = parse_blocks($post->post_content);
     102                // Use the same logic as our debug method to find patterns
     103                foreach ($patterns as $pattern_title => $pattern_data) {
     104                    if ($this->find_pattern_in_blocks($post_blocks, $pattern_data['id'], $pattern_title)) {
     105                        // Ensure the pattern is only added once per post by checking if it's already in the array
     106                        if (!in_array($post->ID, array_column($pattern_usage[$pattern_title], 'post_id'))) {
     107                            $pattern_usage[$pattern_title][] = [
     108                                'post_title' => $post->post_title,
     109                                'post_type'  => $post->post_type,
     110                                'post_id'    => $post->ID
     111                            ];
    125112                        }
    126113                    }
    127114                }
    128 
    129    
     115            }
     116        }
     117
     118        // Now check for blocks in all posts for regular block detection
     119        foreach ($posts as $post) {
    130120            // Check for blocks in posts
    131121            if (has_blocks($post->post_content)) {
     
    203193   
    204194        return ['blocks' => $blocks, 'usage' => $used_blocks, 'patterns' => $patterns, 'pattern_usage' => $pattern_usage];
     195    }
     196
     197
     198
     199    // Helper method to recursively find patterns in blocks
     200    private function find_pattern_in_blocks($blocks, $pattern_id, $pattern_title) {
     201        foreach ($blocks as $block) {
     202            // Check if this is a pattern block
     203            if (isset($block['blockName'])) {
     204                // Check for wp:block with ref
     205                if ($block['blockName'] === 'core/block' &&
     206                    isset($block['attrs']['ref']) &&
     207                    $block['attrs']['ref'] == $pattern_id) {
     208                    return true;
     209                }
     210               
     211                // Check for wp:pattern with slug
     212                if (strpos($block['blockName'], 'core/pattern') === 0 &&
     213                    isset($block['attrs']['slug']) &&
     214                    $block['attrs']['slug'] === $pattern_title) {
     215                    return true;
     216                }
     217            }
     218           
     219            // Recurse into inner blocks
     220            if (isset($block['innerBlocks']) && !empty($block['innerBlocks'])) {
     221                if ($this->find_pattern_in_blocks($block['innerBlocks'], $pattern_id, $pattern_title)) {
     222                    return true;
     223                }
     224            }
     225        }
     226        return false;
    205227    }
    206228
     
    262284    }
    263285}
     286
  • dblocks-finder/trunk/dblocks-finder.php

    r3291512 r3333677  
    55 * Requires at least: 6.1
    66 * Requires PHP:      7.4
    7  * Version:           1.0.6
     7 * Version:           1.0.7
    88 * Author:            DPlugins
    99 * Author URI:        https://dplugins.com/
  • dblocks-finder/trunk/readme.txt

    r3291512 r3333677  
    44Requires at least: 6.6.0
    55Tested up to: 6.8.1
    6 Stable tag: 1.0.6
     6Stable tag: 1.0.7
    77Requires PHP: 7.4
    88License: GPL-2.0-or-later
     
    46462. Preview
    4747
     48== Changelog ==
     49= 1.0.7 =
     50* Fixed: Sync patterns was not scanned in child pages
    4851
    4952== Changelog ==
  • dblocks-finder/trunk/vendor/composer/installed.php

    r3215751 r3333677  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '52aacd5ee7ff82ab19733f0eff0ad5dfc872c61e',
     6        'reference' => '48bcea822d3241fa3d05ca944f37f9864de67fd7',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '52aacd5ee7ff82ab19733f0eff0ad5dfc872c61e',
     16            'reference' => '48bcea822d3241fa3d05ca944f37f9864de67fd7',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.