Skip to content

Commit

Permalink
Fixes autoload error when wp-gears-runner is a copied file.
Browse files Browse the repository at this point in the history
* Fixes #10
* Adds optional WP_GEARS_DIR constant for use with non standard plugin directory
  layout
  • Loading branch information
dsawardekar committed Apr 5, 2016
1 parent 49ae375 commit 80ae2d2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion wp-gears-runner.php
Expand Up @@ -8,7 +8,13 @@
* be used in it's place.
*/

require_once __DIR__ . '/autoload.php';
$wp_gears_autoloader_path = wp_gears_autoloader_file();

if ( $wp_gears_autoloader_path ) {
require_once( $wp_gears_autoloader_path );
} else {
return;
}

function wp_gears_runner() {
wp_gears_autoloader();
Expand All @@ -19,6 +25,19 @@ function wp_gears_runner() {
return $plugin->run();
}

function wp_gears_autoloader_file() {
if ( file_exists( __DIR__ . '/autoload.php' ) ) {
return __DIR__ . '/autoload.php';
} else if ( file_exists( __DIR__ . '/wp-content/plugins/wp-gears/autoload.php' ) ) {
return __DIR__ . '/wp-content/plugins/wp-gears/autoload.php';
} else if ( defined( 'WP_GEARS_DIR' ) ) {
return WP_GEARS_DIR . '/autoload.php';
} else {
error_log( 'WP Gears Fatal Error - Cannot find autoload.php' );
return false;
}
}

if ( ! defined( 'PHPUNIT_RUNNER' ) ) {
ignore_user_abort( true );

Expand Down

0 comments on commit 80ae2d2

Please sign in to comment.