ACF qTranslate - Version 1.7.18

Version Description

  • Core: Prevent error on older versions of ACF5
  • Bug Fix: Updated ACF5 qTranslate File field to match recent ACF update
Download this release

Release Info

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

Code changes from version 1.7.17 to 1.7.18

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.17
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.18
7
Author: funkjedi
8
Author URI: http://funkjedi.com
9
License: GPLv2 or later
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.6.1
6
- Version: 1.7.17
7
- Stable tag: 1.7.17
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -54,6 +54,10 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac
54
55
== Changelog ==
56
57
= 1.7.17 =
58
* Core: Initialize on either `plugins_loaded` or `after_setup_theme`
59
* Core: Drop support for qTranslate Plus, mqTranslate, and zTranslate
3
Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
Requires at least: 3.5.0
5
Tested up to: 4.6.1
6
+ Version: 1.7.18
7
+ Stable tag: 1.7.18
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
54
55
== Changelog ==
56
57
+ = 1.7.18 =
58
+ * Core: Prevent error on older versions of ACF5
59
+ * Bug Fix: Updated ACF5 qTranslate File field to match recent ACF update
60
+
61
= 1.7.17 =
62
* Core: Initialize on either `plugins_loaded` or `after_setup_theme`
63
* Core: Drop support for qTranslate Plus, mqTranslate, and zTranslate
src/acf_5/fields/file.php CHANGED
@@ -44,7 +44,6 @@ class acf_qtranslate_acf_5_file extends acf_field_file {
44
45
// filters
46
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
47
- add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
48
49
acf_field::__construct();
50
}
44
45
// filters
46
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
47
48
acf_field::__construct();
49
}
src/acf_5/fields/wysiwyg.php CHANGED
@@ -34,8 +34,10 @@ class acf_qtranslate_acf_5_wysiwyg extends acf_field_wysiwyg {
34
'default_value' => '',
35
);
36
37
- // add acf_the_content filters
38
- $this->add_filters();
39
40
// actions
41
add_action('acf/input/admin_footer', array($this, 'input_admin_footer'));
34
'default_value' => '',
35
);
36
37
+ // add acf_the_content filters
38
+ if (method_exists($this, 'add_filters')) {
39
+ $this->add_filters();
40
+ }
41
42
// actions
43
add_action('acf/input/admin_footer', array($this, 'input_admin_footer'));
trunk/acf-qtranslate.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
- /*
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.17
7
- Author: funkjedi
8
- Author URI: http://funkjedi.com
9
- License: GPLv2 or later
10
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
- */
12
-
13
- define('ACF_QTRANSLATE_PLUGIN', __FILE__);
14
- define('ACF_QTRANSLATE_PLUGIN_DIR', plugin_dir_path(ACF_QTRANSLATE_PLUGIN));
15
-
16
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/plugin.php';
17
- new acf_qtranslate_plugin;
trunk/assets/acf_4/main.js DELETED
File without changes
trunk/assets/acf_4/qtranslatex.js DELETED
@@ -1,114 +0,0 @@
1
-
2
- jQuery(window).load(function() {
3
-
4
- // Only proceed if qTranslate is loaded
5
- if (typeof qTranslateConfig != 'object' || typeof qTranslateConfig.qtx != 'object') {
6
- return;
7
- }
8
-
9
- // Enable the language switching buttons
10
- qTranslateConfig.qtx.enableLanguageSwitchingButtons('block');
11
-
12
-
13
- // Ensure that translation of standard field types is enabled
14
- if (!window.acf_qtranslate_translate_standard_field_types) {
15
- return;
16
- }
17
-
18
- // Selectors for supported field types
19
- var field_types = [
20
- '.field_type-text input:text',
21
- '.field_type-textarea textarea',
22
- '.field_type-wysiwyg .wp-editor-area'
23
- ].join(',');
24
-
25
- // Remove content hooks from ACF Fields
26
- jQuery('.acf_postbox .field').find('.qtranxs-translatable').each(function() {
27
- qTranslateConfig.qtx.removeContentHook(this);
28
- });
29
-
30
- var post_type = jQuery('#post_type').val();
31
-
32
- // Whitelist fields for translation
33
- function isTranslatableField(field){
34
- if (post_type === 'acf-field-group') {
35
- if (field.id.match(/acf-field-field_[a-z0-9]+_label/)) return true;
36
- if (field.id.match(/acf-field-field_[a-z0-9]+_instructions/)) return true;
37
- if (field.id.match(/acf-field-field_[a-z0-9]+_default_value/)) return true;
38
- return false;
39
- }
40
- return true;
41
- }
42
-
43
- // Watch and add content hooks when new fields are added
44
- jQuery(document).on('acf/setup_fields', function(e, new_field) {
45
- new_field = jQuery(new_field);
46
- new_field.find(field_types).not('.qtranxs-translatable').each(function() {
47
- var field = jQuery(this);
48
-
49
- // Skip over fields inside of ACF Repeater
50
- // and Flexible Content clone rows
51
- if (field.parents('.row-clone').length) {
52
- return;
53
- }
54
-
55
- if (!isTranslatableField(field)) return;
56
-
57
- qTranslateConfig.qtx.addContentHookC(this, field.closest('form').get(0));
58
-
59
- // Since ACFv4 doesn't update tinyMCEPreInit.mceInit so we
60
- // need to manully set it so that the translation hooks apply properly
61
- if (field.hasClass('wp-editor-area')) {
62
- if (typeof tinyMCEPreInit.mceInit[this.id] == 'undefined') {
63
- var mceInit = jQuery.extend({}, tinyMCEPreInit.mceInit.acf_settings);
64
- mceInit.id = this.id;
65
- tinyMCEPreInit.mceInit[this.id] = mceInit;
66
- }
67
- }
68
- });
69
-
70
- // Run in a setTimeout block to give the tinyMCE instance
71
- // enough time to initialize before setting the editor hooks
72
- setTimeout(function(){
73
- jQuery.each(tinyMCE.editors, function(i, ed){
74
- setEditorHooks(ed);
75
- });
76
- },50);
77
- });
78
-
79
- // Watch and remove content hooks when fields are removed
80
- jQuery('body').on('click', '.row .acf-button-remove', function() {
81
- var row = jQuery(this).closest('.row');
82
- row.find(field_types).filter('.qtranxs-translatable').each(function() {
83
- qTranslateConfig.qtx.removeContentHook(this);
84
- });
85
- });
86
-
87
-
88
- // Extracted from qTranslate-X
89
- // admin/js/common.js#L840
90
- function setEditorHooks(ed) {
91
- var id = ed.id;
92
- if (!id) return;
93
- var h=qTranslateConfig.qtx.hasContentHook(id);
94
- if(!h || h.mce) return;
95
- h.mce=ed;
96
- ed.getContainer().className += ' qtranxs-translatable';
97
- ed.getElement().className += ' qtranxs-translatable';
98
- var updateTinyMCEonInit = h.updateTinyMCEonInit;
99
- if (updateTinyMCEonInit == null) {
100
- var text_e = ed.getContent({format: 'html'}).replace(/\s+/g,'');
101
- var text_h = h.contentField.value.replace(/\s+/g,'');
102
- updateTinyMCEonInit = text_e != text_h;
103
- }
104
- if (updateTinyMCEonInit) {
105
- text = h.contentField.value;
106
- if (h.wpautop && window.switchEditors) {
107
- text = window.switchEditors.wpautop(text);
108
- }
109
- h.mce.setContent(text,{format: 'html'});
110
- }
111
- return h;
112
- }
113
-
114
- });
trunk/assets/acf_5/main.js DELETED
@@ -1,51 +0,0 @@
1
-
2
- /**
3
- * Clone functionality from standard Image field type
4
- */
5
- acf.fields.qtranslate_image = acf.fields.image.extend({
6
- type: 'qtranslate_image',
7
- focus: function() {
8
- this.$el = this.$field.find('.acf-image-uploader.current-language');
9
- this.$input = this.$el.find('input[type="hidden"]');
10
- this.$img = this.$el.find('img');
11
-
12
- this.o = acf.get_data(this.$el);
13
- }
14
- });
15
-
16
- /**
17
- * Clone functionality from standard File field type
18
- */
19
- acf.fields.qtranslate_file = acf.fields.file.extend({
20
- type: 'qtranslate_file',
21
- focus: function() {
22
- this.$el = this.$field.find('.acf-file-uploader.current-language');
23
- this.$input = this.$el.find('input[type="hidden"]');
24
-
25
- this.o = acf.get_data(this.$el);
26
- }
27
- });
28
-
29
- /**
30
- * Clone functionality from standard WYSIWYG field type
31
- */
32
- acf.fields.qtranslate_wysiwyg = acf.fields.wysiwyg.extend({
33
- type: 'qtranslate_wysiwyg',
34
- focus: function() {
35
- this.$el = this.$field.find('.wp-editor-wrap.current-language').last();
36
- this.$textarea = this.$el.find('textarea');
37
- this.o = acf.get_data(this.$el);
38
- this.o.id = this.$textarea.attr('id');
39
- },
40
- initialize: function() {
41
- var self = this;
42
- this.$field.find('.wp-editor-wrap').each(function() {
43
- self.$el = jQuery(this);
44
- self.$textarea = self.$el.find('textarea');
45
- self.o = acf.get_data(self.$el);
46
- self.o.id = self.$textarea.attr('id');
47
- acf.fields.wysiwyg.initialize.call(self);
48
- });
49
- this.focus();
50
- }
51
- });
trunk/assets/acf_5/qtranslatex.js DELETED
@@ -1,103 +0,0 @@
1
-
2
- (function(){
3
- var windowLoadCompleted = false;
4
- jQuery(window).load(function() {
5
-
6
- // Prevent from being triggered again
7
- if (windowLoadCompleted) {
8
- return;
9
- }
10
-
11
- windowLoadCompleted = true;
12
-
13
- // Only proceed if qTranslate is loaded
14
- if (typeof qTranslateConfig != 'object' || typeof qTranslateConfig.qtx != 'object') {
15
- return;
16
- }
17
-
18
- // Enable the language switching buttons
19
- qTranslateConfig.qtx.enableLanguageSwitchingButtons('block');
20
-
21
-
22
- // Ensure that translation of standard field types is enabled
23
- if (!window.acf_qtranslate_translate_standard_field_types) {
24
- return;
25
- }
26
-
27
- // Selectors for supported field types
28
- var field_types = {
29
- text: 'input:text',
30
- textarea: 'textarea',
31
- wysiwyg: '.wp-editor-area',
32
- };
33
-
34
- // Remove content hooks from ACF Fields
35
- jQuery('.acf-postbox .acf-field').find('.qtranxs-translatable').each(function() {
36
- qTranslateConfig.qtx.removeContentHook(this);
37
- });
38
-
39
- var post_type = jQuery('#post_type').val();
40
-
41
- // Whitelist fields for translation
42
- function isTranslatableField(field){
43
- if (post_type === 'acf-field-group') {
44
- if (field.id.match(/acf_fields-\d+-label/)) return true;
45
- if (field.id.match(/acf_fields-\d+-instructions/)) return true;
46
- if (field.id.match(/acf_fields-\d+-default_value/)) return true;
47
- return false;
48
- }
49
- return true;
50
- }
51
-
52
- // Setup field types
53
- jQuery.each(field_types, function(field_type, selector) {
54
-
55
- // Add content hooks for existing fields
56
- acf.get_fields({ type: field_type }).each(function() {
57
- var form = jQuery(this).closest('form').get(0);
58
- var field = jQuery(this).find(selector).get(0);
59
- if (!isTranslatableField(field)) return;
60
- qTranslateConfig.qtx.addContentHookC(field, form);
61
- });
62
-
63
- // Watch and add content hooks when new fields are added
64
- acf.add_action('append_field/type=' + field_type, function($el) {
65
- var form = $el.closest('form').get(0);
66
- var field = $el.find(selector).get(0);
67
- if (!isTranslatableField(field)) return;
68
- qTranslateConfig.qtx.addContentHookC(field, form);
69
-
70
- if (jQuery(field).hasClass('wp-editor-area')) {
71
- //qTranslateConfig.qtx.addContentHooksTinyMCE();
72
-
73
- // We must manually trigger load event so that the
74
- // loadTinyMceHooks function which calls setEditorHooks is executed
75
- var loadEvent = document.createEvent('UIEvents');
76
- loadEvent.initEvent('load',false,false,window);
77
- window.dispatchEvent(loadEvent);
78
- }
79
-
80
- // Run at higher integer priority than the default in case the ACF handlers
81
- // change the id of the underlying input
82
- }, 100);
83
-
84
- });
85
-
86
- //qTranslateConfig.qtx.addContentHooksTinyMCE();
87
-
88
- // Watch and remove content hooks when fields are removed
89
- // however ACF removes the elements from the DOM early so
90
- // we must hook into handler and perform updates there
91
- var _hooked_repeater_remove = acf.fields.repeater.remove;
92
- acf.fields.repeater.remove = function($el) {
93
- var row = ($el.$el || $el).closest('.acf-row'); // support old versions of ACF5PRO as well
94
- row.find(_.toArray(field_types).join(',')).filter('.qtranxs-translatable').each(function() {
95
- qTranslateConfig.qtx.removeContentHook(this);
96
- });
97
- // call the original handler
98
- _hooked_repeater_remove.call(this, $el);
99
- };
100
-
101
- });
102
-
103
- })();
trunk/assets/common.css DELETED
@@ -1,102 +0,0 @@
1
-
2
- .qtrans_title_wrap {
3
- margin-bottom: 20px;
4
- padding: 0 !important;
5
- border: 0 !important;
6
- }
7
-
8
- .qtrans_title_input {
9
- padding: 3px 8px !important;
10
- font-size: 1.7em;
11
- line-height: 100%;
12
- height: 1.7em;
13
- outline: 0 !important;
14
- margin: 0;
15
- }
16
-
17
- .acf_wysiwyg .wp-editor-container,
18
- .acf-editor-wrap .wp-editor-container {
19
- border: 1px solid #e5e5e5 !important;
20
- }
21
-
22
- .multi-language-field {
23
- margin-top: -38px;
24
- }
25
-
26
- .acf-table .multi-language-field,
27
- .acf-input-table .multi-language-field {
28
- margin-top: -6px;
29
- }
30
-
31
- .multi-language-field > .wp-switch-editor {
32
- float: right;
33
- position: relative;
34
- top: 1px;
35
- z-index: 100;
36
- border: 1px solid #ededed;
37
- margin-left: -1px;
38
- padding: 6px 7px;
39
- text-transform: uppercase;
40
- cursor: pointer
41
- }
42
-
43
- .multi-language-field input,
44
- .multi-language-field input:focus,
45
- .multi-language-field textarea,
46
- .multi-language-field textarea:focus {
47
- border-color: #ddd;
48
- box-shadow: none;
49
- }
50
-
51
- .multi-language-field.focused .wp-switch-editor {
52
- border-bottom-color: #ddd;
53
- }
54
-
55
- .multi-language-field.focused .wp-switch-editor.current-language {
56
- border-color: #ddd;
57
- border-bottom-color: #fff;
58
- }
59
-
60
- .multi-language-field .wp-switch-editor.current-language {
61
- background-color: #fff;
62
- border-bottom-color: #fff;
63
- color: #333;
64
- }
65
-
66
- .multi-language-field > input,
67
- .multi-language-field > textarea,
68
- .multi-language-field > fieldset,
69
- .multi-language-field .acf_wysiwyg,
70
- .multi-language-field .acf-editor-wrap,
71
- .multi-language-field .acf-file-uploader,
72
- .multi-language-field .acf-image-uploader { display: none }
73
-
74
- .multi-language-field .acf_input input,
75
- .multi-language-field .acf_input textarea,
76
- .multi-language-field .current-language { display: block !important }
77
-
78
- .multi-language-field-wysiwyg {
79
- margin-top: 0;
80
- }
81
-
82
- .multi-language-field .acf-file-uploader,
83
- .multi-language-field .acf-image-uploader {
84
- padding: 20px 10px 10px;
85
- clear: right;
86
- border: 1px solid #dfdfdf;
87
- }
88
-
89
- .multi-language-field .acf-image-uploader.current-language,
90
- .multi-language-field .acf-file-uploader { background: #fff; }
91
-
92
- .multi-language-field-wysiwyg .wp-switch-editor {
93
- background-color: #ebebeb;
94
- border-color: #dedede;
95
- }
96
-
97
- .multi-language-field-wysiwyg .html-active .switch-html,
98
- .multi-language-field-wysiwyg .tmce-active .switch-tmce,
99
- .multi-language-field-wysiwyg .wp-switch-editor.current-language {
100
- background-color: #f5f5f5;
101
- border-bottom-color: #f5f5f5;
102
- }
trunk/assets/common.js DELETED
@@ -1,53 +0,0 @@
1
- jQuery(function($) {
2
-
3
- var $body = $('body');
4
-
5
-
6
- /**
7
- * Sync qtranslate language switchers with qtranslatex language switchers.
8
- */
9
- $body.on('click', '.qtranxs-lang-switch', function() {
10
- var parent = $('.multi-language-field'), language = $(this).attr('lang');
11
- parent.find('.current-language').removeClass('current-language');
12
- parent.find('[data-language="' + language + '"]').addClass('current-language');
13
- parent.find('input[data-language="' + language + '"], textarea[data-language="' + language + '"]');
14
- });
15
-
16
- /**
17
- * Setup qtranslate language switchers.
18
- */
19
- $body.on('click', '.wp-switch-editor[data-language]', function() {
20
- var parent = $(this).parent('.multi-language-field'), language = $(this).data('language');
21
- parent.find('.current-language').removeClass('current-language');
22
- parent.find('[data-language="' + language + '"]').addClass('current-language');
23
- parent.find('input[data-language="' + language + '"], textarea[data-language="' + language + '"]').focus();
24
- });
25
-
26
- /**
27
- * Focus/blur fields.
28
- */
29
- $body.on('focusin', '.multi-language-field input, .multi-language-field textarea', function() {
30
- $(this).parent('.multi-language-field').addClass('focused');
31
- });
32
-
33
- $body.on('focusout', '.multi-language-field input, .multi-language-field textarea', function() {
34
- $(this).parent('.multi-language-field').removeClass('focused');
35
- });
36
-
37
- /**
38
- * Keep the selected editor in sync across languages.
39
- */
40
- $body.on('click', '.wp-editor-tabs .wp-switch-editor', function() {
41
- var parent = $(this).parents('.multi-language-field'),
42
- editor = $(this).hasClass('switch-tmce') ? 'tmce' : 'html';
43
- parent.find('.wp-editor-tabs .wp-switch-editor.switch-' + editor).not(this).each(function() {
44
- var id = $(this).attr( 'data-wp-editor-id' );
45
- if (id) { // WP 4.3
46
- window.switchEditors.go(id, editor);
47
- } else { // WP < 4.3
48
- switchEditors.switchto(this);
49
- }
50
- });
51
- });
52
-
53
- });
trunk/compatibility/ppqtranslate.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- // provide qTranslate compatibility when using qTranslate Plus
4
-
5
- if (function_exists('qtrans_getLanguage') === false):
6
- function qtrans_getLanguage() {
7
- return ppqtrans_getLanguage();
8
- }
9
- endif;
10
-
11
- if (function_exists('qtrans_getSortedLanguages') === false):
12
- function qtrans_getSortedLanguages($reverse = false) {
13
- return ppqtrans_getSortedLanguages($reverse);
14
- }
15
- endif;
16
-
17
- if (function_exists('qtrans_join') === false):
18
- function qtrans_join($texts) {
19
- return ppqtrans_join($texts);
20
- }
21
- endif;
22
-
23
- if (function_exists('qtrans_split') === false):
24
- function qtrans_split($text, $quicktags = true) {
25
- return ppqtrans_split($text, $quicktags);
26
- }
27
- endif;
28
-
29
- if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') === false):
30
- function qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($content) {
31
- return ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($content);
32
- }
33
- endif;
trunk/compatibility/qtranslatex.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- // provide qTranslate compatibility when using qTranslate-X
4
-
5
- if (function_exists('qtrans_getLanguage') === false):
6
- function qtrans_getLanguage() {
7
- return qtranxf_getLanguage();
8
- }
9
- endif;
10
-
11
- if (function_exists('qtrans_getSortedLanguages') === false):
12
- function qtrans_getSortedLanguages($reverse = false) {
13
- return qtranxf_getSortedLanguages($reverse);
14
- }
15
- endif;
16
-
17
- if (function_exists('qtrans_join') === false):
18
- function qtrans_join($texts) {
19
- // qtranxf_join_c doesn't handle non-array values to
20
- // maintain compatibility with qtrans_join we must handle it here
21
- if (is_array($texts) === false) {
22
- $texts = qtranxf_split($texts, false);
23
- }
24
- return qtranxf_join_c($texts);
25
- }
26
- endif;
27
-
28
- if (function_exists('qtrans_split') === false):
29
- function qtrans_split($text, $quicktags = true) {
30
- return qtranxf_split($text, $quicktags);
31
- }
32
- endif;
33
-
34
- if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') === false):
35
- function qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($content) {
36
- return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($content);
37
- }
38
- endif;
trunk/readme.txt DELETED
@@ -1,174 +0,0 @@
1
- === ACF qTranslate ===
2
- Contributors: funkjedi
3
- Tags: acf, advanced custom fields, qtranslate, add-on, admin
4
- Requires at least: 3.5.0
5
- Tested up to: 4.6.1
6
- Version: 1.7.18
7
- Stable tag: 1.7.18
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Provides qTranslate compatible ACF field types for Text, Text Area, WYSIWYG, Image and File.
12
-
13
-
14
- == Description ==
15
-
16
- This plugin provides qTranslate-X compatible ACF4 and ACF5PRO field types for Text, Text Area, WYSIWYG, Image and File. When adding a field to a field group these new field types will be listed under the qTranslate category in the Field Type dropdown.
17
-
18
- = Field Types =
19
- * qTranslate Text (type text, api returns text)
20
- * qTranslate Text Area (type text, api returns text)
21
- * qTranslate WYSIWYG (a wordpress wysiwyg editor, api returns html)
22
- * qTranslate Image (upload an image, api returns the url)
23
- * qTranslate File (upload a file, api returns the url)
24
-
25
- The standard Text, Text Area and WYSIWYG field types can also be enabled for translation.
26
-
27
- = Bug Submission =
28
- https://github.com/funkjedi/acf-qtranslate/issues/
29
-
30
-
31
- == Installation ==
32
-
33
- 1. Upload `acf-qtranslate` directory to the `/wp-content/plugins/` directory
34
- 2. Activate the plugin through the 'Plugins' menu in WordPress
35
-
36
- = Requires ACF4 or ACF5PRO =
37
- * [ACF](https://wordpress.org/plugins/advanced-custom-fields/)
38
- * [ACF5PRO](http://www.advancedcustomfields.com/pro/)
39
-
40
- = Requires qTranslate-X Plugin =
41
- * [qTranslate-X](https://wordpress.org/plugins/qtranslate-x/)
42
-
43
-
44
- == Frequently Asked Questions ==
45
-
46
- = What's the history behind this plugin? =
47
- The plugin is based on code samples posted to the ACF support forums by taeo back in 2013.
48
-
49
-
50
- == Screenshots ==
51
-
52
- 1. Shows the qTranslate Text and Image fields.
53
-
54
-
55
- == Changelog ==
56
-
57
- = 1.7.18 =
58
- * Core: Prevent error on older versions of ACF5
59
- * Bug Fix: Updated ACF5 qTranslate File field to match recent ACF update
60
-
61
- = 1.7.17 =
62
- * Core: Initialize on either `plugins_loaded` or `after_setup_theme`
63
- * Core: Drop support for qTranslate Plus, mqTranslate, and zTranslate
64
-
65
- = 1.7.16 =
66
- * Bug Fix: Fixed ACF4 support for standard WYSIWYG field
67
- * Bug Fix: Updated ACF4 qTranslate WYSIWYG field
68
- * Bug Fix: Prevent translation of key `acf-field-group` fields
69
-
70
- = 1.7.15 =
71
- * Core: Display LSB on ACF Option pages
72
-
73
- = 1.7.14 =
74
- * Bug Fix: Bumped `after_setup_theme` priority to fix ACF4 field inclusion
75
-
76
- = 1.7.13 =
77
- * Bug Fix: ACF5 Image selection fix
78
-
79
- = 1.7.12 =
80
- * Bug Fix: Fixed ACF5 Image/File edit and delete buttons
81
-
82
- = 1.7.11 =
83
- * Core: Enable support for ACF included within theme
84
- * Bug Fix: Fixed do_action support when removing repeater rows
85
- * Bug Fix: Removing qTranslateConfig.qtx.addContentHooksTinyMCE calls
86
-
87
- = 1.7.10 =
88
- * Bug Fix: (HeikoMamerow) ACF5 File compatibility fix
89
- * Bug Fix: (Tusko) ACF5 Image compatibility fix
90
- * Bug Fix: (Tusko) Replace deprecated `acf/input/admin_footer_js` action
91
- * Bug Fix: (Tusko) Switcher styles fixed
92
- * Bug Fix: (fburatti) ACF4 WYSIWYG WP 4.3 compatibility fix
93
- * Bug Fix: (fburatti) WYSIWYG was appending all values together
94
- * Bug Fix: (fburatti) WP 4.3 PHP warning in WYSIWYG value
95
-
96
- = 1.7.9 =
97
- * Bug Fix: WYSIWYG was creating second acf_settings wp_editor instance
98
-
99
- = 1.7.8 =
100
- * Core: Updated WYSIWYG monkey patches for qTranslate Plus
101
- * Bug Fix: E_NOTICE in ACF4 field types
102
- * Bug Fix: E_NOTICE on admin.php pages when Options addon is missing
103
-
104
- = 1.7.7 =
105
- * Core: Added configuration page
106
- * Core: Support for Standard Field Types when using qTranslate-X is disabled by default
107
- * Core: Display standard language toggles when using qTranslate-X
108
- * Bug Fix: qTranslate-X problem with content from languages being mixed
109
- * Bug Fix: Corrected repeater problems introduced by qTranslate-X update
110
-
111
- = 1.7.6 =
112
- * Core: qTranslate-X support for Text, Text Area and WYSIWYG inside repeater
113
- * Bug Fix: Display qTranslate-X switcher for qTranslate Field Types
114
- * Bug Fix: Incorrectly loading in Media Library and Widgets screens
115
-
116
- = 1.7.5 =
117
- * Core: Updates to README file
118
- * Bug Fix: Updated to visible ACF fields detection
119
-
120
- = 1.7.4 =
121
- * Bug Fix: Only load admin javascript when there are visible ACF fields
122
-
123
- = 1.7.3 =
124
- * Core: Removed namespaces to make code compatible with PHP 5.2
125
-
126
- = 1.7.2 =
127
- * Bug Fix: Corrected misnamed variable
128
- * Bug Fix: ACF5 issues using WYSIWYG with the repeater field type
129
- * Bug Fix: qTranslate-X saving content using WYSIWYG with repeater field type
130
- * Core: Support for `qtrans_edit_language` cookie set by qTranslate-X
131
- * Core: Keep switches between Visual/Html modes in sync across languages
132
-
133
- = 1.7.1 =
134
- * Core: Added back ACF5 support for WYSIWYG
135
- * Core: Added qTranslate-X support for the standard WYSIWYG field type
136
- * Core: Bumped version requirement to match ACF
137
- * Bug Fix: qTranslate-X switcher showing up on every admin page
138
-
139
- = 1.7 =
140
- * Core: Refactor of codebase
141
- * Core: Support for qTranslate-X language switchers
142
-
143
- = 1.6 =
144
- * Core: Added ACFv4 support for qTranslate-X
145
-
146
- = 1.5 =
147
- * Core: Added compatibility for qTranslate-X
148
- * Bug Fix: Remove the broken ACF5 WYSIWYG implementation
149
-
150
- = 1.4 =
151
- * Core: Added support for ACF5
152
- * Core: Tested compatibility with mqTranslate
153
-
154
- = 1.3 =
155
- * Core: Updated styles for Wordpress 3.8
156
- * Bug Fix: qTranslate bug with multiple WYSIWYG editors
157
-
158
- = 1.2 =
159
- * Bug Fix: qTranslate bug with multiple WYSIWYG editors
160
-
161
- = 1.1 =
162
- * Core: Added support for Image Fields. Thanks to bookwyrm for the contribution.
163
-
164
- = 1.0 =
165
- * Initial Release. Thanks to taeo for the code samples this plugin was based on.
166
-
167
-
168
- == Upgrade Notice ==
169
-
170
- = 1.7.7 =
171
- If using qTranslate-X translation of the standard Text, Text Area and WYSIWYG field types is now disabled by default.
172
-
173
- = 1.7.3 =
174
- Removed namespaces to make code compatible with PHP 5.2
trunk/src/acf_4/acf.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
-
3
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_interface.php';
4
-
5
- class acf_qtranslate_acf_4 implements acf_qtranslate_acf_interface {
6
-
7
- /**
8
- * The plugin instance.
9
- * @var \acf_qtranslate_plugin
10
- */
11
- protected $plugin;
12
-
13
-
14
- /*
15
- * Create an instance.
16
- * @return void
17
- */
18
- public function __construct($plugin) {
19
- $this->plugin = $plugin;
20
-
21
- add_filter('acf/format_value_for_api', array($this, 'format_value_for_api'));
22
- add_action('acf/register_fields', array($this, 'register_fields'));
23
- add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
24
- }
25
-
26
- /**
27
- * Load javascript and stylesheets on admin pages.
28
- */
29
- public function register_fields() {
30
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/fields/file.php';
31
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/fields/image.php';
32
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/fields/text.php';
33
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/fields/textarea.php';
34
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/fields/wysiwyg.php';
35
-
36
- new acf_qtranslate_acf_4_text($this->plugin);
37
- new acf_qtranslate_acf_4_textarea($this->plugin);
38
- new acf_qtranslate_acf_4_wysiwyg($this->plugin);
39
- new acf_qtranslate_acf_4_image($this->plugin);
40
- new acf_qtranslate_acf_4_file($this->plugin);
41
- }
42
-
43
- /**
44
- * Load javascript and stylesheets on admin pages.
45
- */
46
- public function admin_enqueue_scripts() {
47
- wp_enqueue_script('acf_qtranslate_main', plugins_url('/assets/acf_4/main.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
48
- }
49
-
50
- /**
51
- * This filter is applied to the $value after it is loaded from the db and
52
- * before it is returned to the template via functions such as get_field().
53
- */
54
- public function format_value_for_api($value) {
55
- if (is_string($value)) {
56
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
57
- }
58
- return $value;
59
- }
60
-
61
- /**
62
- * Get the visible ACF fields.
63
- * @return array
64
- */
65
- public function get_visible_acf_fields() {
66
- $visible_fields = array();
67
-
68
- // build field group filters required for current screen
69
- $filter = $this->get_acf_field_group_filters();
70
- if (count($filter) === 0) {
71
- return $visible_fields;
72
- }
73
-
74
- $supported_field_types = array(
75
- 'email',
76
- 'text',
77
- 'textarea',
78
- 'repeater',
79
- 'flexible_content',
80
- 'qtranslate_file',
81
- 'qtranslate_image',
82
- 'qtranslate_text',
83
- 'qtranslate_textarea',
84
- 'qtranslate_wysiwyg'
85
- );
86
-
87
- $visible_field_groups = apply_filters('acf/location/match_field_groups', array(), $filter);
88
-
89
- foreach (apply_filters('acf/get_field_groups', array()) as $field_group) {
90
- if (in_array($field_group['id'], $visible_field_groups)) {
91
- $fields = apply_filters('acf/field_group/get_fields', array(), $field_group['id']);
92
- foreach ($fields as $field) {
93
- if (in_array($field['type'], $supported_field_types)) {
94
- $visible_fields[] = array('id' => $field['id']);
95
- }
96
- }
97
- }
98
- }
99
-
100
- return $visible_fields;
101
- }
102
-
103
- /**
104
- * Get field group filters based on active screen.
105
- */
106
- public function get_acf_field_group_filters() {
107
- global $post, $pagenow, $typenow, $plugin_page;
108
-
109
- $filter = array();
110
- if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
111
- if ($typenow !== 'acf') {
112
- $filter['post_id'] = apply_filters('acf/get_post_id', false);
113
- $filter['post_type'] = $typenow;
114
- }
115
- }
116
- elseif ($pagenow === 'admin.php' && isset($plugin_page)) {
117
- if ($this->acf_get_options_page($plugin_page)) {
118
- $filter['post_id'] = apply_filters('acf/get_post_id', false);
119
- }
120
- }
121
- elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
122
- $filter['ef_taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
123
- }
124
- elseif ($pagenow === 'profile.php') {
125
- $filter['ef_user'] = get_current_user_id();
126
- }
127
- elseif ($pagenow === 'user-edit.php' && isset($_GET['user_id'])) {
128
- $filter['ef_user'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
129
- }
130
- elseif ($pagenow === 'user-new.php') {
131
- $filter['ef_user'] = 'all';
132
- }
133
- elseif ($pagenow === 'media.php' || $pagenow === 'upload.php') {
134
- $filter['post_type'] = 'attachment';
135
- }
136
-
137
- return $filter;
138
- }
139
-
140
- /**
141
- * Get details about ACF Options page.
142
- */
143
- public function acf_get_options_page($slug) {
144
- global $acf_options_page;
145
-
146
- if (!is_object($acf_options_page) || !is_array($acf_options_page->settings)) {
147
- return false;
148
- }
149
-
150
- if ($acf_options_page->settings['slug'] === $slug) {
151
- return array(
152
- 'title' => $acf_options_page->settings['title'],
153
- 'menu' => $acf_options_page->settings['menu'],
154
- 'slug' => $acf_options_page->settings['slug'],
155
- 'capability' => $acf_options_page->settings['capability'],
156
- 'show_parent' => $acf_options_page->settings['show_parent'],
157
- );
158
- }
159
-
160
- foreach ($acf_options_page->settings['pages'] as $page) {
161
- if ($page['slug'] === $slug) {
162
- return $page;
163
- }
164
- }
165
- }
166
-
167
- }
trunk/src/acf_4/fields/file.php DELETED
@@ -1,205 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_4_file extends acf_field_file {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate_plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * Set name / label needed for actions / filters
16
- *
17
- * @since 3.6
18
- * @date 23/01/13
19
- */
20
- function __construct($plugin) {
21
- $this->plugin = $plugin;
22
-
23
- $this->name = 'qtranslate_file';
24
- $this->label = __("File",'acf');
25
- $this->category = __("qTranslate", 'acf');
26
- $this->defaults = array(
27
- 'save_format' => 'object',
28
- 'library' => 'all'
29
- );
30
- $this->l10n = array(
31
- 'select' => __("Select File",'acf'),
32
- 'edit' => __("Edit File",'acf'),
33
- 'update' => __("Update File",'acf'),
34
- 'uploadedTo' => __("uploaded to this post",'acf'),
35
- );
36
-
37
- acf_field::__construct();
38
-
39
- // filters
40
- add_filter('get_media_item_args', array($this, 'get_media_item_args'));
41
- add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
42
-
43
-
44
- // JSON
45
- add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
46
- add_action('wp_ajax_nopriv_acf/fields/file/get_files', array($this, 'ajax_get_files'), 10, 1);
47
- }
48
-
49
- /*
50
- * create_field()
51
- *
52
- * Create the HTML interface for your field
53
- *
54
- * @param $field - an array holding all the field's data
55
- *
56
- * @type action
57
- * @since 3.6
58
- * @date 23/01/13
59
- */
60
- function create_field($field) {
61
- global $q_config;
62
- $languages = qtrans_getSortedLanguages(true);
63
- $values = qtrans_split($field['value'], $quicktags = true);
64
- $currentLanguage = $this->plugin->get_active_language();
65
-
66
- echo '<div class="multi-language-field multi-language-field-file">';
67
-
68
- foreach ($languages as $language) {
69
- $class = 'wp-switch-editor';
70
- if ($language === $currentLanguage) {
71
- $class .= ' current-language';
72
- }
73
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
74
- }
75
-
76
- $base_class = $field['class'];
77
- $base_name = $field['name'];
78
- foreach ($languages as $language) :
79
- $value = $values[$language];
80
- $o = array(
81
- 'class' => '',
82
- 'icon' => '',
83
- 'title' => '',
84
- 'size' => '',
85
- 'url' => '',
86
- 'name' => '',
87
- );
88
-
89
- if($value && is_numeric($value)) {
90
- $file = get_post($value);
91
-
92
- if($file) {
93
- $o['class'] = 'active';
94
- $o['icon'] = wp_mime_type_icon( $file->ID );
95
- $o['title'] = $file->post_title;
96
- $o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
97
- $o['url'] = wp_get_attachment_url( $file->ID );
98
-
99
- $explode = explode('/', $o['url']);
100
- $o['name'] = end( $explode );
101
- }
102
- }
103
-
104
- $field['class'] = $base_class;
105
- if ($language === $currentLanguage) {
106
- $field['class'] .= ' current-language';
107
- $o['class'] .= ' current-language';
108
- }
109
-
110
- $field['name'] = $base_name . '[' . $language . ']';
111
-
112
- ?>
113
- <div class="acf-file-uploader clearfix <?php echo $o['class']; ?>" data-library="<?php echo $field['library']; ?>" data-language="<?php echo $language; ?>">
114
- <input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $value; ?>" />
115
- <div class="has-file">
116
- <ul class="hl clearfix">
117
- <li>
118
- <img class="acf-file-icon" src="<?php echo $o['icon']; ?>" alt=""/>
119
- <div class="hover">
120
- <ul class="bl">
121
- <li><a href="#" class="acf-button-delete ir">Remove</a></li>
122
- <li><a href="#" class="acf-button-edit ir">Edit</a></li>
123
- </ul>
124
- </div>
125
- </li>
126
- <li>
127
- <p>
128
- <strong class="acf-file-title"><?php echo $o['title']; ?></strong>
129
- </p>
130
- <p>
131
- <strong><?php _e('Name', 'acf'); ?>:</strong>
132
- <a class="acf-file-name" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['name']; ?></a>
133
- </p>
134
- <p>
135
- <strong><?php _e('Size', 'acf'); ?>:</strong>
136
- <span class="acf-file-size"><?php echo $o['size']; ?></span>
137
- </p>
138
-
139
- </li>
140
- </ul>
141
- </div>
142
- <div class="no-file">
143
- <ul class="hl clearfix">
144
- <li>
145
- <p><?php _e('No File Selected','acf'); ?> <a href="#" class="button add-file"><?php _e('Add File','acf'); ?></p></a>
146
- </li>
147
- </ul>
148
- </div>
149
- </div>
150
- <?php endforeach;
151
-
152
- echo '</div>';
153
- }
154
-
155
- /*
156
- * format_value
157
- *
158
- * @description: uses the basic value and allows the field type to format it
159
- * @since: 3.6
160
- * @created: 26/01/13
161
- */
162
- function format_value($value, $post_id, $field) {
163
- return $value;
164
- }
165
-
166
- /*
167
- * format_value_for_api()
168
- *
169
- * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
170
- *
171
- * @type filter
172
- * @since 3.6
173
- * @date 23/01/13
174
- *
175
- * @param $value - the value which was loaded from the database
176
- * @param $post_id - the $post_id from which the value was loaded
177
- * @param $field - the field array holding all the field options
178
- *
179
- * @return $value - the modified value
180
- */
181
- function format_value_for_api($value, $post_id, $field) {
182
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
183
- return parent::format_value_for_api($value, $post_id, $field);
184
- }
185
-
186
- /*
187
- * update_value()
188
- *
189
- * This filter is appied to the $value before it is updated in the db
190
- *
191
- * @type filter
192
- * @since 3.6
193
- * @date 23/01/13
194
- *
195
- * @param $value - the value which will be saved in the database
196
- * @param $post_id - the $post_id of which the value will be saved
197
- * @param $field - the field array holding all the field options
198
- *
199
- * @return $value - the modified value
200
- */
201
- function update_value($value, $post_id, $field) {
202
- return qtrans_join($value);
203
- }
204
-
205
- }
trunk/src/acf_4/fields/image.php DELETED
@@ -1,170 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_4_image extends acf_field_image {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate\plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * Set name / label needed for actions / filters
16
- *
17
- * @since 3.6
18
- * @date 23/01/13
19
- */
20
- function __construct($plugin) {
21
- $this->plugin = $plugin;
22
-
23
- $this->name = 'qtranslate_image';
24
- $this->label = __("Image", 'acf');
25
- $this->category = __("qTranslate", 'acf');
26
- $this->defaults = array(
27
- 'save_format' => 'object',
28
- 'preview_size' => 'thumbnail',
29
- 'library' => 'all'
30
- );
31
- $this->l10n = array(
32
- 'select' => __("Select Image",'acf'),
33
- 'edit' => __("Edit Image",'acf'),
34
- 'update' => __("Update Image",'acf'),
35
- 'uploadedTo' => __("uploaded to this post",'acf'),
36
- );
37
-
38
- acf_field::__construct();
39
-
40
- // filters
41
- add_filter('get_media_item_args', array($this, 'get_media_item_args'));
42
- add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
43
-
44
- // JSON
45
- add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
46
- add_action('wp_ajax_nopriv_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
47
- }
48
-
49
- /*
50
- * create_field()
51
- *
52
- * Create the HTML interface for your field
53
- *
54
- * @param $field - an array holding all the field's data
55
- *
56
- * @type action
57
- * @since 3.6
58
- * @date 23/01/13
59
- */
60
- function create_field($field) {
61
- global $q_config;
62
- $languages = qtrans_getSortedLanguages(true);
63
- $values = qtrans_split($field['value'], $quicktags = true);
64
- $currentLanguage = $this->plugin->get_active_language();
65
-
66
- echo '<div class="multi-language-field multi-language-field-image">';
67
-
68
- foreach ($languages as $language) {
69
- $class = 'wp-switch-editor';
70
- if ($language === $currentLanguage) {
71
- $class .= ' current-language';
72
- }
73
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
74
- }
75
-
76
- $base_class = $field['class'];
77
- $base_name = $field['name'];
78
- foreach ($languages as $language) :
79
- $value = $values[$language];
80
- $o = array(
81
- 'class' => '',
82
- 'url' => '',
83
- );
84
-
85
- if ($value && is_numeric($value)) {
86
- $url = wp_get_attachment_image_src($value, $field['preview_size']);
87
- $o['class'] = 'active';
88
- $o['url'] = $url[0];
89
- }
90
-
91
- $field['class'] = $base_class;
92
- if ($language === $currentLanguage) {
93
- $field['class'] .= ' current-language';
94
- $o['class'] .= ' current-language';
95
- }
96
-
97
- $field['name'] = $base_name . '[' . $language . ']';
98
-
99
- ?>
100
- <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; ?>" >
101
- <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $value; ?>" />
102
- <div class="has-image">
103
- <div class="hover">
104
- <ul class="bl">
105
- <li><a class="acf-button-delete ir" href="#"><?php _e("Remove", 'acf'); ?></a></li>
106
- <li><a class="acf-button-edit ir" href="#"><?php _e("Edit", 'acf'); ?></a></li>
107
- </ul>
108
- </div>
109
- <img class="acf-image-image" src="<?php echo $o['url']; ?>" alt="" />
110
- </div>
111
- <div class="no-image">
112
- <p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
113
- </div>
114
- </div>
115
- <?php endforeach;
116
-
117
- echo '</div>';
118
- }
119
-
120
- /*
121
- * format_value
122
- *
123
- * @description: uses the basic value and allows the field type to format it
124
- * @since: 3.6
125
- * @created: 26/01/13
126
- */
127
- function format_value($value, $post_id, $field) {
128
- return $value;
129
- }
130
-
131
- /*
132
- * format_value_for_api()
133
- *
134
- * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
135
- *
136
- * @type filter
137
- * @since 3.6
138
- * @date 23/01/13
139
- *
140
- * @param $value - the value which was loaded from the database
141
- * @param $post_id - the $post_id from which the value was loaded
142
- * @param $field - the field array holding all the field options
143
- *
144
- * @return $value - the modified value
145
- */
146
- function format_value_for_api($value, $post_id, $field) {
147
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
148
- return parent::format_value_for_api($value, $post_id, $field);
149
- }
150
-
151
- /*
152
- * update_value()
153
- *
154
- * This filter is appied to the $value before it is updated in the db
155
- *
156
- * @type filter
157
- * @since 3.6
158
- * @date 23/01/13
159
- *
160
- * @param $value - the value which will be saved in the database
161
- * @param $post_id - the $post_id of which the value will be saved
162
- * @param $field - the field array holding all the field options
163
- *
164
- * @return $value - the modified value
165
- */
166
- function update_value($value, $post_id, $field) {
167
- return qtrans_join($value);
168
- }
169
-
170
- }
trunk/src/acf_4/fields/text.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_4_text extends acf_field_text {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate\plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * Set name / label needed for actions / filters
16
- *
17
- * @since 3.6
18
- * @date 23/01/13
19
- */
20
- function __construct($plugin) {
21
- $this->plugin = $plugin;
22
-
23
- $this->name = 'qtranslate_text';
24
- $this->label = __("Text",'acf');
25
- $this->category = __("qTranslate",'acf');
26
- $this->defaults = array(
27
- 'default_value' => '',
28
- 'formatting' => 'html',
29
- 'maxlength' => '',
30
- 'placeholder' => '',
31
- 'prepend' => '',
32
- 'append' => ''
33
- );
34
-
35
- acf_field::__construct();
36
- }
37
-
38
- /*
39
- * create_field()
40
- *
41
- * Create the HTML interface for your field
42
- *
43
- * @param $field - an array holding all the field's data
44
- *
45
- * @type action
46
- * @since 3.6
47
- * @date 23/01/13
48
- */
49
- function create_field($field) {
50
- global $q_config;
51
- $languages = qtrans_getSortedLanguages(true);
52
- $values = qtrans_split($field['value'], $quicktags = true);
53
- $currentLanguage = $this->plugin->get_active_language();
54
-
55
- echo '<div class="multi-language-field">';
56
-
57
- foreach ($languages as $language) {
58
- $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
59
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
60
- }
61
-
62
- foreach ($languages as $language) {
63
- $class = ($language === $currentLanguage) ? $field['class'] . ' current-language' : $field['class'];
64
- 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]") . '" />';
65
- }
66
-
67
- echo '</div>';
68
- }
69
-
70
- /*
71
- * format_value
72
- *
73
- * @description: uses the basic value and allows the field type to format it
74
- * @since: 3.6
75
- * @created: 26/01/13
76
- */
77
- function format_value($value, $post_id, $field) {
78
- return $value;
79
- }
80
-
81
- /*
82
- * format_value_for_api()
83
- *
84
- * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
85
- *
86
- * @type filter
87
- * @since 3.6
88
- * @date 23/01/13
89
- *
90
- * @param $value - the value which was loaded from the database
91
- * @param $post_id - the $post_id from which the value was loaded
92
- * @param $field - the field array holding all the field options
93
- *
94
- * @return $value - the modified value
95
- */
96
- function format_value_for_api($value, $post_id, $field) {
97
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
98
- return parent::format_value_for_api($value, $post_id, $field);
99
- }
100
-
101
- /*
102
- * update_value()
103
- *
104
- * This filter is appied to the $value before it is updated in the db
105
- *
106
- * @type filter
107
- * @since 3.6
108
- * @date 23/01/13
109
- *
110
- * @param $value - the value which will be saved in the database
111
- * @param $post_id - the $post_id of which the value will be saved
112
- * @param $field - the field array holding all the field options
113
- *
114
- * @return $value - the modified value
115
- */
116
- function update_value($value, $post_id, $field) {
117
- return qtrans_join($value);
118
- }
119
-
120
- }
trunk/src/acf_4/fields/textarea.php DELETED
@@ -1,119 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_4_textarea extends acf_field_textarea {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate_plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * Set name / label needed for actions / filters
16
- *
17
- * @since 3.6
18
- * @date 23/01/13
19
- */
20
- function __construct($plugin) {
21
- $this->plugin = $plugin;
22
-
23
- $this->name = 'qtranslate_textarea';
24
- $this->label = __("Text Area",'acf');
25
- $this->category = __("qTranslate",'acf');
26
- $this->defaults = array(
27
- 'default_value' => '',
28
- 'formatting' => 'br',
29
- 'maxlength' => '',
30
- 'placeholder' => '',
31
- 'rows' => ''
32
- );
33
-
34
- acf_field::__construct();
35
- }
36
-
37
- /*
38
- * create_field()
39
- *
40
- * Create the HTML interface for your field
41
- *
42
- * @param $field - an array holding all the field's data
43
- *
44
- * @type action
45
- * @since 3.6
46
- * @date 23/01/13
47
- */
48
- function create_field($field) {
49
- global $q_config;
50
- $languages = qtrans_getSortedLanguages(true);
51
- $values = qtrans_split($field['value'], $quicktags = true);
52
- $currentLanguage = $this->plugin->get_active_language();
53
-
54
- echo '<div class="multi-language-field">';
55
-
56
- foreach ($languages as $language) {
57
- $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
58
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
59
- }
60
-
61
- foreach ($languages as $language) {
62
- $class = ($language === $currentLanguage) ? $field['class'] . ' current-language' : $field['class'];
63
- 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>';
64
- }
65
-
66
- echo '</div>';
67
- }
68
-
69
- /*
70
- * format_value
71
- *
72
- * @description: uses the basic value and allows the field type to format it
73
- * @since: 3.6
74
- * @created: 26/01/13
75
- */
76
- function format_value($value, $post_id, $field) {
77
- return $value;
78
- }
79
-
80
- /*
81
- * format_value_for_api()
82
- *
83
- * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
84
- *
85
- * @type filter
86
- * @since 3.6
87
- * @date 23/01/13
88
- *
89
- * @param $value - the value which was loaded from the database
90
- * @param $post_id - the $post_id from which the value was loaded
91
- * @param $field - the field array holding all the field options
92
- *
93
- * @return $value - the modified value
94
- */
95
- function format_value_for_api($value, $post_id, $field) {
96
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
97
- return parent::format_value_for_api($value, $post_id, $field);
98
- }
99
-
100
- /*
101
- * update_value()
102
- *
103
- * This filter is appied to the $value before it is updated in the db
104
- *
105
- * @type filter
106
- * @since 3.6
107
- * @date 23/01/13
108
- *
109
- * @param $value - the value which will be saved in the database
110
- * @param $post_id - the $post_id of which the value will be saved
111
- * @param $field - the field array holding all the field options
112
- *
113
- * @return $value - the modified value
114
- */
115
- function update_value($value, $post_id, $field) {
116
- return qtrans_join($value);
117
- }
118
-
119
- }
trunk/src/acf_4/fields/wysiwyg.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_4_wysiwyg extends acf_field_wysiwyg {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate_plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * Set name / label needed for actions / filters
16
- *
17
- * @since 3.6
18
- * @date 23/01/13
19
- */
20
- function __construct($plugin) {
21
- $this->plugin = $plugin;
22
-
23
- $this->name = 'qtranslate_wysiwyg';
24
- $this->label = __("Wysiwyg Editor",'acf');
25
- $this->category = __("qTranslate",'acf');
26
- $this->defaults = array(
27
- 'toolbar' => 'full',
28
- 'media_upload' => 'yes',
29
- 'default_value' => '',
30
- );
31
-
32
- // Create an acf version of the_content filter (acf_the_content)
33
- if( isset($GLOBALS['wp_embed']) ) {
34
-
35
- add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
36
- add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
37
-
38
- }
39
-
40
- add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
41
- add_filter( 'acf_the_content', 'wptexturize' );
42
- add_filter( 'acf_the_content', 'convert_smilies' );
43
- add_filter( 'acf_the_content', 'convert_chars' );
44
- add_filter( 'acf_the_content', 'wpautop' );
45
- add_filter( 'acf_the_content', 'shortcode_unautop' );
46
- //add_filter( 'acf_the_content', 'prepend_attachment' ); *should only be for the_content (causes double image on attachment page)
47
- add_filter( 'acf_the_content', 'do_shortcode', 11);
48
-
49
- acf_field::__construct();
50
-
51
- // filters
52
- add_filter( 'acf/fields/wysiwyg/toolbars', array( $this, 'toolbars'), 1, 1 );
53
- add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins'), 20, 1 );
54
- }
55
-
56
- /*
57
- * input_admin_head()
58
- *
59
- * This action is called in the admin_head action on the edit screen where your field is created.
60
- * Use this action to add css and javascript to assist your create_field() action.
61
- *
62
- * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
63
- * @type action
64
- * @since 3.6
65
- * @date 23/01/13
66
- */
67
- function input_admin_head() {}
68
-
69
- /*
70
- * create_field()
71
- *
72
- * Create the HTML interface for your field
73
- *
74
- * @param $field - an array holding all the field's data
75
- *
76
- * @type action
77
- * @since 3.6
78
- * @date 23/01/13
79
- */
80
- function create_field($field) {
81
- global $q_config, $wp_version;
82
- $languages = qtrans_getSortedLanguages(true);
83
- $values = qtrans_split($field['value'], $quicktags = true);
84
- $currentLanguage = $this->plugin->get_active_language();
85
-
86
- // vars
87
- //$id = uniqid('acf-editor-');
88
- $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
89
- $default_editor = 'tinymce';
90
-
91
- // filter value for editor
92
- remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
93
- remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 );
94
- remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 );
95
-
96
- // WP 4.3
97
- if( version_compare($wp_version, '4.3', '>=' ) ) {
98
- add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
99
- // WP < 4.3
100
- } else {
101
- $function = user_can_richedit() ? 'wp_richedit_pre' : 'wp_htmledit_pre';
102
- add_filter('acf_the_editor_content', $function, 10, 1);
103
- }
104
-
105
- echo '<div class="multi-language-field multi-language-field-wysiwyg">';
106
-
107
- foreach ($languages as $language) {
108
- $class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
109
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
110
- }
111
-
112
- foreach ($languages as $language):
113
- $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
114
- $name = $field['name'] . "[$language]";
115
- $class = ($language === $currentLanguage) ? 'current-language' : '';
116
- $value = apply_filters('acf_the_editor_content', $values[$language], 'tinymce');
117
-
118
- ?>
119
- <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-core-ui wp-editor-wrap tmce-active <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
120
- <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
121
- <?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
122
- <div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
123
- <?php do_action( 'media_buttons', $id ); ?>
124
- </div>
125
- <?php endif; ?>
126
- </div>
127
- <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
128
- <textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>"><?php echo $value; ?></textarea>
129
- </div>
130
- </div>
131
-
132
- <?php endforeach;
133
-
134
- echo '</div>';
135
- }
136
-
137
- /*
138
- * format_value
139
- *
140
- * @description: uses the basic value and allows the field type to format it
141
- * @since: 3.6
142
- * @created: 26/01/13
143
- */
144
- function format_value($value, $post_id, $field) {
145
- return $value;
146
- }
147
-
148
- /*
149
- * format_value_for_api()
150
- *
151
- * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
152
- *
153
- * @type filter
154
- * @since 3.6
155
- * @date 23/01/13
156
- *
157
- * @param $value - the value which was loaded from the database
158
- * @param $post_id - the $post_id from which the value was loaded
159
- * @param $field - the field array holding all the field options
160
- *
161
- * @return $value - the modified value
162
- */
163
- function format_value_for_api($value, $post_id, $field) {
164
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
165
- return parent::format_value_for_api($value, $post_id, $field);
166
- }
167
-
168
- /*
169
- * update_value()
170
- *
171
- * This filter is appied to the $value before it is updated in the db
172
- *
173
- * @type filter
174
- * @since 3.6
175
- * @date 23/01/13
176
- *
177
- * @param $value - the value which will be saved in the database
178
- * @param $post_id - the $post_id of which the value will be saved
179
- * @param $field - the field array holding all the field options
180
- *
181
- * @return $value - the modified value
182
- */
183
- function update_value($value, $post_id, $field) {
184
- return qtrans_join($value);
185
- }
186
-
187
- }
trunk/src/acf_5/acf.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
-
3
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_interface.php';
4
-
5
- class acf_qtranslate_acf_5 implements acf_qtranslate_acf_interface {
6
-
7
- /**
8
- * The plugin instance.
9
- * @var \acf_qtranslate_plugin
10
- */
11
- protected $plugin;
12
-
13
-
14
- /*
15
- * Create an instance.
16
- * @return void
17
- */
18
- public function __construct($plugin) {
19
- $this->plugin = $plugin;
20
-
21
- add_filter('acf/format_value', array($this, 'format_value'));
22
- add_action('acf/include_fields', array($this, 'include_fields'));
23
- add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
24
- }
25
-
26
- /**
27
- * Load javascript and stylesheets on admin pages.
28
- */
29
- public function include_fields() {
30
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/fields/file.php';
31
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/fields/image.php';
32
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/fields/text.php';
33
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/fields/textarea.php';
34
- require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/fields/wysiwyg.php';
35
-
36
- new acf_qtranslate_acf_5_text($this->plugin);
37
- new acf_qtranslate_acf_5_textarea($this->plugin);
38
- new acf_qtranslate_acf_5_wysiwyg($this->plugin);
39
- new acf_qtranslate_acf_5_image($this->plugin);
40
- new acf_qtranslate_acf_5_file($this->plugin);
41
- }
42
-
43
- /**
44
- * Load javascript and stylesheets on admin pages.
45
- */
46
- public function admin_enqueue_scripts() {
47
- wp_enqueue_script('acf_qtranslate_main', plugins_url('/assets/acf_5/main.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
48
- }
49
-
50
- /**
51
- * This filter is applied to the $value after it is loaded from the db and
52
- * before it is returned to the template via functions such as get_field().
53
- */
54
- public function format_value($value) {
55
- if (is_string($value)) {
56
- $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value);
57
- }
58
- return $value;
59
- }
60
-
61
- /**
62
- * Get the visible ACF fields.
63
- * @return array
64
- */
65
- public function get_visible_acf_fields($widget_id = null) {
66
- global $wp_registered_widgets;
67
-
68
- $visible_fields = array();
69
-
70
- // build field group filters required for current screen
71
- $filter = $this->get_acf_field_group_filters();
72
- if (count($filter) === 0) {
73
- return $visible_fields;
74
- }
75
-
76
- // widgets need some special handling since they
77
- // require multiple acf_get_field_group_visibility()
78
- // calls in order to return all the visible fields
79
- if (acf_is_screen('widgets') || acf_is_screen('customize')) {
80
- if ($widget_id) {
81
- $filter['widget'] = _get_widget_id_base($widget_id);
82
- }
83
- else {
84
- // process each widget form individually for any visible fields
85
- foreach ($wp_registered_widgets as $widget) {
86
- $visible_fields += $this->get_visible_acf_fields($widget['id']);
87
- }
88
- return $visible_fields;
89
- }
90
- }
91
-
92
- $supported_field_types = array(
93
- 'email',
94
- 'text',
95
- 'textarea',
96
- 'repeater',
97
- 'flexible_content',
98
- 'qtranslate_file',
99
- 'qtranslate_image',
100
- 'qtranslate_text',
101
- 'qtranslate_textarea',
102
- 'qtranslate_wysiwyg'
103
- );
104
-
105
- foreach (acf_get_field_groups($filter) as $field_group) {
106
- $fields = acf_get_fields($field_group);
107
- foreach ($fields as $field) {
108
- if (in_array($field['type'], $supported_field_types)) {
109
- $visible_fields[] = array('id' => 'acf-' . $field['key']);
110
- }
111
- }
112
- }
113
-
114
- return $visible_fields;
115
- }
116
-
117
- /**
118
- * Get field group filters based on active screen.
119
- */
120
- public function get_acf_field_group_filters() {
121
- global $post, $pagenow, $typenow, $plugin_page;
122
-
123
- $filter = array();
124
- if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
125
- if ($typenow !== 'acf') {
126
- $filter['post_id'] = $post->ID;
127
- $filter['post_type'] = $typenow;
128
- }
129
- }
130
- elseif ($pagenow === 'admin.php' && isset($plugin_page)) {
131
- if (acf_get_options_page($plugin_page)) {
132
- $filter['post_id'] = acf_get_valid_post_id('options');
133
- }
134
- }
135
- elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
136
- $filter['taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
137
- }
138
- elseif ($pagenow === 'profile.php') {
139
- $filter['user_id'] = get_current_user_id();
140
- $filter['user_form'] = 'edit';
141
- }
142
- elseif ($pagenow === 'user-edit.php' && isset($_GET['user_id'])) {
143
- $filter['user_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
144
- $filter['user_form'] = 'edit';
145
- }
146
- elseif ($pagenow === 'user-new.php') {
147
- $filter['user_id'] = 'new';
148
- $filter['user_form'] = 'edit';
149
- }
150
- elseif ($pagenow === 'media.php' || $pagenow === 'upload.php') {
151
- $filter['attachment'] = 'All';
152
- }
153
- elseif (acf_is_screen('widgets') || acf_is_screen('customize')) {
154
- $filter['widget'] = 'all';
155
- }
156
-
157
- return $filter;
158
- }
159
-
160
- }
trunk/src/acf_5/fields/file.php DELETED
@@ -1,208 +0,0 @@
1
- <?php
2
-
3
- class acf_qtranslate_acf_5_file extends acf_field_file {
4
-
5
- /**
6
- * The plugin instance.
7
- * @var \acf_qtranslate_plugin
8
- */
9
- protected $plugin;
10
-
11
-
12
- /*
13
- * __construct
14
- *
15
- * This function will setup the field type data
16
- *
17
- * @type function
18
- * @date 5/03/2014
19
- * @since 5.0.0
20
- *
21
- * @param n/a
22
- * @return n/a
23
- */
24
- function __construct($plugin) {
25
- $this->plugin = $plugin;
26
-
27
- $this->name = 'qtranslate_file';
28
- $this->label = __("File", 'acf');
29
- $this->category = __("qTranslate", 'acf');
30
- $this->defaults = array(
31
- 'return_format' => 'array',
32
- 'library' => 'all',
33
- 'min_size' => 0,
34
- 'max_size' => 0,
35
- 'mime_types' => ''
36
- );
37
- $this->l10n = array(
38
- 'select' => __("Select File",'acf'),
39
- 'edit' => __("Edit File",'acf'),
40
- 'update' => __("Update File",'acf'),
41
- 'uploadedTo' => __("uploaded to this post",'acf'),
42
- );
43
-
44
-
45
- // filters
46
- add_filter('get_media_item_args', array($this, 'get_media_item_args'));
47
-
48
- acf_field::__construct();
49
- }
50
-
51
- /*
52
- * render_field()
53
- *
54
- * Create the HTML interface for your field
55
- *
56
- * @param $field - an array holding all the field's data
57
- *
58
- * @type action
59
- * @since 3.6
60
- * @date 23/01/13
61
- */
62
- function render_field($field) {
63
- global $q_config;
64
-
65
- $languages = qtrans_getSortedLanguages(true);
66
- $values = qtrans_split($field['value'], $quicktags = true);
67
- $currentLanguage = $this->plugin->get_active_language();
68
-
69
- // vars
70
- $uploader = acf_get_setting('uploader');
71
-
72
- // enqueue
73
- if( $uploader == 'wp' ) {
74
- acf_enqueue_uploader();
75
- }
76
-
77
- // vars
78
- $o = array(
79
- 'icon' => '',
80
- 'title' => '',
81
- 'url' => '',
82
- 'filesize' => '',
83
- 'filename' => '',
84
- );
85
-
86
- $div = array(
87
- 'class' => 'acf-file-uploader acf-cf',
88
- 'data-library' => $field['library'],
89
- 'data-mime_types' => $field['mime_types'],
90
- 'data-uploader' => $uploader
91
- );
92
-
93
- echo '<div class="multi-language-field multi-language-field-image">';
94
-
95
- foreach ($languages as $language) {
96
- $class = 'wp-switch-editor';
97
- if ($language === $currentLanguage) {
98
- $class .= ' current-language';
99
- }
100
- echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
101
- }