WooCommerce & qTranslate-X - Version 1.0.1

Version Description

Download this release

Release Info

Developer johnclause
Plugin Icon wp plugin WooCommerce & qTranslate-X
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0 to 1.0.1

Files changed (4) hide show
  1. qwc-admin.php +67 -5
  2. qwc-front.php +39 -3
  3. readme.txt +17 -12
  4. woocommerce-qtranslate-x.php +3 -3
qwc-admin.php CHANGED
@@ -4,6 +4,29 @@ if(!defined('ABSPATH'))exit;
4
  add_filter('qtranslate_load_admin_page_config','qwc_add_admin_page_config');
5
  function qwc_add_admin_page_config($page_configs)
6
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  {//edit.php?post_type=product&page=product_attributes
9
  $page_config = array();
@@ -19,8 +42,8 @@ function qwc_add_admin_page_config($page_configs)
19
  $fields = &$f['fields']; // shorthand
20
 
21
  $fields[] = array( 'id' => 'attribute_label' );
22
- //$fields[] = array( 'tag' => 'a', 'container_class' => 'attributes-table', 'encode' => 'display' );
23
- $fields[] = array( 'tag' => 'td', 'container_id' => 'col-right', 'encode' => 'display' );
24
 
25
  $page_config['forms'][] = $f;
26
  $page_configs[] = $page_config;
@@ -39,8 +62,8 @@ function qwc_add_admin_page_config($page_configs)
39
  $f['fields'] = array();
40
  $fields = &$f['fields']; // shorthand
41
 
42
- $fields[] = array( 'tag' => 'h2', 'container_class' => 'wrap', 'encode' => 'display' );
43
- $fields[] = array( 'tag' => 'h3', 'container_id' => 'col-left', 'encode' => 'display' );
44
  $fields[] = array( 'id' => 'search-submit', 'attr' => 'value', 'encode' => 'display' );
45
  $fields[] = array( 'id' => 'submit', 'attr' => 'value', 'encode' => 'display' );
46
  //$fields[] = array( 'id' => '' );
@@ -465,4 +488,43 @@ function qwc_email_get_option($value_translated, $wce /* WC_Email object*/, $val
465
  }
466
  add_filter( 'woocommerce_email_get_option', 'qwc_email_get_option', 0, 4 );
467
 
468
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  add_filter('qtranslate_load_admin_page_config','qwc_add_admin_page_config');
5
  function qwc_add_admin_page_config($page_configs)
6
  {
7
+ {//post.php //since 1.0.1
8
+ $page_config = array();
9
+ $page_config['pages'] = array( 'post.php' => '');
10
+ $page_config['anchors'] = array( 'post', 'woocommerce-product-data', 'postexcerpt' );
11
+
12
+ $page_config['forms'] = array();
13
+
14
+ $f = array();
15
+ $f['form'] = array( 'id' => 'post' );
16
+
17
+ $f['fields'] = array();
18
+ $fields = &$f['fields']; // shorthand
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' );
25
+ //$fields[] = array( 'class' => 'attribute_values', 'encode' => 'display' );
26
+
27
+ $page_config['forms'][] = $f;
28
+ $page_configs[] = $page_config;
29
+ }
30
 
31
  {//edit.php?post_type=product&page=product_attributes
32
  $page_config = array();
42
  $fields = &$f['fields']; // shorthand
43
 
44
  $fields[] = array( 'id' => 'attribute_label' );
45
+ //$fields[] = array( 'tag' => 'A', 'container_class' => 'attributes-table', 'encode' => 'display' );
46
+ $fields[] = array( 'tag' => 'TD', 'container_id' => 'col-right', 'encode' => 'display' );
47
 
48
  $page_config['forms'][] = $f;
49
  $page_configs[] = $page_config;
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' => '' );
488
  }
489
  add_filter( 'woocommerce_email_get_option', 'qwc_email_get_option', 0, 4 );
490
 
491
+ /**
492
+ * @since 1.0.1
493
+ */
494
+ /*
495
+ function qwc_attribute_label($label, $name){
496
+ //global $q_config;
497
+ //if(isset($q_config['term_name'][$name])) {
498
+ // $label = qtranxf_join_b($q_config['term_name'][$name]);
499
+ //}
500
+ //qtranxf_dbg_log('qwc_attribute_label: label="'.$label.'"; name: ',$name);
501
+ $label = qtranxf_term_name_encoded($label);
502
+ //qtranxf_dbg_log('qwc_attribute_label: label: ',$label);
503
+ return $label;
504
+ }
505
+ add_filter( 'woocommerce_attribute_label', 'qwc_attribute_label', 0, 2 );
506
+ */
507
+ add_filter( 'woocommerce_variation_option_name', 'qtranxf_term_name_encoded', 5);
508
+
509
+ /*
510
+ // it does the job, but WC javascript breaks it anyway later.
511
+ function qwc_useAdminTermLibJoin($obj, $taxonomies=null, $args=null) {
512
+ global $pagenow;
513
+ //qtranxf_dbg_log('qwc_useAdminTermLibJoin: $pagenow='.$pagenow);
514
+ //qtranxf_dbg_log('qwc_useAdminTermLibJoin: $obj:',$obj);
515
+ //qtranxf_dbg_log('qwc_useAdminTermLibJoin: $taxonomies:',$taxonomies);
516
+ //qtranxf_dbg_log('qwc_useAdminTermLibJoin: $args:',$args);
517
+ switch($pagenow){
518
+ case 'post.php':
519
+ if($taxonomies){
520
+ foreach($taxonomies as $t){
521
+ if(strpos($t,'pa_')===0)
522
+ return qtranxf_get_terms_joined($obj);
523
+ }
524
+ }
525
+ default: return $obj;// is done in qtranxf_useAdminTermLibJoin
526
+ }
527
+ }
528
+ //add_filter('get_term', 'qwc_useAdminTermLibJoin', 4, 2);
529
+ add_filter('get_terms', 'qwc_useAdminTermLibJoin', 4, 3);
530
+ */
qwc-front.php CHANGED
@@ -3,6 +3,9 @@ if(!defined('ABSPATH'))exit;
3
 
4
  function qwc_add_filters_front() {
5
 
 
 
 
6
  $use_filters = array(
7
  /* do not exist any more */
8
  //'option_woocommerce_email_from_name' => 10,
@@ -46,7 +49,10 @@ function qwc_add_filters_front() {
46
  'woocommerce_attribute' => 20,
47
  'woocommerce_cart_item_name' => 20,
48
  'woocommerce_cart_item_thumbnail' => 20,
49
- 'woocommerce_order_subtotal_to_display' => 20
 
 
 
50
 
51
  //not in front
52
  //'woocommerce_email_get_option' => 0
@@ -56,11 +62,41 @@ function qwc_add_filters_front() {
56
  add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority );
57
  }
58
 
59
- //do not seem to need
 
60
  //foreach ( $url_filters as $name => $priority ) {
61
  // add_filter( $name, 'qtranxf_convertURL', $priority );
62
  //}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
  qwc_add_filters_front();
65
 
66
- ?>
 
 
 
 
 
 
 
3
 
4
  function qwc_add_filters_front() {
5
 
6
+ remove_filter('get_post_metadata', 'qtranxf_filter_postmeta', 5);
7
+ add_filter('get_post_metadata', 'qwc_filter_postmeta', 5, 4);
8
+
9
  $use_filters = array(
10
  /* do not exist any more */
11
  //'option_woocommerce_email_from_name' => 10,
49
  'woocommerce_attribute' => 20,
50
  'woocommerce_cart_item_name' => 20,
51
  'woocommerce_cart_item_thumbnail' => 20,
52
+ 'woocommerce_order_subtotal_to_display' => 20,
53
+
54
+ /* four-argument filters */
55
+ 'woocommerce_format_content' => 20,//function wc_format_content in woocommerce/includes/wc-formatting-functions.php
56
 
57
  //not in front
58
  //'woocommerce_email_get_option' => 0
62
  add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority );
63
  }
64
 
65
+ //below do not seem to need
66
+
67
  //foreach ( $url_filters as $name => $priority ) {
68
  // add_filter( $name, 'qtranxf_convertURL', $priority );
69
  //}
70
+
71
+ /* Fix the product categories and tags (displayed above the "additional informations" tab) *
72
+ add_filter( 'wp_get_object_terms', function ( $terms ) {
73
+ foreach ( $terms as $term ) {
74
+ if ( $term->taxonomy == 'product_cat' || $term->taxonomy == 'product_tag' ) {
75
+ $term->name = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage( $term->name );
76
+ }
77
+ }
78
+
79
+ return $terms;
80
+ } );
81
+
82
+ /* Fix the product attributes (displayed in the "additional informations" tab) *
83
+ add_filter( 'woocommerce_attribute', function ( $text ) {
84
+ $values = explode( ', ', $text );
85
+ foreach ( $values as $i => $val ) {
86
+ $values[ $i ] = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage( $val );
87
+ }
88
+
89
+ return implode( ', ', $values );
90
+ } );
91
+ */
92
  }
93
  qwc_add_filters_front();
94
 
95
+ function qwc_filter_postmeta($original_value, $object_id, $meta_key = '', $single = false){
96
+ //qtranxf_dbg_log_if($object_id==58,'qwc_filter_postmeta: $object_id='.$object_id.' $meta_key:',$meta_key);
97
+ switch($meta_key){
98
+ case '_product_attributes':
99
+ return $original_value;
100
+ default: return qtranxf_filter_postmeta($original_value, $object_id, $meta_key, $single);
101
+ }
102
+ }
readme.txt CHANGED
@@ -1,17 +1,17 @@
1
- === WooCommerce & qTranslate-X ===
2
  Developed by: qTranslate Team
3
- Contributors: johnclause
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.0
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
11
 
12
  Enables multilingual framework for plugin "WooCommerce - excelling eCommerce".
13
 
14
- == Description ==
15
 
16
  This plugin enables [qTranslate-X](https://wordpress.org/plugins/qtranslate-x/) multilingual framework (version 3.1 or later) for WordPress plugin [WooCommerce - excelling eCommerce](https://wordpress.org/plugins/woocommerce/) (version 2.3.5 or later).
17
 
@@ -21,7 +21,7 @@ After the activation, depending on your theme, you may need to do the following
21
 
22
  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.
23
 
24
- == Installation ==
25
 
26
  Standard, as any other normal plugin hosted at WordPress.
27
 
@@ -29,26 +29,31 @@ After the activation, depending on your theme, you may need to do the following
29
 
30
  * In all customizable template files, replace calls to `bloginfo('xxx')` with `bloginfo('xxx','display')`, if you have any. You do not have to do this, if title of your blog appears correctly everywhere you can see it (especially in emails sent), or if you do not localize the name of your blog.
31
 
32
- == Screenshots ==
33
 
34
  Plugin does not have any configuration options, and no screenshots needed.
35
 
36
- == Frequently Asked Questions ==
37
 
38
- = How do I open a page with configuration options? =
39
 
40
  Plugin does not have any configuration options, simply activate it and it will enable the translation of relevant fields for WooCommerce back- and front-end.
41
 
42
- = I submitted a question on support forum, but the authors did not respond? =
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 =
 
 
 
 
 
54
  * Initial release
1
+ # WooCommerce & qTranslate-X #
2
  Developed by: qTranslate Team
3
+ 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.0.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
11
 
12
  Enables multilingual framework for plugin "WooCommerce - excelling eCommerce".
13
 
14
+ ## Description ##
15
 
16
  This plugin enables [qTranslate-X](https://wordpress.org/plugins/qtranslate-x/) multilingual framework (version 3.1 or later) for WordPress plugin [WooCommerce - excelling eCommerce](https://wordpress.org/plugins/woocommerce/) (version 2.3.5 or later).
17
 
21
 
22
  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.
23
 
24
+ ## Installation ##
25
 
26
  Standard, as any other normal plugin hosted at WordPress.
27
 
29
 
30
  * In all customizable template files, replace calls to `bloginfo('xxx')` with `bloginfo('xxx','display')`, if you have any. You do not have to do this, if title of your blog appears correctly everywhere you can see it (especially in emails sent), or if you do not localize the name of your blog.
31
 
32
+ ## Screenshots ##
33
 
34
  Plugin does not have any configuration options, and no screenshots needed.
35
 
36
+ ## Frequently Asked Questions ##
37
 
38
+ ### How do I open a page with configuration options? ###
39
 
40
  Plugin does not have any configuration options, simply activate it and it will enable the translation of relevant fields for WooCommerce back- and front-end.
41
 
42
+ ### I submitted a question on support forum, but the authors did not respond? ###
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.
56
+ * Fix: problem with custom attributes: [Issue #2](https://github.com/qTranslate-Team/woocommerce-qtranslate-x/issues/2).
57
+
58
+ ### 1.0 ###
59
  * Initial release
woocommerce-qtranslate-x.php CHANGED
@@ -3,16 +3,16 @@
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.0
7
  * Author: qTranslate Team
8
  * Author URI: http://qtranslatexteam.wordpress.com/about
9
  * License: GPL2
10
- * Tags: multilingual, multi, language, translation, qTranslate-X, Events Made Easy
11
  * Author e-mail: qTranslateTeam@gmail.com
12
  */
13
  if(!defined('ABSPATH'))exit;
14
 
15
- define('QWC_VERSION','1.0');
16
 
17
  function qwc_init_language($url_info)
18
  {
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.0.1
7
  * Author: qTranslate Team
8
  * Author URI: http://qtranslatexteam.wordpress.com/about
9
  * License: GPL2
10
+ * Tags: multilingual, multi, language, translation, qTranslate-X, WooCommerce
11
  * Author e-mail: qTranslateTeam@gmail.com
12
  */
13
  if(!defined('ABSPATH'))exit;
14
 
15
+ define('QWC_VERSION','1.0.1');
16
 
17
  function qwc_init_language($url_info)
18
  {