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 | 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 +1 -1
- readme.txt +6 -2
- src/acf_5/fields/file.php +0 -1
- src/acf_5/fields/wysiwyg.php +4 -2
- trunk/acf-qtranslate.php +0 -17
- trunk/assets/acf_4/main.js +0 -0
- trunk/assets/acf_4/qtranslatex.js +0 -114
- trunk/assets/acf_5/main.js +0 -51
- trunk/assets/acf_5/qtranslatex.js +0 -103
- trunk/assets/common.css +0 -102
- trunk/assets/common.js +0 -53
- trunk/compatibility/ppqtranslate.php +0 -33
- trunk/compatibility/qtranslatex.php +0 -38
- trunk/readme.txt +0 -174
- trunk/src/acf_4/acf.php +0 -167
- trunk/src/acf_4/fields/file.php +0 -205
- trunk/src/acf_4/fields/image.php +0 -170
- trunk/src/acf_4/fields/text.php +0 -120
- trunk/src/acf_4/fields/textarea.php +0 -119
- trunk/src/acf_4/fields/wysiwyg.php +0 -187
- trunk/src/acf_5/acf.php +0 -160
- trunk/src/acf_5/fields/file.php +0 -208
- trunk/src/acf_5/fields/image.php +0 -193
- trunk/src/acf_5/fields/text.php +0 -166
- trunk/src/acf_5/fields/textarea.php +0 -133
- trunk/src/acf_5/fields/wysiwyg.php +0 -219
- trunk/src/acf_interface.php +0 -11
- trunk/src/mqtranslate.php +0 -53
- trunk/src/plugin.php +0 -265
- trunk/src/ppqtranslate.php +0 -56
- trunk/src/qtranslatex.php +0 -96
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.
|
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.
|
7 |
-
Stable tag: 1.7.
|
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 |
-
|
38 |
-
|
|
|
|
|
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 |
-
}
|
102 |
-
|
103 |
-
$field_name = $field['name'];
|
104 |
-
|
105 |
-
foreach ($languages as $language):
|
106 |
-
|
107 |
-
$field['name'] = $field_name . '[' . $language . ']';
|
108 |
-
$field['value'] = $values[$language];
|
109 |
-
$div['data-language'] = $language;
|
110 |
-
$div['class'] = 'acf-file-uploader acf-cf';
|
111 |
-
|
112 |
-
// has value?
|
113 |
-
if( $field['value'] ) {
|
114 |
-
$file = get_post( $field['value'] );
|
115 |
-
if( $file ) {
|
116 |
-
$o['icon'] = wp_mime_type_icon( $file->ID );
|
117 |
-
$o['title'] = $file->post_title;
|
118 |
-
$o['filesize'] = @size_format(filesize( get_attached_file( $file->ID ) ));
|
119 |
-
$o['url'] = wp_get_attachment_url( $file->ID );
|
120 |
-
|
121 |
-
$explode = explode('/', $o['url']);
|
122 |
-
$o['filename'] = end( $explode );
|
123 |
-
}
|
124 |
-
|
125 |
-
// url exists
|
126 |
-
if( $o['url'] ) {
|
127 |
-
$div['class'] .= ' has-value';
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
if ($language === $currentLanguage) {
|
132 |
-
$div['class'] .= ' current-language';
|
133 |
-
}
|
134 |
-
|
135 |
-
?>
|
136 |
-
<div <?php acf_esc_attr_e($div); ?>>
|
137 |
-
<div class="acf-hidden">
|
138 |
-
<?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
|
139 |
-
</div>
|
140 |
-
<div class="show-if-value file-wrap acf-soh">
|
141 |
-
<div class="file-icon">
|
142 |
-
<img data-name="icon" src="<?php echo $o['icon']; ?>" alt=""/>
|
143 |
-
</div>
|
144 |
-
<div class="file-info">
|
145 |
-
<p>
|
146 |
-
<strong data-name="title"><?php echo $o['title']; ?></strong>
|
147 |
-
</p>
|
148 |
-
<p>
|
149 |
-
<strong><?php _e('File name', 'acf'); ?>:</strong>
|
150 |
-
<a data-name="filename" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['filename']; ?></a>
|
151 |
-
</p>
|
152 |
-
<p>
|
153 |
-
<strong><?php _e('File size', 'acf'); ?>:</strong>
|
154 |
-
<span data-name="filesize"><?php echo $o['filesize']; ?></span>
|
155 |
-
</p>
|
156 |
-
|
157 |
-
<ul class="acf-hl acf-soh-target">
|
158 |
-
<?php if( $uploader != 'basic' ): ?>
|
159 |
-
<li><a class="acf-icon -pencil dark" data-name="edit" href="#"></a></li>
|
160 |
-
<?php endif; ?>
|
161 |
-
<li><a class="acf-icon -cancel dark" data-name="remove" href="#"></a></li>
|
162 |
-
</ul>
|
163 |
-
</div>
|
164 |
-
</div>
|
165 |
-
<div class="hide-if-value">
|
166 |
-
<?php if( $uploader == 'basic' ): ?>
|
167 |
-
|
168 |
-
<?php if( $field['value'] && !is_numeric($field['value']) ): ?>
|
169 |
-
<div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
|
170 |
-
<?php endif; ?>
|
171 |
-
|
172 |
-
<input type="file" name="<?php echo $field['name']; ?>" id="<?php echo $field['id']; ?>" />
|
173 |
-
|
174 |
-
<?php else: ?>
|
175 |
-
|
176 |
-
<p style="margin:0;"><?php _e('No file selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add File','acf'); ?></a></p>
|
177 |
-
|
178 |
-
<?php endif; ?>
|
179 |
-
|
180 |
-
</div>
|
181 |
-
</div>
|
182 |
-
|
183 |
-
<?php endforeach;
|
184 |
-
|
185 |
-
echo '</div>';
|
186 |
-
}
|
187 |
-
|
188 |
-
/*
|
189 |
-
* update_value()
|
190 |
-
*
|
191 |
-
* This filter is appied to the $value before it is updated in the db
|
192 |
-
*
|
193 |
-
* @type filter
|
194 |
-
* @since 3.6
|
195 |
-
* @date 23/01/13
|
196 |
-
*
|
197 |
-
* @param $value - the value which will be saved in the database
|
198 |
-
* @param $post_id - the $post_id of which the value will be saved
|
199 |
-
* @param $field - the field array holding all the field options
|
200 |
-
*
|
201 |
-
* @return $value - the modified value
|
202 |
-
*/
|
203 |
-
function update_value($value, $post_id, $field) {
|
204 |
-
$value = parent::update_value($value, $post_id, $field);
|
205 |
-
return qtrans_join($value);
|
206 |
-
}
|
207 |
-
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/acf_5/fields/image.php
DELETED
@@ -1,193 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_qtranslate_acf_5_image extends acf_field_image {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* The plugin instance.
|
7 |
-
* @var \acf_qtranslate_plugin
|
8 |
-
*/
|
9 |
-
protected $plugin;
|
10 |
-
|
11 |
-
/*
|
12 |
-
* __construct
|
13 |
-
*
|
14 |
-
* This function will setup the field type data
|
15 |
-
*
|
16 |
-
* @type function
|
17 |
-
* @date 5/03/2014
|
18 |
-
* @since 5.0.0
|
19 |
-
*
|
20 |
-
* @param n/a
|
21 |
-
* @return n/a
|
22 |
-
*/
|
23 |
-
function __construct($plugin) {
|
24 |
-
$this->plugin = $plugin;
|
25 |
-
|
26 |
-
$this->name = 'qtranslate_image';
|
27 |
-
$this->label = __("Image", 'acf');
|
28 |
-
$this->category = __("qTranslate", 'acf');
|
29 |
-
$this->defaults = array(
|
30 |
-
'return_format' => 'array',
|
31 |
-
'preview_size' => 'thumbnail',
|
32 |
-
'library' => 'all',
|
33 |
-
'min_width' => 0,
|
34 |
-
'min_height' => 0,
|
35 |
-
'min_size' => 0,
|
36 |
-
'max_width' => 0,
|
37 |
-
'max_height' => 0,
|
38 |
-
'max_size' => 0,
|
39 |
-
'mime_types' => ''
|
40 |
-
);
|
41 |
-
$this->l10n = array(
|
42 |
-
'select' => __("Select Image",'acf'),
|
43 |
-
'edit' => __("Edit Image",'acf'),
|
44 |
-
'update' => __("Update Image",'acf'),
|
45 |
-
'uploadedTo' => __("Uploaded to this post",'acf'),
|
46 |
-
'all' => __("All images",'acf'),
|
47 |
-
);
|
48 |
-
|
49 |
-
|
50 |
-
// filters
|
51 |
-
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
52 |
-
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
53 |
-
|
54 |
-
acf_field::__construct();
|
55 |
-
}
|
56 |
-
|
57 |
-
/*
|
58 |
-
* render_field()
|
59 |
-
*
|
60 |
-
* Create the HTML interface for your field
|
61 |
-
*
|
62 |
-
* @param $field - an array holding all the field's data
|
63 |
-
*
|
64 |
-
* @type action
|
65 |
-
* @since 3.6
|
66 |
-
* @date 23/01/13
|
67 |
-
*/
|
68 |
-
function render_field($field) {
|
69 |
-
global $q_config;
|
70 |
-
|
71 |
-
$languages = qtrans_getSortedLanguages(true);
|
72 |
-
$values = qtrans_split($field['value'], $quicktags = true);
|
73 |
-
$currentLanguage = $this->plugin->get_active_language();
|
74 |
-
|
75 |
-
|
76 |
-
// vars
|
77 |
-
$uploader = acf_get_setting('uploader');
|
78 |
-
|
79 |
-
// enqueue
|
80 |
-
if( $uploader == 'wp' ) {
|
81 |
-
acf_enqueue_uploader();
|
82 |
-
}
|
83 |
-
|
84 |
-
// vars
|
85 |
-
$url = '';
|
86 |
-
$alt = '';
|
87 |
-
$div = array(
|
88 |
-
'class' => 'acf-image-uploader acf-cf',
|
89 |
-
'data-preview_size' => $field['preview_size'],
|
90 |
-
'data-library' => $field['library'],
|
91 |
-
'data-mime_types' => $field['mime_types'],
|
92 |
-
'data-uploader' => $uploader
|
93 |
-
);
|
94 |
-
|
95 |
-
// get size of preview value
|
96 |
-
$size = acf_get_image_size($field['preview_size']);
|
97 |
-
|
98 |
-
|
99 |
-
echo '<div class="multi-language-field multi-language-field-image">';
|
100 |
-
|
101 |
-
foreach ($languages as $language) {
|
102 |
-
$class = 'wp-switch-editor';
|
103 |
-
if ($language === $currentLanguage) {
|
104 |
-
$class .= ' current-language';
|
105 |
-
}
|
106 |
-
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
|
107 |
-
}
|
108 |
-
|
109 |
-
$field_name = $field['name'];
|
110 |
-
|
111 |
-
foreach ($languages as $language):
|
112 |
-
|
113 |
-
$field['name'] = $field_name . '[' . $language . ']';
|
114 |
-
$field['value'] = $values[$language];
|
115 |
-
$div['data-language'] = $language;
|
116 |
-
$div['class'] = 'acf-image-uploader acf-cf';
|
117 |
-
|
118 |
-
// has value?
|
119 |
-
if( $field['value'] ) {
|
120 |
-
// update vars
|
121 |
-
$url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
|
122 |
-
$alt = get_post_meta($field['value'], '_wp_attachment_image_alt', true);
|
123 |
-
|
124 |
-
// url exists
|
125 |
-
if( $url ) $url = $url[0];
|
126 |
-
|
127 |
-
// url exists
|
128 |
-
if( $url ) {
|
129 |
-
$div['class'] .= ' has-value';
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($language === $currentLanguage) {
|
134 |
-
$div['class'] .= ' current-language';
|
135 |
-
}
|
136 |
-
|
137 |
-
?>
|
138 |
-
<div <?php acf_esc_attr_e( $div ); ?>>
|
139 |
-
<div class="acf-hidden">
|
140 |
-
<?php acf_hidden_input(array( 'name' => $field['name'], 'value' => $field['value'] )); ?>
|
141 |
-
</div>
|
142 |
-
<div class="view show-if-value acf-soh" <?php if( $size['width'] ) echo 'style="max-width: '.$size['width'].'px"'; ?>>
|
143 |
-
<img data-name="image" src="<?php echo $url; ?>" alt="<?php echo $alt; ?>"/>
|
144 |
-
<ul class="acf-hl acf-soh-target">
|
145 |
-
<?php if( $uploader != 'basic' ): ?>
|
146 |
-
<li><a class="acf-icon -pencil dark" data-name="edit" href="#" title="<?php _e('Edit', 'acf'); ?>"></a></li>
|
147 |
-
<?php endif; ?>
|
148 |
-
<li><a class="acf-icon -cancel dark" data-name="remove" href="#" title="<?php _e('Remove', 'acf'); ?>"></a></li>
|
149 |
-
</ul>
|
150 |
-
</div>
|
151 |
-
<div class="view hide-if-value">
|
152 |
-
<?php if( $uploader == 'basic' ): ?>
|
153 |
-
|
154 |
-
<?php if( $field['value'] && !is_numeric($field['value']) ): ?>
|
155 |
-
<div class="acf-error-message"><p><?php echo $field['value']; ?></p></div>
|
156 |
-
<?php endif; ?>
|
157 |
-
|
158 |
-
<input type="file" name="<?php echo $field['name']; ?>" id="<?php echo $field['id']; ?>" />
|
159 |
-
|
160 |
-
<?php else: ?>
|
161 |
-
|
162 |
-
<p style="margin:0;"><?php _e('No image selected','acf'); ?> <a data-name="add" class="acf-button button" href="#"><?php _e('Add Image','acf'); ?></a></p>
|
163 |
-
|
164 |
-
<?php endif; ?>
|
165 |
-
</div>
|
166 |
-
</div>
|
167 |
-
|
168 |
-
<?php endforeach;
|
169 |
-
|
170 |
-
echo '</div>';
|
171 |
-
}
|
172 |
-
|
173 |
-
/*
|
174 |
-
* update_value()
|
175 |
-
*
|
176 |
-
* This filter is appied to the $value before it is updated in the db
|
177 |
-
*
|
178 |
-
* @type filter
|
179 |
-
* @since 3.6
|
180 |
-
* @date 23/01/13
|
181 |
-
*
|
182 |
-
* @param $value - the value which will be saved in the database
|
183 |
-
* @param $post_id - the $post_id of which the value will be saved
|
184 |
-
* @param $field - the field array holding all the field options
|
185 |
-
*
|
186 |
-
* @return $value - the modified value
|
187 |
-
*/
|
188 |
-
function update_value($value, $post_id, $field) {
|
189 |
-
$value = parent::update_value($value, $post_id, $field);
|
190 |
-
return qtrans_join($value);
|
191 |
-
}
|
192 |
-
|
193 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/acf_5/fields/text.php
DELETED
@@ -1,166 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_qtranslate_acf_5_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 |
-
* 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_text';
|
28 |
-
$this->label = __("Text",'acf');
|
29 |
-
$this->category = __("qTranslate",'acf');
|
30 |
-
$this->defaults = array(
|
31 |
-
'default_value' => '',
|
32 |
-
'maxlength' => '',
|
33 |
-
'placeholder' => '',
|
34 |
-
'prepend' => '',
|
35 |
-
'append' => '',
|
36 |
-
'readonly' => 0,
|
37 |
-
'disabled' => 0,
|
38 |
-
);
|
39 |
-
|
40 |
-
acf_field::__construct();
|
41 |
-
}
|
42 |
-
|
43 |
-
/*
|
44 |
-
* render_field()
|
45 |
-
*
|
46 |
-
* Create the HTML interface for your field
|
47 |
-
*
|
48 |
-
* @param $field - an array holding all the field's data
|
49 |
-
*
|
50 |
-
* @type action
|
51 |
-
* @since 3.6
|
52 |
-
* @date 23/01/13
|
53 |
-
*/
|
54 |
-
function render_field($field) {
|
55 |
-
global $q_config;
|
56 |
-
$languages = qtrans_getSortedLanguages(true);
|
57 |
-
$values = qtrans_split($field['value'], $quicktags = true);
|
58 |
-
$currentLanguage = $this->plugin->get_active_language();
|
59 |
-
|
60 |
-
// vars
|
61 |
-
$o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' );
|
62 |
-
$s = array( 'readonly', 'disabled' );
|
63 |
-
$e = '';
|
64 |
-
|
65 |
-
// maxlength
|
66 |
-
if( $field['maxlength'] !== "" ) {
|
67 |
-
$o[] = 'maxlength';
|
68 |
-
}
|
69 |
-
|
70 |
-
// populate atts
|
71 |
-
$atts = array();
|
72 |
-
foreach( $o as $k ) {
|
73 |
-
$atts[ $k ] = $field[ $k ];
|
74 |
-
}
|
75 |
-
|
76 |
-
// special atts
|
77 |
-
foreach( $s as $k ) {
|
78 |
-
if( $field[ $k ] ) {
|
79 |
-
$atts[ $k ] = $k;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
// render
|
84 |
-
$e .= '<div class="acf-input-wrap multi-language-field">';
|
85 |
-
|
86 |
-
foreach ($languages as $language) {
|
87 |
-
$class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
|
88 |
-
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
|
89 |
-
}
|
90 |
-
|
91 |
-
foreach ($languages as $language) {
|
92 |
-
$atts['class'] = $field['class'];
|
93 |
-
if ($language === $currentLanguage) {
|
94 |
-
$atts['class'] .= ' current-language';
|
95 |
-
}
|
96 |
-
$atts['type'] = 'text';
|
97 |
-
$atts['name'] = $field['name'] . "[$language]";
|
98 |
-
$atts['value'] = $values[$language];
|
99 |
-
$atts['data-language'] = $language;
|
100 |
-
$e .= '<input ' . acf_esc_attr( $atts ) . ' />';
|
101 |
-
}
|
102 |
-
|
103 |
-
$e .= '</div>';
|
104 |
-
|
105 |
-
// return
|
106 |
-
echo $e;
|
107 |
-
}
|
108 |
-
|
109 |
-
/*
|
110 |
-
* render_field_settings()
|
111 |
-
*
|
112 |
-
* Create extra options for your field. This is rendered when editing a field.
|
113 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
114 |
-
*
|
115 |
-
* @param $field - an array holding all the field's data
|
116 |
-
*
|
117 |
-
* @type action
|
118 |
-
* @since 3.6
|
119 |
-
* @date 23/01/13
|
120 |
-
*/
|
121 |
-
function render_field_settings($field) {
|
122 |
-
// default_value
|
123 |
-
acf_render_field_setting( $field, array(
|
124 |
-
'label' => __('Default Value','acf'),
|
125 |
-
'instructions' => __('Appears when creating a new post','acf'),
|
126 |
-
'type' => 'text',
|
127 |
-
'name' => 'default_value',
|
128 |
-
));
|
129 |
-
|
130 |
-
// placeholder
|
131 |
-
acf_render_field_setting( $field, array(
|
132 |
-
'label' => __('Placeholder Text','acf'),
|
133 |
-
'instructions' => __('Appears within the input','acf'),
|
134 |
-
'type' => 'text',
|
135 |
-
'name' => 'placeholder',
|
136 |
-
));
|
137 |
-
|
138 |
-
// maxlength
|
139 |
-
acf_render_field_setting( $field, array(
|
140 |
-
'label' => __('Character Limit','acf'),
|
141 |
-
'instructions' => __('Leave blank for no limit','acf'),
|
142 |
-
'type' => 'number',
|
143 |
-
'name' => 'maxlength',
|
144 |
-
));
|
145 |
-
}
|
146 |
-
|
147 |
-
/*
|
148 |
-
* update_value()
|
149 |
-
*
|
150 |
-
* This filter is appied to the $value before it is updated in the db
|
151 |
-
*
|
152 |
-
* @type filter
|
153 |
-
* @since 3.6
|
154 |
-
* @date 23/01/13
|
155 |
-
*
|
156 |
-
* @param $value - the value which will be saved in the database
|
157 |
-
* @param $post_id - the $post_id of which the value will be saved
|
158 |
-
* @param $field - the field array holding all the field options
|
159 |
-
*
|
160 |
-
* @return $value - the modified value
|
161 |
-
*/
|
162 |
-
function update_value($value, $post_id, $field) {
|
163 |
-
return qtrans_join($value);
|
164 |
-
}
|
165 |
-
|
166 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/acf_5/fields/textarea.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_qtranslate_acf_5_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 |
-
* 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_textarea';
|
28 |
-
$this->label = __("Text Area",'acf');
|
29 |
-
$this->category = __("qTranslate",'acf');
|
30 |
-
$this->defaults = array(
|
31 |
-
'default_value' => '',
|
32 |
-
'new_lines' => '',
|
33 |
-
'maxlength' => '',
|
34 |
-
'placeholder' => '',
|
35 |
-
'readonly' => 0,
|
36 |
-
'disabled' => 0,
|
37 |
-
'rows' => ''
|
38 |
-
);
|
39 |
-
|
40 |
-
acf_field::__construct();
|
41 |
-
}
|
42 |
-
|
43 |
-
/*
|
44 |
-
* render_field()
|
45 |
-
*
|
46 |
-
* Create the HTML interface for your field
|
47 |
-
*
|
48 |
-
* @param $field - an array holding all the field's data
|
49 |
-
*
|
50 |
-
* @type action
|
51 |
-
* @since 3.6
|
52 |
-
* @date 23/01/13
|
53 |
-
*/
|
54 |
-
function render_field($field) {
|
55 |
-
global $q_config;
|
56 |
-
$languages = qtrans_getSortedLanguages(true);
|
57 |
-
$values = qtrans_split($field['value'], $quicktags = true);
|
58 |
-
$currentLanguage = $this->plugin->get_active_language();
|
59 |
-
|
60 |
-
// vars
|
61 |
-
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
|
62 |
-
$s = array( 'readonly', 'disabled' );
|
63 |
-
$e = '';
|
64 |
-
|
65 |
-
// maxlength
|
66 |
-
if( $field['maxlength'] !== '' ) {
|
67 |
-
$o[] = 'maxlength';
|
68 |
-
}
|
69 |
-
|
70 |
-
// rows
|
71 |
-
if( empty($field['rows']) ) {
|
72 |
-
$field['rows'] = 8;
|
73 |
-
}
|
74 |
-
|
75 |
-
// populate atts
|
76 |
-
$atts = array();
|
77 |
-
foreach( $o as $k ) {
|
78 |
-
$atts[ $k ] = $field[ $k ];
|
79 |
-
}
|
80 |
-
|
81 |
-
// special atts
|
82 |
-
foreach( $s as $k ) {
|
83 |
-
if( $field[ $k ] ) {
|
84 |
-
$atts[ $k ] = $k;
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
// render
|
89 |
-
$e .= '<div class="acf-input-wrap multi-language-field">';
|
90 |
-
|
91 |
-
foreach ($languages as $language) {
|
92 |
-
$class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
|
93 |
-
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
|
94 |
-
}
|
95 |
-
|
96 |
-
foreach ($languages as $language) {
|
97 |
-
$atts['class'] = $field['class'];
|
98 |
-
if ($language === $currentLanguage) {
|
99 |
-
$atts['class'] .= ' current-language';
|
100 |
-
}
|
101 |
-
$atts['name'] = $field['name'] . "[$language]";
|
102 |
-
$atts['data-language'] = $language;
|
103 |
-
$e .= '<textarea ' . acf_esc_attr( $atts ) . ' >';
|
104 |
-
$e .= esc_textarea( $values[$language] );
|
105 |
-
$e .= '</textarea>';
|
106 |
-
}
|
107 |
-
|
108 |
-
$e .= '</div>';
|
109 |
-
|
110 |
-
// return
|
111 |
-
echo $e;
|
112 |
-
}
|
113 |
-
|
114 |
-
/*
|
115 |
-
* update_value()
|
116 |
-
*
|
117 |
-
* This filter is appied to the $value before it is updated in the db
|
118 |
-
*
|
119 |
-
* @type filter
|
120 |
-
* @since 3.6
|
121 |
-
* @date 23/01/13
|
122 |
-
*
|
123 |
-
* @param $value - the value which will be saved in the database
|
124 |
-
* @param $post_id - the $post_id of which the value will be saved
|
125 |
-
* @param $field - the field array holding all the field options
|
126 |
-
*
|
127 |
-
* @return $value - the modified value
|
128 |
-
*/
|
129 |
-
function update_value($value, $post_id, $field) {
|
130 |
-
return qtrans_join($value);
|
131 |
-
}
|
132 |
-
|
133 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/acf_5/fields/wysiwyg.php
DELETED
@@ -1,219 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_qtranslate_acf_5_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 |
-
* 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_wysiwyg';
|
28 |
-
$this->label = __("Wysiwyg Editor",'acf');
|
29 |
-
$this->category = __("qTranslate",'acf');
|
30 |
-
$this->defaults = array(
|
31 |
-
'tabs' => 'all',
|
32 |
-
'toolbar' => 'full',
|
33 |
-
'media_upload' => 1,
|
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'));
|
44 |
-
|
45 |
-
acf_field::__construct();
|
46 |
-
}
|
47 |
-
|
48 |
-
/*
|
49 |
-
* render_field()
|
50 |
-
*
|
51 |
-
* Create the HTML interface for your field
|
52 |
-
*
|
53 |
-
* @param $field - an array holding all the field's data
|
54 |
-
*
|
55 |
-
* @type action
|
56 |
-
* @since 3.6
|
57 |
-
* @date 23/01/13
|
58 |
-
*/
|
59 |
-
function render_field($field) {
|
60 |
-
|
61 |
-
// global
|
62 |
-
global $wp_version;
|
63 |
-
|
64 |
-
|
65 |
-
// enqueue
|
66 |
-
acf_enqueue_uploader();
|
67 |
-
|
68 |
-
|
69 |
-
// vars
|
70 |
-
$id = uniqid('acf-editor-');
|
71 |
-
$default_editor = 'html';
|
72 |
-
$show_tabs = true;
|
73 |
-
$button = '';
|
74 |
-
|
75 |
-
|
76 |
-
// get height
|
77 |
-
$height = acf_get_user_setting('wysiwyg_height', 300);
|
78 |
-
$height = max( $height, 300 ); // minimum height is 300
|
79 |
-
|
80 |
-
|
81 |
-
// detect mode
|
82 |
-
if( !user_can_richedit() ) {
|
83 |
-
|
84 |
-
$show_tabs = false;
|
85 |
-
|
86 |
-
} elseif( $field['tabs'] == 'visual' ) {
|
87 |
-
|
88 |
-
// case: visual tab only
|
89 |
-
$default_editor = 'tinymce';
|
90 |
-
$show_tabs = false;
|
91 |
-
|
92 |
-
} elseif( $field['tabs'] == 'text' ) {
|
93 |
-
|
94 |
-
// case: text tab only
|
95 |
-
$show_tabs = false;
|
96 |
-
|
97 |
-
} elseif( wp_default_editor() == 'tinymce' ) {
|
98 |
-
|
99 |
-
// case: both tabs
|
100 |
-
$default_editor = 'tinymce';
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
// must be logged in tp upload
|
106 |
-
if( !current_user_can('upload_files') ) {
|
107 |
-
|
108 |
-
$field['media_upload'] = 0;
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
// mode
|
114 |
-
$switch_class = ($default_editor === 'html') ? 'html-active' : 'tmce-active';
|
115 |
-
|
116 |
-
|
117 |
-
// filter value for editor
|
118 |
-
remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
|
119 |
-
remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 );
|
120 |
-
remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 );
|
121 |
-
|
122 |
-
|
123 |
-
// WP 4.3
|
124 |
-
if( version_compare($wp_version, '4.3', '>=' ) ) {
|
125 |
-
|
126 |
-
add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
|
127 |
-
|
128 |
-
$button = 'data-wp-editor-id="' . $id . '"';
|
129 |
-
|
130 |
-
// WP < 4.3
|
131 |
-
} else {
|
132 |
-
|
133 |
-
$function = ($default_editor === 'html') ? 'wp_htmledit_pre' : 'wp_richedit_pre';
|
134 |
-
|
135 |
-
add_filter('acf_the_editor_content', $function, 10, 1);
|
136 |
-
|
137 |
-
$button = 'onclick="switchEditors.switchto(this);"';
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
|
142 |
-
global $q_config;
|
143 |
-
|
144 |
-
$languages = qtrans_getSortedLanguages(true);
|
145 |
-
$values = qtrans_split($field['value'], $quicktags = true);
|
146 |
-
$currentLanguage = $this->plugin->get_active_language();
|
147 |
-
|
148 |
-
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
|
149 |
-
|
150 |
-
foreach ($languages as $language) {
|
151 |
-
$class = ($language === $currentLanguage) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
|
152 |
-
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
|
153 |
-
}
|
154 |
-
|
155 |
-
$uid = uniqid('acf-editor-');
|
156 |
-
foreach ($languages as $language):
|
157 |
-
|
158 |
-
$id = $uid . "-$language";
|
159 |
-
$name = $field['name'] . "[$language]";
|
160 |
-
$class = $switch_class;
|
161 |
-
if ($language === $currentLanguage) {
|
162 |
-
$class .= ' current-language';
|
163 |
-
}
|
164 |
-
|
165 |
-
// WP 4.3
|
166 |
-
if( version_compare($wp_version, '4.3', '>=' ) ) {
|
167 |
-
$button = 'data-wp-editor-id="' . $id . '"';
|
168 |
-
// WP < 4.3
|
169 |
-
} else {
|
170 |
-
$button = 'onclick="switchEditors.switchto(this);"';
|
171 |
-
}
|
172 |
-
|
173 |
-
$value = apply_filters('acf_the_editor_content', $values[$language], $default_editor);
|
174 |
-
|
175 |
-
?>
|
176 |
-
<div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>" data-language="<?php echo $language; ?>">
|
177 |
-
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
|
178 |
-
<?php if( $field['media_upload'] ): ?>
|
179 |
-
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
|
180 |
-
<?php do_action( 'media_buttons' ); ?>
|
181 |
-
</div>
|
182 |
-
<?php endif; ?>
|
183 |
-
<?php if( user_can_richedit() && $show_tabs ): ?>
|
184 |
-
<div class="wp-editor-tabs">
|
185 |
-
<button id="<?php echo $id; ?>-tmce" class="wp-switch-editor switch-tmce" <?php echo $button; ?> type="button"><?php echo __('Visual', 'acf'); ?></button>
|
186 |
-
<button id="<?php echo $id; ?>-html" class="wp-switch-editor switch-html" <?php echo $button; ?> type="button"><?php echo _x( 'Text', 'Name for the Text editor tab (formerly HTML)', 'acf' ); ?></button>
|
187 |
-
</div>
|
188 |
-
<?php endif; ?>
|
189 |
-
</div>
|
190 |
-
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
|
191 |
-
<textarea id="<?php echo $id; ?>" class="qtx-wp-editor-area" name="<?php echo $name; ?>" <?php if($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $value; ?></textarea>
|
192 |
-
</div>
|
193 |
-
</div>
|
194 |
-
|
195 |
-
<?php endforeach;
|
196 |
-
|
197 |
-
echo '</div>';
|
198 |
-
}
|
199 |
-
|
200 |
-
/*
|
201 |
-
* update_value()
|
202 |
-
*
|
203 |
-
* This filter is appied to the $value before it is updated in the db
|
204 |
-
*
|
205 |
-
* @type filter
|
206 |
-
* @since 3.6
|
207 |
-
* @date 23/01/13
|
208 |
-
*
|
209 |
-
* @param $value - the value which will be saved in the database
|
210 |
-
* @param $post_id - the $post_id of which the value will be saved
|
211 |
-
* @param $field - the field array holding all the field options
|
212 |
-
*
|
213 |
-
* @return $value - the modified value
|
214 |
-
*/
|
215 |
-
function update_value($value, $post_id, $field) {
|
216 |
-
return qtrans_join($value);
|
217 |
-
}
|
218 |
-
|
219 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/acf_interface.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
interface acf_qtranslate_acf_interface {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Get the visible ACF fields.
|
7 |
-
* @return array
|
8 |
-
*/
|
9 |
-
public function get_visible_acf_fields();
|
10 |
-
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/mqtranslate.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_interface.php';
|
4 |
-
|
5 |
-
class acf_qtranslate_mqtranslate {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* An ACF instance.
|
9 |
-
* @var \acf_qtranslate_acf_interface
|
10 |
-
*/
|
11 |
-
protected $acf;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* The plugin instance.
|
15 |
-
* @var \acf_qtranslate_plugin
|
16 |
-
*/
|
17 |
-
protected $plugin;
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Create an instance.
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
public function __construct(acf_qtranslate_plugin $plugin, acf_qtranslate_acf_interface $acf) {
|
25 |
-
$this->acf = $acf;
|
26 |
-
$this->plugin = $plugin;
|
27 |
-
|
28 |
-
$this->monkey_patches();
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Monkey patches.
|
33 |
-
*/
|
34 |
-
public function monkey_patches() {
|
35 |
-
global $q_config;
|
36 |
-
|
37 |
-
// http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3497
|
38 |
-
if (isset($q_config['js']['qtrans_switch'])) {
|
39 |
-
if (strpos($q_config['js']['qtrans_switch'], 'originalSwitchEditors') === false) {
|
40 |
-
$q_config['js']['qtrans_switch'] = "var _switchEditors = jQuery.extend(true, {}, switchEditors);\n" . $q_config['js']['qtrans_switch'];
|
41 |
-
$q_config['js']['qtrans_switch'] = preg_replace("/(var vta = document\.getElementById\('qtrans_textarea_' \+ id\);)/", "\$1\nif(!vta)return _switchEditors.go(id, lang);", $q_config['js']['qtrans_switch']);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
// https://github.com/funkjedi/acf-qtranslate/issues/2#issuecomment-37612918
|
46 |
-
if (isset($q_config['js']['qtrans_hook_on_tinyMCE'])) {
|
47 |
-
if (strpos($q_config['js']['qtrans_hook_on_tinyMCE'], 'ed.editorId.match(/^qtrans_/)') === false) {
|
48 |
-
$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']);
|
49 |
-
}
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/plugin.php
DELETED
@@ -1,265 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_qtranslate_plugin {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* An ACF instance.
|
7 |
-
* @var \acf_qtranslate_acf_interface
|
8 |
-
*/
|
9 |
-
protected $acf;
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Create an instance.
|
14 |
-
* @return void
|
15 |
-
*/
|
16 |
-
public function __construct() {
|
17 |
-
add_action('plugins_loaded', array($this, 'init'), 3);
|
18 |
-
add_action('after_setup_theme', array($this, 'init'), -10);
|
19 |
-
add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
20 |
-
add_action('admin_footer', array($this, 'admin_footer'));
|
21 |
-
add_action('admin_menu', array($this, 'admin_menu'));
|
22 |
-
add_action('admin_init', array($this, 'admin_init'));
|
23 |
-
|
24 |
-
add_filter('qtranslate_load_admin_page_config', array($this, 'qtranslate_load_admin_page_config'));
|
25 |
-
add_filter('plugin_action_links_' . plugin_basename(ACF_QTRANSLATE_PLUGIN), array($this, 'plugin_action_links'));
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Setup plugin if Advanced Custom Fields is enabled.
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
public function init() {
|
33 |
-
static $plugin_loaded;
|
34 |
-
|
35 |
-
if (!$plugin_loaded && $this->acf_enabled() && $this->qtranslatex_enabled()) {
|
36 |
-
|
37 |
-
// setup qtranslate fields for ACF 4
|
38 |
-
if ($this->acf_major_version() === 4) {
|
39 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_4/acf.php';
|
40 |
-
$this->acf = new acf_qtranslate_acf_4($this);
|
41 |
-
}
|
42 |
-
|
43 |
-
// setup qtranslate fields for ACF 5
|
44 |
-
if ($this->acf_major_version() === 5) {
|
45 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_5/acf.php';
|
46 |
-
$this->acf = new acf_qtranslate_acf_5($this);
|
47 |
-
}
|
48 |
-
|
49 |
-
// setup qtranslatex integration
|
50 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/qtranslatex.php';
|
51 |
-
new acf_qtranslate_qtranslatex($this, $this->acf);
|
52 |
-
|
53 |
-
$plugin_loaded = true;
|
54 |
-
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Check if Advanced Custom Fields is enabled.
|
60 |
-
* @return boolean
|
61 |
-
*/
|
62 |
-
public function acf_enabled() {
|
63 |
-
if (function_exists('acf')) {
|
64 |
-
return $this->acf_major_version() === 4 || $this->acf_major_version() === 5;
|
65 |
-
}
|
66 |
-
return false;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Return the major version number for Advanced Custom Fields.
|
71 |
-
* @return int
|
72 |
-
*/
|
73 |
-
public function acf_major_version() {
|
74 |
-
return (int) acf()->settings['version'][0];
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Check if qTranslate-X is enabled.
|
79 |
-
*/
|
80 |
-
public function qtranslatex_enabled() {
|
81 |
-
return function_exists('qtranxf_getLanguage');
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Get the active language.
|
86 |
-
*/
|
87 |
-
public function get_active_language() {
|
88 |
-
return apply_filters('acf_qtranslate_get_active_language', qtrans_getLanguage());
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Load javascript and stylesheets on admin pages.
|
93 |
-
*/
|
94 |
-
public function admin_enqueue_scripts() {
|
95 |
-
wp_enqueue_style('acf_qtranslate_common', plugins_url('/assets/common.css', ACF_QTRANSLATE_PLUGIN), array('acf-input'));
|
96 |
-
wp_enqueue_script('acf_qtranslate_common', plugins_url('/assets/common.js', ACF_QTRANSLATE_PLUGIN), array('acf-input','underscore'));
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Output a hidden block that can be use to force qTranslate-X
|
101 |
-
* to include the LSB.
|
102 |
-
*/
|
103 |
-
public function admin_footer() {
|
104 |
-
echo '<span id="acf-qtranslate-lsb-shim" style="display:none">[:en]LSB[:]</span>';
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Add settings link on plugin page.
|
109 |
-
* @param array
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
public function plugin_action_links($links) {
|
113 |
-
array_unshift($links, '<a href="options-general.php?page=acf-qtranslate">Settings</a>');
|
114 |
-
return $links;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Enable the display of the LSB on ACF Options pages.
|
119 |
-
* @param array
|
120 |
-
* @return array
|
121 |
-
*/
|
122 |
-
public function qtranslate_load_admin_page_config($config)
|
123 |
-
{
|
124 |
-
$config['acf-display-nodes'] = array(
|
125 |
-
'pages' => array('post.php' => '', 'admin.php' => 'page='),
|
126 |
-
'forms' => array(
|
127 |
-
'wpwrap' => array(
|
128 |
-
'fields' => array(
|
129 |
-
'lsb-shim' => array(
|
130 |
-
'jquery' => '#acf-qtranslate-lsb-shim',
|
131 |
-
'encode' => 'display',
|
132 |
-
),
|
133 |
-
'acf4-field-group-handle' => array(
|
134 |
-
'jquery' => '.acf_postbox h2 span,.acf_postbox h3 span',
|
135 |
-
'encode' => 'display',
|
136 |
-
),
|
137 |
-
'acf5-field-group-handle' => array(
|
138 |
-
'jquery' => '.acf-postbox h2 span,.acf-postbox h3 span',
|
139 |
-
'encode' => 'display',
|
140 |
-
),
|
141 |
-
'acf5-field-label' => array(
|
142 |
-
'jquery' => '.acf-field .acf-label label',
|
143 |
-
'encode' => 'display',
|
144 |
-
),
|
145 |
-
'acf5-field-description' => array(
|
146 |
-
'jquery' => '.acf-field .acf-label p.description',
|
147 |
-
'encode' => 'display',
|
148 |
-
),
|
149 |
-
)),
|
150 |
-
),
|
151 |
-
);
|
152 |
-
|
153 |
-
$config['acf-field-group'] = array(
|
154 |
-
'pages' => array('post.php' => ''),
|
155 |
-
'post_type' => 'acf-field-group',
|
156 |
-
'forms' => array(
|
157 |
-
'post' => array(
|
158 |
-
'fields' => array(
|
159 |
-
'field-group-object-label' => array(
|
160 |
-
'jquery' => '.li-field-label .edit-field',
|
161 |
-
'encode' => 'display',
|
162 |
-
),
|
163 |
-
)),
|
164 |
-
),
|
165 |
-
);
|
166 |
-
|
167 |
-
return $config;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Retrieve the value of a plugin setting.
|
172 |
-
*/
|
173 |
-
function get_plugin_setting($name, $default = null) {
|
174 |
-
$options = get_option('acf_qtranslate');
|
175 |
-
if (isset($options[$name]) === true) {
|
176 |
-
return $options[$name];
|
177 |
-
}
|
178 |
-
return $default;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Register the options page with the Wordpress menu.
|
183 |
-
*/
|
184 |
-
function admin_menu() {
|
185 |
-
add_options_page('ACF qTranslate', 'ACF qTranslate', 'manage_options', 'acf-qtranslate', array($this, 'options_page'));
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Register settings and default fields.
|
190 |
-
*/
|
191 |
-
function admin_init() {
|
192 |
-
register_setting('acf_qtranslate', 'acf_qtranslate');
|
193 |
-
|
194 |
-
add_settings_section(
|
195 |
-
'qtranslatex_section',
|
196 |
-
'qTranslate-X',
|
197 |
-
array($this, 'render_section_qtranslatex'),
|
198 |
-
'acf_qtranslate'
|
199 |
-
);
|
200 |
-
|
201 |
-
add_settings_field(
|
202 |
-
'translate_standard_field_types',
|
203 |
-
'Enable translation for Standard Field Types',
|
204 |
-
array($this, 'render_setting_translate_standard_field_types'),
|
205 |
-
'acf_qtranslate',
|
206 |
-
'qtranslatex_section'
|
207 |
-
);
|
208 |
-
|
209 |
-
add_settings_field(
|
210 |
-
'show_language_tabs',
|
211 |
-
'Display language tabs',
|
212 |
-
array($this, 'render_setting_show_language_tabs'),
|
213 |
-
'acf_qtranslate',
|
214 |
-
'qtranslatex_section'
|
215 |
-
);
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Render the options page.
|
220 |
-
*/
|
221 |
-
function options_page() {
|
222 |
-
?>
|
223 |
-
<form action="options.php" method="post">
|
224 |
-
<h2>ACF qTranslate Settings</h2>
|
225 |
-
<br>
|
226 |
-
<?php
|
227 |
-
|
228 |
-
settings_fields('acf_qtranslate');
|
229 |
-
do_settings_sections('acf_qtranslate');
|
230 |
-
submit_button();
|
231 |
-
|
232 |
-
?>
|
233 |
-
</form>
|
234 |
-
<?php
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Render the qTranslate-X section.
|
239 |
-
*/
|
240 |
-
function render_section_qtranslatex() {
|
241 |
-
?>
|
242 |
-
The following options represent additional functionality that is available when
|
243 |
-
using qTranslate-X. These functionality is off by default and must be enabled below.
|
244 |
-
<?php
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Render setting.
|
249 |
-
*/
|
250 |
-
function render_setting_translate_standard_field_types() {
|
251 |
-
?>
|
252 |
-
<input type="checkbox" name="acf_qtranslate[translate_standard_field_types]" <?php checked($this->get_plugin_setting('translate_standard_field_types'), 1); ?> value="1">
|
253 |
-
<?php
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Render setting.
|
258 |
-
*/
|
259 |
-
function render_setting_show_language_tabs() {
|
260 |
-
?>
|
261 |
-
<input type="checkbox" name="acf_qtranslate[show_language_tabs]" <?php checked($this->get_plugin_setting('show_language_tabs'), 1); ?> value="1">
|
262 |
-
<?php
|
263 |
-
}
|
264 |
-
|
265 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/ppqtranslate.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_interface.php';
|
4 |
-
|
5 |
-
class acf_qtranslate_ppqtranslate {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* An ACF instance.
|
9 |
-
* @var \acf_qtranslate_acf_interface
|
10 |
-
*/
|
11 |
-
protected $acf;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* The plugin instance.
|
15 |
-
* @var \acf_qtranslate_plugin
|
16 |
-
*/
|
17 |
-
protected $plugin;
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Create an instance.
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
public function __construct(acf_qtranslate_plugin $plugin, acf_qtranslate_acf_interface $acf) {
|
25 |
-
$this->acf = $acf;
|
26 |
-
$this->plugin = $plugin;
|
27 |
-
|
28 |
-
// include compatibility functions
|
29 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'compatibility/ppqtranslate.php';
|
30 |
-
|
31 |
-
$this->monkey_patches();
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Monkey patches.
|
36 |
-
*/
|
37 |
-
public function monkey_patches() {
|
38 |
-
global $q_config;
|
39 |
-
|
40 |
-
// http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=3497
|
41 |
-
if (isset($q_config['js']['ppqtrans_switch'])) {
|
42 |
-
if (strpos($q_config['js']['ppqtrans_switch'], '_switchEditors') === false) {
|
43 |
-
$q_config['js']['ppqtrans_switch'] = "var _switchEditors = jQuery.extend(true, {}, switchEditors);\n" . $q_config['js']['ppqtrans_switch'];
|
44 |
-
$q_config['js']['ppqtrans_switch'] = preg_replace("/(var vta = document\.getElementById\('ppqtrans_textarea_' \+ id\);)/", "\$1\nif(!vta)return _switchEditors.go(id, lang);", $q_config['js']['ppqtrans_switch']);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
// https://github.com/funkjedi/acf-qtranslate/issues/2#issuecomment-37612918
|
49 |
-
if (isset($q_config['js']['ppqtrans_hook_on_tinyMCE'])) {
|
50 |
-
if (strpos($q_config['js']['ppqtrans_hook_on_tinyMCE'], 'ed.id.match(/^ppqtrans_/)') === false) {
|
51 |
-
$q_config['js']['ppqtrans_hook_on_tinyMCE'] = preg_replace("/(ppqtrans_save\(switchEditors\.pre_wpautop\(e\.content\)\);)/", "if (ed.id.match(/^ppqtrans_/)) \$1", $q_config['js']['ppqtrans_hook_on_tinyMCE']);
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/src/qtranslatex.php
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'src/acf_interface.php';
|
4 |
-
|
5 |
-
class acf_qtranslate_qtranslatex {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* An ACF instance.
|
9 |
-
* @var \acf_qtranslate_acf_interface
|
10 |
-
*/
|
11 |
-
protected $acf;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* The plugin instance.
|
15 |
-
* @var \acf_qtranslate_plugin
|
16 |
-
*/
|
17 |
-
protected $plugin;
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Create an instance.
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
public function __construct(acf_qtranslate_plugin $plugin, acf_qtranslate_acf_interface $acf) {
|
25 |
-
$this->acf = $acf;
|
26 |
-
$this->plugin = $plugin;
|
27 |
-
|
28 |
-
// include compatibility functions
|
29 |
-
require_once ACF_QTRANSLATE_PLUGIN_DIR . 'compatibility/qtranslatex.php';
|
30 |
-
|
31 |
-
add_action('admin_head', array($this, 'admin_head'));
|
32 |
-
add_filter('qtranslate_custom_admin_js', array($this, 'qtranslate_custom_admin_js'));
|
33 |
-
add_filter('acf_qtranslate_get_active_language', array($this, 'get_active_language'));
|
34 |
-
add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Add additional styles and scripts to head.
|
39 |
-
*/
|
40 |
-
public function admin_head() {
|
41 |
-
// Hide the language tabs if they shouldn't be displayed
|
42 |
-
$show_language_tabs = $this->plugin->get_plugin_setting('show_language_tabs');
|
43 |
-
if (!$show_language_tabs) {
|
44 |
-
?>
|
45 |
-
<style>
|
46 |
-
.multi-language-field {margin-top:0!important;}
|
47 |
-
.multi-language-field .wp-switch-editor[data-language] {display:none!important;}
|
48 |
-
</style>
|
49 |
-
<?php
|
50 |
-
}
|
51 |
-
|
52 |
-
// Enable translation of standard field types
|
53 |
-
$translate_standard_field_types = $this->plugin->get_plugin_setting('translate_standard_field_types');
|
54 |
-
if ($translate_standard_field_types) {
|
55 |
-
?>
|
56 |
-
<script>
|
57 |
-
var acf_qtranslate_translate_standard_field_types = <?= json_encode($translate_standard_field_types) ?>;
|
58 |
-
</script>
|
59 |
-
<?php
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Load javascript and stylesheets on admin pages.
|
65 |
-
*/
|
66 |
-
public function admin_enqueue_scripts() {
|
67 |
-
$version = $this->plugin->acf_major_version();
|
68 |
-
wp_enqueue_script('acf_qtranslatex', plugins_url("/assets/acf_{$version}/qtranslatex.js", ACF_QTRANSLATE_PLUGIN), array('acf_qtranslate_common'));
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Use the edit-post script on admin pages.
|
73 |
-
* @return string
|
74 |
-
*/
|
75 |
-
public function qtranslate_custom_admin_js() {
|
76 |
-
global $pagenow, $plugin_page;
|
77 |
-
|
78 |
-
if ($pagenow === 'admin.php' && isset($plugin_page)) {
|
79 |
-
return 'admin/js/edit-post';
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Get the active language.
|
85 |
-
*/
|
86 |
-
public function get_active_language($language) {
|
87 |
-
if (empty($_COOKIE['qtrans_edit_language']) === false) {
|
88 |
-
$enabledLanguages = qtrans_getSortedLanguages();
|
89 |
-
if (in_array($_COOKIE['qtrans_edit_language'], $enabledLanguages)) {
|
90 |
-
$language = $_COOKIE['qtrans_edit_language'];
|
91 |
-
}
|
92 |
-
}
|
93 |
-
return $language;
|
94 |
-
}
|
95 |
-
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|