forked from Automattic/vip-go-mu-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
z-client-mu-plugins.php
50 lines (36 loc) · 993 Bytes
/
z-client-mu-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
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// Note: This file is prefixed with `z-` for load order
define( 'WPCOM_VIP_CLIENT_MU_PLUGIN_DIR', WP_CONTENT_DIR . '/client-mu-plugins' );
function wpcom_vip_load_client_mu_plugins() {
static $loaded = false;
// Prevent running this multiple times
if ( $loaded ) {
return;
}
$loaded = true;
// Code below is adapted from wp_get_mu_plugins()
$client_mu_plugins = [];
if ( ! is_dir( WPCOM_VIP_CLIENT_MU_PLUGIN_DIR ) ) {
return;
}
$dh = opendir( WPCOM_VIP_CLIENT_MU_PLUGIN_DIR );
if ( ! $dh ) {
return;
}
do {
$plugin = readdir( $dh );
if ( false === $plugin ) {
break;
}
if ( substr( $plugin, -4 ) === '.php' ) {
$client_mu_plugins[] = WPCOM_VIP_CLIENT_MU_PLUGIN_DIR . '/' . $plugin;
}
} while ( false !== $plugin );
closedir( $dh );
// Make sure plugins load in a consistent, predictable order
sort( $client_mu_plugins );
foreach ( $client_mu_plugins as $plugin ) {
include_once( $plugin );
}
}
wpcom_vip_load_client_mu_plugins();