# tableberg/0.5.7/includes/Patterns/RegisterPatterns.php

Tableberg – Simple Gutenberg Table Block, version 0.5.7. 51 lines.

- Page: https://pluginprobe.com/plugins/tableberg/0.5.7/code/includes/Patterns/RegisterPatterns.php
- Raw: https://pluginprobe.com/plugins/tableberg/0.5.7/raw/includes/Patterns/RegisterPatterns.php
- Modified: 2024-07-31T03:53:02+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tableberg/0.5.7/code/includes/Patterns/RegisterPatterns.php#L10-L20`.

```php
<?php

namespace Tableberg\Patterns;

class RegisterPatterns
{

    public static function from_dir($dir)
    {
        if (!file_exists($dir)) {
            return;
        }
        $files = scandir($dir);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $content = json_decode(file_get_contents($dir . '/' . $file), true);
            register_block_pattern('tableberg/' . str_replace('.json', '', $file), $content);
        }
    }

    public static function upsells()
    {
        $dir = __DIR__ . '/upsells';
        if (!file_exists($dir)) {
            return;
        }
        $files = scandir($dir);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $content = json_decode(file_get_contents($dir . '/' . $file), true);
            $content['content'] = str_replace('::PLUGIN_URL::', TABLEBERG_URL, $content['content']);
            register_block_pattern('tableberg/' . str_replace('.json', '', $file), $content);
        }
    }

    public static function categories()
    {
        register_block_pattern_category('tableberg', array('label' => 'Tableberg'));
        
        register_block_pattern_category('comparison-table', array('label' => 'Comparison Table'));
        register_block_pattern_category('featured-box', array('label' => 'Featured Box'));
        register_block_pattern_category('pricing-table', array('label' => 'Pricing Table'));
        register_block_pattern_category('pros-cons', array('label' => 'Pros & Cons'));

        register_block_pattern_category('other', array('label' => 'Other'));
    }
}
```
