Genesis Responsive Slider is still not displaying. Upon searching I found that, WooCommerce interferes with the sliders sometimes.
So I want to conditionally load the WooCommerce scripts and styles.
I have found the handle of all the scripts and styles loaded using the code:
# Finding handle for your plugins
function display_script_handles() {
global $wp_scripts;
if(current_user_can('manage_options') && ! is_admin()){ # Only load when user is admin
foreach( $wp_scripts->queue as $handle ) :
$obj = $wp_scripts->registered [$handle];
echo $filename = $obj->src;
echo ' : <b>Handle for this script is:</b> <span style="color:green"> '.$handle.'</span><br/><br/>';
endforeach;
}
}
add_action( 'wp_print_scripts', 'display_script_handles' );
Script Handles found for WooCommerce:
Handle: wc-add-to-cart
Handle: woocommerce
Handle: wc-cart-fragments
Handle: flexslider
Style Handles found for WooCommerce:
Handle: woocommerce-layout
Handle: woocommerce-smallscreen
Handle: woocommerce-general
Handle: genesis-sample-woocommerce-styles
I am trying to remove these WooCommerce handles conditionally using the code:
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
//first check that woo exists to prevent fatal errors
if ( function_exists( 'is_woocommerce' ) ) {
//dequeue scripts and styles
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
wp_dequeue_script( 'wc-add-to-cart' );
wp_dequeue_script( 'wc-cart-fragments' );
wp_dequeue_script( 'woocommerce' );
wp_dequeue_script( 'flexslider' );
wp_dequeue_style('woocommerce-layout');
wp_dequeue_style('woocommerce-smallscreen');
wp_dequeue_style('woocommerce-general');
wp_dequeue_style('genesis-sample-woocommerce-styles');
}
}
}
Even after removing all the WooCommerce scripts and styles on the homepage, Genesis responsive slider is not working.
Please suggest what can be the issue.