Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement