Support » Plugin: Fetch Tweets » Dequeuing style

  • Resolved Matt Radford


    I’m trying to dequeue Fetch Tweets style for a custom template, to remove the extra HTTP request – but I’m having to guess the handle a bit. The code in include/template/FetchTweets_TenplatesLoader.php indicates that it’s creating the handle from the template:

    wp_enqueue_style( "fetch-tweets-" . md5( $_aTemplate['sDirPath'] ) );

    So I’m trying to dequeue the Plain template to test this (template is activated), with the following code:

    function remove_unwanted_css(){
    add_action( 'wp_enqueue_scripts', 'remove_unwanted_css', 100 );

    I’ve also tried wp_deregister_style.

    Any help would be much appreciated. Thanks, Matt

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author miunosoft



    What about deactivating the Plain template? This way, the CSS file of Plain won’t be enqueued. To do so, you need to make your custom template the default one. Then deactivate the Plain template.

    Hope it helps.

    Hi, thanks for replying.

    I’m only activating the Plain template as a test as I think the handle should be ‘fetch-tweets-plain’. The function above should, but does not, dequeue the style, so either the handle is wrong or it’s not a high enough priority number (which I’ve tested against).

    I will deactivate Plain when I have a working solution, but I’m trying to dequeue my custom template, as I can then save a HTTP request and stick the CSS into my single compiled theme file.

    So, do I have the correct handle for the Plain template?

    Plugin Author miunosoft



    Which one are you trying to deactivate, the Plain template or your own custom template?

    I may have not explained well.

    If the Plain template is deactivated via Dashboard -> Fetch Tweets -> Templates, the stylesheet of the Pain template won’t be enqueued. So rather than going with a coding solution, I suggest you simply deactivate the template.

    Ok, forget the Plain template. I’m only using that as a test to see if I can dequeue the stylesheet.

    I am using a Fetch Tweets custom template, which I’ve set up according to your documentation. It’s working fine and the stylesheet for that loads on the front end. But I want to dequeue this stylesheet. I’ve taken the CSS out of the custom template’s style.css and added it elsewhere. So – the custom template’s style.css does not need to be loaded, as it’s an extra HTTP request I could do without.

    I’m trying to get the correct handle of the custom template’s stylesheet in order to dequeue it. Have I got the handle format correct?

    Plugin Author miunosoft



    Interesting. So you are doing something advanced.

    And the answer is no, ‘fetch-tweets-plain’ won’t be the correct handle id.

    In order to accept duplicated template names, the plugin generates a resource handle id from the template directory path. That’s what you see md5( $_aTemplate['sDirPath'] ).

    For this reason, in each environment, the template will have a different id. So you need to find out the directory path of the template which is assigned to the template option array element.

    To do so, you can do something like this.

    function _debug_fetch_tweets_template_options() {
        $_oOption = FetchTweets_Option::getInstance();
        FetchTweets_Debug::log( $_oOption->getActiveTemplates() );
    add_action( 'fetch_tweets_action_after_loading_plugin', '_debug_fetch_tweets_template_options' );

    It will create a log file in your wp-content directory. And check the array contents and the value assigned to an array element with the key sDirPath.

    Once you get the value, the handle is ‘”fetch-tweets-” . md5( $_directory_path )’. Assign the value to the $_directory_path variable.

    Let me know if you get stuck.

    Thanks very much for your reply – that’s helped me figure it out. I tried the function you kindly supplied, but it didn’t output anything in wp-content or any other directory. However, I realised I could look in the <head> – and there was an ID added to the stylesheet link, e.g.


    I replaced ‘fetch-tweets-plain’ with fetch-tweets-931d83299fdae5cb7f44dff076336678 in my function and bingo! Stylesheet dequeued!

    Thanks so much for your help and an awesome plugin 🙂

    Plugin Author miunosoft


    You are welcome.

    I tried the function you kindly supplied, but it didn’t output anything in wp-content or any other directory.

    Ah, you need to turn on the WordPress debug mode by setting the WP_DEBUG constant to true in wp-config.php.

    I’m glad that you sorted it out. For now it will work. Still, the id will change if you move the site and activate/deactivate the template. So if you need to dequeue a certain template’s stylesheet programmatically, parse the plugin options array that holds active templates and find the directory path associated with the target template.

    If you need help with that, let me know.

    Ah, you need to turn on the WordPress debug mode by setting the WP_DEBUG constant to true in wp-config.php.

    Doh. Should have that on while developing anyway.

    I appreciate that my solution isn’t portable, but it’ll do for now (development deadlines, you know…). I’ll take a look at a more robust function when I get time. Thanks again.

    Plugin Author miunosoft


    Glad it helped! Good luck with your project!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Dequeuing style’ is closed to new replies.