I use the following code in my functions.php
to disable the dashicons.min.css
file from the frontend. It works fine, but how can I use that action only for visitors, who are not currently signed in to WordPress?
The reason is that the WordPress admin bar at the top is broken, if the dashicons css file is not available.
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
wp_deregister_style( 'dashicons' );
}
You want to use the function
is_user_logged_in()
which comes with WordPress. Read about it at https://developer.wordpress.org/reference/functions/is_user_logged_in/.So your code would be: