WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Logging Service
Overcoming plugin load order? (2 posts)

  1. khromov
    Member
    Posted 8 months ago #

    I'm trying to implement WLS support in another plugin, but there is an issue - WLS is loaded after my plugin.

    So, for example to add a category I have to do this:

    add_action( 'plugins_loaded', array( &$this, 'register_logging' ));
    ...
    function register_logging()
    {
    	if($this->wls_logging_is_available())
    		wls_register( 'Posts Importer', 'Posts importer logs');
    }

    So now my category works but I can't log anything because wls_log() is not defined when I call it in my plugin.

    So how would I call wls_log() and ensure that it is actually loaded?

    http://wordpress.org/plugins/wordpress-logging-service/

  2. khromov
    Member
    Posted 8 months ago #

    So one solution I have found is to delay loading of your plugin until after the 'plugins_loaded' hook. But I really don't like this solution - it seems very hacky. Hoping for an alternative.

    Here's the code.

    /* Makes sure the plugin loads dead last so it can use WLS logging. */
    $your_plugin = new Your_Plugin();
    add_action('plugins_loaded','your_plugin_load_plugin_last');
    function your_plugin_load_plugin_last()
    {
    	//Init your plugin here
    	global $your_plugin;
    	$your_plugin->init();
    }

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.