Plugin Directory

Changeset 2772023


Ignore:
Timestamp:
08/18/2022 10:39:37 AM (4 years ago)
Author:
frpet
Message:

Attempt to fix duplication of post

Location:
easytranslate/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • easytranslate/trunk/README.txt

    r2771692 r2772023  
    55Requires at least: 4.7
    66Tested up to: 6.0
    7 Stable tag: 4.5
     7Stable tag: 4.6
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • easytranslate/trunk/admin/class-easy-translate-post-translation-list.php

    r2771692 r2772023  
    367367            );
    368368            $this->update_string_status($a_string_id, self::STATUS_WAITING);
    369             $this->update_duplicate_status(
    370                 $_REQUEST['posts'],
    371                 array_keys($_REQUEST['target_languages']),
    372                 self::STATUS_WAITING
    373             );
     369            try {
     370                $this->update_duplicate_status(
     371                    $_REQUEST['posts'],
     372                    array_keys($_REQUEST['target_languages']),
     373                    self::STATUS_WAITING
     374                );
     375            } catch (\Exception $exception) {
     376                add_settings_error(
     377                    '',
     378                    'translate-error',
     379                    $exception->getMessage(),
     380                    'error'
     381                );
     382            }
    374383        }
    375384    }
  • easytranslate/trunk/admin/class-easy-translate-translation-list.php

    r2771692 r2772023  
    326326     * @param $post_id
    327327     * @param $lang
     328     * @throws Exception
    328329     */
    329330    protected static function duplicate_post($post_id, $lang)
    330331    {
    331         $url = get_site_url() . '/wp-admin/admin-ajax.php';
    332         $args = [
    333             'body'    => [
    334                 'action'                       => 'wpml_duplicate_dashboard',
    335                 'duplicate_post_ids[]'         => $post_id,
    336                 'duplicate_target_languages[]' => $lang,
    337                 '_icl_nonce'                   => wp_create_nonce('wpml_duplicate_dashboard_nonce'),
    338             ],
    339             'headers' => [
    340                 'Content-Type' => 'application/x-www-form-urlencoded',
    341                 'Accept'       => 'application/json, text/javascript, */*',
    342             ],
    343             'cookies' => $_COOKIE,
    344             'timeout' => 300,
    345         ];
    346         wp_remote_post($url, $args);
     332        global $sitepress;
     333
     334        if ($sitepress->make_duplicate($post_id, $lang) === false) {
     335            throw new Exception('Unable to duplicate post');
     336        }
    347337    }
    348338
  • easytranslate/trunk/easy-translate.php

    r2771692 r2772023  
    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.7.2
     17 * Version:           1.7.3
    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.7.2');
     36define('EASY_TRANSLATE_VERSION', '1.7.3');
    3737
    3838/**
Note: See TracChangeset for help on using the changeset viewer.