troubleshooting Question

how to use add_filter for this specific function

Avatar of Aaron Roessler
Aaron Roessler asked on
7 Comments1 Solution70 ViewsLast Modified:
I am learning how to use add_filter but cannot seem to get it to work for this specific one.

I created a short video to also help explain

The plugin has an admin toggle setting that enables and disables the woocommerce product hover effect. I need to make it conditional and turn it off for the Shop Page but leave it on for all other pages.  I found the source code and apply_filter of the plugin that I need to edit (see 2nd code below): The last line apply_filters tells me I can use add_filter

So here is what I have now which does nothing and just returns the same data the source code was doing... but I dont know how to modify the return $newdata to disable the hover effect
function conditional_hover_effect($newdata) {
	echo '<script>console.log("Function is firing")</script>';
return $newdata ;
add_filter( 'jet-woo-builder/template-functions/product-thumbnail', 'conditional_hover_effect', 10, 2 );

Open in new window

		public function get_product_thumbnail( $image_size = 'thumbnail_size', $use_thumb_effect = false, $attr = array() ) {
			global $product;

			if ( ! is_a( $product, 'WC_Product' ) ) {

			$thumbnail_id        = get_post_thumbnail_id( $product->get_id() );
			$enable_thumb_effect = filter_var( jet_woo_builder_settings()->get( 'enable_product_thumb_effect' ), FILTER_VALIDATE_BOOLEAN );
			$placeholder_src     = apply_filters( 'jet-woo-builder/template-functions/product-thumbnail-placeholder', Elementor\Utils::get_placeholder_image_src() );
			$attr                = array( 'data-no-lazy' => '1' );

			if ( empty( $thumbnail_id ) ) {
				return sprintf( '<img src="%s" alt="EMPTY">', $placeholder_src );

			$html = wp_get_attachment_image( $thumbnail_id, $image_size, false, $attr );

			if ( $use_thumb_effect && $enable_thumb_effect ) {
				$html = $this->add_thumb_effect( $html, $product, $image_size, $attr );
			return apply_filters( 'jet-woo-builder/template-functions/product-thumbnail', $html );

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros