-
Notifications
You must be signed in to change notification settings - Fork 2
/
pattern-editor.php
69 lines (62 loc) · 1.4 KB
/
pattern-editor.php
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
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Plugin Name: Pattern Editor
* Plugin URI: https://blockifywp.com/pattern-editor
* Author: Blockify
* Author URI: https://blockifywp.com/
* Version: 0.2.0
* License: GPLv2-or-later
* Requires WP: 6.3
* Requires PHP: 7.4
* Tested up to: 6.5
* Text Domain: pattern-editor
* Description: Import, export and edit block patterns in the Site Editor and save directly to your theme.
*/
namespace Blockify\PatternEditor;
use function add_action;
use function dirname;
use function glob;
use function load_plugin_textdomain;
use function plugin_basename;
use function version_compare;
use const PHP_VERSION;
const NS = __NAMESPACE__ . '\\';
const DS = DIRECTORY_SEPARATOR;
const DIR = __DIR__ . DS;
const FILE = __FILE__;
if ( ! version_compare( '7.4.0', PHP_VERSION, '<=' ) ) {
return;
}
add_action( 'plugins_loaded', NS . 'load_textdomain' );
/**
* Load textdomain.
*
* @since 0.0.1
*
* @return void
*/
function load_textdomain(): void {
load_plugin_textdomain(
'pattern-editor',
false,
dirname( plugin_basename( FILE ) ) . '/languages'
);
}
add_action( 'after_setup_theme', NS . 'setup', 9 );
/**
* Setup Pattern Editor.
*
* @return void
*/
function setup(): void {
$files = [
DIR . 'vendor/autoload.php',
...glob( DIR . 'includes/*.php' ),
...glob( DIR . 'includes/blocks/*.php' ),
];
foreach ( $files as $file ) {
if ( is_readable( $file ) ) {
require_once $file;
}
}
}