Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

register_plugin_directory doesn't exist #11

Open
sebastiaandegeus opened this Issue · 1 comment

1 participant

@sebastiaandegeus

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.