Plugin Directory

Changeset 1942509


Ignore:
Timestamp:
09/17/2018 09:59:53 AM (8 years ago)
Author:
aghati
Message:

fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-autotagger/trunk/247-wp-smart-tagger.php

    r1940988 r1942509  
    149149         <td colspan="1" >
    150150         <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() ; ?>">
    152152         </td>
    153153         <td colspan="1" ><?php echo the_id(); ?></td>
    154          <td colspan="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>
    155155         <td><?php echo the_title(); ?></td>
    156156         <td><?php
     
    186186        console.log("all tags")
    187187        var checkboxValues = [];
    188         var images_urls = [];
     188        var ids = []
    189189          jQuery('input[type="checkbox"]').each(function(index, elem) {
    190190            checkboxValues.push($(elem).val());
    191191           });
    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];
    197196              var tags = [];
    198197              console.log(element);
     
    201200              jQuery.post( "http://auto-tagger.thedemo.co/api/predict/", {
    202201                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(),
    204203                security: '<?php echo wp_create_nonce( "bk-ajax-nonce" ); ?>' ,
    205204                provider : "clarafai"
     
    227226                 complete: function(){
    228227                     console.log("product ",i)
    229                      if(i == 9 ){
     228                     if(i == 8 ){
    230229                         console.log("all tagged")
    231230                         window.location.reload(false);
     
    245244       jQuery( '#woo-products' ).on( 'click', function() {
    246245        var checkboxValues = [];
    247         var images_urls = [];
    248246       
    249247        jQuery('input[type="checkbox"]:checked').each(function(index, elem) {
    250248            checkboxValues.push($(elem).val());
    251249        });
    252         jQuery('.product_image').each(function(index, elem) {
    253             images_urls.push($(elem).val());
    254         });
     250       
    255251         
    256252          for (let i = 0; i < checkboxValues.length; i++) {
     
    258254              const element = checkboxValues[i];
    259255              var tags = [];
    260               console.log(element);
    261               console.log(images_urls[i])
     256            //  console.log(element);
     257            //  console.log(images_urls[i])
    262258              // get tags for each image
    263259              jQuery.post( "http://auto-tagger.thedemo.co/api/predict/", {
    264260                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(),
    266262                security: '<?php echo wp_create_nonce( "bk-ajax-nonce" ); ?>' ,
    267263                provider : "clarafai"
     
    274270               
    275271                console.log( "tags results" ,tags );
     272                console.log( "tags post id" ,element );
    276273                // Update Product Tags
    277274                jQuery.ajax({ // We use jQuery instead $ sign, because Wordpress convention.
     
    320317     $postid = intval( esc_html($_POST['postid'] ));
    321318     $tags =  Wp_Smart_Tagger_recursive_sanitize_text_field($_POST['tags']) ;
    322      wp_set_object_terms($postid , [], 'product_tag');
    323319     wp_set_object_terms($postid , $tags, 'product_tag');
    324320     wp_die();
     
    346342
    347343?>
     344
     345
Note: See TracChangeset for help on using the changeset viewer.