Results 1 to 4 of 4

Thread: WordPress Popular Posts plugin - Combining stylesheets

  1. #1
    zestylemon is offline Hello World
    Join Date
    Apr 2011
    Posts
    2

    Icon5 WordPress Popular Posts plugin - Combining stylesheets

    I've been using YSlow to improve the speed that pages load on my WordPress site. One of the reccomendations is to combine all external stylesheets into one.

    I could do with a bit of help in trying to acheive this for the WordPress Popular Posts plugin.

    I've copied the CSS for this plugin into my theme's stylesheet but I'm not sure which portion of wordpress-popular-posts.php I should comment out to stop the plugin including the reference to it's own stylesheet.

    Has anyone else here done this? Is anyone able to offer any assistance?

  2. #2
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Here is where the stylesheet is added:
    PHP Code:
    // print stylesheet
    add_action('wp_head', array(&$this'wpp_print_stylesheet')); 
    You can either simply comment-out this line:
    PHP Code:
    // print stylesheet
    // add_action('wp_head', array(&$this, 'wpp_print_stylesheet')); 
    Or, call a remove_action() call in your Theme's "functions.php" file, to remove this action:
    PHP Code:
    remove_action'wp_head''wpp_print_stylesheet'11 ); 
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  3. #3
    zestylemon is offline Hello World
    Join Date
    Apr 2011
    Posts
    2

    Icon14

    Thanks for the super-speedy reply; much appreciated. I decided to go for option #2 making a change to my functions.php file (which means I won't have to edit the plugin's file each time there's an update).

    Unfortunately it didn't do the job but the PHP you supplied gave me something to search on and came across this post. It appears the problem is the add_action function sets the stylesheet in the widget constructor - I don't really understand what this means (I just copy & pasted) but for the benefit of others here's PHP for your functions.php file that does the job:

    Code:
    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') ); }

  4. #4
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Ah, crap; forgot to account for the class array... glad you figured it out. :)
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •