How to add css classes to widgets using functions.php?

Alright, so I managed to pull it off thanks to @toscho who provided me with this link: Add class to before_widget for all widgets with a dropdown and a counter I kind of worked up through it. All I wanted to do was add one class “col-sm-4” from Bootstrap to the search widget. is_admin() || … Read more

Change CSS when user is logged in

Here is another CSS-only approach, without any inline-PHP and needless CSS-spam in the head. If your theme is correctly using body_class() and a user is logged in, WordPress adds a class “logged-in” to the body-element, so we can use this in our stylesheet: <–logged out–> .sellertitle { float: none; width: 49%; } .otherseller { display: … Read more

Responsive background images added inline

If you use Adaptive Images plugin for WordPress, you would just make one inline css for all viewport widths using the biggest image and then it does all the work on the server. You do nothing to your markup but in the Adaptive Images plugin settings you enter your breakpoints, so it will serve small … Read more

Adding dashicon fonts to the admin of pre 3.8 installs

This happens sometimes when the font is sent with a wrong MIME type. application/x-font-woff for example, is wrong. Try to add proper MIME types to your server configuration. In Apache, your can do that in a .htaccess: AddType image/svg+xml .svg AddType application/x-font-ttf .ttf AddType application/x-font-opentype .otf AddType application/vnd.ms-fontobject .eot AddType application/font-woff .woff You should add … Read more

How can I enqueue a style only when a particular widget is active?

You need to modify this a little bit. class Organiser extends WP_Widget { … function __construct() { add_action( ‘wp_enqueue_scripts’, array(‘Organiser’, ‘register_plugin_styles’) ); … } public function widget( $args, $instance ) { wp_enqueue_style( ‘organiserStyle’ ); include(dirname(__FILE__).”/organiserWidget.php”); } static function register_plugin_styles() { wp_register_style( ‘organiserStyle’, plugins_url( ‘organiser/css/organiserStyle.css’ ) ); // wp_register_style( ‘organiserStyle’, plugin_dir_url( __FILE__ ) . ‘css/organiserStyle.css’ ); … Read more