Disable wp_enqueue_style for theme on wp-admin

There is a conditional tag is_admin() which checks are you in the Administration Panel or Frontend. So, if( !is_admin() ) { wp_enqueue_style( ‘css-minified’, get_stylesheet_directory_uri() . DIRECTORY_SEPARATOR . ‘style.css’, [], null, ‘all’ ); wp_enqueue_style( ‘font-awesome’, ‘https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css’, [], null, ‘all’ ); } See is_admin().

How the Css File is Linked without calling it in header.php?

The correct way to register styles in WordPress is to enque them through wp_enqueue_style function in your theme’s functions.php. You can read and learn how to do it here – wp_enqueue_style /** * Proper way to enqueue scripts and styles */ function wpdocs_theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, … Read more

Is it possible to enqueue CSS files from plugin before theme’s CSS files?

It’s easy to add your plugin stylesheet after theme stylesheet. If you’re sure that your theme styles and plugin styles have the same selector weight (theme has this style .site-header { background-color: #ccc; } and your plugin has this .site-header { background-color: #f1f1f1; }) then enqueuing plugin stylesheet after theme stylesheet will work. If you’re … Read more

How to remove scripts/style added to customize_controls_enqueue_scripts hook by current active theme

You can use the global $wp_scripts and global $wp_styles; to get all registerd scripts and styles. Eg. All Scripts // All Scripts global $wp_scripts; $all_scripts = array(); foreach( $wp_scripts->registered as $script ) : $all_scripts[$script->handle] = $script->src; endforeach; // echo ‘<pre>’; // print_r( $all_scripts ); // echo ‘</pre>’; All Styles // All Styles global $wp_styles; $all_styles … Read more

enqueue admin styling and scripts only on plugin page

You can use $screen = get_current_screen(); functions to get the current screen and add warp your enqueue method with the if conditions to check the screen. https://codex.wordpress.org/Function_Reference/get_current_screen public function enqueue_scripts() { $screen = get_current_screen(); // Check screen base and page if ( ‘options-general’ === $screen->base && $_GET[‘page’] ===’uwc’ ) { wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) … Read more

Child theme style.css versioning

Are you sure the version is included in style.css in the right way? In that case this should really work (hook with wp_enqueue_scripts): $theme_data = wp_get_theme(); wp_register_style(‘your-style-handle’, get_template_directory_uri() . ‘/style.css’, ”, $theme_data[‘version’], ‘all’); wp_enqueue_style(‘your-style-handle’); While developing you may not want to change the file version in style.css all the time, in which case you could … Read more