when faced something similar I found a solution that works if your framework resides inside a plugin (so it seems).
If your main plugin file (one that is recognized by WordPress as the plugin file) is in, e.g. /plugin/Aisis/
you can put this path in a constant, eg.
define('AISISPATH', dirname(__FILE__));
require ( trailingslashit (AISISPATH) . 'AisisCore/Loader/AutoLoader.php' );
if ( ! class_exists('AisisCore_Loader_AutoLoader') ) die('Something strange happened.');
AisisCore_Loader_AutoLoader::get_instance();
In your get_instance()
method of AisisCore_Loader_AutoLoader
class put:
self::$_directories = array(
get_template_directory(),
get_stylesheet_directory(),
trailingslashit( AISISPATH )
);
Doing like so, AisisCore_Loader_AutoLoader::$_directories[2]
will be {wp_path_here}/plugin/Aisis
so when you call $obj = new AisisCore_Http_Http();
your autoloader method will search in {wp_path_here}/plugin/Aisis/AisisCore/Http/Http.php
.
Everything works, of course, if the plugin is activated from WP dashboard.
If you follow this process, is a good idea start the get_instance()
method with:
if ( ! defined('AISISPATH ') ) die('Framework not initilized.');
Your logic probably doesn’t work because plugin_dir_path($file)
, is just a wrapper for trailingslashit( dirname( $file ) )
(see the Codex) so if you use this function passing __FILE__
as param it will return the folder in which the file that call the function is (in your case ‘AisisCore/Loader/’) and not your framework root.
Hope this helps you.