Enable bootstrap for wordpress backend plugins

In one of my recent plugins it was necessary to enable bootstrap for easy styling my plugin option pages. If you simply add bootstrap to the backend css, the whole backend gets the style, thats not really cool. With the use of less and a little wrapper class only for your plugin you can get rid of this circumstance.

First download the recent bootstrap distribution from getbootstrap.com

Move into the bootstrap directory and create a little less file:
.wrapper-class {
@import (less) url( ‚css/bootstrap.css‘ );

Compile that file and you get a complete bootstrap css wrapped with your wrapper-class.
See http://lesscss.org/ for instructions.

Just add that file to the backend style of wordpress an there you go.

add_action(‚admin_enqueue_scripts‘, ‚backend_scripts‘);

function backend_scripts() {
wp_enqueue_style(‚backend_style‘, plugins_url(‚myplugin/css/bootstrap-wrapper-class.css‘));

Every bootstrap component is available within wrapper-class.

© Copyright wundertal.net | Impressum | Datenschutzerklärung