ACF qTranslate - Version 1.7.6

Version Description

  • Core: qTranslate-X support for Text, Text Area and WYSIWYG inside repeater
  • Bug Fix: Display qTranslate-X switcher for qTranslate Field Types
  • Bug Fix: Incorrectly loading in Media Library and Widgets screens
Download this release

Release Info

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

Code changes from version 1.7.5 to 1.7.6

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.5
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.6
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
assets/acf_4/main.js ADDED
@@ -0,0 +1,60 @@
1
+
2
+ /**
3
+ * Handle qTranslate-X integrations after jQuery.ready()
4
+ */
5
+ jQuery(function($) {
6
+ $(window).load(function() {
7
+
8
+ // only proceed if qTranslate is loaded
9
+ if (!qTranslateConfig || !qTranslateConfig.qtx) {
10
+ return;
11
+ }
12
+
13
+ // Add display hooks to ACF metaboxes
14
+ $('.acf_postbox h3 span').each(function() {
15
+ this.id = _.uniqueId('acf-postbox-h3-span');
16
+ qTranslateConfig.qtx.addDisplayHookById(this.id);
17
+ });
18
+
19
+ // Selectors for supported field types
20
+ var field_types = [
21
+ '.field_type-text input:text',
22
+ '.field_type-textarea textarea',
23
+ '.field_type-wysiwyg .wp-editor-area'
24
+ ].join(',');
25
+
26
+ // Remove content hooks from ACF Repeater and Flexible Fields clones
27
+ $('.row-clone .qtranxs-translatable').each(function() {
28
+ qTranslateConfig.qtx.removeContentHook(this);
29
+ });
30
+
31
+ // Add content hooks for existing fields
32
+ $('.field_type-repeater .row, .field_type-flexible_content .row').each(function() {
33
+ var row = $(this);
34
+ row.find(field_types).not('.qtranxs-translatable').each(function() {
35
+ qTranslateConfig.qtx.addContentHookC(this, row.closest('form').get(0));
36
+ });
37
+ })
38
+
39
+ // Watch and add content hooks when new fields are added
40
+ $(document).on('acf/setup_fields', function(e, new_field) {
41
+ new_field = $(new_field);
42
+ if (new_field.hasClass('row')) {
43
+ new_field.find(field_types).not('.qtranxs-translatable').each(function() {
44
+ qTranslateConfig.qtx.addContentHookC(this, new_field.closest('form').get(0));
45
+ });
46
+ }
47
+ });
48
+
49
+ // Watch and remove content hooks when fields are removed
50
+ $('body').on('click', '.row .acf-button-remove', function() {
51
+ var row = $(this).closest('.row');
52
+ row.find(field_types).filter('.qtranxs-translatable').each(function() {
53
+ qTranslateConfig.qtx.removeContentHook(this);
54
+ });
55
+ });
56
+
57
+ });
58
+ });
59
+
60
+
assets/acf_5/main.js CHANGED
@@ -44,3 +44,74 @@ acf.fields.qtranslate_wysiwyg = acf.fields.wysiwyg.extend({
44
this.focus();
45
}
46
});
44
this.focus();
45
}
46
});
47
+
48
+
49
+
50
+ /**
51
+ * Handle qTranslate-X integrations after jQuery.ready()
52
+ */
53
+ jQuery(function($) {
54
+ $(window).load(function() {
55
+
56
+ // only proceed if qTranslate is loaded
57
+ if (!qTranslateConfig || !qTranslateConfig.qtx) {
58
+ return;
59
+ }
60
+
61
+ // Add display hooks to ACF metaboxes
62
+ $('.acf-postbox h3 span').each(function() {
63
+ this.id = _.uniqueId('acf-postbox-h3-span');
64
+ qTranslateConfig.qtx.addDisplayHookById(this.id);
65
+ });
66
+
67
+ // Selectors for supported field types
68
+ var field_types = {
69
+ repeater: 'input:hidden',
70
+ flexible_content: 'input:hidden',
71
+ text: 'input:text',
72
+ textarea: 'textarea',
73
+ wysiwyg: '.wp-editor-area',
74
+ };
75
+
76
+ // Remove content hooks from ACF Repeater and Flexible Fields clones
77
+ $('.acf-clone .wp-editor-area.qtranxs-translatable').each(function() {
78
+ qTranslateConfig.qtx.removeContentHook(this);
79
+ });
80
+
81
+ // Setup field types
82
+ $.each(field_types, function(field_type, selector) {
83
+
84
+ // Add content hooks for existing fields
85
+ acf.get_fields({ type: field_type }).each(function() {
86
+ var form = $(this).closest('form').get(0);
87
+ var field = $(this).find(selector).get(0);
88
+ qTranslateConfig.qtx.addContentHookC(field, form);
89
+ });
90
+
91
+ // Watch and add content hooks when new fields are added
92
+ acf.add_action('append_field/type=' + field_type, function($el) {
93
+ var form = $el.closest('form').get(0);
94
+ var field = $el.find(selector).get(0);
95
+ qTranslateConfig.qtx.addContentHookC(field, form);
96
+ // Run at higher integer priority than the default in case the ACF handlers
97
+ // change the id of the underlying input
98
+ }, 100);
99
+
100
+ });
101
+
102
+ // Watch and remove content hooks when fields are removed
103
+ // however ACF removes the elements from the DOM early so
104
+ // we must hook into handler and perform updates there
105
+ var _hooked_repeater_remove = acf.fields.repeater.remove;
106
+ acf.fields.repeater.remove = function(event) {
107
+ var row = event.$el.closest('.acf-row');
108
+ row.find(_.toArray(field_types).join(',')).filter('.qtranxs-translatable').each(function() {
109
+ qTranslateConfig.qtx.removeContentHook(this);
110
+ });
111
+ // call the original handler
112
+ _hooked_repeater_remove.call(this, event);
113
+ }
114
+
115
+ });
116
+ });
117
+
assets/common.js CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
jQuery(function($) {
4
5
var $body = $('body');
@@ -48,5 +46,21 @@ jQuery(function($) {
48
});
49
});
50
51
- });
52
1
jQuery(function($) {
2
3
var $body = $('body');
46
});
47
});
48
49
50
+ /**
51
+ * Handle qTranslate-X integrations after jQuery.ready()
52
+ */
53
+ $(window).load(function() {
54
+ // only proceed if qTranslate is loaded
55
+ if (!qTranslateConfig || !qTranslateConfig.qtx) {
56
+ return;
57
+ }
58
+
59
+ // Add display hooks to ACF metaboxes
60
+ $('.acf_postbox h3 span, .acf-postbox h3 span').each(function() {
61
+ this.id = _.uniqueId('acf-postbox-h3-span');
62
+ qTranslateConfig.qtx.addDisplayHookById(this.id);
63
+ });
64
+ });
65
+
66
+ });
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.5
7
- Stable tag: 1.7.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -59,6 +59,11 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
59
60
== Changelog ==
61
62
= 1.7.5 =
63
* Core: Updates to README file
64
* Bug Fix: Updated to visible ACF fields detection
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.6
7
+ Stable tag: 1.7.6
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
59
60
== Changelog ==
61
62
+ = 1.7.6 =
63
+ * Core: qTranslate-X support for Text, Text Area and WYSIWYG inside repeater
64
+ * Bug Fix: Display qTranslate-X switcher for qTranslate Field Types
65
+ * Bug Fix: Incorrectly loading in Media Library and Widgets screens
66
+
67
= 1.7.5 =
68
* Core: Updates to README file
69
* Bug Fix: Updated to visible ACF fields detection
src/acf_4/acf.php CHANGED
@@ -46,9 +46,10 @@ class acf_qtranslate_acf_4 implements acf_qtranslate_acf_interface {
46
* Load javascript and stylesheets on admin pages.
47
*/
48
public function admin_enqueue_scripts() {
49
- if ($this->get_acf_field_group_filters()) {
50
- wp_enqueue_style('acf_qtranslate_common', plugins_url('/assets/common.css', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
51
- wp_enqueue_script('acf_qtranslate_common', plugins_url('/assets/common.js', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
52
}
53
}
54
@@ -80,6 +81,13 @@ class acf_qtranslate_acf_4 implements acf_qtranslate_acf_interface {
80
'email',
81
'text',
82
'textarea',
83
);
84
85
$visible_field_groups = apply_filters('acf/location/match_field_groups', array(), $filter);
46
* Load javascript and stylesheets on admin pages.
47
*/
48
public function admin_enqueue_scripts() {
49
+ if ($this->get_visible_acf_fields()) {
50
+ wp_enqueue_style('acf_qtranslate_common', plugins_url('/assets/common.css', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
51
+ wp_enqueue_script('acf_qtranslate_common', plugins_url('/assets/common.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
52
+ wp_enqueue_script('acf_qtranslate_main', plugins_url('/assets/acf_4/main.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
53
}
54
}
55
81
'email',
82
'text',
83
'textarea',
84
+ 'repeater',
85
+ 'flexible_content',
86
+ 'qtranslate_file',
87
+ 'qtranslate_image',
88
+ 'qtranslate_text',
89
+ 'qtranslate_textarea',
90
+ 'qtranslate_wysiwyg'
91
);
92
93
$visible_field_groups = apply_filters('acf/location/match_field_groups', array(), $filter);
src/acf_5/acf.php CHANGED
@@ -44,10 +44,10 @@ class acf_qtranslate_acf_5 implements acf_qtranslate_acf_interface {
44
* Load javascript and stylesheets on admin pages.
45
*/
46
public function admin_enqueue_scripts() {
47
- if ($this->get_acf_field_group_filters()) {
48
wp_enqueue_style('acf_qtranslate_common', plugins_url('/assets/common.css', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
49
- wp_enqueue_script('acf_qtranslate_common', plugins_url('/assets/common.js', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
50
- wp_enqueue_script('acf_qtranslate_main', plugins_url('/assets/acf_5/main.js', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
51
}
52
}
53
@@ -97,6 +97,13 @@ class acf_qtranslate_acf_5 implements acf_qtranslate_acf_interface {
97
'email',
98
'text',
99
'textarea',
100
);
101
102
foreach (acf_get_field_groups($filter) as $field_group) {
44
* Load javascript and stylesheets on admin pages.
45
*/
46
public function admin_enqueue_scripts() {
47
+ if ($this->get_visible_acf_fields()) {
48
wp_enqueue_style('acf_qtranslate_common', plugins_url('/assets/common.css', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
49
+ wp_enqueue_script('acf_qtranslate_common', plugins_url('/assets/common.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
50
+ wp_enqueue_script('acf_qtranslate_main', plugins_url('/assets/acf_5/main.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
51
}
52
}
53
97
'email',
98
'text',
99
'textarea',
100
+ 'repeater',
101
+ 'flexible_content',
102
+ 'qtranslate_file',
103
+ 'qtranslate_image',
104
+ 'qtranslate_text',
105
+ 'qtranslate_textarea',
106
+ 'qtranslate_wysiwyg'
107
);
108
109
foreach (acf_get_field_groups($filter) as $field_group) {