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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -