Remove WPDiscuz styling from WordPress head  

  RSS

lostnotstranded
(@lostnotstranded)
New Member
Joined: 1 year ago
Posts: 1
03/12/2018 9:05 pm  

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 1 year ago by lostnotstranded
This topic was modified 1 year ago by Tom

Quote
Astghik
(@astghik)
Support Team Admin
Joined: 2 years ago
Posts: 3513
04/12/2018 4:04 pm  

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
(@mirsch)
New Member
Joined: 1 year ago
Posts: 1
27/12/2018 4:11 am  

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
(@luboslives)
New Member
Joined: 2 weeks ago
Posts: 2
10/01/2020 4:57 pm  

@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)
Reputable Member Moderator
Joined: 5 months ago
Posts: 425
11/01/2020 12:45 pm  

@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
(@luboslives)
New Member
Joined: 2 weeks ago
Posts: 2
13/01/2020 4:32 pm  

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:
Green
Default
Pear
Black Emo
{green}:grinning:
{green}:wink:
{green}:face:
{green}:inlove:
{green}:sweaty:
{green}:surprised:
{green}:lovekiss:
{green}:laugh:
{green}:formalsmile:
{green}:displeased:
{green}:cool:
{green}:resent:
{green}:nerd:
{green}:screaming:
{green}:amazed:
{green}:sad:
{green}:deceitful:
{green}:starryeyes:
{green}:evil:
{green}:shocked:
{green}:tears:
{green}:sulky:
{green}:smile:
{green}:vomited:
{green}:hi:
{green}:afraid:
{green}:crazy:
{green}:rabid:
{green}:fighting:
{green}:nonoise:
{green}:blushed:
{green}:idontknow:
{green}:scared:
{green}:razz:
{green}:kiss:
{green}:eat:
{green}:shutmouth:
{green}:gape:
{green}:suspicious:
{green}:laughingoutloud:
{green}:bruise:
{green}:crying:
{green}:pray:
{green}:serious:
{green}:excitement:
:)
:d
:wink:
:mrgreen:
:neutral:
:twisted:
:arrow:
:shock:
:???:
:cool:
:evil:
:oops:
:razz:
:roll:
:cry:
:eek:
:lol:
:mad:
:sad:
:!:
:?:
:idea:
:hmm:
:beg:
:whew:
:chuckle:
:silly:
:envy:
:shutmouth:
{pear}:happy:
{pear}:smile:
{pear}:laugh:
{pear}:laughingoutloud:
{pear}:crying:
{pear}:exhausted:
{pear}:nerd:
{pear}:surprised:
{pear}:veryhungry:
{pear}:wink:
{blackemo}:laughtertotears:
{blackemo}:gift:
{blackemo}:love:
{blackemo}:inlove:
{blackemo}:shamefaced:
{blackemo}:heart:
{blackemo}:crazy:
{blackemo}:anguished:
{blackemo}:bruise:
{blackemo}:easymoney:
{blackemo}:exhausted:
{blackemo}:vampire:
{blackemo}:shutmouth:
{blackemo}:wink:
{blackemo}:carnival:
{blackemo}:flowers:
{blackemo}:hotdrink:
{blackemo}:party: