-
Notifications
You must be signed in to change notification settings - Fork 9
/
plugins.php
37 lines (33 loc) · 958 Bytes
/
plugins.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
<?php
/**
* Handles loading plugins.
*
* @package Eight_Day_Week
*/
namespace Eight_Day_Week\Plugins;
/**
* Allows filtering of Eight Day Week plugin loading
*
* Use the first filter (Eight_Day_Week\Core\load_plugins) to disable all
* Use the second (Eight_Day_Week\Core\load_{$plugin}) to disable a specific one
*
* @param string $plugin The plugin in question.
*
* @return mixed|void Whether or not to load the given plugin
*/
function should_load_plugin( $plugin ) {
return apply_filters( __NAMESPACE__ . '\load_plugins', apply_filters( __NAMESPACE__ . '\load_' . $plugin, true ), $plugin );
}
add_filter(
'edw_files_to_load',
function( $files ) {
foreach ( $files as $file_path => $namespace ) {
if ( false !== strpos( $file_path, EDW_INC . 'functions/plugins/' ) ) {
if ( ! should_load_plugin( str_replace( '.php', '', basename( $file_path ) ) ) ) {
unset( $files[ $file_path ] );
}
}
}
return $files;
}
);