Is it possible to use Classes between WordPress plugins with separate namespaces?

Its likely due to the WordPress load process. Plugins are not all loaded at once. It’s possible that when you in the constructor phase on one plugin the other plugin is not yet loaded.

This means you need to “hook” into the “init” of WordPress and check your function or class exists before running your class constructor.

Ways to deal with this:

  1. Use an init hook and registration to make sure the class exists before your dependant function is loaded.

  2. Update your Autoloader inside the dependant plugin to use the PSR-4 or what ever autoloader you are using to get the class so you know it will exist.

  3. Directly require the file inside your plugin init that has the child class.

  4. Convert you classes to a composer package so you can load it and namespace it in each plugin.

All are a bit messy but plugins are meant to be isolated. Look up pluggable functions and it should give you an idea of some next steps.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino