I'm using a theme that chooses to add/remove different depending on what browser etc that is recognized by the http header. I'm having an issue with this because it doesn't work all the time. The design shows things not as expected on the page. Only sometimes, so it was kind of hard to figure out what was going on.

In functions.php of the main theme (Bridge) a webkit stylesheet is added:

if($is_chrome || $is_safari) {
    wp_enqueue_style("webkit", QODE_ROOT . "/css/webkit_stylesheet.css");

BUT the problem is that webkit css is applied in Firefox sometimes (and sometimes not). When it is NOT applied, design of homepage works as expected in Firefox.

I don't want to change the main themes code:

if($is_chrome || $is_safari) {
    //wp_enqueue_style("webkit", QODE_ROOT . "/css/webkit_stylesheet.css");

, so I figured I could do something like this in the child theme:



I've also tried to add function from main themes functions.php that applies the css and apply the css used in the childs theme, but with no luck.

I've also checked if the style is applied in the child's themes functions.php:

if (wp_style_is("webkit") === true) {
    echo 'WEBKIT is defined';    
else {
    echo 'WEBKIT is NOT defined';

and I always get get WEBKIT is NOT defined.

Is there a way to deque the style with higher priority? Like som equivalent to !important in css. I hope you understand what I mean :)

1 Answer 1


Your problem lies in detecting browsers. There is no way for server side languages like PHP to know which browser is used to render a page/website. This is all client side processes.

Someone "clever" invented ways to detect browsers and devices in PHP and claimed it worked. Yes, it does work, BUT not always. As I said, server side languages cannot detect browsers or devices, and conditionals like the ones you are using (and the circus clown wp_is_mobile()) relies on client side prosesses which is never reliable as it can be altered nd modified on client side.

You are unfortunately stuffed here. You have something that will work in some cases and will fail in other cases, and there is nothing you can do about that. You will need to live with that until the end of days as I cannot see any reliable way for server side languages to ever detect browsers or devices


To remove the stylesheet completely, you will need to deregister and dequeue it

add_action( 'wp_enqueue_scripts', wpse_219467_remove_webkit, PHP_INT_MAX );
function wpse_219467_remove_webkit()
    wp_dequeue_style( 'webkit' );
    wp_deregister_style( 'webkit' );
  • 1
    I agee with you 100%, but I don't really see this as an answer on my question: Is there a way to deque the style with higher priority? :-) I'm trying to figure out a way to remove the applied style in a sensible way (webkit_style.css), it's better that it is not used at all, because it just messes things up. Mar 2, 2016 at 8:25
  • See my edit. Hope this is what you are looking for ;-) Mar 2, 2016 at 8:30
  • YES! Thanks a lot! This was exactly what I was looking for! Mar 2, 2016 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.