-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjust-another-block-plugin.php
73 lines (58 loc) · 2.19 KB
/
just-another-block-plugin.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
70
71
72
73
<?php
/**
* This file is read by WordPress to generate the plugin information in the plugin admin area. This file also includes
* all the dependencies used by the plugin and starts the plugin.
*
* @since 1.0.0
* @package Just_Another_Block_Plugin
*
* @wordpress-plugin
* Plugin Name: Just Another Block Plugin
* Description: Enhances the block editor by adding usefully accessible blocks to the block editor.
* Version: 1.0.0
* Author: Paul van Impelen <[email protected]>
* Author URI: https://themeforest.net/search/paulvanimpelen
* Text Domain: jabp
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
defined( 'YABP_VERSION' ) or define( 'YABP_VERSION', '1.0.0' );
defined( 'YABP_BASENAME' ) or define( 'YABP_BASENAME', plugin_basename( __FILE__ ) );
defined( 'YABP_DIR' ) or define( 'YABP_DIR', plugin_dir_path( __FILE__ ) );
defined( 'YABP_URI' ) or define( 'YABP_URI', plugin_dir_url( __FILE__ ) );
defined( 'YABP_WP_REQUIRED_VERSION' ) or define( 'YABP_WP_REQUIRED_VERSION', '6.2' );
defined( 'YABP_WP_VALID_VERSION' ) or define( 'YABP_WP_VALID_VERSION', version_compare( get_bloginfo( 'version' ), YABP_WP_REQUIRED_VERSION, '>=' ) );
/**
* Load all files from a given path.
*
* @param {string} $path The path from the root of the plugin to include.
*
* @return void
*/
function load( $path ) {
$files = glob( YABP_DIR . $path . DIRECTORY_SEPARATOR . '*.php' );
foreach ( $files as $file ) {
require_once $file;
}
$directories = glob( YABP_DIR . $path, GLOB_ONLYDIR );
if ( ! empty( $directories ) ) {
foreach ( $directories as $directory ) {
$scanned_directories = array_diff( scandir( $directory ), array( '..', '.' ) );
if ( empty( $scanned_directories ) ) {
continue;
}
foreach ( $scanned_directories as $scanned_directory ) {
if ( is_file( YABP_DIR . $path . DIRECTORY_SEPARATOR . $scanned_directory ) ) {
// File in directory;
require_once YABP_DIR . $path . DIRECTORY_SEPARATOR . $scanned_directory;
continue;
}
load( $path . DIRECTORY_SEPARATOR . $scanned_directory );
}
}
}
}
load( 'includes' );