Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /**
  5. * We do not want to load any plugins.
  6. */
  7. function wpcom_vip_load_plugin( $plugin ) {
  8.  
  9. // Array of files to check for loading the plugin. This is to support
  10. // non-standard plugin structures, such as $folder/plugin.php
  11. $test_files = array(
  12. "{$plugin}.php",
  13. 'plugin.php',
  14. );
  15.  
  16. // Is $plugin a filepath? If so, that's the only file we should test
  17. if ( basename( $plugin ) !== $plugin ) {
  18. $test_files = [ basename( $plugin ) ];
  19. $plugin = dirname( $plugin );
  20. }
  21.  
  22. // Array of directories to check for the above files in, in priority order
  23. $test_directories = [ dirname( __DIR__, 3 ) . '/plugins' ];
  24.  
  25. foreach ( $test_directories as $directory ) {
  26. foreach ( $test_files as $file ) {
  27. $plugin = basename( $plugin ); // Just to be double, extra sure
  28. $file = basename( $file );
  29. $path = "{$directory}/{$plugin}/{$file}";
  30. if ( file_exists( $path ) ) {
  31. include_once( $path );
  32. break 2;
  33. }
  34. }
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement