public static function init($className, $isActive = true, $isDefault = false) { //If the $isActive parameter is false, do not do anything. This will be useful if we store the plugins in the database //The $isDefault parameter will change the default shipping plugin if (!$isActive) { return; } if (!isset(ECommShipping::$activeShippingPlugin[$className])) { require "{$className}.php"; ECommShipping::$activeShippingPlugin[$className] = new $className(); } //If this is the first plugin, make it the default one if (count(ECommShipping::$activeShippingPlugin) == 1) { $isDefault = true; } if ($isDefault) { //If a plugin is the default shipping class: //First, set the defaultPlugin variable to the name of this class //Second, change the order of the array becuase the default plugin MUST always be the first shipping plugin ECommShipping::$defaultPlugin = $className; $tempArray = ECommShipping::$activeShippingPlugin; ECommShipping::$activeShippingPlugin = array(); ECommShipping::$activeShippingPlugin[$className] = $tempArray[$className]; //Put the default plugin at the beginning foreach ($tempArray as $key => $val) { ECommShipping::$activeShippingPlugin[$key] = $val; } } }