• Hi,
    I want to minimize the HTTP requests on some of my websites so I’m trying to combine the stylesheets. I’ve tried to get rid of the wpp.css with no luck.

    According to this: Remove unwanted WordPress header elements I’ve added the following line in functions.php
    remove_action('wp_head', 'wpp_print_stylesheet');
    But it doesn’t work. I’ve removed other external stylesheets that other plugins are adding but I can’t remove this one.

    Any help please?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi mpiftex,

    That’s an easy fix. Open wordpress-popular-posts.php using a text editor such as Notepad or Dreamweaver and find this code (around line 68):

    add_action(‘wp_head’, array(&$this, ‘wpp_print_stylesheet’));

    … and replace it with:

    //add_action(‘wp_head’, array(&$this, ‘wpp_print_stylesheet’));

    That should do it.

    Thread Starter mpiftex

    (@mpiftex)

    Hey Ikki24,
    that was a quick reply as usual! ??

    This is a quick, easy but unfortunately “dirty” fix! I’ve done that already but after every plugin update the line will be uncommented. I believe the remove_action method is the clean way to do it but I guess I’m doing something wrong…

    Hey Hi! I got the same problem, I wanted to remove the <link> stylesheet which has nothing, only CSS classes…

    Well, I found the solution after a headache. The problem comes with the plugin.

    I realized that the add_action function to set the stylesheet is called in the widget constructor, so… actually if you could get the unique-id assigned to the function “wpp_print_stylesheet”, the remove_action thing simply fails! (WP assigns a unique-id for the “multiple instance widgets” thing, and to catch the assigned name is not possible, only traversing the global $wp-filter and matching patterns, I have to do this)

    And the problem is at the plugin ’cause this is not mean to be. The function wpp_print_stylesheet must NOT be part of the Widget class and be called within the constructor. The function could be outside the Widget class and called outside.

    This happens ’cause WP (based on what I see when testing) loads all the widgets and the constructor will inevitably run. <- I think.

    Other plugins I’ve seen, define this kind of functions outside the widget class and the actions can be removed, modified, etc. this way in the functions.php file.

    I hope this could help.

    By the way, nice plugin ?? I’ll wait for a fix and I’ll be applying the dirty solution till then.

    Greets!

    Hey mpiftex, juliorfa,

    Did a small research and found another way to remove WordPress Popular Posts’ stylesheet without having to hack the plugin. Please add the following code to your theme’s functions.php:

    add_action(‘wp_head’, ‘remove_widget_action’, 1);

    function remove_widget_action() {
    global $wp_widget_factory;

    remove_action( ‘wp_head’, array($wp_widget_factory->widgets[‘WordPressPopularPosts’], ‘wpp_print_stylesheet’) );
    }

    That should do it!

    P.S.: I also found out that for it to work you should be running WordPress 2.9, otherwise it won’t work because of a core bug.

    Hey thanks! this does the job.

    I was searching for the way WP stores the widgets with no luck (since the new approach in version 2.8)… and there it is!. Just point out the add_action priority must be less than 10.

    Thanks again and keep the good work!

    ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Remove the stylesheet’ is closed to new replies.