{"id":1551,"date":"2020-12-10T13:56:54","date_gmt":"2020-12-10T12:56:54","guid":{"rendered":"https:\/\/codesavory.com\/demo\/?post_type=knowledgebase&#038;p=1551"},"modified":"2021-06-30T16:19:07","modified_gmt":"2021-06-30T14:19:07","slug":"how-to-customize-the-notices","status":"publish","type":"knowledgebase","link":"https:\/\/basepresskb.com\/docs\/knowledge-base\/basepress-themes\/how-to-customize-the-notices\/","title":{"rendered":"How to customize the notices"},"content":{"rendered":"<section class='bpress-notice has-title has-icon is-style-info'><div class=\"bpress-notice-icon\"><span class=\"bp-check-circle\"><\/span><\/div><div class=\"bpress-notice-title\">Info<\/div><div class=\"bpress-notice-content\">Notices are a Premium feature.<\/p>\n<p><a href=\"https:\/\/basepresskb.com\/pricing\/\">Upgrade today<\/a> to take your documentation to the next level!<\/div><\/section>\n<p>BasePress comes with 5 preset Notices: Default, Info, Success, Warning and Danger.<br \/>\nAll notices except the Default one can be replaced or extra ones added via filters. The rendering of the notices can also be customized in case you need. We will show below the main possible customizations.<\/p>\n<h2>Add a custom notice<\/h2>\n<pre><code class=\"language-php\">\r\n\/\/Add a custom notice\r\nadd_filter( 'basepress_notices', function( $items ){\r\n\t$items['custom'] = 'Custom';\r\n\treturn $items;\r\n});\r\n<\/code><\/pre>\n<h2>Remove a preset notice<\/h2>\n<pre><code class=\"language-php\">\r\n\/\/Remove a preset notice\r\nadd_filter( 'basepress_notices', function( $items ){\r\n        \/\/If the danger notice exists remove it\r\n\tif( isset( $items['danger'] ) ){\r\n\t\tunset( $items['danger'] );\r\n\t}\r\n\treturn $items;\r\n});\r\n<\/code><\/pre>\n<h2>Replace the preset notices<\/h2>\n<p>You can replace all preset notices except for the default one. Use the code below to replace the notices with your own:<\/p>\n<pre><code class=\"language-php\">\r\n\/\/Replace the preset notices\r\nadd_filter( 'basepress_notices', function( $items ){\r\n\treturn array(\r\n\t\t'tips-tricks' =&gt; 'Tips &amp; Tricks',\r\n\t\t'no-forget'   =&gt; 'Do not forget',\r\n\t\t'extra'       =&gt; 'Extra notes'\r\n\t);\r\n});\r\n<\/code><\/pre>\n<p>We are creating an associative array with the slug for the notice as key and a label as the value for each item.<br \/>\nThe labels are used in list of notices in the Settings; you can set the actual titles displayed in the frontend in the Notices Settings.<br \/>\nIf you are using the shortcode to add notices to your articles, you can use the notice slug to set the style for each notice:<\/p>\n<pre>[basepress-notice style=\"tips-tricks\"]The notice message here[\/basepress-notice]<\/pre>\n<h2>How to disable the icon and title for a notice<\/h2>\n<p>Let&#8217;s say your notices are displayed with icons and titles. Yet you would like to have the default notice with just the content. You can use the code below to disable the title and the icon for all Default notices.<\/p>\n<pre><code class=\"language-php\">\r\nadd_filter( 'basepress_notice_data', function( $data){\r\n\tif( $data['style'] == 'default' ){\r\n\t\t$data['show_title'] = false;\r\n\t\t$data['show_icon'] = false;\r\n\t}\r\n\treturn $data;\r\n} );\r\n<\/code><\/pre>\n<h2>How to render the notices with custom code<\/h2>\n<p>BasePress notices have a very clean and simple look which should fit most projects. If you want to fully customize the rendering of your notices you can use the action hook below:<\/p>\n<pre><code class=\"language-php\">\r\nadd_action( 'basepress_notice_output', function( $data ){\r\n\t\/**\r\n\t * $data is an array with the following entries:\r\n\t * [\r\n\t *   'style'      =&gt; string,      \/\/the notice slug like default, info, success, warning, danger or your custom notice slug\r\n\t *   'content'    =&gt; string,      \/\/the content of the notice\r\n\t *   'title'      =&gt; string,      \/\/the title for the notice\r\n\t *   'icon'       =&gt; string,      \/\/the icon class name\r\n\t *   'show_title' =&gt; bool,        \/\/true\/false as set in the BasePress Notices Settings\r\n\t *   'show_icon'  =&gt; $show_icon   \/\/true\/false as set in the BasePress Notices Settings\r\n\t * ]\r\n\t *\/\r\n\t\r\n\t\/\/Your custom rendering goes here.\r\n        ...\r\n});\r\n<\/code><\/pre>\n<h2>How to change the colour of the Notices<\/h2>\n<p>The notices are styled via CSS. If you are customizing the default notices or you are adding new ones you can change the colour via CSS like this:<\/p>\n<pre><code class=\"language-css\">\r\n.bpress-notice.is-style-info{\r\n\tbackground-color: #7ebdce;\r\n\tcolor: white;\r\n}\r\n<\/code><\/pre>\n<p>You can target each notice with the class <strong>.bpress-notice.is-style-{notice-slug}<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BasePress comes with 5 preset Notices: Default, Info, Success, Warning and Danger. All notices except the Default one can be replaced or extra ones added via filters. The rendering of the notices can also be customized in case you need. We will show below the main possible customizations. Add a custom notice \/\/Add a custom [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"https:\/\/basepresskb.com\/docs\/knowledge-base\/basepress-themes\/how-to-customize-the-notices\/\">Read More&#8230;<span class=\"screen-reader-text\"> from How to customize the notices<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","knowledgebase_cat":[20],"knowledgebase_tag":[],"class_list":["post-1551","knowledgebase","type-knowledgebase","status-publish","hentry","knowledgebase_cat-basepress-themes"],"_links":{"self":[{"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase\/1551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase"}],"about":[{"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/types\/knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/comments?post=1551"}],"version-history":[{"count":13,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase\/1551\/revisions"}],"predecessor-version":[{"id":1643,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase\/1551\/revisions\/1643"}],"wp:attachment":[{"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/media?parent=1551"}],"wp:term":[{"taxonomy":"knowledgebase_cat","embeddable":true,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase_cat?post=1551"},{"taxonomy":"knowledgebase_tag","embeddable":true,"href":"https:\/\/basepresskb.com\/docs\/wp-json\/wp\/v2\/knowledgebase_tag?post=1551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}