Recently, I created a customized child theme based on the Divi Theme, tailor-made for integration with Buddypress. Everything was going smoothly until I encountered a conflict involving the commenting buttons due to a script.
In my theme, there is a JavaScript file (js/custom.js
) that contains the following function:
$( 'a[href*=#]:not([href=#])' ).click( function() {
if ( $(this).closest( '.woocommerce-tabs' ).length && $(this).closest( '.tabs' ).length ) {
return false;
}
if ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) {
var target = $( this.hash );
target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' );
if ( target.length ) {
et_pb_smooth_scroll( target, false, 800 );
if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
setTimeout(function(){
et_pb_smooth_scroll( target, false, 200);
}, 500 );
}
return false;
}
}
});
This function happens to affect the same button used by Buddypress for commenting, thereby hindering the AJAX form from loading when clicked.
I am reluctant to modify the parent theme's script (custom.js). Is there a way to resolve this conflict without editing the main script? Perhaps through some workaround in functions.php?
UPDATE
Even after attempting to delay the loading of the script using [wp_dequeue_script][4] in functions.php, it did not yield the desired outcome. The code snippet utilized was as follows:
function de_script() {
wp_dequeue_script( 'divi-custom-script' );
}
add_action( 'wp_print_scripts', 'de_script', 100 );
Unfortunately, this action resulted in the complete non-loading of the entire script (custom.js).