Compatible sync translation with wp cli
-
Hey,
It seems the sync translation doesn’t work while you are updating a product through wp cli, for support it, please make below changes:
1. classes/class-woocommerce-wpml.php L199
if ( is_admin() || wpml_is_rest_request() ) { }
Should changed to:
if (is_admin() || wpml_is_rest_request() || defined('WP_CLI')) { }
2. Add a new method in class
woocommerce_wpml
public function get_sync_object() { return $this->sync_product_data; }
3. inc/translation-editor/class-wcml-synchronize-product-data.php L95
$trashing = isset( $_GET['action'] ) && 'trash' === $_GET['action']; if ( $post_type !== 'product' || empty( $original_product_id ) || isset( $_POST['autosave'] ) || ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'admin.php' && ! $ajax_call && ! $api_call ) || $trashing || $auto_draft ) { return; }
Should changed to:
$trashing = isset( $_GET['action'] ) && 'trash' === $_GET['action']; if ( !defined('WP_CLI') and $post_type !== 'product' || empty( $original_product_id ) || isset( $_POST['autosave'] ) || ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'admin.php' && ! $ajax_call && ! $api_call ) || $trashing || $auto_draft ) { return; }
If you have a git repository for your plugin, then let me know, I’ll send a pull request.
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Compatible sync translation with wp cli’ is closed to new replies.