-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
58 lines (49 loc) · 1.34 KB
/
Copy pathplugin.php
File metadata and controls
58 lines (49 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
Plugin Name: Block Button Popup
Plugin URI: http://genero.fi
Description: A boilerplate WordPress Gutenberg block
Version: 1.0.0
Author: Genero
Author URI: http://genero.fi/
License: MIT License
License URI: http://opensource.org/licenses/MIT
*/
namespace GeneroWP\BlockButtonPopup;
use Illuminate\Support\Str;
use ReflectionClass;
if (!defined('ABSPATH')) {
exit;
}
if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
require_once $composer;
}
class Plugin
{
protected static $instance;
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new static();
}
return self::$instance;
}
public function __construct()
{
add_action('plugins_loaded', [$this, 'init']);
}
public function init()
{
foreach (glob(__DIR__ . '/src/blocks/*/*.php') as $file) {
$composer = __NAMESPACE__ . str_replace(
['/', '.php'],
['\\', ''],
Str::after($file, __DIR__ . '/src')
);
if (is_subclass_of($composer, Block::class) && ! (new ReflectionClass($composer))->isAbstract()) {
(new $composer())->compose();
}
}
}
}
Plugin::getInstance();