A WordPress Customise Widget to add a global website banner, styled using a Bootstrap alert box.
The plugin assumes that you’re already using Bootstrap, so you need to load the Bootstrap javascript and CSS separately.
Once installed, you can add the alert to the correct location in your theme (for example, in header.php
with the global_bootstrap_banner()
function.
For example:
if (function_exists('global_bootstrap_banner')){
echo global_bootstrap_banner();
}
If you prefer, you can use a shortcode instead:
[global-bootstrap-banner]
The plugin works best when using the Customizer interface. However, if you wish you can use a shortcode and override most fields.
enabled
(default true
)
colour
(default alert-primary
)
header_text
body_text
link_text
link_url
link_class
(default btn-primary
)
link_new_window
(default false
)
link_btn_lg
(default false
)
btn-lg
class for the button (big button).link_btn_sm
(default false
)
btn-sm
class for the button (small button).link_btn_block
(default false
)
btn-block
class for the button (full width button).dismiss_btn
(default true
)
dismiss_expiry
(default 14
)
dismiss_id
alert_before
(default <div class="global-bootstrap-banner container">
)
alert_after
(default </div>
)
header_before
(default <h4 class="global-bootstrap-banner-heading alert-heading">
)
header_after
(default </h4>
)
link_before
(default <p class="global-bootstrap-banner-btn-p mb-0">
)
link_after
(default </p>
)
For example, a simple shortcode usage would be:
[global-bootstrap-banner body_text="This alert says something different"]
Note that the shortcode first takes the settings from the Customizer and then overwrites these.
So the above shortcode would show a header if it is set in the Customizer settings.
This plugin was written by @ewels.
If you would like to contribute to this plugin, please go to the GitHub repository and make a personal fork of the development version. You can then make your changes and submit a pull request. I will happily review the code and then merge when we’re both happy.