Skip to content
Kit edited this page Jan 8, 2016 · 1 revision

###Description

This action hook allows your plugin access to WP-Librarian's core plugin class WP_Librarian.

###Context

This hook is called from the hook plugins_loaded which is called very early on, before init. This hook is called on every request.

###Parameters

$wp_librarian
(WP_Librarian) The single instance of WP-Librarian's core plugin class

###Example

If you want your plugin's main class to have WP-Librarian's main class as a property. You could use the following code:


class My_Plugin_Class {
	/**
	 * Single instance of WP-Librarian's core class
	 * @var WP_Librarian
	 */
	public $wp_librarian;
	
	public function __construct() {
		add_action('wp_lib_loaded', array($this, 'getLibraryClass'));
	}
	
	/**
	 * Sets single instance of WP-Librarian as class property
	 * @var WP_Librarian $wp_librarian Single instance of WP_Librarian
	 */
	public function getLibraryClass(WP_Librarian $wp_librarian) {
		$this->wp_librarian = $wp_librarian;
	}
}

You'd now have access to WP-Librarian's core plugin class for your other hooks. Note that, because this hook is only run at WP's plugins_loaded, you won't have access to the class when the constructor is run. Most hooks should be fine though.

Clone this wiki locally