ACF qTranslate - Version 1.7.2

Version Description

  • Bug Fix: Corrected misnamed variable
  • Bug Fix: ACF5 issues using WYSIWYG with the repeater field type
  • Bug Fix: qTranslate-X saving content using WYSIWYG with repeater field type
  • Core: Support for qtrans_edit_language cookie set by qTranslate-X
  • Core: Keep switches between Visual/Html modes in sync across languages
Download this release

Release Info

Developer funkjedi
Plugin Icon wp plugin ACF qTranslate
Version 1.7.2
Comparing to
See all releases

Code changes from version 1.7.1 to 1.7.2

acf-qtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Advanced Custom Fields: qTranslate
4
Plugin URI: http://github.com/funkjedi/acf-qtranslate
5
Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
6
- Version: 1.7.1
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
3
Plugin Name: Advanced Custom Fields: qTranslate
4
Plugin URI: http://github.com/funkjedi/acf-qtranslate
5
Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
6
+ Version: 1.7.2
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
assets/acf_5/main.js CHANGED
@@ -32,35 +32,15 @@ acf.fields.qtranslate_wysiwyg = acf.fields.wysiwyg.extend({
32
this.o = acf.get_data(this.$el);
33
this.o.id = this.$textarea.attr('id');
34
},
35
- initialize: function(){
36
- if (typeof tinyMCEPreInit === 'undefined' || typeof tinymce === 'undefined') {
37
- return false;
38
- }
39
var self = this;
40
this.$field.find('.wp-editor-wrap').each(function() {
41
self.$el = jQuery(this);
42
self.$textarea = self.$el.find('textarea');
43
self.o = acf.get_data(self.$el);
44
self.o.id = self.$textarea.attr('id');
45
- // vars
46
- var mceInit = self.get_mceInit();
47
- var qtInit = self.get_qtInit();
48
- // append settings
49
- tinyMCEPreInit.mceInit[ mceInit.id ] = mceInit;
50
- tinyMCEPreInit.qtInit[ qtInit.id ] = qtInit;
51
- // initialize mceInit
52
- if (self.$el.hasClass('tmce-active')) {
53
- try {
54
- tinymce.init( mceInit );
55
- } catch(e){}
56
- }
57
- // initialize qtInit
58
- try {
59
- var qtag = quicktags( qtInit );
60
- self._buttonsInit( qtag );
61
- } catch(e){}
62
});
63
this.focus();
64
}
65
});
66
-
32
this.o = acf.get_data(this.$el);
33
this.o.id = this.$textarea.attr('id');
34
},
35
+ initialize: function() {
36
var self = this;
37
this.$field.find('.wp-editor-wrap').each(function() {
38
self.$el = jQuery(this);
39
self.$textarea = self.$el.find('textarea');
40
self.o = acf.get_data(self.$el);
41
self.o.id = self.$textarea.attr('id');
42
+ acf.fields.wysiwyg.initialize.call(self);
43
});
44
this.focus();
45
}
46
});
assets/common.js CHANGED
@@ -38,5 +38,15 @@ jQuery(function($) {
38
$(this).parent('.multi-language-field').removeClass('focused');
39
});
40
41
});
42
38
$(this).parent('.multi-language-field').removeClass('focused');
39
});
40
41
+ /**
42
+ * Keep the selected editor in sync across languages.
43
+ */
44
+ $body.on('click', '.wp-editor-tabs .wp-switch-editor', function() {
45
+ var parent = $(this).parents('.multi-language-field'), editor = $(this).hasClass('switch-tmce') ? 'tmce' : 'html';
46
+ parent.find('.wp-editor-tabs .wp-switch-editor.switch-' + editor).not(this).each(function() {
47
+ switchEditors.switchto(this);
48
+ });
49
+ });
50
+
51
});
52
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: funkjedi
3
Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
Requires at least: 3.5.0
5
Tested up to: 4.1.1
6
- Version: 1.7.1
7
- Stable tag: 1.7.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -56,8 +56,15 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
56
57
== Changelog ==
58
59
= 1.7.1 =
60
- * Core: Added back ACFv5 support for WYSIWYG
61
* Core: Added qTranslate-X support for the standard WYSIWYG field type
62
* Core: Bumped version requirement to match ACF
63
* Bug Fix: qTranslate-X switcher showing up on every admin page
@@ -67,14 +74,14 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
67
* Core: Support for qTranslate-X language switchers
68
69
= 1.6 =
70
- * Added ACFv4 support for qTranslate-X
71
72
= 1.5 =
73
* Core: Added compatibility for qTranslate-X
74
- * Bug Fix: Remove the broken ACFv5 WYSIWYG implementation
75
76
= 1.4 =
77
- * Core: Added support for ACFv5
78
* Core: Tested compatibility with mqTranslate
79
80
= 1.3 =
3
Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
Requires at least: 3.5.0
5
Tested up to: 4.1.1
6
+ Version: 1.7.2
7
+ Stable tag: 1.7.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
56
57
== Changelog ==
58
59
+ = 1.7.2 =
60
+ * Bug Fix: Corrected misnamed variable
61
+ * Bug Fix: ACF5 issues using WYSIWYG with the repeater field type
62
+ * Bug Fix: qTranslate-X saving content using WYSIWYG with repeater field type
63
+ * Core: Support for `qtrans_edit_language` cookie set by qTranslate-X
64
+ * Core: Keep switches between Visual/Html modes in sync across languages
65
+
66
= 1.7.1 =
67
+ * Core: Added back ACF5 support for WYSIWYG
68
* Core: Added qTranslate-X support for the standard WYSIWYG field type
69
* Core: Bumped version requirement to match ACF
70
* Bug Fix: qTranslate-X switcher showing up on every admin page
74
* Core: Support for qTranslate-X language switchers
75
76
= 1.6 =
77
+ * Core: Added ACFv4 support for qTranslate-X
78
79
= 1.5 =
80
* Core: Added compatibility for qTranslate-X
81
+ * Bug Fix: Remove the broken ACF5 WYSIWYG implementation
82
83
= 1.4 =
84
+ * Core: Added support for ACF5
85
* Core: Tested compatibility with mqTranslate
86
87
= 1.3 =
src/acf_4/acf.php CHANGED
@@ -68,7 +68,7 @@ class acf implements acf_interface {
68
* @return array
69
*/
70
public function get_visible_acf_fields() {
71
- global $post, $pagenow, $typenow;
72
73
$filter = array();
74
if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
@@ -77,9 +77,8 @@ class acf implements acf_interface {
77
$filter['post_type'] = $typenow;
78
}
79
}
80
- elseif ($pagenow === 'admin.php' && isset($_GET['page'])) {
81
$filter['post_id'] = apply_filters('acf/get_post_id', false);
82
- $filter['post_type'] = $typenow;
83
}
84
elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
85
$filter['ef_taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
68
* @return array
69
*/
70
public function get_visible_acf_fields() {
71
+ global $post, $pagenow, $typenow, $plugin_page;
72
73
$filter = array();
74
if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
77
$filter['post_type'] = $typenow;
78
}
79
}
80
+ elseif ($pagenow === 'admin.php' && isset($plugin_page)) {
81
$filter['post_id'] = apply_filters('acf/get_post_id', false);
82
}
83
elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
84
$filter['ef_taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
src/acf_4/fields/file.php CHANGED
@@ -66,7 +66,7 @@ class file extends acf_field_file {
66
global $q_config;
67
$languages = qtrans_getSortedLanguages(true);
68
$values = qtrans_split($field['value'], $quicktags = true);
69
- $currentLanguage = qtrans_getLanguage();
70
71
echo '<div class="multi-language-field multi-language-field-file">';
72
66
global $q_config;
67
$languages = qtrans_getSortedLanguages(true);
68
$values = qtrans_split($field['value'], $quicktags = true);
69
+ $currentLanguage = $this->plugin->get_active_language();
70
71
echo '<div class="multi-language-field multi-language-field-file">';
72
src/acf_4/fields/image.php CHANGED
@@ -66,7 +66,7 @@ class image extends acf_field_image {
66
global $q_config;
67
$languages = qtrans_getSortedLanguages(true);
68
$values = qtrans_split($field['value'], $quicktags = true);
69
- $currentLanguage = qtrans_getLanguage();
70
71
echo '<div class="multi-language-field multi-language-field-image">';
72
66
global $q_config;
67
$languages = qtrans_getSortedLanguages(true);
68
$values = qtrans_split($field['value'], $quicktags = true);
69
+ $currentLanguage = $this->plugin->get_active_language();
70
71
echo '<div class="multi-language-field multi-language-field-image">';
72
src/acf_4/fields/text.php CHANGED
@@ -47,16 +47,17 @@ class text extends acf_field_text {
47
global $q_config;
48
$languages = qtrans_getSortedLanguages(true);
49
$values = qtrans_split($field['value'], $quicktags = true);
50
51
echo '<div class="multi-language-field">';
52
53
foreach ($languages as $language) {
54
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
55
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
56
}
57
58
foreach ($languages as $language) {
59
- $class = ($language === end($languages)) ? $field['class'] . ' current-language' : $field['class'];
60
echo '<input type="text" data-language="' . esc_attr($language) . '" value="' . esc_attr($values[$language]) . '" id="' . esc_attr( $field['id'] ) . '" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[$language]") . '" />';
61
}
62
47
global $q_config;
48
$languages = qtrans_getSortedLanguages(true);
49
$values = qtrans_split($field['value'], $quicktags = true);
50
+ $currentLanguage = $this->plugin->get_active_language();
51
52
echo '<div class="multi-language-field">';
53
54
foreach ($languages as $language) {
55
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
56
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
57
}
58
59
foreach ($languages as $language) {
60
+ $class = ($language === $currentLanguage) ? $field['class'] . ' current-language' : $field['class'];
61
echo '<input type="text" data-language="' . esc_attr($language) . '" value="' . esc_attr($values[$language]) . '" id="' . esc_attr( $field['id'] ) . '" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[$language]") . '" />';
62
}
63
src/acf_4/fields/textarea.php CHANGED
@@ -47,16 +47,17 @@ class textarea extends acf_field_textarea {
47
global $q_config;
48
$languages = qtrans_getSortedLanguages(true);
49
$values = qtrans_split($field['value'], $quicktags = true);
50
51
echo '<div class="multi-language-field">';
52
53
foreach ($languages as $language) {
54
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
55
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
56
}
57
58
foreach ($languages as $language) {
59
- $class = ($language === end($languages)) ? $field['class'] . ' current-language' : $field['class'];
60
echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr( $field['id'] ) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[$language]") . '">' . esc_textarea($values[$language]) . '</textarea>';
61
}
62
47
global $q_config;
48
$languages = qtrans_getSortedLanguages(true);
49
$values = qtrans_split($field['value'], $quicktags = true);
50
+ $currentLanguage = $this->plugin->get_active_language();
51
52
echo '<div class="multi-language-field">';
53
54
foreach ($languages as $language) {
55
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
56
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
57
}
58
59
foreach ($languages as $language) {
60
+ $class = ($language === $currentLanguage) ? $field['class'] . ' current-language' : $field['class'];
61
echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr( $field['id'] ) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[$language]") . '">' . esc_textarea($values[$language]) . '</textarea>';
62
}
63
src/acf_4/fields/wysiwyg.php CHANGED
@@ -73,11 +73,12 @@ class wysiwyg extends acf_field_wysiwyg {
73
global $q_config, $wp_version;
74
$languages = qtrans_getSortedLanguages(true);
75
$values = qtrans_split($field['value'], $quicktags = true);
76
77
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
78
79
foreach ($languages as $language) {
80
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
81
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
82
}
83
@@ -85,7 +86,7 @@ class wysiwyg extends acf_field_wysiwyg {
85
$value = $values[$language];
86
$id = 'wysiwyg' . $field['id'] . "[$language]";
87
$name = $field['name'] . "[$language]";
88
- $class = ($language === end($languages)) ? 'acf_wysiwyg wp-editor-wrap current-language' : 'acf_wysiwyg wp-editor-wrap';
89
90
?>
91
<div id="wp-<?php echo $id; ?>-wrap" class="<?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
@@ -105,7 +106,7 @@ class wysiwyg extends acf_field_wysiwyg {
105
<?php endif; ?>
106
<?php endif; ?>
107
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
108
- <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $name; ?>" ><?php echo wp_richedit_pre($value); ?></textarea>
109
</div>
110
</div>
111
<?php endforeach;
73
global $q_config, $wp_version;
74
$languages = qtrans_getSortedLanguages(true);
75
$values = qtrans_split($field['value'], $quicktags = true);
76
+ $currentLanguage = $this->plugin->get_active_language();
77
78
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
79
80
foreach ($languages as $language) {
81
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
82
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
83
}
84
86
$value = $values[$language];
87
$id = 'wysiwyg' . $field['id'] . "[$language]";
88
$name = $field['name'] . "[$language]";
89
+ $class = ($language === $currentLanguage) ? 'acf_wysiwyg wp-editor-wrap current-language' : 'acf_wysiwyg wp-editor-wrap';
90
91
?>
92
<div id="wp-<?php echo $id; ?>-wrap" class="<?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
106
<?php endif; ?>
107
<?php endif; ?>
108
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
109
+ <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>" ><?php echo wp_richedit_pre($value); ?></textarea>
110
</div>
111
</div>
112
<?php endforeach;
src/acf_5/acf.php CHANGED
@@ -67,7 +67,7 @@ class acf implements acf_interface {
67
* @return array
68
*/
69
public function get_visible_acf_fields() {
70
- global $post, $pagenow, $typenow;
71
72
$filter = array();
73
if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
@@ -76,9 +76,10 @@ class acf implements acf_interface {
76
$filter['post_type'] = $typenow;
77
}
78
}
79
- elseif ($pagenow === 'admin.php' && isset($_GET['page'])) {
80
- $filter['post_id'] = $post->ID;
81
- $filter['post_type'] = $typenow;
82
}
83
elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
84
$filter['taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
@@ -110,7 +111,7 @@ class acf implements acf_interface {
110
);
111
112
$visible_fields = array();
113
- foreach (acf_get_field_groups($args) as $field_group) {
114
$fields = acf_get_fields($field_group);
115
foreach ($fields as $field) {
116
if (in_array($field['type'], $supported_field_types)) {
67
* @return array
68
*/
69
public function get_visible_acf_fields() {
70
+ global $post, $pagenow, $typenow, $plugin_page;
71
72
$filter = array();
73
if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
76
$filter['post_type'] = $typenow;
77
}
78
}
79
+ elseif ($pagenow === 'admin.php' && isset($plugin_page)) {
80
+ if (acf_get_options_page($plugin_page)) {
81
+ $filter['post_id'] = acf_get_valid_post_id('options');
82
+ }
83
}
84
elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
85
$filter['taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
111
);
112
113
$visible_fields = array();
114
+ foreach (acf_get_field_groups($filter) as $field_group) {
115
$fields = acf_get_fields($field_group);
116
foreach ($fields as $field) {
117
if (in_array($field['type'], $supported_field_types)) {
src/acf_5/fields/file.php CHANGED
@@ -69,7 +69,7 @@ class file extends acf_field_file {
69
global $q_config;
70
$languages = qtrans_getSortedLanguages(true);
71
$values = qtrans_split($field['value'], $quicktags = true);
72
- $currentLanguage = qtrans_getLanguage();
73
74
// enqueue
75
acf_enqueue_uploader();
69
global $q_config;
70
$languages = qtrans_getSortedLanguages(true);
71
$values = qtrans_split($field['value'], $quicktags = true);
72
+ $currentLanguage = $this->plugin->get_active_language();
73
74
// enqueue
75
acf_enqueue_uploader();
src/acf_5/fields/image.php CHANGED
@@ -74,7 +74,7 @@ class image extends acf_field_image {
74
global $q_config;
75
$languages = qtrans_getSortedLanguages(true);
76
$values = qtrans_split($field['value'], $quicktags = true);
77
- $currentLanguage = qtrans_getLanguage();
78
79
// enqueue
80
acf_enqueue_uploader();
74
global $q_config;
75
$languages = qtrans_getSortedLanguages(true);
76
$values = qtrans_split($field['value'], $quicktags = true);
77
+ $currentLanguage = $this->plugin->get_active_language();
78
79
// enqueue
80
acf_enqueue_uploader();
src/acf_5/fields/text.php CHANGED
@@ -60,6 +60,7 @@ class text extends acf_field_text {
60
global $q_config;
61
$languages = qtrans_getSortedLanguages(true);
62
$values = qtrans_split($field['value'], $quicktags = true);
63
64
// vars
65
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
@@ -88,12 +89,13 @@ class text extends acf_field_text {
88
$e .= '<div class="acf-input-wrap multi-language-field">';
89
90
foreach ($languages as $language) {
91
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
92
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
93
}
94
95
foreach ($languages as $language) {
96
- if ($language === end($languages)) {
97
$atts['class'] .= ' current-language';
98
}
99
$atts['type'] = 'text';
60
global $q_config;
61
$languages = qtrans_getSortedLanguages(true);
62
$values = qtrans_split($field['value'], $quicktags = true);
63
+ $currentLanguage = $this->plugin->get_active_language();
64
65
// vars
66
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
89
$e .= '<div class="acf-input-wrap multi-language-field">';
90
91
foreach ($languages as $language) {
92
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
93
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
94
}
95
96
foreach ($languages as $language) {
97
+ $atts['class'] = $field['class'];
98
+ if ($language === $currentLanguage) {
99
$atts['class'] .= ' current-language';
100
}
101
$atts['type'] = 'text';
src/acf_5/fields/textarea.php CHANGED
@@ -60,6 +60,7 @@ class textarea extends acf_field_textarea {
60
global $q_config;
61
$languages = qtrans_getSortedLanguages(true);
62
$values = qtrans_split($field['value'], $quicktags = true);
63
64
// vars
65
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
@@ -93,12 +94,13 @@ class textarea extends acf_field_textarea {
93
$e .= '<div class="acf-input-wrap multi-language-field">';
94
95
foreach ($languages as $language) {
96
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
97
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
98
}
99
100
foreach ($languages as $language) {
101
- if ($language === end($languages)) {
102
$atts['class'] .= ' current-language';
103
}
104
$atts['name'] = $field['name'] . "[$language]";
60
global $q_config;
61
$languages = qtrans_getSortedLanguages(true);
62
$values = qtrans_split($field['value'], $quicktags = true);
63
+ $currentLanguage = $this->plugin->get_active_language();
64
65
// vars
66
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
94
$e .= '<div class="acf-input-wrap multi-language-field">';
95
96
foreach ($languages as $language) {
97
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
98
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
99
}
100
101
foreach ($languages as $language) {
102
+ $atts['class'] = $field['class'];
103
+ if ($language === $currentLanguage) {
104
$atts['class'] .= ' current-language';
105
}
106
$atts['name'] = $field['name'] . "[$language]";
src/acf_5/fields/wysiwyg.php CHANGED
@@ -117,11 +117,12 @@ class wysiwyg extends acf_field_wysiwyg {
117
global $q_config, $wp_version;
118
$languages = qtrans_getSortedLanguages(true);
119
$values = qtrans_split($field['value'], $quicktags = true);
120
121
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
122
123
foreach ($languages as $language) {
124
- $class = ($language === end($languages)) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
125
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
126
}
127
@@ -130,12 +131,13 @@ class wysiwyg extends acf_field_wysiwyg {
130
$value = apply_filters('acf_the_editor_content', $values[$language]);
131
$id = $uid . "-$language";
132
$name = $field['name'] . "[$language]";
133
- if ($language === end($languages)) {
134
- $switch_class .= ' current-language';
135
}
136
137
?>
138
- <div id="wp-<?php echo $id; ?>-wrap" class="acfqt-inactive acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $switch_class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
139
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
140
<?php if( $field['media_upload'] ): ?>
141
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
@@ -150,7 +152,7 @@ class wysiwyg extends acf_field_wysiwyg {
150
<?php endif; ?>
151
</div>
152
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
153
- <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $name; ?>" <?php if($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $value; ?></textarea>
154
</div>
155
</div>
156
117
global $q_config, $wp_version;
118
$languages = qtrans_getSortedLanguages(true);
119
$values = qtrans_split($field['value'], $quicktags = true);
120
+ $currentLanguage = $this->plugin->get_active_language();
121
122
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
123
124
foreach ($languages as $language) {
125
+ $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
126
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
127
}
128
131
$value = apply_filters('acf_the_editor_content', $values[$language]);
132
$id = $uid . "-$language";
133
$name = $field['name'] . "[$language]";
134
+ $class = $switch_class;
135
+ if ($language === $currentLanguage) {
136
+ $class .= ' current-language';
137
}
138
139
?>
140
+ <div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
141
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
142
<?php if( $field['media_upload'] ): ?>
143
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
152
<?php endif; ?>
153
</div>
154
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
155
+ <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>" <?php if($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $value; ?></textarea>
156
</div>
157
</div>
158
src/plugin.php CHANGED
@@ -112,24 +112,31 @@ class plugin {
112
}
113
114
/**
115
- * Check if qTranslate Plus is enabled
116
*/
117
public function ppqtranslate_enabled() {
118
return function_exists('ppqtrans_getLanguage');
119
}
120
121
/**
122
- * Check if qTranslate-X is enabled
123
*/
124
public function qtranslatex_enabled() {
125
return function_exists('qtranxf_getLanguage');
126
}
127
128
/**
129
- * Check if mqTranslate is enabled
130
*/
131
public function mqtranslate_enabled() {
132
return function_exists('mqtrans_currentUserCanEdit');
133
}
134
135
}
112
}
113
114
/**
115
+ * Check if qTranslate Plus is enabled.
116
*/
117
public function ppqtranslate_enabled() {
118
return function_exists('ppqtrans_getLanguage');
119
}
120
121
/**
122
+ * Check if qTranslate-X is enabled.
123
*/
124
public function qtranslatex_enabled() {
125
return function_exists('qtranxf_getLanguage');
126
}
127
128
/**
129
+ * Check if mqTranslate is enabled.
130
*/
131
public function mqtranslate_enabled() {
132
return function_exists('mqtrans_currentUserCanEdit');
133
}
134
135
+ /**
136
+ * Get the active language.
137
+ */
138
+ public function get_active_language() {
139
+ return apply_filters('acf_qtranslate_get_active_language', qtrans_getLanguage());
140
+ }
141
+
142
}
src/qtranslatex.php CHANGED
@@ -28,9 +28,11 @@ class qtranslatex {
28
// include compatibility functions
29
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'compatibility/qtranslatex.php';
30
31
- add_filter('admin_head', array($this, 'admin_head'));
32
- add_filter('qtranslate_custom_admin_js', array($this, 'qtranslate_custom_admin_js'));
33
- add_filter('qtranslate_load_admin_page_config', array($this, 'qtranslate_load_admin_page_config'));
34
}
35
36
/**
@@ -40,11 +42,25 @@ class qtranslatex {
40
?>
41
<style>
42
.multi-language-field {margin-top:0!important;}
43
- .multi-language-field .wp-switch-editor {display:none!important;}
44
</style>
45
<?php
46
}
47
48
/**
49
* Load ACF form element ids into qTranslate-X.
50
* @return void
@@ -79,4 +95,17 @@ class qtranslatex {
79
}
80
}
81
82
}
28
// include compatibility functions
29
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'compatibility/qtranslatex.php';
30
31
+ add_action('admin_head', array($this, 'admin_head'));
32
+ add_action('admin_footer', array($this, 'admin_footer'), 9999); //after qTranslate-X
33
+ add_filter('qtranslate_custom_admin_js', array($this, 'qtranslate_custom_admin_js'));
34
+ add_filter('qtranslate_load_admin_page_config', array($this, 'qtranslate_load_admin_page_config'));
35
+ add_filter('acf_qtranslate_get_active_language', array($this, 'get_active_language'));
36
}
37
38
/**
42
?>
43
<style>
44
.multi-language-field {margin-top:0!important;}
45
+ .multi-language-field .wp-switch-editor[data-language] {display:none!important;}
46
</style>
47
<?php
48
}
49
50
+ /**
51
+ * Load custom version of edit-post.js if needed.
52
+ */
53
+ public function admin_footer() {
54
+ if (wp_script_is('qtranslate-admin-edit')) {
55
+
56
+ //$handle = wp_script_is('qtranslate-admin-edit', 'registered');
57
+
58
+ //wp_register_script('qtranslate-admin-edit', $script_url, array(), QTX_VERSION);
59
+ //wp_enqueue_script('qtranslate-admin-edit');
60
+
61
+ }
62
+ }
63
+
64
/**
65
* Load ACF form element ids into qTranslate-X.
66
* @return void
95
}
96
}
97
98
+ /**
99
+ * Get the active language.
100
+ */
101
+ public function get_active_language($language) {
102
+ if (empty($_COOKIE['qtrans_edit_language']) === false) {
103
+ $enabledLanguages = qtrans_getSortedLanguages();
104
+ if (in_array($_COOKIE['qtrans_edit_language'], $enabledLanguages)) {
105
+ $language = $_COOKIE['qtrans_edit_language'];
106
+ }
107
+ }
108
+ return $language;
109
+ }
110
+
111
}