WordPress.org

Ready to get started?Download WordPress

Forums

Simple Colorbox
[resolved] Remove plugin's CSS file (11 posts)

  1. asterbird
    Member
    Posted 1 year ago #

    First of all, thanks for this plugin! I love how simple and lightweight this is.

    I would like to make it even more lightweight by removing the plugin's CSS and using my theme's CSS instead.

    How do I remove Simple Colorbox's CSS file? I am using Theme1 (by default) and noticed that it's being called in the plugin's index.php via this code:

    public function __construct() {
    	// Add action hooks
    	add_action( 'wp_enqueue_scripts', array( $this, 'external_css' ) );
    	add_action( 'wp_enqueue_scripts', array( $this, 'external_scripts' ) );
    	add_action( 'wp_head',            array( $this, 'simplecolorbox_ad' ) );
    	add_action( 'wp_head',            array( $this, 'inline_scripts' ) );
    }

    Commenting out the first add_action accomplishes exactly what I want. However, I would rather not hack the plugin code itself.

    Any way to do this?

    http://wordpress.org/extend/plugins/simple-colorbox/

  2. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    Ohh, interesting idea. The code is written in a way that would prevent you from doing that.

    If you change the code new Simple_Colorbox() to $simple_colorbox = new Simple_Colorbox() then you will be able to unhook the CSS files.

    I'll try to find some time to do this either today or tomorrow, although my schedule is busy, so it might need to wait until Wednesday. Feel free to pester me by posting back here, as I'll get an email notification then :)

  3. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    I've released version 1.3 which sets the variable to the class for you.
    http://ryanhellyer.net/

    If you need a hand working out how to unhook the styles, just let me know.

    Depending on what exactly you are doing, you may just want to copy the main class out of the plugin and use that directly instead though, perhaps in a custom plugin.

  4. asterbird
    Member
    Posted 1 year ago #

    Where is version 1.3? I couldn't find it on your website.

    I'm not sure how to unhook the files. If you could give me a hand, that would be great. Do I use enqueue or something?

    I'm using the plugin on a client's site - test site is here. I'm using it for all linked images and galleries. It's the only javascript functionality I need for the site.

  5. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    Oh shoot! It never uploaded. Oops. I'll fix that shortly.

  6. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    It's now uploaded ...
    http://wordpress.org/extend/plugins/simple-colorbox/

    For some reason half the files never uploaded and that prevented the repository from refreshing itself with the latest version.

  7. asterbird
    Member
    Posted 1 year ago #

    Thanks! I upgraded Simple Colorbox to 1.3. Now how to unhook the CSS? I added this to my theme's functions.php file, but I don't think it's right:

    function remove_simple_colorbox_css() {
    	remove_action('wp_enqueue_scripts', 'external_css');
    }
    add_action('wp_enqueue_scripts', 'remove_simple_colorbox_css', 1);
  8. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    That won't work as it's inside a class. You need to dequeue it from the object.

    I'll write some code for you later on. I need to go to a party right now, but will be back online later this evening. If I don't reply to this within the next 12 hours then I'm either too drunk or I forgot. Either way, post back here so I get an email notification alerting me to the fact that I haven't come back to help you yet.

  9. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    I wrote up a blog post for you explaining how to dequeue the CSS file. If you experience any problems implementing it then please let me know.

  10. asterbird
    Member
    Posted 1 year ago #

    With 1.3.1 update, I was able to implement the code from your blog post - works great now!

    Thanks so much for spending all this work and time helping me.

  11. Ryan Hellyer
    Member
    Plugin Author

    Posted 1 year ago #

    Awesome :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic