{"id":5177,"date":"2017-09-11T10:59:19","date_gmt":"2017-09-11T14:59:19","guid":{"rendered":"https:\/\/themespress.ca\/?p=5177"},"modified":"2022-10-01T15:04:54","modified_gmt":"2022-10-01T19:04:54","slug":"using-wp-enqueue-style","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/using-wp-enqueue-style\/","title":{"rendered":"Using the wp_enqueue_style Bootstrap Function"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With this tutorial we will use the Bootstrap Stylesheet in one or multiple pages of our plugin; such as Settings, sub menus, etc&#8230;<\/p>\n<p>This will help avoid CSS conflicts or force other CSS styling from other WordPress plugins. Here&#8217;s a quick trick to use <strong>wp_enqueue_style<\/strong> in the <strong>admin_enqueue_scripts<\/strong> hook.<\/p>\n<p>This condition only works with a page ID. So if for example you have sub-pages in your plugin, we will develop it under it:<\/p>\n<p>[gridzy id=&#8221;5&#8243;]<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-9293438\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-9293438\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"standard\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function themeplifyenqueuebootstrap()\n{\n    \/\/replace themeplify with your slug page ID\n    if(($_GET[&#039;page&#039;] == &#039;themeplify&#039;) || ($_GET[&#039;page&#039;] == &#039;autreslugid&#039;) || ($_GET[&#039;page&#039;] == &#039;encoreunautreslugid&#039;) ) {\n        wp_enqueue_style(&#039;bootstrap.min&#039;, &#039;https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.7\/css\/bootstrap.min.css&#039;);\n    }\n}\n\nadd_action(&#039;admin_enqueue_scripts&#039;, &#039;themeplifyenqueuebootstrap&#039;);<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With multiple GET pages &#8230;<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-8367069\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-8367069\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"standard\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function themeplifyenqueuebootstrap()\n{\n    \/\/replace themeplify with your slug page ID\n    if(($_GET[&#039;page&#039;] == &#039;themeplify&#039;) || ($_GET[&#039;page&#039;] == &#039;autreslugid&#039;) || ($_GET[&#039;page&#039;] == &#039;encoreunautreslugid&#039;) ) {\n        wp_enqueue_style(&#039;bootstrap.min&#039;, &#039;https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.7\/css\/bootstrap.min.css&#039;);\n    }\n}\n\nadd_action(&#039;admin_enqueue_scripts&#039;, &#039;themeplifyenqueuebootstrap&#039;);<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>You can also add another function or class for the Javascripts Bootstrap by using the same conditions. You allow your plugin to have an independant Javascript and\/or CSS stylesheet.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial we will use the Bootstrap Stylesheet in one or multiple pages of our plugin; such as Settings, sub menus, etc... This will help avoid CSS conflicts or<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/using-wp-enqueue-style\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":5181,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[323,313],"class_list":["post-5177","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-javascript-coding","tag-plugins"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=5177"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5177\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/5181"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=5177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=5177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=5177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}