How do I create a new WP admin color scheme?

This code works with WordPress 5.2 and is correct. You now need to go to your Profile and select it by going to Users > Your Profile > Admin Color Scheme select the scheme and save. Edit: Adding updated code for your colors CSS file since you’re using a child theme: function additional_admin_color_schemes() { wp_admin_css_color( … Read more

Automatically decrease font size for long words

I’ve done something similar taking the simple approach of adding a CSS class to titles based on their character count. That CSS class then decreases letter-spacing and/or font-size. // Count the characters, taking Unicode into account $chars = mb_strlen($post->post_title); // For every 10 characters after the first 20, add a size $size = max(0, ceil(($chars … Read more

How to target with css, admin elements according to user role level?

The admin_body_class filter lets you add classes to the body tag. This function will add all roles as classes in the form role-$role, for example role-administrator, to the body tag: function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user->roles as $role ) $classes .= ‘ role-‘ . $role; return trim( $classes ); } add_filter( ‘admin_body_class’, … Read more

How to set two different themes on one WordPress? (Desktop vs. Mobile)

To employ two entirely separate themes is a suboptimal architectural approach. Themes are activated site-wide/globally and not on a per-user basis. You don’t want to change the current theme constantly. While I personally really dislike this option, WordPress ships with a function that sniffs the UA-String, wp_is_mobile. This function can be employed to either output … Read more

How can I reduce the amount of files loaded/included per plugin?

Previous versions of WordPress didn’t really provide a good means to conditionally enqueue stylesheets and JavaScript within a plugin (i.e. only when needed). So most plugin authors enqueued both on every WordPress init/load, even if the plugin wasn’t being used on a given page. Current versions of WordPress allow for enqueuing later in the flow … Read more

Automatically Refresh WordPress Stylesheet

“Quick” fix: Right Click -> view page source ( ctrl+U ), find .css file you changed, open it in new tab and reload ( you should see change in place you’ve made it ) ONLY in development mode add php function time() in place of version number wp_enqueue_style( $handle, $src, array(), time() , ‘all’ ); … Read more

How do I register/enqueue a custom CSS file?

Refer to the Codex entry for wp_enqueue_style(). Assuming you have a custom stylesheet, named custom.css, located in your Theme’s root directory: wp_enqueue_style( ‘mytheme-custom’, get_template_directory_uri() . ‘/custom.css’ ); You would put this in functions.php, inside a callback, hooked into an appropriate callback, like so: function wpse87681_enqueue_custom_stylesheets() { if ( ! is_admin() ) { wp_enqueue_style( ‘mytheme-custom’, get_template_directory_uri() … Read more

Editing the custom background CSS

Yes, that is possible. Take a look at the codex and you will see that you can pass arguments with add_theme_support( ‘custom-background’). One of them is the callback function that generates the <style> tags: _custom_background_cb. You can pass your own function as an argument to add_theme_support. Here is the code of the original function (retrieved … Read more