Make the css of the widget overwrite theme css

Is possible to make bootstrap css “contextualized” inside a selector, i.e. bootstrap styles works inside that selector, and thanks to css specificity rules, there them take precence over other rules. How to do: First of all download bootstrap less. Let’s assume that this files are in ‘bootstrap/less’ folder. Now create a new less file, let’s … Read more

Styles and Scripts, Selectively enqueue across entire site

Right I figured this out myself not sure how “hacky” this is but basically this is the code: public function filter_scripts_styles(){ if(is_page($this->plugin_name)){ //Same name is used for the style as the js file so can reuse this array $allowed = array(‘jquery’, $this->plugin_name.’_scrollpath’, $this->plugin_name); //Check Scripts First global $wp_scripts; foreach($wp_scripts->queue as $handle ) { if(!in_array($handle, $allowed)){ … Read more

Simple/basic use of get_current_screen

I haven’t tested this but theoretically you could do something like this (Using the Codex as an Example): function load_custom_wp_admin_style() { $pageArr = array(1, 2, 3); if(isset($_GET[‘post’]) && in_array($_GET[‘post’], $pageArr)){ wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } } add_action( ‘admin_enqueue_scripts’, ‘load_custom_wp_admin_style’ ); We get the current screen and set the … Read more

Getting rid of unused css directives [closed]

The guys behind this project I trust a lot. https://unused-css.com/ Also I used this long time ago: https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/ However, you need to be careful, because you must not remove some CSS that will be used in the future, or in case some feature is enabled later.

WordPress Register Style Called Incorrectly

The notice is quite obvious. It is telling you that you are not running wp_register_style() within the wp_enqueue_scripts hook. SOLUTION Move your wp_register_script() and wp_register_style() calls to inside your function which is hooked to wp_enqueue_scripts

How do you modify CSS files via admin panel?

If you’re wanting styles to be dynamic, then you’ll have to emit your CSS file as you are suggesting. However, as WordPress often uses styles.css as a theme definition file, renaming styles.php might cause problems. It might be better to collect all the ‘dynamic’ definitions into a separate file (eg dynamic-styles.php) and import them from … Read more