Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed. We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

Remove WPDiscuz styling from WordPress head

6 Posts
5 Users
0 Reactions
3,088 Views
(@lostnotstranded)
New Member
Joined: 7 years ago
Posts: 1
Topic starter  

Hi,

I'm curious if anyone has found a way to use the functions.php file in a child theme to remove the WPDiscuz CSs styling from the head. Those settings never change and I want to load them from within my custom external stylesheet that is loaded only on single post pages instead of within the HTML. I've found a function called InitCustomCSS while looking through the plugin files in my cPanel, but I cannot figure out how to remove that action from the wp_head, which I assume the function is hooking into to add styling to the head. If anyone has figured out a way to remove WPDiscuz's styling from the head section that'd be terrific. 

This topic was modified 7 years ago by lostnotstranded

   
Quote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 8 years ago
Posts: 6444
 

Hi  lostnotstranded,

I'm really sorry, but there is no any way to do it. We'll take it into consideration for future releases.


   
ReplyQuote
(@mirsch)
New Member
Joined: 7 years ago
Posts: 1
 

I stumbled over this thread while searching for a solution for this problem.

To solve it I now iterate over the "wp_head" callbacks and search the right one to remove it:

function remove_wpdiscuz_custom_css()
{
    global $wp_filter;

    $priority = 10;
    $hooks = $wp_filter['wp_head']->callbacks[$priority];
    foreach ($hooks as $hook) {
        if (isset($hook['function'][0]) && $hook['function'][0] instanceof WpdiscuzCss && $hook['function'][1] == 'initCustomCss') {
            remove_action('wp_head', $hook['function'], $priority);
            break;
        }
    }
}

add_action('wp_head', 'remove_wpdiscuz_custom_css', 8);
 

 


   
ReplyQuote
(@luboslives)
New Member
Joined: 6 years ago
Posts: 2
 

@mirsch

I followed your suggestion and Query Monitor is showing that the hook is no longer registered inside wp_head, and yet... the inline CSS gets printed inside my document head regardless.

(no i'm not using a caching plugin)

Has anyone figured out how to stop initCustomCss from firing? Is the plugin doubling down on the method somewhere else?


   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 6 years ago
Posts: 1403
 

@luboslives,

We've just checked on our test website and don't find such an issue. Everything works fine.
Could you please check one more time.


   
ReplyQuote
(@luboslives)
New Member
Joined: 6 years ago
Posts: 2
 

I've figured it out – I missed a small detail! I didn't realize @mirsch was using a hook priority of 8. I had it at 10 in my theme functions file. It might seem counterintuitive in a way, but it needs to have a higher priority than the initCustomCss hook so that it can deregister it before it's executed by WordPress.

I guess Query Monitor can't figure out whether something actually executed before being removed by a function that happens to have the same priority.


   
ReplyQuote
Share:
Scroll to top