fabiorino / crelly-slider

A free responsive slider for WordPress that supports layers. Add texts, images, videos and beautify them with transitions and animations.
MIT License
105 stars 36 forks source link

Change enqueueing to make plugin more flexible. #14

Closed schlessera closed 7 years ago

schlessera commented 9 years ago

Hello,

Here's a pull request that implements two small changes that make Crelly Slider more flexible.

The Diffs are a mess, because your source files include lots of superfluous whitespace, you should check your editor settings to automatically remove them. As mine does, to adhere to WordPress Coding Standards, the whole file looks changed, but there are only small tweaks done.

One change is to add a filtering mechanism to the CSS and JS for Crelly Slider. This way, a theme can choose if and where these resources should be loaded.

Here's an example for my theme, where I never load the CSS (it is included in my theme's stylesheet) and I only load the JS on the frontpage:

    add_filter( 'crellyslider_enqueue_css', '__return_false' );
    if ( ( ! is_home() ) && ( ! is_front_page() ) ) {
        add_filter( 'crellyslider_enqueue_js', '__return_false' );
    }

The other change is a small addition to the JS callback functions, so that they pass the slide_index into the callback. When reacting to slide changes, it is important to know which slide will come next, as the order is not fixed when having controls enabled.

I am not sure if this is the way to solve these problems, but it works for me know. So, even if you don't like the coding style, keep in mind that these are real issues for practical usage that should be solved.

Thanks for the great plugin!

Alain