• Resolved Ate Up With Motor

    (@ate-up-with-motor)


    I’m trying to set up a new site using a child theme based on the Sundance theme. Sundance has a couple of scripts related to video blogging that I don’t need, so I would like to disable those scripts so they’re not loaded at all.

    The Sundance functions.php file loads those scripts like this:

    function sundance_scripts() {
    	global $post;
    
    	wp_enqueue_style( 'style', get_stylesheet_uri() );
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    	}
    
    	if ( is_singular() && wp_attachment_is_image( $post->ID ) ) {
    		wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
    	}
    	wp_enqueue_script( 'sundance-small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120305', true );
    
    	wp_enqueue_script( 'sundance-fit-vids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '20120213', true );
    
    	wp_enqueue_script( 'sundance-flex-slider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ), '20120903', true );
    
    	wp_enqueue_script( 'sundance-theme', get_template_directory_uri() . '/js/theme.js', array( 'jquery', 'sundance-fit-vids', 'sundance-flex-slider' ), '20120213', true );
    
    }

    The ones I want to get rid of are the sundance-fit-vids and sundance-flex-slider. I can disable them by going into the parent theme’s functions.php and commenting out those lines, but obviously that will get overwritten the first time the parent is updated.

    I was looking at this and tried to remove those scripts by creating a functions.php in the child directory with the following code:

    <?php
    
    /** remove fit-vids and flex-slider
    */
    add_action('sundance-fit-vids','child_overwrite_fitvids', 100 );
    add_action('sundance-flex-slider','child_overwrite_flexslider', 100 );
    
    function child_overwrite_fitvids() {
    	wp_deregister_script('sundance-fit-vids' );
    }
    
    function child_overwrite_flexslider() {
    	wp_deregister_script('sundance-flex-slider' );
    }

    However, when I do that, it loads the scripts anyway and the admin backend shows the following error messages:

    ‘Warning: Cannot modify header information – headers already sent by (output started at [redacted]/themes/sundance-custom/functions.php:1) in [redacted]/wp-includes/option.php on line 571

    Warning: Cannot modify header information – headers already sent by (output started at [redacted]/themes/sundance-custom/functions.php:1) in [redacted]/wp-includes/option.php on line 572′

    I’m already at the bleeding edge of what I understand about PHP, so I have no idea what to make of that. Any ideas how I can successfully remove those scripts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I tried the following code in the functions.php of the child theme and it worked great

    <?php
    function remove_scripts()
    {
    wp_deregister_script('sundance-fit-vids' );
    wp_deregister_script('sundance-flex-slider');
    }
    add_action( 'wp_enqueue_scripts', 'remove_scripts', 100 );
    ?>
    Thread Starter Ate Up With Motor

    (@ate-up-with-motor)

    I’ll try that, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Child Theme: Removing scripts from parent functions.php’ is closed to new replies.