Toolbox = $Toolbox; } /** * @return array */ public function getHooks() { return $this->_hooks; } /** * Add a hook as being available to the plugin * * @param int $type Type of hook being added i.e. hook or action * @param string $hook WordPress hook reference * @param string $method Callback method in the call for the hook * @param array $args Any special argumrents to pass in to the hook * * @author Nigel Wells * @version 0.1.1.16.10.07 * @return void; */ public function addHook( $type, $hook, $method, $args = Array() ) { $this->_hooks[] = new toolboxHookModel( $type, $hook, $method, $args ); } /** * @return string */ public function getLabel() { return $this->_label; } /** * @param string $label */ public function setLabel( $label ) { $this->_label = $label; } /** * Get the name of the controller that extended this controller minus the prefix and suffix * * @author Nigel Wells * @version 0.1.1.16.10.07 * @return string; */ public function getName() { $ReflectionClass = new ReflectionClass( $this ); $filename = $ReflectionClass->getFileName(); $filename = substr( $filename, strrpos( $filename, '/' ) + 1 ); $filename = substr( $filename, 5, strlen( $filename ) - 9 ); return $filename; } /** * Add a notice to be displayed on page load * * @param string $notice Text to be displayed * @param int $type What sort of notice to display - defaults to success * * @author Nigel Wells * @version 0.3.1.16.10.07 * @return void; */ public function addNotice( $notice, $type = 1) { $this->setupNotices(); $_SESSION[ $this->Toolbox->getPrefix() . 'notices' ][] = Array( 'text' => $notice, 'type' => $type ); } /** * Prepare the notices session array to make sure it can be added to or reset * * @param boolean $reset Reset the notice array to clear all active notices * * @author Nigel Wells * @version 0.3.1.16.10.11 * @return void; */ private function setupNotices( $reset = false ) { if ( ! isset( $_SESSION[ $this->Toolbox->getPrefix() . 'notices' ] ) || $reset === true ) { $_SESSION[ $this->Toolbox->getPrefix() . 'notices' ] = Array(); } } /** * Get a list of all the current notices * * @author Nigel Wells * @version 0.3.1.16.10.07 * @return array; */ private function getNotices() { $this->setupNotices(); return $_SESSION[ $this->Toolbox->getPrefix() . 'notices' ]; } /** * Display a notice in any output screens if required * * @author Nigel Wells * @version 0.3.1.16.10.07 * @return string; */ public function displayNotices() { $html = ''; foreach ( $this->getNotices() as $notice ) { // Check the type of notice to display if ( $notice['type'] == 2 ) { $type = 'warning'; } elseif ( $notice['type'] == 3 ) { $type = 'danger'; } else { $type = 'success'; } // Output the notice $html .= '
' . $notice['text'] . '