Support » Plugins » Plugins using php libraries, where to put the libraries

  • Hi wordpressUsers,

    I create lots of plugins and have a common library they all use. I would like all my plugins to have access to this library, but where do I put it?

    I read some posts on the internet to put it in the themes directory,.. but that just opens a new can of worms; Permissions, how to get a non programmer to install it and so on….

    Right now I have added my library as a plugin and forcing it to be the first to load. This works, but it too has it’s problems. If another plugin fights for the first place then every load will be a battle for first plugin to load.

    How and where do I install my common library in wordpress?

    any suggestions?


Viewing 1 replies (of 1 total)
  • I don’t think there is a good solution for that problem. From what you write, I assume that you want WordPress to load the plugin, so that you do not need to require it. But what speaks against require?

    I use something along these lines in such cases, assuming that I use myplugin located at myplugin/myplugin.php in WordPress’ plugins directory:

    // Just to save me some typing.
    define( __NAMESPACE__ . '\\MYPLUGIN', '/myplugin/myplugin.php' );

    To me, this has the additional benefit that the plugin only needs to be installed, it doesn’t need to be activated.

    Am I missing something?

Viewing 1 replies (of 1 total)
  • The topic ‘Plugins using php libraries, where to put the libraries’ is closed to new replies.