• Resolved arturino

    (@arturdesign2devcom)


    as you can see in the first carousel, every other image is missing.
    i confirmed this when i disabled your code.

    what can i do to fix this on your code?
    thanks

    Artur

    • This topic was modified 5 years, 9 months ago by arturino.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter arturino

    (@arturdesign2devcom)

    hi i found your issue:

    I see they append your code to the hook “woocommerce_after_shop_loop_item”.

    Is there is a way to append your code to a different hook instead, maybe with a filter, to avoid this kind of issues.

    I think that if you appended your code to “woocommerce_after_shop_loop_item_title” hook that would fix my and many other’s issue.

    thanks

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    that hook actually is necessary appends a <span data-content_category="%s" style="display:none;"></span> element, in order to have the content_category fulfilled in the Add To Cart event. This is the only one method to do that in WooCommerce.

    If you don’t need that field, you may simply remove the filter as I think you already did.

    Otherwise, could you please reproduce again the error and check in the console if there are some JS errors? I need to understand what this issue causes in your page

    Thread Starter arturino

    (@arturdesign2devcom)

    hi Antonino, i had to hire a developer to make custom add-on plugin to remove this filter, so that any future updates of your plugin would not require more manual work. thanks for the followup

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    thanks for confirming this is solved for you! 🙂

    If you will be able to share the exact solution, I’ll check if I can integrate this for all users and have it built-in in the plugin.

    Thanks.

    Thread Starter arturino

    (@arturdesign2devcom)

    `<?php
    /*
    * Plugin Name: Remove Hook From Pxel Plugin
    * Description: Remove hook from the pixel plugin
    * Version: 1.0.0
    * Author: Kevin
    * Requires at least: 5.0.0
    * Tested up to: 5.4.0
    * WC requires at least: 3.3.0
    * WC tested up to: 3.4.4
    * Text Domain: remove-hook-from-pixel
    * Domain Path: /languages/
    * License: GNU General Public License v3.0
    * License URI: http://www.gnu.org/licenses/gpl-3.0.html
    */

    function remove_filters_with_method_name( $hook_name = ”, $method_name = ”, $priority = 0 ) {
    global $wp_filter;

    // Take only filters on right hook name and priority
    if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
    return false;
    }

    // Loop on filters registered
    foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
    // Test if filter is an array ! (always for class/method)
    if ( isset( $filter_array[‘function’] ) && is_array( $filter_array[‘function’] ) ) {
    // Test if object is a class and method is equal to param !
    if ( is_object( $filter_array[‘function’][0] ) && get_class( $filter_array[‘function’][0] ) && $filter_array[‘function’][1] == $method_name ) {
    // Test for WordPress >= 4.7 WP_Hook class (https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/)
    if ( is_a( $wp_filter[ $hook_name ], ‘WP_Hook’ ) ) {
    unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
    } else {
    unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
    }
    }
    }

    }

    return false;
    }

    /**
    * Allow to remove method for an hook when, it’s a class method used and class don’t have variable, but you know the class name 🙂
    */
    function remove_filters_for_anonymous_class( $hook_name = ”, $class_name = ”, $method_name = ”, $priority = 0 ) {
    global $wp_filter;

    // Take only filters on right hook name and priority
    if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
    return false;
    }

    // Loop on filters registered
    foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
    // Test if filter is an array ! (always for class/method)
    if ( isset( $filter_array[‘function’] ) && is_array( $filter_array[‘function’] ) ) {
    // Test if object is a class, class and method is equal to param !
    if ( is_object( $filter_array[‘function’][0] ) && get_class( $filter_array[‘function’][0] ) && get_class( $filter_array[‘function’][0] ) == $class_name && $filter_array[‘function’][1] == $method_name ) {

    if ( is_a( $wp_filter[ $hook_name ], ‘WP_Hook’ ) ) {
    unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
    } else {
    unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
    }
    }
    }

    }

    return false;
    }

    add_action(‘wp_head’, function() {

    remove_filters_for_anonymous_class( ‘woocommerce_after_shop_loop_item’, ‘AEPC_Woocommerce_Addon_Support’, ‘add_content_category_meta’, 99 );

    if ( class_exists(‘AEPC_Woocommerce_Addon_Support’) ) {

    $object = new AEPC_Woocommerce_Addon_Support();

    add_action( ‘woocommerce_after_shop_loop_item_title’, array( $object, ‘add_content_category_meta’ ), 99 );
    }
    });

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    thanks for sharing your solution. I’ll evaluate if I can move the hook in that woocommerce_after_shop_loop_item_title.

    Thanks 🙂

    Plugin Author Antonino Scarfì

    (@antoscarface)

    Hi,

    the new version with this fix is available, so you won’t need your custom plugin anymore 🙂

    Thank you for reporting this.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Plugin is breaking my Carousel’ is closed to new replies.