Created
March 29, 2017 19:18
-
-
Save mattheu/8eeaf3e22ea772cfda52b7001b2de539 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* We do not want to load any plugins. | |
*/ | |
function wpcom_vip_load_plugin( $plugin ) { | |
// Array of files to check for loading the plugin. This is to support | |
// non-standard plugin structures, such as $folder/plugin.php | |
$test_files = array( | |
"{$plugin}.php", | |
'plugin.php', | |
); | |
// Is $plugin a filepath? If so, that's the only file we should test | |
if ( basename( $plugin ) !== $plugin ) { | |
$test_files = [ basename( $plugin ) ]; | |
$plugin = dirname( $plugin ); | |
} | |
// Array of directories to check for the above files in, in priority order | |
$test_directories = [ dirname( __DIR__, 3 ) . '/plugins' ]; | |
foreach ( $test_directories as $directory ) { | |
foreach ( $test_files as $file ) { | |
$plugin = basename( $plugin ); // Just to be double, extra sure | |
$file = basename( $file ); | |
$path = "{$directory}/{$plugin}/{$file}"; | |
if ( file_exists( $path ) ) { | |
include_once( $path ); | |
break 2; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment