Changeset 1942509
- Timestamp:
- 09/17/2018 09:59:53 AM (8 years ago)
- File:
-
- 1 edited
-
wp-autotagger/trunk/247-wp-smart-tagger.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-autotagger/trunk/247-wp-smart-tagger.php
r1940988 r1942509 149 149 <td colspan="1" > 150 150 <input type="checkbox" name="product_id" value="<?php echo the_id(); ?>" > 151 <input type="hidden" class="product_image " value="<?php echo the_post_thumbnail_url() ; ?>">151 <input type="hidden" class="product_image auto-tagger-img-<?php echo the_id(); ?>" value="<?php echo the_post_thumbnail_url() ; ?>"> 152 152 </td> 153 153 <td colspan="1" ><?php echo the_id(); ?></td> 154 <td c olspan="2" ><?php the_post_thumbnail( array(100,100), ['class' => 'attachment-thumbnail size-thumbnail wp-post-image'] ); ?></td>154 <td class=""colspan="2" ><?php the_post_thumbnail( array(100,100), ['class' => 'attachment-thumbnail size-thumbnail wp-post-image' ] ); ?></td> 155 155 <td><?php echo the_title(); ?></td> 156 156 <td><?php … … 186 186 console.log("all tags") 187 187 var checkboxValues = []; 188 var i mages_urls = [];188 var ids = [] 189 189 jQuery('input[type="checkbox"]').each(function(index, elem) { 190 190 checkboxValues.push($(elem).val()); 191 191 }); 192 jQuery('.product_image').each(function(index, elem) { 193 images_urls.push($(elem).val()); 194 }); 195 for (let i = 0; i < 10; i++) { 196 const element = checkboxValues[i]; 192 193 for (let i = 0; i < 9; i++) { 194 195 const element = checkboxValues[i]; 197 196 var tags = []; 198 197 console.log(element); … … 201 200 jQuery.post( "http://auto-tagger.thedemo.co/api/predict/", { 202 201 api_key : '<?php echo esc_attr( get_option('wp-smart_tagger_option_api_key') ); ?>', 203 url: images_urls[i],202 url: jQuery('.auto-tagger-img-'+element).val(), 204 203 security: '<?php echo wp_create_nonce( "bk-ajax-nonce" ); ?>' , 205 204 provider : "clarafai" … … 227 226 complete: function(){ 228 227 console.log("product ",i) 229 if(i == 9){228 if(i == 8 ){ 230 229 console.log("all tagged") 231 230 window.location.reload(false); … … 245 244 jQuery( '#woo-products' ).on( 'click', function() { 246 245 var checkboxValues = []; 247 var images_urls = [];248 246 249 247 jQuery('input[type="checkbox"]:checked').each(function(index, elem) { 250 248 checkboxValues.push($(elem).val()); 251 249 }); 252 jQuery('.product_image').each(function(index, elem) { 253 images_urls.push($(elem).val()); 254 }); 250 255 251 256 252 for (let i = 0; i < checkboxValues.length; i++) { … … 258 254 const element = checkboxValues[i]; 259 255 var tags = []; 260 console.log(element);261 console.log(images_urls[i])256 // console.log(element); 257 // console.log(images_urls[i]) 262 258 // get tags for each image 263 259 jQuery.post( "http://auto-tagger.thedemo.co/api/predict/", { 264 260 api_key : '<?php echo esc_attr( get_option('wp-smart_tagger_option_api_key') ); ?>', 265 url: images_urls[i],261 url: jQuery('.auto-tagger-img-'+element).val(), 266 262 security: '<?php echo wp_create_nonce( "bk-ajax-nonce" ); ?>' , 267 263 provider : "clarafai" … … 274 270 275 271 console.log( "tags results" ,tags ); 272 console.log( "tags post id" ,element ); 276 273 // Update Product Tags 277 274 jQuery.ajax({ // We use jQuery instead $ sign, because Wordpress convention. … … 320 317 $postid = intval( esc_html($_POST['postid'] )); 321 318 $tags = Wp_Smart_Tagger_recursive_sanitize_text_field($_POST['tags']) ; 322 wp_set_object_terms($postid , [], 'product_tag');323 319 wp_set_object_terms($postid , $tags, 'product_tag'); 324 320 wp_die(); … … 346 342 347 343 ?> 344 345
Note: See TracChangeset
for help on using the changeset viewer.