Version Description
Download this release
Release Info
Developer | johnclause |
Plugin | WooCommerce & qTranslate-X |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.1
- qwc-admin.php +160 -1
- qwc-front.php +13 -0
- readme.txt +10 -2
- woocommerce-qtranslate-x.php +2 -3
qwc-admin.php
CHANGED
@@ -1,6 +1,50 @@
|
|
1 |
<?php
|
2 |
if(!defined('ABSPATH'))exit;
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
add_filter('qtranslate_load_admin_page_config','qwc_add_admin_page_config');
|
5 |
function qwc_add_admin_page_config($page_configs)
|
6 |
{
|
@@ -19,6 +63,8 @@ function qwc_add_admin_page_config($page_configs)
|
|
19 |
|
20 |
//$fields[] = array( 'tag' => 'INPUT', 'class' => 'attribute_name' );//needs more work
|
21 |
//$fields[] = array( 'class' => 'attribute_name', 'encode' => 'display' );//catches some twice
|
|
|
|
|
22 |
$fields[] = array( 'tag' => 'TD', 'class' => 'attribute_name', 'encode' => 'display' );
|
23 |
$fields[] = array( 'tag' => 'STRONG', 'class' => 'attribute_name', 'encode' => 'display' );
|
24 |
$fields[] = array( 'tag' => 'OPTION', 'encode' => 'display' );
|
@@ -49,7 +95,7 @@ function qwc_add_admin_page_config($page_configs)
|
|
49 |
$page_configs[] = $page_config;
|
50 |
}
|
51 |
|
52 |
-
{//edit-tags.php?taxonomy=
|
53 |
$page_config = array();
|
54 |
$page_config['pages'] = array( 'edit-tags.php' => 'post_type=product');
|
55 |
//$page_config['anchors'] = array( 'col-container' );
|
@@ -62,10 +108,14 @@ function qwc_add_admin_page_config($page_configs)
|
|
62 |
$f['fields'] = array();
|
63 |
$fields = &$f['fields']; // shorthand
|
64 |
|
|
|
|
|
|
|
65 |
$fields[] = array( 'tag' => 'H2', 'container_class' => 'wrap', 'encode' => 'display' );
|
66 |
$fields[] = array( 'tag' => 'H3', 'container_id' => 'col-left', 'encode' => 'display' );
|
67 |
$fields[] = array( 'id' => 'search-submit', 'attr' => 'value', 'encode' => 'display' );
|
68 |
$fields[] = array( 'id' => 'submit', 'attr' => 'value', 'encode' => 'display' );
|
|
|
69 |
//$fields[] = array( 'id' => '' );
|
70 |
|
71 |
$page_config['forms'][] = $f;
|
@@ -528,3 +578,112 @@ function qwc_useAdminTermLibJoin($obj, $taxonomies=null, $args=null) {
|
|
528 |
//add_filter('get_term', 'qwc_useAdminTermLibJoin', 4, 2);
|
529 |
add_filter('get_terms', 'qwc_useAdminTermLibJoin', 4, 3);
|
530 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
if(!defined('ABSPATH'))exit;
|
3 |
|
4 |
+
function qwc_add_filters_admin() {
|
5 |
+
//priority 20 is used because in case other plugins add some untranslated content on normal priority, it will still hopefully then get translated.
|
6 |
+
$use_filters = array(
|
7 |
+
// Email subjects
|
8 |
+
'woocommerce_email_subject_customer_invoice_paid' => 20,
|
9 |
+
'woocommerce_email_subject_customer_invoice' => 20,
|
10 |
+
'woocommerce_email_subject_customer_completed_order' => 20,
|
11 |
+
'woocommerce_email_subject_low_stock' => 20,
|
12 |
+
'woocommerce_email_subject_no_stock' => 20,
|
13 |
+
'woocommerce_email_subject_backorder' => 20,
|
14 |
+
'woocommerce_email_subject_customer_note' => 20,
|
15 |
+
'woocommerce_email_subject_cancelled_order' => 20,
|
16 |
+
'woocommerce_email_subject_customer_new_account' => 20,
|
17 |
+
'woocommerce_email_subject_customer_processing_order' => 20,
|
18 |
+
'woocommerce_email_subject_customer_refunded_order' => 20,
|
19 |
+
'woocommerce_email_subject_customer_reset_password' => 20,
|
20 |
+
'woocommerce_email_subject_new_order' => 20,
|
21 |
+
|
22 |
+
// Email headings
|
23 |
+
'woocommerce_email_heading_customer_invoice_paid' => 20,
|
24 |
+
'woocommerce_email_heading_customer_invoice' => 20,
|
25 |
+
'woocommerce_email_heading_customer_completed_order' => 20,
|
26 |
+
'woocommerce_email_heading_low_stock' => 20,
|
27 |
+
'woocommerce_email_heading_no_stock' => 20,
|
28 |
+
'woocommerce_email_heading_backorder' => 20,
|
29 |
+
'woocommerce_email_heading_customer_note' => 20,
|
30 |
+
'woocommerce_email_heading_cancelled_order' => 20,
|
31 |
+
'woocommerce_email_heading_customer_new_account' => 20,
|
32 |
+
'woocommerce_email_heading_customer_processing_order' => 20,
|
33 |
+
'woocommerce_email_heading_customer_refunded_order' => 20,
|
34 |
+
'woocommerce_email_heading_customer_reset_password' => 20,
|
35 |
+
'woocommerce_email_heading_new_order' => 20,
|
36 |
+
|
37 |
+
// Email body
|
38 |
+
'woocommerce_email_footer_text' => 20,
|
39 |
+
//'woocommerce_email_order_items_table' => 20,//see below
|
40 |
+
);
|
41 |
+
|
42 |
+
foreach ( $use_filters as $name => $priority ) {
|
43 |
+
add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
qwc_add_filters_admin();
|
47 |
+
|
48 |
add_filter('qtranslate_load_admin_page_config','qwc_add_admin_page_config');
|
49 |
function qwc_add_admin_page_config($page_configs)
|
50 |
{
|
63 |
|
64 |
//$fields[] = array( 'tag' => 'INPUT', 'class' => 'attribute_name' );//needs more work
|
65 |
//$fields[] = array( 'class' => 'attribute_name', 'encode' => 'display' );//catches some twice
|
66 |
+
$fields[] = array( 'class' => 'order_number', 'encode' => 'display' );
|
67 |
+
$fields[] = array( 'class' => 'display_meta', 'encode' => 'display' );
|
68 |
$fields[] = array( 'tag' => 'TD', 'class' => 'attribute_name', 'encode' => 'display' );
|
69 |
$fields[] = array( 'tag' => 'STRONG', 'class' => 'attribute_name', 'encode' => 'display' );
|
70 |
$fields[] = array( 'tag' => 'OPTION', 'encode' => 'display' );
|
95 |
$page_configs[] = $page_config;
|
96 |
}
|
97 |
|
98 |
+
{//edit-tags.php?taxonomy=xxx&post_type=product
|
99 |
$page_config = array();
|
100 |
$page_config['pages'] = array( 'edit-tags.php' => 'post_type=product');
|
101 |
//$page_config['anchors'] = array( 'col-container' );
|
108 |
$f['fields'] = array();
|
109 |
$fields = &$f['fields']; // shorthand
|
110 |
|
111 |
+
//all input fields are ok from default qTranslate-X configuration
|
112 |
+
|
113 |
+
$fields[] = array( 'tag' => 'LABEL', 'container_class' => 'screen-options', 'encode' => 'display' );
|
114 |
$fields[] = array( 'tag' => 'H2', 'container_class' => 'wrap', 'encode' => 'display' );
|
115 |
$fields[] = array( 'tag' => 'H3', 'container_id' => 'col-left', 'encode' => 'display' );
|
116 |
$fields[] = array( 'id' => 'search-submit', 'attr' => 'value', 'encode' => 'display' );
|
117 |
$fields[] = array( 'id' => 'submit', 'attr' => 'value', 'encode' => 'display' );
|
118 |
+
$fields[] = array( 'id' => 'search-submit', 'attr' => 'value', 'encode' => 'display' );
|
119 |
//$fields[] = array( 'id' => '' );
|
120 |
|
121 |
$page_config['forms'][] = $f;
|
578 |
//add_filter('get_term', 'qwc_useAdminTermLibJoin', 4, 2);
|
579 |
add_filter('get_terms', 'qwc_useAdminTermLibJoin', 4, 3);
|
580 |
*/
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Append the language to the link for changing the order status, so that mails are sent in the language the customer used during the order process
|
584 |
+
* @since 1.1
|
585 |
+
*/
|
586 |
+
function qwc_admin_url_append_language($url) {
|
587 |
+
if ( strpos( $url, 'action=woocommerce_mark_order_status' ) ) {
|
588 |
+
$components = parse_url( $url );
|
589 |
+
$params = array();
|
590 |
+
|
591 |
+
parse_str( $components['query'], $params );
|
592 |
+
|
593 |
+
$order_id = absint( $params['order_id'] );
|
594 |
+
$user_language = get_post_meta( $order_id, '_user_language', true );
|
595 |
+
|
596 |
+
if ( $user_language ) {
|
597 |
+
$url .= '&lang=' . $user_language;
|
598 |
+
}
|
599 |
+
}
|
600 |
+
return $url;
|
601 |
+
}
|
602 |
+
add_filter('admin_url', 'qwc_admin_url_append_language');
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Append the language to ajax links on the order edit page, so that mails are sent in the language the customer used during the order process
|
606 |
+
* @since 1.1
|
607 |
+
*/
|
608 |
+
function qwc_admin_url_append_language_edit_page( $url ) {
|
609 |
+
global $post;
|
610 |
+
if ( strpos( $url, 'admin-ajax.php' ) && isset( $_GET['action'] ) && isset( $_GET['post'] ) && $_GET['action'] == 'edit' ) {
|
611 |
+
$order_id = absint( $_GET['post'] );
|
612 |
+
$post = get_post( $order_id );
|
613 |
+
if ( $post->post_type != 'shop_order' ) {
|
614 |
+
return $url;
|
615 |
+
}
|
616 |
+
$user_language = get_post_meta( $order_id, '_user_language', true );
|
617 |
+
|
618 |
+
if ( $user_language ) {
|
619 |
+
$url .= '?lang=' . $user_language;
|
620 |
+
}
|
621 |
+
}
|
622 |
+
return $url;
|
623 |
+
}
|
624 |
+
add_filter('admin_url', 'qwc_admin_url_append_language_edit_page' );
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Option 'woocommerce_email_from_name' needs to be translated for e-mails, and needs to stay untranslated for settings.
|
628 |
+
* @since 1.1
|
629 |
+
*/
|
630 |
+
function qwc_admin_email_option($val) {
|
631 |
+
global $q_config;
|
632 |
+
global $pagenow;
|
633 |
+
//qtranxf_dbg_log('qwc_admin_email_option('.$val.'): $pagenow: ',$pagenow);
|
634 |
+
switch($pagenow){
|
635 |
+
case 'admin-ajax.php':
|
636 |
+
case 'post.php':
|
637 |
+
return qtranxf_use($q_config['language'], $val, false, false);
|
638 |
+
case 'admin.php'://for sure off
|
639 |
+
default: return $val;
|
640 |
+
}
|
641 |
+
}
|
642 |
+
add_filter('option_woocommerce_email_from_name', 'qwc_admin_email_option');
|
643 |
+
//add_filter('option_woocommerce_email_from_address', 'qwc_admin_email_option');//not yet translatable
|
644 |
+
|
645 |
+
/**
|
646 |
+
* This helps to use order's language on re-sent emails from post.php order edit page.
|
647 |
+
* @since 1.1
|
648 |
+
*/
|
649 |
+
function qwc_admin_email_translate($content, $order=null) {
|
650 |
+
global $q_config;
|
651 |
+
$lang = null;
|
652 |
+
if($order && isset($order->id)){
|
653 |
+
$lang = get_post_meta( $order->id, '_user_language', true );
|
654 |
+
}
|
655 |
+
if(!$lang) $lang = $q_config['language'];
|
656 |
+
return qtranxf_use($lang, $content, false, false);
|
657 |
+
}
|
658 |
+
add_filter('woocommerce_email_order_items_table', 'qwc_admin_email_translate', 20, 2);
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Called to process action when button 'Save Order' pressed in /wp-admin/post.php?post=xxx&action=edit
|
662 |
+
* Helps to partly change language in email sent, but not all, since some parts are already translated into admin language.
|
663 |
+
* @since 1.1
|
664 |
+
*/
|
665 |
+
function qwc_admin_before_resend_order_emails($order) {
|
666 |
+
if(!$order || !isset($order->id)) return;
|
667 |
+
$lang = get_post_meta( $order->id, '_user_language', true );
|
668 |
+
if(!$lang) return;
|
669 |
+
global $q_config;
|
670 |
+
$q_config['language'] = $lang;
|
671 |
+
}
|
672 |
+
add_action( 'woocommerce_before_resend_order_emails', 'qwc_admin_before_resend_order_emails' );
|
673 |
+
|
674 |
+
/**
|
675 |
+
* Undo the effect of qwc_admin_before_resend_order_emails
|
676 |
+
* @since 1.1
|
677 |
+
*/
|
678 |
+
function qwc_admin_after_resend_order_emails($order) {
|
679 |
+
global $q_config;
|
680 |
+
$q_config['language'] = $q_config['url_info']['language'];
|
681 |
+
}
|
682 |
+
add_action( 'woocommerce_after_resend_order_email', 'qwc_admin_after_resend_order_emails' );
|
683 |
+
|
684 |
+
/*
|
685 |
+
Reminder for table handling
|
686 |
+
Line 436: function qtranxf_languageColumnHeader($columns){
|
687 |
+
Line 659: add_filter('manage_posts_columns', 'qtranxf_languageColumnHeader');
|
688 |
+
Line 661: add_filter('manage_pages_columns', 'qtranxf_languageColumnHeader');
|
689 |
+
*/
|
qwc-front.php
CHANGED
@@ -100,3 +100,16 @@ function qwc_filter_postmeta($original_value, $object_id, $meta_key = '', $singl
|
|
100 |
default: return qtranxf_filter_postmeta($original_value, $object_id, $meta_key, $single);
|
101 |
}
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
default: return qtranxf_filter_postmeta($original_value, $object_id, $meta_key, $single);
|
101 |
}
|
102 |
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Store the current WordPress language along with the order, so we know later on which language the customer used while ordering
|
106 |
+
* Called with
|
107 |
+
* do_action( 'woocommerce_checkout_update_order_meta', $order_id, $this->posted );
|
108 |
+
* in /woocommerce/includes/class-wc-checkout.php
|
109 |
+
* @since 1.1
|
110 |
+
*/
|
111 |
+
add_action( 'woocommerce_checkout_update_order_meta', 'save_post_qwc_store_language', 100 );
|
112 |
+
function save_post_qwc_store_language ( $order_id ) {
|
113 |
+
global $q_config;
|
114 |
+
add_post_meta( $order_id, '_user_language', $q_config['language'], true );
|
115 |
+
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: johnclause, michelweimerskirch
|
|
4 |
Tags: multilingual, language, bilingual, i18n, l10n, multilanguage, translation, WooCommerce
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.1.1
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3 or later
|
9 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QEXEK3HX8AR6U
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -43,13 +43,21 @@ Plugin does not have any configuration options, simply activate it and it will e
|
|
43 |
|
44 |
This plugin is not supported by the authors on the WordPress forum due to its simplicity. If you find a field which is not translatable, follow the pattern how it is done in the code for other fields, and make it translatable. Then submit a pull request at [GitHub](https://github.com/qTranslate-Team/woocommerce-qtranslate-x) to enable your changes for everyone else.
|
45 |
|
46 |
-
|
47 |
## Upgrade Notice ##
|
48 |
|
49 |
No need for Upgrade Notice.
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
## Changelog ##
|
52 |
|
|
|
|
|
|
|
|
|
53 |
### 1.0.1 ###
|
54 |
* Improvement: display of fields of class 'attribute_name' in `post.php` page.
|
55 |
* Improvement: added filter 'woocommerce_format_content', subject to approval from Woocommerce - was already approved, wait for next release after 2.3.5 - done by now.
|
4 |
Tags: multilingual, language, bilingual, i18n, l10n, multilanguage, translation, WooCommerce
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.1.1
|
7 |
+
Stable tag: 1.1
|
8 |
License: GPLv3 or later
|
9 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QEXEK3HX8AR6U
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
43 |
|
44 |
This plugin is not supported by the authors on the WordPress forum due to its simplicity. If you find a field which is not translatable, follow the pattern how it is done in the code for other fields, and make it translatable. Then submit a pull request at [GitHub](https://github.com/qTranslate-Team/woocommerce-qtranslate-x) to enable your changes for everyone else.
|
45 |
|
|
|
46 |
## Upgrade Notice ##
|
47 |
|
48 |
No need for Upgrade Notice.
|
49 |
|
50 |
+
## Known Issues ##
|
51 |
+
* Admin e-mails sent by pressing one of the buttons in column 'Actions' on order list page, `/wp-admin/edit.php?post_type=shop_order`, go in the original customer language used to submit the order. However, same e-mails sent using the "Resend order emails" option in order editor page, `/wp-admin/post.php?post=nnn&action=edit`, go in the mixed language of admin and customer. As a workaround, you can switch the admin language to the customer language before resending an e-mail (which shouldn't happen too often).
|
52 |
+
* Two buttons, "Add New XXX" and "Search XXX", on attribute editor page, `/wp-admin/edit-tags.php?taxonomy=xxx&post_type=product`, are displayed with raw multilingual text. This should be fixed with a later qTranslate-X version.
|
53 |
+
* HTML header title on admin page `/wp-admin/edit-tags.php?taxonomy=xxx&post_type=product` displays raw multilingual values.
|
54 |
+
|
55 |
## Changelog ##
|
56 |
|
57 |
+
### 1.1 ###
|
58 |
+
* Improvement: during an order, the language currently used by the customer is stored along with the order meta data
|
59 |
+
* Improvement: complete order e-mails on admin side are now sent with the order's original language (only for orders made after this update). [[Issue #3]( https://github.com/qTranslate-Team/woocommerce-qtranslate-x/issues/3)]
|
60 |
+
|
61 |
### 1.0.1 ###
|
62 |
* Improvement: display of fields of class 'attribute_name' in `post.php` page.
|
63 |
* Improvement: added filter 'woocommerce_format_content', subject to approval from Woocommerce - was already approved, wait for next release after 2.3.5 - done by now.
|
woocommerce-qtranslate-x.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce & qTranslate-X
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-qtranslate-x
|
5 |
* Description: Enables multilingual framework for plugin "WooCommerce".
|
6 |
-
* Version: 1.
|
7 |
* Author: qTranslate Team
|
8 |
* Author URI: http://qtranslatexteam.wordpress.com/about
|
9 |
* License: GPL2
|
@@ -12,7 +12,7 @@
|
|
12 |
*/
|
13 |
if(!defined('ABSPATH'))exit;
|
14 |
|
15 |
-
define('QWC_VERSION','1.
|
16 |
|
17 |
function qwc_init_language($url_info)
|
18 |
{
|
@@ -23,4 +23,3 @@ function qwc_init_language($url_info)
|
|
23 |
}
|
24 |
}
|
25 |
add_action('qtranslate_init_language','qwc_init_language');
|
26 |
-
?>
|
3 |
* Plugin Name: WooCommerce & qTranslate-X
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-qtranslate-x
|
5 |
* Description: Enables multilingual framework for plugin "WooCommerce".
|
6 |
+
* Version: 1.1
|
7 |
* Author: qTranslate Team
|
8 |
* Author URI: http://qtranslatexteam.wordpress.com/about
|
9 |
* License: GPL2
|
12 |
*/
|
13 |
if(!defined('ABSPATH'))exit;
|
14 |
|
15 |
+
define('QWC_VERSION','1.1');
|
16 |
|
17 |
function qwc_init_language($url_info)
|
18 |
{
|
23 |
}
|
24 |
}
|
25 |
add_action('qtranslate_init_language','qwc_init_language');
|
|