Support » Plugin: Easy FancyBox » Remove Action for Easy FancyBox on Shopping Cart Pages

  • Resolved Trishah

    (@trishahdee)


    Hello. I love your plugin. The site I’m using it on has a shopping cart with it’s own shadowbox image effect. So when you click an image in the shopping cart it is brought up twice; once with EasyFancyBox and once with the cart shadowbox.

    I’ve been using the following in the functions page to remove EasyFancyBox from the shopping cart pages but it stopped working and I can’t figure out why. Can you help me find the error? Or, do you have an easier way to remove it from certain pages.

    /* Remove Scripts from Shoppe */
    
    add_action('wp_head','my_conditional_script',0);
    
    function my_conditional_script() {
    if(preg_match("/\/product\//",$_SERVER['REQUEST_URI']) || preg_match("/\/product-category\//",$_SERVER['REQUEST_URI'])){
       //if /xxx/ is anywhere in the URL..
    
            remove_action('init','easy_fancybox_init');
            remove_action('wp_print_styles', 'easy_fancybox_enqueue_styles', 999);
            remove_action('wp_enqueue_scripts', 'easy_fancybox_enqueue_scripts', 999);
            remove_action('wp_head', 'easy_fancybox', 999);
            remove_action('wp_head', 'easy-fancybox', 999);
        }
    }

    http://wordpress.org/plugins/easy-fancybox/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author RavanH

    (@ravanh)

    Hi Trishah,

    The plugin has been changed dramatically since then so this code will indeed not do the job any more. You could try the following but I’m not sure if it will work at all :

    add_action('wp_head','my_conditional_script',0);
    
    function my_conditional_script() {
        if( class_exists('easyFancyBox') && ( is_singular('product') || is_post_type_archive('product') ) ) {
            remove_action('wp_enqueue_scripts', array('easyFancyBox','enqueue_styles'), 999);
            remove_action('wp_print_scripts', array('easyFancyBox','register_scripts'), 999);
            remove_action('wp_head', array('easyFancyBox','main_script', 999);
            remove_action('wp_footer', array('easyFancyBox','enqueue_footer_scripts'), 999);
    	remove_action('wp_footer', array('easyFancyBox', 'on_ready'), 999);
        }
    }

    I’m assuming the post type for products is called ‘product’…

    Thank you for your reply. I found a solution by simply stopping the shadowbox the shopping cart uses.

    But I wanted to test your solution anyway as I, and others, may need it someday. It does work. However, you forgot a closing parenthesis in your code. Here is the code that works:

    /* Remove FancyBox Scripts from Shoppe */
    
    add_action('wp_head','my_conditional_script',0);
    
    function my_conditional_script() {
        if( class_exists('easyFancyBox') && ( is_singular('product') || is_post_type_archive('product') ) ) {
            remove_action('wp_enqueue_scripts', array('easyFancyBox','enqueue_styles'), 999);
            remove_action('wp_print_scripts', array('easyFancyBox','register_scripts'), 999);
            remove_action('wp_head', array('easyFancyBox','main_script'), 999);
            remove_action('wp_footer', array('easyFancyBox','enqueue_footer_scripts'), 999);
    	remove_action('wp_footer', array('easyFancyBox', 'on_ready'), 999);
        }
    }

    Thank you for the help!

    Plugin Author RavanH

    (@ravanh)

    Excellent! Thanks for sharing 🙂

    Hi,
    I want to disable this plugin function on Fast Flickr Widget can you please guide me how can I do this?

    @kumaillakhani – this thread is marked resolved and on a different topic – please start your own per the forum guidelines – http://codex.wordpress.org/Forum_Welcome#Where_To_Post

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove Action for Easy FancyBox on Shopping Cart Pages’ is closed to new replies.