Skip to content

Commit

Permalink
Explicitly load Composer's autoloader if it exists, fall back to load…
Browse files Browse the repository at this point in the history
…ing classes manually
  • Loading branch information
Philip John committed Apr 6, 2016
1 parent 1508491 commit 53e007d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions loader.php
@@ -1,29 +1,33 @@
<?php

if ( !class_exists( 'Composer\Autoload\ClassLoader' ) ) {
//loadd classes if library not managed by composer
if ( !class_exists( 'O2O' ) ) {
// Use Composer's autoloader if it exists
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once( __DIR__ . '/vendor/autoload.php' );
}
// Otherwise, load classes manually
else {
if ( ! class_exists( 'O2O' ) ) {
require_once ( __DIR__ . '/src/o2o.php' );
}

if ( !class_exists( 'O2O_Connection_Factory' ) ) {
if ( ! class_exists( 'O2O_Connection_Factory' ) ) {
require_once ( __DIR__ . '/src/factory.php' );
}

if ( !class_exists( 'O2O_Query' ) ) {
if ( ! class_exists( 'O2O_Query' ) ) {
require_once ( __DIR__ . '/src/query.php' );
}

if ( !class_exists( 'O2O_Rewrites' ) ) {
if ( ! class_exists( 'O2O_Rewrites' ) ) {
require_once ( __DIR__ . '/src/rewrites.php' );
}

if ( !class_exists( 'O2O_Connection_Taxonomy' ) ) {
if ( ! class_exists( 'O2O_Connection_Taxonomy' ) ) {
require_once ( __DIR__ . '/src/connection-types/taxonomy/taxonomy.php' );
}
}

$o2oInstance = O2O::GetInstance();
if ( !has_action( 'init', array( $o2oInstance, 'init' ) ) ) {
if ( ! has_action( 'init', array( $o2oInstance, 'init' ) ) ) {
add_action( 'init', array( O2O::GetInstance(), 'init' ), 20 );
}
}

0 comments on commit 53e007d

Please sign in to comment.