# Toolset Common A collection of php, javascript and CSS libraries, utilities and models to be used with Toolsets plugins. ## Install: Fetch the toolset-common library using composer: composer install --no-autoloader ## How To Use Toolset Admin Notices #### Simple Admin Notice We call Simple Admin Notice the temporary success / warning / error messages in WordPress. Like "Post saved.", "Field XY is required" and so on... all these messages are temporary. ##### Success Notice Toolset_Admin_Notices_Manager::add_notice( 'types-post-saved', 'Your post was successfully saved!' ); The first parameter is the id of the notice, and the second the content of the notice. It is a short version of: $n = new Toolset_Admin_Notice_Success( 'types-post-saved' ); $n->set_content( 'Your post was successfully saved!' ); Toolset_Admin_Notices_Manager::add_notice( $n ); You see we first initialise the success notice with the id `types-post-saved`. Than adding our content to the notice and finally apply it to our `Toolset_Admin_Notices_Manager`. Every notice has an id, this is used for making sure not displaying twice the same and for dismissable notices. ##### Warning / Error notice You can use the previous code also for adding Error and Warning messages. $n = new Toolset_Admin_Notice_Error( 'error-on-save' ); ... $n = new Toolset_Admin_Notice_Warning( 'warning-message' ); ... #### Toolset Admin Notice If you want to show a more advanced or permanent message, like running our installer, doing a database update or something like that, you should create a toolset styled admin notice. Here an example of use: ``` $notice = new Toolset_Admin_Notice_Required_Action( 'toolset-run-installer' ); Toolset_Admin_Notices_Manager::add_notice( $notice ); $notice->set_content( __DIR__ .'/templates/admin/notice/content/run-installer.phtml' ); // ON THE LAST STEP OF THE INSTALLER: if( $installation_done ) { Toolset_Admin_Notices_Manager::dismiss_notice_by_id( 'toolset-run-installer', true ); } ``` This message uses a template for the content: ```