ACF qTranslate - Version 1.3

Version Description

Updated styles for Wordpress 3.8 Updated monkey patch qTranslate to fix bug with multiple WYSIWYG editors

Download this release

Release Info

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

Code changes from version 1.2 to 1.3

Files changed (4) hide show
  1. acf-qtranslate.php +6 -1
  2. assets/main.css +42 -48
  3. fields/image.php +105 -107
  4. readme.txt +6 -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.2.0
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
@@ -55,4 +55,9 @@ function acf_qtranslate_monkey_patch() {
55
$q_config['js']['qtrans_switch'] = "originalSwitchEditors = jQuery.extend(true, {}, switchEditors);\n" . $q_config['js']['qtrans_switch'];
56
$q_config['js']['qtrans_switch'] = preg_replace("/(var vta = document\.getElementById\('qtrans_textarea_' \+ id\);)/", "\$1\nif(!vta)return originalSwitchEditors.go(id, lang);", $q_config['js']['qtrans_switch']);
57
}
58
}
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.3.0
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
55
$q_config['js']['qtrans_switch'] = "originalSwitchEditors = jQuery.extend(true, {}, switchEditors);\n" . $q_config['js']['qtrans_switch'];
56
$q_config['js']['qtrans_switch'] = preg_replace("/(var vta = document\.getElementById\('qtrans_textarea_' \+ id\);)/", "\$1\nif(!vta)return originalSwitchEditors.go(id, lang);", $q_config['js']['qtrans_switch']);
57
}
58
+
59
+ // https://github.com/funkjedi/acf-qtranslate/issues/2#issuecomment-37612918
60
+ if (strpos($q_config['js']['qtrans_hook_on_tinyMCE'], 'ed.editorId.match(/^qtrans_/)') === false) {
61
+ $q_config['js']['qtrans_hook_on_tinyMCE'] = preg_replace("/(qtrans_save\(switchEditors\.pre_wpautop\(o\.content\)\);)/", "if (ed.editorId.match(/^qtrans_/)) \$1", $q_config['js']['qtrans_hook_on_tinyMCE']);
62
+ }
63
}
assets/main.css CHANGED
@@ -1,16 +1,48 @@
1
2
- .multi-language-field { margin-top: -32px }
3
- .repeater .multi-language-field { margin-top: 0 }
4
5
6
.multi-language-field .wp-switch-editor {
7
- border-color: #dfdfdf;
8
position: relative;
9
top: 1px;
10
z-index: 100;
11
}
12
13
- .multi-language-field.focused .wp-switch-editor { border-color: #bbb }
14
15
.multi-language-field .wp-switch-editor.current-language {
16
background-color: #fff;
@@ -18,7 +50,6 @@
18
color: #333;
19
}
20
21
-
22
.multi-language-field > input,
23
.multi-language-field > textarea,
24
.multi-language-field > fieldset,
@@ -29,42 +60,6 @@
29
.multi-language-field .acf_input textarea,
30
.multi-language-field .current-language { display: block !important }
31
32
-
33
- .multi-language-widget .wp-switch-editor {
34
- height: 18px;
35
- font: 13px/18px Arial,Helvetica,sans-serif normal;
36
- margin: 5px 5px 0 0;
37
- padding: 4px 5px 2px;
38
- float: right;
39
- cursor: pointer;
40
- border-width: 1px;
41
- border-style: solid;
42
- border-top-right-radius: 3px;
43
- border-top-left-radius: 3px;
44
- background-color: #f1f1f1;
45
- border-color: #dfdfdf;
46
- color: #999;
47
- }
48
-
49
- .multi-language-widget .wp-switch-editor.current-language {
50
- background: #ededed;
51
- border-bottom-color: #ededed;
52
- }
53
-
54
- .multi-language-widget.button-widget .wp-switch-editor.current-language {
55
- background-color: #fff;
56
- border-bottom-color: #fff;
57
- }
58
-
59
- .multi-language-widget.text-widget fieldset {
60
- background: #ededed;
61
- border: 1px solid #dfdfdf;
62
- border-radius: 5px;
63
- margin: 0 0 10px 0;
64
- padding: 10px;
65
- width: 95%;
66
- }
67
-
68
.multi-language-field-wysiwyg { margin-top: 0 }
69
70
.multi-language-field .acf-image-uploader {
@@ -73,16 +68,15 @@
73
border: 1px solid #dfdfdf;
74
}
75
76
.multi-language-field-wysiwyg .wp-switch-editor {
77
- background-color: #f1f1f1;
78
- border-color: #dfdfdf;
79
- border-bottom-color: #ccc;
80
- top: 0px;
81
}
82
83
.multi-language-field-wysiwyg .wp-switch-editor.current-language {
84
- background-color: #f4f4f4;
85
- border-color: #ccc;
86
- border-bottom-color: #f4f4f4;
87
}
88
1
2
3
+ #edit-slug-box { margin-top: -15px; }
4
+
5
+ .qtrans_title_wrap {
6
+ margin-bottom: 20px;
7
+ padding: 0 !important;
8
+ border: 0 !important;
9
+ }
10
+
11
+ .qtrans_title_input {
12
+ padding: 3px 8px !important;
13
+ font-size: 1.7em;
14
+ line-height: 100%;
15
+ height: 1.7em;
16
+ outline: 0 !important;
17
+ margin: 0;
18
+ }
19
+
20
+
21
+ .acf_wysiwyg .wp-editor-container { border: 1px solid #e5e5e5 !important; }
22
23
.multi-language-field .wp-switch-editor {
24
+ border-color: #dedede;
25
position: relative;
26
top: 1px;
27
z-index: 100;
28
}
29
30
+ .multi-language-field input,
31
+ .multi-language-field input:focus,
32
+ .multi-language-field textarea,
33
+ .multi-language-field textarea:focus {
34
+ border-color: #ddd;
35
+ box-shadow: none;
36
+ }
37
+
38
+ .multi-language-field.focused .wp-switch-editor {
39
+ border-bottom-color: #ddd;
40
+ }
41
+
42
+ .multi-language-field.focused .wp-switch-editor.current-language {
43
+ border-color: #ddd;
44
+ border-bottom-color: #fff;
45
+ }
46
47
.multi-language-field .wp-switch-editor.current-language {
48
background-color: #fff;
50
color: #333;
51
}
52
53
.multi-language-field > input,
54
.multi-language-field > textarea,
55
.multi-language-field > fieldset,
60
.multi-language-field .acf_input textarea,
61
.multi-language-field .current-language { display: block !important }
62
63
.multi-language-field-wysiwyg { margin-top: 0 }
64
65
.multi-language-field .acf-image-uploader {
68
border: 1px solid #dfdfdf;
69
}
70
71
+ .multi-language-field .acf-image-uploader.current-language { background: #fff; }
72
+
73
.multi-language-field-wysiwyg .wp-switch-editor {
74
+ background-color: #ebebeb;
75
+ border-color: #dedede;
76
}
77
78
.multi-language-field-wysiwyg .wp-switch-editor.current-language {
79
+ background-color: #f5f5f5;
80
+ border-bottom-color: #f5f5f5;
81
}
82
fields/image.php CHANGED
@@ -3,13 +3,11 @@
3
class acf_field_qtranslate_image extends acf_field_image
4
{
5
6
- function __construct()
7
- {
8
-
9
- $this->name = 'qtranslate_image';
10
- $this->label = __("Image", 'acf');
11
- $this->category = __("qTranslate", 'acf');
12
-
13
$this->defaults = array(
14
'save_format' => 'object',
15
'preview_size' => 'thumbnail',
@@ -18,114 +16,114 @@ class acf_field_qtranslate_image extends acf_field_image
18
$this->l10n = array(
19
'select' => __("Select Image",'acf'),
20
'edit' => __("Edit Image",'acf'),
21
'uploadedTo' => __("uploaded to this post",'acf'),
22
);
23
24
25
- acf_field::__construct();
26
-
27
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
28
- add_action('acf_head-update_attachment-' . $this->name, array($this, 'acf_head_update_attachment'));
29
- add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
30
31
add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
32
add_action('wp_ajax_nopriv_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
33
- add_action('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
34
- }
35
-
36
- function create_field($field)
37
- {
38
- if (!acf_qtranslate_enabled()) {
39
- acf_field_image::create_field($field);
40
- return;
41
- }
42
-
43
- global $q_config;
44
- $languages = qtrans_getSortedLanguages(true);
45
- $values = qtrans_split($field['value'], $quicktags = true);
46
- $currentLanguage = qtrans_getLanguage();
47
-
48
- echo '<div class="multi-language-field multi-language-field-image">';
49
-
50
- foreach ($languages as $language) {
51
- $class = 'wp-switch-editor';
52
- if ($language === $currentLanguage) {
53
- $class .= ' current-language';
54
- }
55
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
56
- }
57
-
58
- $base_class = $field['class'];
59
- $base_name = $field['name'];
60
- foreach ($languages as $language) :
61
- $value = $values[$language];
62
- $o = array(
63
- 'class' => '',
64
- 'url' => '',
65
- );
66
-
67
- if ($value && is_numeric($value)) {
68
- $url = wp_get_attachment_image_src($value, $field['preview_size']);
69
- $o['class'] = 'active';
70
- $o['url'] = $url[0];
71
- }
72
- $field['class'] = $base_class;
73
- if ($language === $currentLanguage) {
74
- $field['class'] .= ' current-language';
75
- $o['class'] .= ' current-language';
76
- }
77
-
78
- $field['name'] = $base_name . '[' . $language . ']';
79
-
80
- ?>
81
- <div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" data-language="<?php echo $language; ?>" >
82
- <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $value; ?>" />
83
- <div class="has-image">
84
- <div class="hover">
85
- <ul class="bl">
86
- <li><a class="acf-button-delete ir" href="#"><?php _e("Remove", 'acf'); ?></a></li>
87
- <li><a class="acf-button-edit ir" href="#"><?php _e("Edit", 'acf'); ?></a></li>
88
- </ul>
89
- </div>
90
- <img class="acf-image-image" src="<?php echo $o['url']; ?>" alt="" />
91
- </div>
92
- <div class="no-image">
93
- <p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
94
- </div>
95
- </div>
96
-
97
- <?php endforeach;
98
-
99
- echo '</div>';
100
- }
101
-
102
- function format_value($value, $post_id, $field)
103
- {
104
- return $value;
105
- }
106
-
107
- function format_value_for_api($value, $post_id, $field)
108
- {
109
- if (acf_qtranslate_enabled()) {
110
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
111
- }
112
-
113
- return acf_field_image::format_value_for_api($value, $post_id, $field);
114
- }
115
-
116
- function update_value($value, $post_id, $field)
117
- {
118
- if (acf_qtranslate_enabled()) {
119
- $value = qtrans_join($value);
120
- }
121
-
122
- return $value;
123
- }
124
-
125
- function create_options( $field )
126
- {
127
- acf_field_image::create_options($field);
128
- }
129
}
130
131
new acf_field_qtranslate_image();
3
class acf_field_qtranslate_image extends acf_field_image
4
{
5
6
+ function __construct()
7
+ {
8
+ $this->name = 'qtranslate_image';
9
+ $this->label = __("Image", 'acf');
10
+ $this->category = __("qTranslate", 'acf');
11
$this->defaults = array(
12
'save_format' => 'object',
13
'preview_size' => 'thumbnail',
16
$this->l10n = array(
17
'select' => __("Select Image",'acf'),
18
'edit' => __("Edit Image",'acf'),
19
+ 'update' => __("Update Image",'acf'),
20
'uploadedTo' => __("uploaded to this post",'acf'),
21
);
22
23
+ acf_field::__construct();
24
25
+ // filters
26
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
27
+ add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
28
29
+ // JSON
30
add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
31
add_action('wp_ajax_nopriv_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
32
+ }
33
+
34
+ function create_field($field)
35
+ {
36
+ if (!acf_qtranslate_enabled()) {
37
+ acf_field_image::create_field($field);
38
+ return;
39
+ }
40
+
41
+ global $q_config;
42
+ $languages = qtrans_getSortedLanguages(true);
43
+ $values = qtrans_split($field['value'], $quicktags = true);
44
+ $currentLanguage = qtrans_getLanguage();
45
+
46
+ echo '<div class="multi-language-field multi-language-field-image">';
47
+
48
+ foreach ($languages as $language) {
49
+ $class = 'wp-switch-editor';
50
+ if ($language === $currentLanguage) {
51
+ $class .= ' current-language';
52
+ }
53
+ echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
54
+ }
55
+
56
+ $base_class = $field['class'];
57
+ $base_name = $field['name'];
58
+ foreach ($languages as $language) :
59
+ $value = $values[$language];
60
+ $o = array(
61
+ 'class' => '',
62
+ 'url' => '',
63
+ );
64
+
65
+ if ($value && is_numeric($value)) {
66
+ $url = wp_get_attachment_image_src($value, $field['preview_size']);
67
+ $o['class'] = 'active';
68
+ $o['url'] = $url[0];
69
+ }
70
+
71
+ $field['class'] = $base_class;
72
+ if ($language === $currentLanguage) {
73
+ $field['class'] .= ' current-language';
74
+ $o['class'] .= ' current-language';
75
+ }
76
+
77
+ $field['name'] = $base_name . '[' . $language . ']';
78
+
79
+ ?>
80
+ <div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" data-language="<?php echo $language; ?>" >
81
+ <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $value; ?>" />
82
+ <div class="has-image">
83
+ <div class="hover">
84
+ <ul class="bl">
85
+ <li><a class="acf-button-delete ir" href="#"><?php _e("Remove", 'acf'); ?></a></li>
86
+ <li><a class="acf-button-edit ir" href="#"><?php _e("Edit", 'acf'); ?></a></li>
87
+ </ul>
88
+ </div>
89
+ <img class="acf-image-image" src="<?php echo $o['url']; ?>" alt="" />
90
+ </div>
91
+ <div class="no-image">
92
+ <p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
93
+ </div>
94
+ </div>
95
+ <?php endforeach;
96
+
97
+ echo '</div>';
98
+ }
99
+
100
+ function format_value($value, $post_id, $field)
101
+ {
102
+ return $value;
103
+ }
104
+
105
+ function format_value_for_api($value, $post_id, $field)
106
+ {
107
+ if (acf_qtranslate_enabled()) {
108
+ $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
109
+ }
110
+
111
+ return acf_field_image::format_value_for_api($value, $post_id, $field);
112
+ }
113
+
114
+ function update_value($value, $post_id, $field)
115
+ {
116
+ if (acf_qtranslate_enabled()) {
117
+ $value = qtrans_join($value);
118
+ }
119
+
120
+ return $value;
121
+ }
122
+
123
+ function create_options( $field )
124
+ {
125
+ acf_field_image::create_options($field);
126
+ }
127
}
128
129
new acf_field_qtranslate_image();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: funkjedi
3
Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
Requires at least: 3.0.0
5
Tested up to: 3.7.1
6
- Version: 1.2
7
- Stable tag: 1.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -48,6 +48,10 @@ The plugin is based on code samples posted to the [ACF support forums](http://ol
48
49
== Changelog ==
50
51
= 1.2 =
52
Monkey patch qTranslate to fix [bug with multiple WYSIWYG editors](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3497).
53
3
Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
Requires at least: 3.0.0
5
Tested up to: 3.7.1
6
+ Version: 1.3
7
+ Stable tag: 1.3
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
48
49
== Changelog ==
50
51
+ = 1.3 =
52
+ Updated styles for Wordpress 3.8
53
+ Updated monkey patch qTranslate to fix [bug with multiple WYSIWYG editors](https://github.com/funkjedi/acf-qtranslate/issues/2#issuecomment-37612918)
54
+
55
= 1.2 =
56
Monkey patch qTranslate to fix [bug with multiple WYSIWYG editors](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3497).
57