1jQuery(document).ready(function ($) { 2 replaceByShortcode($); 3}); 4 5function replaceByShortcode() { 6 jQuery('a.woocommerce-LoopProduct-link.woocommerce-loop-product__link').find('[id^=fifu-shortcode]').each(function (index) { 7 var id = jQuery(this).attr('id'); 8 var post_id = id.split('-')[2]; 9 jQuery.ajax({ 10 type: "POST", 11 dataType: "json", 12 url: ajax_object.ajaxurl, 13 cache: false, 14 data: {action: 'fifu_callback_shortcode', id: post_id}, 15 success: function (response) { 16 findAndReplace(id, response.longcode); 17 } 18 }).fail(function (data) { 19 console.log(data); 20 }); 21 }); 22} 23 24function findAndReplace(id, longcode) { 25 jQuery('a.woocommerce-LoopProduct-link.woocommerce-loop-product__link').find('#' + id).each(function (index) { 26 jQuery(this).replaceWith(longcode); 27 //for all shortcodes on home/shop 28 if ('<?php echo fifu_should_crop(); ?>') 29 cropShortcode(); 30 }); 31} 32 33function cropShortcode() { 34 var root = jQuery("a.woocommerce-LoopProduct-link.woocommerce-loop-product__link"); 35 root.find('iframe').each(function (index) { 36 var width = root.parent().css('width').replace('px', ''); 37 jQuery(this).css('height', width * 3 / 4); 38 jQuery(this).css('width', '100%'); 39 jQuery(this).css('object-fit', 'cover'); 40 }); 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.