Plugin Directory

Changeset 1248850


Ignore:
Timestamp:
09/18/2015 10:02:37 PM (11 years ago)
Author:
erichie
Message:

fix for copy feature, fix for statuses, other minor fixes

Location:
lingotek-translation
Files:
90 added
11 edited

Legend:

Unmodified
Added
Removed
  • lingotek-translation/trunk/admin/actions.php

    r1243686 r1248850  
    9696            ),
    9797
    98             'error' => array(
    99                 'title' => __('There was an error contacting Lingotek', 'wp-lingotek'),
    100                 'icon'  => 'warning'
    101             ),
     98            // Removed error reporting for release 1.1.2
     99            // 'error' => array(
     100            //  'title' => __('There was an error contacting Lingotek', 'wp-lingotek'),
     101            //  'icon'  => 'warning'
     102            // ),
    102103        );
    103104
     
    187188    }
    188189
    189     /*
    190      * outputs an API error icon
    191      *
    192      * @since 0.2
    193      *
    194      * @param string $name
    195      * @param string $additional parameters to add (js, target)
    196      */
    197     public static function display_error_icon($name, $api_error, $additional = '') {
    198         return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>',
    199             self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional);
    200     }
     190    // Removed error reporting for release 1.1.2
     191    // /*
     192    //  * outputs an API error icon
     193    //  *
     194    //  * @since 0.2
     195    //  *
     196    //  * @param string $name
     197    //  * @param string $additional parameters to add (js, target)
     198    //  */
     199    // public static function display_error_icon($name, $api_error, $additional = '') {
     200    //  return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>',
     201    //      self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional);
     202    // }
    201203
    202204    /*
     
    486488        check_ajax_referer('lingotek_progress', '_lingotek_nonce');
    487489        if ($document = $this->lgtm->get_group($this->type, $_POST['id'])) {
    488             $document->disassociate(); 
     490            $document->disassociate();
    489491        }
    490492        die();
  • lingotek-translation/trunk/admin/admin.php

    r1243686 r1248850  
    9696                foreach ($content_metadata as $group => $status) {
    9797                    $language_obj = $pllm->get_language($source_language);
     98                    $target_lang_obj = $pllm->get_language($language);
    9899                    $profile = Lingotek_Model::get_profile($taxonomy, $language_obj, $group);
    99100                    if ($profile['profile'] != 'disabled' && $status['source'] != false) {
    100101                        if (!isset($status[$language])) {
    101102                            $content_metadata[$group][$language]['status'] = "none";
    102                             if ($document->is_disabled_target($pllm->get_language($source_language), $pllm->get_language($language))) {
     103                            if ($document->is_disabled_target($pllm->get_language($source_language), $pllm->get_language($language)) || (isset($document->desc_array[$target_lang_obj->slug]) && !isset($document->source))) {
    103104                                $content_metadata[$group][$language]['status'] = 'disabled';
    104105                            }
  • lingotek-translation/trunk/admin/filters-columns.php

    r1243686 r1248850  
    9696
    9797        $document = $this->lgtm->get_group($type, $object_id);
     98        if (isset($document->source)) {
     99            $source_language = $type == 'post' ? $this->model->get_post_language($document->source) : $this->model->get_term_language($document->source);
     100        }
     101        else {
     102            $source_language = $lang;
     103        }
    98104
    99105        // FIXME not very clean
     
    101107
    102108        $profile = Lingotek_Model::get_profile($this->content_type, $language, $object_id);
     109        $source_profile = Lingotek_Model::get_profile($this->content_type, $lang, $id);
    103110        $disabled = 'disabled' == $profile['profile'];
    104111
     
    112119
    113120        // translation disabled
    114         elseif (isset($document->source) && $document->is_disabled_target($lang, $language) && !isset($document->translations[$language->locale])) {
     121        elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) {
    115122            return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id);
    116123    }
     
    165172    public function post_column($column, $post_id) {
    166173        $this->content_type = get_post_type($post_id);
    167        
     174
    168175        echo $this->_column('post', $column, $post_id);
    169176
     177        // Removed error reporting for release 1.1.2
    170178        // checking for api errors
    171         $column_language_only = substr($column, 0, 11);
    172         $group = $this->lgtm->get_group('post', $post_id);
    173        
    174         if ($group) {
    175             $source = $group->desc_array['lingotek']['source'];
    176             // remove the remnants of previous API errors if there aren't any current errors
    177             if (isset($group->desc_array['lingotek']['api_errors'])) {
    178                 $api_errors = $group->desc_array['lingotek']['api_errors'];
    179                 if (empty($api_errors)) {
    180                     unset($group->desc_array['lingotek']['api_errors']);
    181                 }
    182             }
    183             if ($column_language_only == $this->get_first_language_column() && $post_id === $source && isset($group->desc_array['lingotek']['api_errors'])) {
    184                 $error = $this->retrieve_api_error($group);
    185                 echo Lingotek_Actions::display_error_icon('error', $error);
    186             }
    187         }
     179        // $column_language_only = substr($column, 0, 11);
     180        // $group = $this->lgtm->get_group('post', $post_id);
     181
     182        // if ($group) {
     183        //  $source = $group->desc_array['lingotek']['source'];
     184        //  // remove the remnants of previous API errors if there aren't any current errors
     185        //  if (isset($group->desc_array['lingotek']['api_errors'])) {
     186        //      $api_errors = $group->desc_array['lingotek']['api_errors'];
     187        //      if (empty($api_errors)) {
     188        //          unset($group->desc_array['lingotek']['api_errors']);
     189        //          $group->save();
     190        //      }
     191        //  }
     192        //  if ($column_language_only == $this->get_first_language_column() && $post_id === $source && isset($group->desc_array['lingotek']['api_errors'])) {
     193        //      $error = $this->retrieve_api_error($group);
     194        //      echo Lingotek_Actions::display_error_icon('error', $error);
     195        //  }
     196        // }
    188197    }
    189198
     
    208217    }
    209218
    210 
    211     /*
    212     * collects and returns all API errors in the group object
    213     *
    214     * @since 1.1
    215     *
    216      * @param string $group
    217     */
    218     protected function retrieve_api_error($group) {
    219         $api_error = "\n";
    220 
    221         if (isset($group->desc_array['lingotek']['api_errors']['source_status'])){
    222             $source_status = $group->desc_array['lingotek']['api_errors']['source_status'];
    223             $api_error = $api_error . $source_status . "\n";
    224         }
    225         if (isset($group->desc_array['lingotek']['api_errors']['translations_status'])){
    226             $translations_status = $group->desc_array['lingotek']['api_errors']['translations_status'];
    227             $api_error = $api_error . $translations_status . "\n";
    228         }
    229         if (isset($group->desc_array['lingotek']['api_errors']['request_translation'])){
    230             $request_translation = $group->desc_array['lingotek']['api_errors']['request_translation'];
    231             $api_error = $api_error . $request_translation . "\n";
    232         }
    233         if (isset($group->desc_array['lingotek']['api_errors']['_request_translations'])) {
    234             $request_translations = $group->desc_array['lingotek']['api_errors']['_request_translations'];
    235             foreach ($request_translations as $lang => $error) {
    236                 $api_error = $api_error . $error . "\n";
    237             }
    238         }
    239         if (isset($group->desc_array['lingotek']['api_errors']['create_translation'])) {
    240             $create_translation = $group->desc_array['lingotek']['api_errors']['create_translation'];
    241             foreach ($create_translation as $locale => $error) {
    242                 $api_error = $api_error . $error . "\n";
    243             }
    244         }
    245         if (isset($group->desc_array['lingotek']['api_errors']['disassociate'])) {
    246             $disassociate = $group->desc_array['lingotek']['api_errors']['disassociate'];
    247             $api_error = $api_error . $disassociate . "\n";
    248         }
    249         if (isset($group->desc_array['lingotek']['api_errors']['patch'])) {
    250             $patch = $group->desc_array['lingotek']['api_errors']['patch'];
    251             $api_error = $api_error . $patch . "\n";
    252         }
    253         if (isset($group->desc_array['lingotek']['api_errors']['upload'])) {
    254             $upload = $group->desc_array['lingotek']['api_errors']['upload'];
    255             $api_error = $api_error . $upload . "\n";
    256         }
    257         return $api_error;
    258     }
     219    // Removed error reporting for release 1.1.2
     220    // /*
     221    // * collects and returns all API errors in the group object
     222    // *
     223    // * @since 1.1
     224    // *
     225    //  * @param string $group
     226    // */
     227    // protected function retrieve_api_error($group) {
     228    // $api_error = "\n";
     229
     230    // if (isset($group->desc_array['lingotek']['api_errors']['source_status'])){
     231    //      $source_status = $group->desc_array['lingotek']['api_errors']['source_status'];
     232    //      $api_error = $api_error . $source_status . "\n";
     233    // }
     234    // if (isset($group->desc_array['lingotek']['api_errors']['translations_status'])){
     235    //      $translations_status = $group->desc_array['lingotek']['api_errors']['translations_status'];
     236    //      $api_error = $api_error . $translations_status . "\n";
     237    // }
     238    // if (isset($group->desc_array['lingotek']['api_errors']['request_translation'])){
     239    //      $request_translation = $group->desc_array['lingotek']['api_errors']['request_translation'];
     240    //      $api_error = $api_error . $request_translation . "\n";
     241    // }
     242    // if (isset($group->desc_array['lingotek']['api_errors']['_request_translations'])) {
     243    //      $request_translations = $group->desc_array['lingotek']['api_errors']['_request_translations'];
     244    //      foreach ($request_translations as $lang => $error) {
     245    //          $api_error = $api_error . $error . "\n";
     246    //      }
     247    // }
     248    // if (isset($group->desc_array['lingotek']['api_errors']['create_translation'])) {
     249    //      $create_translation = $group->desc_array['lingotek']['api_errors']['create_translation'];
     250    //      foreach ($create_translation as $locale => $error) {
     251    //          $api_error = $api_error . $error . "\n";
     252    //      }
     253    // }
     254    // if (isset($group->desc_array['lingotek']['api_errors']['disassociate'])) {
     255    //      $disassociate = $group->desc_array['lingotek']['api_errors']['disassociate'];
     256    //      $api_error = $api_error . $disassociate . "\n";
     257    // }
     258    // if (isset($group->desc_array['lingotek']['api_errors']['patch'])) {
     259    //      $patch = $group->desc_array['lingotek']['api_errors']['patch'];
     260    //      $api_error = $api_error . $patch . "\n";
     261    // }
     262    // if (isset($group->desc_array['lingotek']['api_errors']['upload'])) {
     263    //      $upload = $group->desc_array['lingotek']['api_errors']['upload'];
     264    //      $api_error = $api_error . $upload . "\n";
     265    // }
     266    // return $api_error;
     267    // }
    259268}
  • lingotek-translation/trunk/css/admin.css

    r1243686 r1248850  
    8888
    8989.lingotek-error {
    90   color: #FF0000;
     90  color: #999999;
    9191}
    9292
  • lingotek-translation/trunk/include/api.php

    r1243686 r1248850  
    188188            }
    189189        }
    190         else {
    191             if (wp_remote_retrieve_response_code($response) != 404) {
    192                 return false;
    193             }
    194         }
     190        // Removed error reporting for release 1.1.2
     191        // else {
     192        //  if (empty(wp_remote_retrieve_response_code($response))) {
     193        //      return false;
     194        //  }
     195        // }
    195196
    196197        return empty($translations) ? array() : $translations;
  • lingotek-translation/trunk/include/group-post.php

    r1243686 r1248850  
    5656            );
    5757
    58         // if the user hasn't visited the custom fields tab, and hasn't saved actions for custom 
    59         // fields, and uploaded a post, check the wpml file for settings 
     58        // if the user hasn't visited the custom fields tab, and hasn't saved actions for custom
     59        // fields, and uploaded a post, check the wpml file for settings
    6060        if ($post_ID) {
    6161            self::get_updated_meta_values($post_ID);
     
    108108    static public function get_custom_fields_from_wp_postmeta($post_ID = NULL) {
    109109        $custom_fields = get_option('lingotek_custom_fields', array());
    110         $meta_black_list = array('_encloseme', '_edit_last', '_edit_lock', '_wp_trash_meta_status', '_wp_trash_meta_time'); 
     110        $meta_black_list = array('_encloseme', '_edit_last', '_edit_lock', '_wp_trash_meta_status', '_wp_trash_meta_time');
    111111        $arr = array();
    112112        $keys = array();
     
    154154
    155155    /*
    156      * updates meta (custom) fields values in the lingotek_custom_fields option 
     156     * updates meta (custom) fields values in the lingotek_custom_fields option
    157157     *
    158158     * @since 0.2
     
    198198
    199199    /*
    200      * returns cached meta (custom) fields values in the lingotek_custom_fields option 
     200     * returns cached meta (custom) fields values in the lingotek_custom_fields option
    201201     *
    202202     * @since 0.2
     
    255255            }
    256256        }
    257        
     257
    258258        return json_encode($arr);
    259259    }
     
    294294
    295295        if (false === ($translation = $client->get_translation($this->document_id, $locale))) {
    296             // Error reporting here causes problems. FIXME
     296            // Error reporting removed for release 1.1.2
    297297            // $this->desc_array['lingotek']['api_errors']['create_translation'][$locale] = __('Error downloading ', 'wp-lingotek') . $locale . __(' translation for post ', 'wp-lingotek') . $this->source;
    298298            // $this->save();
    299299            return;
    300300        }
    301         // else {
    302         //  unset($this->desc_array['lingotek']['api_errors']['create_translation'][$locale]);
    303         //  $this->save();
    304         // }
     301        //else {
     302            // unset($this->desc_array['lingotek']['api_errors']['create_translation'][$locale]);
     303            // if (empty($this->desc_array['lingotek']['api_errors']['create_translation'])) {
     304            //  unset($this->desc_array['lingotek']['api_errors']['create_translation']);
     305            // }
     306            // $this->save();
     307        //}
    305308
    306309        self::$creating_translation = true;
  • lingotek-translation/trunk/include/group.php

    r1243686 r1248850  
    140140            $this->status = 'importing';
    141141            $this->translations = array_fill_keys(array_keys($this->translations), 'pending');
    142             unset($this->desc_array['lingotek']['api_errors']['patch']);
     142            // Removed error reporting for release 1.1.2
     143            // unset($this->desc_array['lingotek']['api_errors']['patch']);
     144            // $this->save();
     145        // }
     146        // else {
     147        //  $this->desc_array['lingotek']['api_errors']['patch'] = __('Error uploading updated post ', 'wp-lingotek') . $this->source;
     148        $this->save();
     149        }
     150    }
     151
     152    /*
     153     * checks the status of source document
     154     *
     155     * @since 0.2
     156     */
     157    public function source_status() {
     158        $client = new Lingotek_API();
     159
     160        if ('importing' == $this->status && $client->document_exists($this->document_id)) {
     161            $this->status = 'current';
    143162            $this->save();
    144163        }
    145         else {
    146             $this->desc_array['lingotek']['api_errors']['patch'] = __('Error uploading updated post ', 'wp-lingotek') . $this->source;
    147             $this->save();
    148         }
    149     }
    150 
    151     /*
    152      * checks the status of source document
    153      *
    154      * @since 0.2
    155      */
    156     public function source_status() {
    157         $client = new Lingotek_API();
    158 
    159         if ($client->document_exists($this->document_id)) {
    160             unset($this->desc_array['lingotek']['api_errors']['source_status']);
    161             if ('importing' == $this->status) {
    162                 $this->status = 'current';
    163             }
    164         }
    165         // note api errors
    166         else {
    167             $this->desc_array['lingotek']['api_errors']['source_status'] = __('Error updating translation status of post ', 'wp-lingotek') . $this->source;
    168         }
    169 
    170         $this->save();
     164
     165        // Removed error reporting for release 1.1.2
     166        // $response = $client->document_exists($this->document_id);
     167
     168        // if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
     169        //  unset($this->desc_array['lingotek']['api_errors']['source_status']);
     170        //  if ('importing' == $this->status) {
     171        //      $this->status = 'current';
     172        //  }
     173        // }
     174        // elseif (400 == wp_remote_retrieve_response_code($response) || empty(wp_remote_retrieve_response_code($response))) {
     175        //  $this->desc_array['lingotek']['api_errors']['source_status'] = __('Error updating source status of post ', 'wp-lingotek') . $this->source;
     176        // }
     177
     178        // $this->save();
    171179    }
    172180
     
    195203
    196204        if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale])) {
    197             if ($client->request_translation($this->document_id, $language->locale, $args)) {
    198                 $this->status = 'current';
    199                 $this->translations[$language->locale] = 'pending';
    200                 unset($this->desc_array['lingotek']['api_errors']['request_translation']);
    201             }
    202             else {
    203                 $this->desc_array['lingotek']['api_errors']['request_translation'] = __('Error requesting translations for post ', 'wp-lingotek') . $this->source;
    204             }
    205            
     205            $client->request_translation($this->document_id, $language->locale, $args);
     206            $this->status = 'current';
     207            $this->translations[$language->locale] = 'pending';
     208            // Removed error reporting for release 1.1.2
     209            // if ($client->request_translation($this->document_id, $language->locale, $args)) {
     210            //  $this->status = 'current';
     211            //  $this->translations[$language->locale] = 'pending';
     212            //  unset($this->desc_array['lingotek']['api_errors']['request_translation']);
     213            //  unset($this->desc_array['lingotek']['api_errors']['_request_translations']);
     214            // }
     215            // else {
     216            //  $this->desc_array['lingotek']['api_errors']['request_translation'] = __('Error requesting translation for ' . $language->name . ' for post ', 'wp-lingotek') . $this->source;
     217            // }
     218
    206219            $this->save();
    207220        }
     
    222235                $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $source_language, $lang, $this->source);
    223236                $args = $workflow ? array('workflow_id' => $workflow) : array();
    224                 if ($client->request_translation($this->document_id, $lang->lingotek_locale, $args)) {
    225                     $this->status = 'current';
    226                     $this->translations[$lang->locale] = 'pending';
    227                     unset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name]);
    228                 }
    229                 else {
    230                     $this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name] = __('Error requesting translation for ', 'wp-lingotek') . $lang->name . __(' for post ', 'wp-lingotek') . $this->source;
    231                 }
     237                $client->request_translation($this->document_id, $lang->lingotek_locale, $args);
     238                $this->status = 'current';
     239                $this->translations[$lang->locale] = 'pending';
     240                // Removed error reporting for release 1.1.2
     241                // if ($client->request_translation($this->document_id, $lang->lingotek_locale, $args)) {
     242                //  $this->status = 'current';
     243                //  $this->translations[$lang->locale] = 'pending';
     244                //  unset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name]);
     245                //  unset($this->desc_array['lingotek']['api_errors']['request_translation']);
     246                //  if (empty($this->desc_array['lingotek']['api_errors']['_request_translations'])) {
     247                //      unset($this->desc_array['lingotek']['api_errors']['_request_translations']);
     248                //  }
     249                // }
     250                // else {
     251                //  if (!isset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name])) {
     252                //      $this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name] = __('Error requesting translation for ', 'wp-lingotek') . $lang->name . __(' for post ', 'wp-lingotek') . $this->source;
     253                //  }
     254                // }
    232255            }
    233256        }
     
    244267        $client = new Lingotek_API();
    245268        $translations = $client->get_translations_status($this->document_id); // key are Lingotek locales
    246         if ($translations !== false) {
    247             foreach($this->translations as $locale => $status) {
    248                 $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
    249                 if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
    250                     $this->translations[$locale] = 'ready';
    251             }
    252             unset($this->desc_array['lingotek']['api_errors']['translations_status']);
    253             $this->save();
    254         }
    255         // take note of api errors
    256         else {
    257             $this->desc_array['lingotek']['api_errors']['translations_status'] = __('Error checking translations status of post ', 'wp-lingotek') . $this->source;
    258             $this->save();
    259         }
     269        foreach($this->translations as $locale => $status) {
     270            $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
     271            if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
     272                $this->translations[$locale] = 'ready';
     273        // Removed error reporting for release 1.1.2
     274        // if ($translations !== false) {
     275        //  foreach($this->translations as $locale => $status) {
     276        //      $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale;
     277        //      if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale])
     278        //          $this->translations[$locale] = 'ready';
     279        //  }
     280        //  unset($this->desc_array['lingotek']['api_errors']['translations_status']);
     281        //  $this->save();
     282        // }
     283        // // take note of api errors
     284        // else {
     285        //  $this->desc_array['lingotek']['api_errors']['translations_status'] = __('Error checking translations status of post ', 'wp-lingotek') . $this->source;
     286        //  $this->save();
     287        }
     288        $this->save();
    260289    }
    261290
  • lingotek-translation/trunk/include/model.php

    r1243686 r1248850  
    99class Lingotek_Model {
    1010    public $pllm; // Polylang model
     11    static public $copying_post;
     12    static public $copying_term;
    1113
    1214    /*
     
    210212     */
    211213    public function copy_post($post, $target) {
     214        self::$copying_post = true;
    212215        $document = $this->get_group('post', $post->ID);
    213216        $prefs = self::get_prefs();
     
    226229                $document->desc_array[$target] = $new_post_id;
    227230                $document->save();
    228                 return $new_post_id;
    229             }
    230             else {
    231                 return false;
    232             }
    233         }
    234         else {
    235             return false;
    236         }
     231            }
     232        }
     233        self::$copying_post = false;
    237234    }
    238235
    239236    public function copy_term($term, $target, $taxonomy) {
     237        self::$copying_term = true;
    240238        $document = $this->get_group('term', $term->term_id);
    241239        $cp_lang = $this->pllm->get_language($target);
     
    254252            $document->save();
    255253        }
     254        self::$copying_term = false;
    256255    }
    257256
     
    298297        }
    299298
    300         elseif (!Lingotek_Group::$creating_translation) {
     299        elseif (!Lingotek_Group::$creating_translation && !self::$copying_post) {
    301300            $document_id = $client->upload_document($params);
    302301
    303302            if ($document_id) {
    304303                Lingotek_Group_Post::create($post->ID , $language, $document_id);
    305                 $group = $this->get_group('post', $post_id);
    306                 unset($group->desc_array['lingotek']['api_errors']['upload']);
    307                 $group->save();
    308             }
    309             else {
    310                 $group = $this->get_group('post', $post_id);
    311                 $group->desc_array['lingotek']['api_errors']['upload'] = __('Error uploading post ', 'wp-lingotek') . $group->source;
    312                 $group->save();
    313             }
    314         }
    315 
    316         // If a translation profile has targets set to copy then copy them
    317         $targets_to_copy = $this->targets_to_be_copied($profile);
    318         if (!empty($targets_to_copy)) {
    319             foreach ($targets_to_copy as $target) {
    320                 $this->copy_post($post, $target);
    321             }
     304
     305                // If a translation profile has targets set to copy then copy them
     306                $targets_to_copy = $this->targets_to_be_copied($profile);
     307                if (!empty($targets_to_copy)) {
     308                    foreach ($targets_to_copy as $target) {
     309                        $this->copy_post($post, $target);
     310                    }
     311                }
     312                // Error reporting commented out for release 1.1.2
     313                // $group = $this->get_group('post', $post_id);
     314                // unset($group->desc_array['lingotek']['api_errors']['upload']);
     315                // $group->save();
     316            }
     317            // else {
     318            //  $group = $this->get_group('post', $post_id);
     319            //  $group->desc_array['lingotek']['api_errors']['upload'] = __('Error uploading post ', 'wp-lingotek') . $group->source;
     320            //  $group->save();
     321            // }
    322322        }
    323323    }
     
    364364        }
    365365
    366         elseif (!Lingotek_Group::$creating_translation) {
     366        elseif (!Lingotek_Group::$creating_translation && !self::$copying_term) {
    367367            $document_id = $client->upload_document($params);
    368368
    369369            if ($document_id) {
    370370                Lingotek_Group_Term::create($term_id, $taxonomy , $language, $document_id);
    371             }
    372         }
    373 
    374         // If a translation profile has targets set to copy then copy them
    375         $targets_to_copy = $this->targets_to_be_copied($profile);
    376         if (!empty($targets_to_copy)) {
    377             foreach ($targets_to_copy as $target) {
    378                 $this->copy_term($term, $target, $taxonomy);
     371
     372                // If a translation profile has targets set to copy then copy them
     373                $targets_to_copy = $this->targets_to_be_copied($profile);
     374                if (!empty($targets_to_copy)) {
     375                    foreach ($targets_to_copy as $target) {
     376                        $this->copy_term($term, $target, $taxonomy);
     377                    }
     378                }
    379379            }
    380380        }
     
    473473
    474474                return !empty($language) && (empty($document) ||
    475                     (1 == count($this->pllm->get_translations($type, $object_id)) && empty($document->source))  || // specific for terms as document is never empty
     475                    (empty($document->translations) && empty($document->source))  || // specific for terms as document is never empty
    476476                    (isset($document) && 'edited' == $document->status && $document->source == $object_id));
    477477        }
  • lingotek-translation/trunk/js/defaults.js

    r1243686 r1248850  
    1818}
    1919
    20 
    2120jQuery(document).ready(function($) {
    22     if ($('#lingotek_profile_meta').val() == 'default') {
     21    function init_profiles() {
     22        var pl_choice = $('#post_lang_choice').val();
     23        var content_profiles = $('#lingotek-language-profiles').text();
     24        var content_json = $.parseJSON(content_profiles);
     25        var profile_name = content_json[pl_choice] ? content_json[pl_choice] : content_json.defaults.content_default;
     26        $('#lingotek_profile_meta option:first').text(content_json.defaults.title + ' (' + profile_name + ')');
     27    }
     28  if ($('#lingotek_profile_meta').val() == 'default') {
    2329        $('#post_lang_choice').change(function(){
    24             var pl_choice = $('#post_lang_choice').val();
    25             var content_profiles = $('#lingotek-language-profiles').text();
    26             var content_json = $.parseJSON(content_profiles);
    27             var profile_name = content_json[pl_choice] ? content_json[pl_choice] : content_json.defaults.content_default;
    28 
    29             $('#lingotek_profile_meta option:first').text(content_json.defaults.title + ' (' + profile_name + ')');
    30         }).change();
     30            init_profiles();
     31        });
     32        init_profiles();
    3133    }
    3234});
  • lingotek-translation/trunk/lingotek.php

    r1243686 r1248850  
    33Plugin name: Lingotek Translation
    44Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
    5 Version: 1.1.1
     5Version: 1.1.2
    66Author: Lingotek and Frédéric Demarle
    77Author uri: http://lingotek.com
     
    1616    exit();
    1717
    18 define('LINGOTEK_VERSION', '1.1.1'); // plugin version (should match above meta)
     18define('LINGOTEK_VERSION', '1.1.2'); // plugin version (should match above meta)
    1919define('LINGOTEK_MIN_PLL_VERSION', '1.7.4.2');
    2020define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
  • lingotek-translation/trunk/readme.txt

    r1243686 r1248850  
    55Requires at least: 3.8
    66Tested up to: 4.3
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    119119== Changelog ==
    120120
     121= 1.1.2 (2015-09-18) =
     122
     123* Fix for copy feature
     124* Fix for content status displays
     125* Other minor fixes
     126
    121127= 1.1.1 (2015-09-11) =
    122128
Note: See TracChangeset for help on using the changeset viewer.