Support » Plugin: Simple Responsive Slider » Deregister script / remove action if not on front page

  • Resolved Makewebgr

    (@makewebgr)


    http://wordpress.org/plugins/simple-responsive-slider/

    Hello, thanks for the great plugin.

    I am trying to remove the scripts from other pages except for the front page. The first part, deregstering the .js file works fine, but the second, removing the action from wp_head does not.
    Any ideas? What am I missing?
    Thank you in advance.

    add_action( 'wp_print_scripts', 'mw_deregister_javascript');
    function mw_deregister_javascript() {
    if ( !is_front_page() ) {
    wp_deregister_script( 'responsiveslides' );
    }
    }
    add_action( 'wp_head', 'mw_remove_actions');
    function mw_remove_actions() {
    if ( !is_front_page() ) {
    global $simple_responsive_slider;
    remove_filter( 'wp_head', array($simple_responsive_slider, 'dynamics_scripts') );
    }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author marcelotorres

    (@marcelotorres)

    Hi Makewebgr,

    I will check it and if necessary will correct in next version.

    Thanks for your feedback

    Plugin Author marcelotorres

    (@marcelotorres)

    Hi Makewebgr,

    I found a solution, try it:

    function no_srs_scripts() {
    	if(!is_home()){
    		global $simple_responsive_slider;
    
    		wp_deregister_script('responsiveslides');
    		wp_deregister_style('responsiveslides');
    		remove_filter( 'wp_head', array($simple_responsive_slider, 'dynamics_scripts') );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'no_srs_scripts' );
    add_action( 'wp_head', 'no_srs_scripts');
    Thread Starter Makewebgr

    (@makewebgr)

    Thank you!!!!

    In my case, it works using !is_front_page() instead of !is_home()

    Thanx again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Deregister script / remove action if not on front page’ is closed to new replies.