php - Wordpress - plug-in functions is available in templates but not available to other plug-ins -


case:

plugin specifies function can called in wp template.

but, calling same function within code of plugin b yields error:

fatal error: call undefined function...

i'm assuming problem has includes and/or scope, far have not been able find answer. requiring or including plugin php file contains desired function yields "redeclaration" errors in (the plugin php file).

if plugin b relies on functions plugin a, start plugin b code in init function called when active plugins have been loaded using plugins_loaded action in wordpress.

you can find list of actions here.

this example assumes you're writing plugins using classes:

in plugin b:

function __construct() {     add_action( 'plugins_loaded', array( $this, 'init' ) ); }  function init() {     // functions plugin available point on } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -