chrisguitarguy / WP-Plugin-Directories

Allows you to add additional plugin directories to WordPress.
MIT License
23 stars 8 forks source link

register_plugin_directory doesn't exist #11

Open sebastiaandegeus opened 11 years ago

sebastiaandegeus commented 11 years ago

The order of which the plugin are loaded seem to be off.

I made a second plugin named: plugin_autoloader and I added the following code:

/**
 * Registers a new plugin directory
 * 
 * @example
 * $args Array (Valid args for `root`) 'content', 'plugins', 'muplugins', 'root'
 * The new directories must be subdirectories of the following WP file system constants:
 * 'content':   (default) WP_CONTENT_DIR
 * 'plugins':   WP_PLUGIN_DIR
 * 'muplugins': WPMU_PLUGIN_DIR
 * 'root':      one level below WP_CONTENT_DIR
 * 
 * @return void
 */
function autoloader_register_additional_plugin_directories()
{
  var_dump('1');
  // Better abort - if we don't do this, we'll create an error on deactivation of the main plugin.
  if ( ! function_exists( 'register_plugin_directory' ) ) {
    var_dump('register_plugin_directory doesnt exist');
    return;
  }
    //return;

  var_dump('2');
  // Call the public API function once for every directory you want to add.
  register_plugin_directory( array( 
     'dir'   => 'custom'
    ,'label' => 'Example Label for the list table'
    ,'root'  => 'plugins'
  ) );
}
// Needs to be added on the `plugins_loaded` hook with a priority of `0`.
add_action( 'plugins_loaded', 'autoloader_register_additional_plugin_directories', 0 );

This always get's halted in the ! function_exists part. Which to me seems that the plugin wasn't loaded before my plugin.

I renamed my plugin to zplugin_autoloader to make sure it's later but still no joy.

Is this hook still valid and working? add_action( 'plugins_loaded', 'autoloader_register_additional_plugin_directories', 0 );

Thanks

sebastiaandegeus commented 11 years ago

For your information my WP_PLUGINS_DIR is set to workspace/project/packages/plugins