Plugin Directory

Changeset 2818386


Ignore:
Timestamp:
11/15/2022 03:34:28 PM (3 years ago)
Author:
frpet
Message:

Handle package strings and full post at once

Location:
easytranslate/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • easytranslate/trunk/README.txt

    r2801060 r2818386  
    44Tags: translation, wpml, easytranslate, multilingual, translate
    55Requires at least: 4.7
    6 Tested up to: 6.0
    7 Stable tag: 4.10
     6Tested up to: 6.1
     7Stable tag: 4.11
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • easytranslate/trunk/admin/class-easy-translate-translation-list.php

    r2801060 r2818386  
    310310     * @param array $langs
    311311     * @param int   $status
     312     * @throws Exception
    312313     */
    313314    public static function update_duplicate_status(array $ids, array $langs, int $status)
     
    340341    protected static function duplicate_post($post_id, $lang)
    341342    {
     343        /** @var SitePress $sitepress */
    342344        global $sitepress;
    343345
     
    461463        array $yoast_seo = []
    462464    ) {
    463         $update = '';
     465        $update = [];
    464466        if ($post_title) {
    465             $update .= ', post_title="' . esc_sql($post_title) . '"';
     467            $update[] = 'post_title="' . esc_sql($post_title) . '"';
     468        }
     469        if ($post_content) {
     470            $update[] = 'post_content="' . esc_sql($post_content) . '"';
    466471        }
    467472        if ($post_excerpt) {
    468             $update .= ', post_excerpt="' . esc_sql($post_excerpt) . '"';
    469         }
    470 
    471         global $wpdb;
    472         $post_content = esc_sql($post_content);
    473         $query = "UPDATE {$wpdb->prefix}posts SET post_content = '{$post_content}' {$update} WHERE id = {$post_id}";
     473            $update[] = 'post_excerpt="' . esc_sql($post_excerpt) . '"';
     474        }
     475        $update = implode(', ', $update);
     476
     477        global $wpdb;
     478        $query = "UPDATE {$wpdb->prefix}posts SET {$update} WHERE id = {$post_id}";
    474479        $wpdb->query($query);
    475480
     
    650655                $a_string_id[] = $string['id'];
    651656            }
    652             if ($post->post_title) {
    653                 $content['post_strings'][$post_id]['title'] = $post->post_title;
    654             }
    655         } elseif ($post) {
    656             if ($post->post_content) {
     657        }
     658        if ($post) {
     659            if ($post->post_content && !$package_id) {
    657660                $content['post_full'][$post_id]['content'] = $post->post_content;
    658661            }
  • easytranslate/trunk/admin/class-easy-translate-translation.php

    r2795813 r2818386  
    2828
    2929            foreach ($content as $item) {
    30                 $handler = key($item) . '_handler';
    31                 $this->$handler(current($item), $target_language);
     30                foreach ($item as $handlerName => $translations) {
     31                    $handler = "{$handlerName}_handler";
     32                    $this->$handler($translations, $target_language);
     33                }
    3234            }
    3335        }
     
    4547    protected function post_strings_handler($content, $target_language)
    4648    {
    47         if (isset(current($content)['title']) && current($content)['title']) {
    48             if ($source_translations = Easy_Translate_Post_Translation_List::get_translations_by_element_id(key($content))) {
    49                 $translations = Easy_Translate_Post_Translation_List::get_translations_by_source(
    50                     $source_translations,
    51                     $target_language
    52                 );
    53                 if ($translations) {
    54                     Easy_Translate_Post_Translation_List::update_post_title(
    55                         $translations['element_id'],
    56                         current($content)['title']
    57                     );
    58                 }
    59             }
    60         }
    61 
    6249        $this->strings_handler(current($content)['content'], $target_language);
    6350    }
  • easytranslate/trunk/easy-translate.php

    r2801060 r2818386  
    1515 * Plugin URI:        https://www.easytranslate.com/en/integrations/cms/wordpress-plugin/
    1616 * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    17  * Version:           1.9.1
     17 * Version:           1.9.2
    1818 * Author:            EasyTranslate
    1919 * Author URI:        https://easytranslate.com
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define('EASY_TRANSLATE_VERSION', '1.9.1');
     36define('EASY_TRANSLATE_VERSION', '1.9.2');
    3737
    3838/**
Note: See TracChangeset for help on using the changeset viewer.