• 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?

    https://www.ads-software.com/plugins/wordpress-logging-service/

Viewing 1 replies (of 1 total)
  • Thread Starter Stanislav Khromov

    (@khromov)

    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();
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Overcoming plugin load order?’ is closed to new replies.