Error in code — data-template and data-terms attributes
-
Hello, as you can see on the two attached screenshots, there is an error in the HTML syntax in the Woo_Product_Gallery.php file. It misses single quotation both in the data-template and the data-terms attributes.
It should be, respectively:
data-template='{“dir”:”lite”,”file_name”:”default.php”,”name”:”Woo-Product-Gallery”}’
and:
data-terms='[“combos”]’
I have hacked your plugin and fixed it, but to prevent loosing the changes when the plugin is updated, I suggest you to implement the fix as well:
echo '<ul class="eael-cat-tab" data-layout="' . esc_attr( $settings[ "eael_product_gallery_items_layout" ] ) . '" data-template=' . json_encode( [ 'dir' => $dir_name, 'file_name' => $this->get_filename_only( $template ), 'name' => $this->process_directory_name() ], 1 ) . ' data-nonce="' . wp_create_nonce( 'eael_product_gallery' ) . '" data-page-id="' . $this->page_id . '" data-widget-id="' . esc_attr( $this->get_id() ) . '" data-widget="' . esc_attr( $this->get_id() ) . '" data-class="' . get_class( $this ) . '" data-args="' . http_build_query( $args ) . '" data-page="1">';
you should add \’ before and after, so the above should be:
echo '<ul class="eael-cat-tab" data-layout="' . esc_attr( $settings[ "eael_product_gallery_items_layout" ] ) . '" data-template=\'' . json_encode( [ 'dir' => $dir_name, 'file_name' => $this->get_filename_only( $template ), 'name' => $this->process_directory_name() ], 1 ) . '\' data-nonce="' . wp_create_nonce( 'eael_product_gallery' ) . '" data-page-id="' . $this->page_id . '" data-widget-id="' . esc_attr( $this->get_id() ) . '" data-widget="' . esc_attr( $this->get_id() ) . '" data-class="' . get_class( $this ) . '" data-args="' . http_build_query( $args ) . '" data-page="1">';
==================================================
Similarly, this:
echo '<li><a href="javascript:;" data-page="1" data-taxonomy="product_cat" data-terms=' . json_encode ( [ $category->slug ] ) . ' data-id="' . $category->term_id . '" class="post-list-filter-item ">' . $show_cat_thumb_tag . '' . $category->name . '</a></li>';
should be:
echo '<li><a href="javascript:;" data-page="1" data-taxonomy="product_cat" data-terms=\'' . json_encode ( [ $category->slug ] ) . '\' data-id="' . $category->term_id . '" class="post-list-filter-item ">' . $show_cat_thumb_tag . '' . $category->name . '</a></li>';
==================================================
And just a live below, almost at the end of the file:
echo '<li><a href="javascript:;" data-page="1" data-taxonomy="product_tag" data-terms=' . json_encode ( [ $product_tag->slug ] ) . ' data-id="' . $product_tag->term_id . '" class="post-list-filter-item ">' . $show_cat_thumb_tag . '' . $product_tag->name . '</a></li>';
it should be also:
echo '<li><a href="javascript:;" data-page="1" data-taxonomy="product_tag" data-terms=\'' . json_encode ( [ $product_tag->slug ] ) . '\' data-id="' . $product_tag->term_id . '" class="post-list-filter-item ">' . $show_cat_thumb_tag . '' . $product_tag->name . '</a></li>';
Please, include this fix in your next plugin update.
Thank you!
Esteban
- The topic ‘Error in code — data-template and data-terms attributes’ is closed to new replies.