WPGlobus – Multilingual Everything! - Version 2.7.6

Version Description

  • (Vendor/ACF) Updated doc.
  • (Vendor/ACF) Added init param for WPGlobus_Vendor_Acf class.
  • (Vendor/ACF) Added translatableClass key in localizing script.
  • (Vendor/ACF) Set translatableClass for elements in Builder mode.
  • (Vendor/ACF) Perform a global search and replace in JS.
Download this release

Release Info

Developer tivnet
Plugin Icon 128x128 WPGlobus – Multilingual Everything!
Version 2.7.6
Comparing to
See all releases

Code changes from version 2.7.5 to 2.7.6

data/wpglobus-product-info.json CHANGED
@@ -1 +1 @@
1
- {"multilingual-woocommerce-nets-netaxept":{"title":"{:en}Multilingual WooCommerce Nets Netaxept{:}{:ru}\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce Nets Netaxept{:}","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.8"},"wpglobus-multi-currency":{"title":"{:en}Multi-Currency for WooCommerce{:}{:ru}WPGlobus - \u041c\u0443\u043b\u044c\u0442\u0438\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce{:}","_api_new_version":"1.1.1","_api_tested_up_to":"4.9.4"},"wpglobus-mobile-menu":{"title":"{:en}WPGlobus Mobile Menu{:}{:ru}WPGlobus Mobile Menu{:}","_api_new_version":"2.2.0","_api_tested_up_to":"5.6"},"wpglobus-header-images":{"title":"{:en}WPGlobus Header Images{:}{:ru}WPGlobus Header Images{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.5"},"wpglobus-for-ultimate-member":{"title":"{:en}WPGlobus for Ultimate Member{:}{:ru}WPGlobus \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Ultimate Member{:}","_api_new_version":"1.1.0","_api_tested_up_to":"5.6"},"wpglobus-menu-visibility":{"title":"WPGlobus Menu Visibility","_api_new_version":"2.0.0","_api_tested_up_to":"5.6"},"wpglobus-for-bridge-theme":{"title":"{:en}WPGlobus for the \"Bridge\" theme{:}{:ru}WPGlobus \u0434\u043b\u044f \u0442\u0435\u043c\u044b Bridge{:}","_api_new_version":"2.4.0","_api_tested_up_to":"5.5"},"wpglobus-plus":{"title":"{:en}WPGlobus Plus multilingual extension{:}{:ru}WPGlobus \u041f\u043b\u044e\u0441{:}","_api_new_version":"1.6.0","_api_tested_up_to":"5.7.1"},"wpglobus-language-widgets":{"title":"{:en}WPGlobus Language Widgets{:}{:ru}\u042f\u0437\u044b\u043a\u0438 WPGlobus \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-popups":{"title":"{:en}WPGlobus Multilingual Popups{:}{:ru}WPGlobus Multilingual Popups{:}","_api_new_version":"1.4.0","_api_tested_up_to":"5.7"},"woocommerce-wpglobus":{"title":"{:en}WPGlobus for WooCommerce{:}{:ru}\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 WooCommerce WPGlobus{:}","_api_new_version":"5.3.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-notices":{"title":"{:en}WPGlobus Multilingual Notices{:}{:ru}WPGlobus - \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f{:}","_api_new_version":"2.7.0","_api_tested_up_to":"5.7"}}
1
+ {"multilingual-woocommerce-nets-netaxept":{"title":"{:en}Multilingual WooCommerce Nets Netaxept{:}{:ru}\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce Nets Netaxept{:}","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.8"},"wpglobus-multi-currency":{"title":"{:en}Multi-Currency for WooCommerce{:}{:ru}WPGlobus - \u041c\u0443\u043b\u044c\u0442\u0438\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce{:}","_api_new_version":"1.1.1","_api_tested_up_to":"4.9.4"},"wpglobus-mobile-menu":{"title":"{:en}WPGlobus Mobile Menu{:}{:ru}WPGlobus Mobile Menu{:}","_api_new_version":"2.2.0","_api_tested_up_to":"5.6"},"wpglobus-header-images":{"title":"{:en}WPGlobus Header Images{:}{:ru}WPGlobus Header Images{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.5"},"wpglobus-for-ultimate-member":{"title":"{:en}WPGlobus for Ultimate Member{:}{:ru}WPGlobus \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Ultimate Member{:}","_api_new_version":"1.1.0","_api_tested_up_to":"5.6"},"wpglobus-menu-visibility":{"title":"WPGlobus Menu Visibility","_api_new_version":"2.0.0","_api_tested_up_to":"5.6"},"wpglobus-for-bridge-theme":{"title":"{:en}WPGlobus for the \"Bridge\" theme{:}{:ru}WPGlobus \u0434\u043b\u044f \u0442\u0435\u043c\u044b Bridge{:}","_api_new_version":"2.4.0","_api_tested_up_to":"5.5"},"wpglobus-plus":{"title":"{:en}WPGlobus Plus multilingual extension{:}{:ru}WPGlobus \u041f\u043b\u044e\u0441{:}","_api_new_version":"1.6.0","_api_tested_up_to":"5.7.1"},"wpglobus-language-widgets":{"title":"{:en}WPGlobus Language Widgets{:}{:ru}\u042f\u0437\u044b\u043a\u0438 WPGlobus \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-popups":{"title":"{:en}WPGlobus Multilingual Popups{:}{:ru}WPGlobus Multilingual Popups{:}","_api_new_version":"1.4.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-notices":{"title":"{:en}WPGlobus Multilingual Notices{:}{:ru}WPGlobus - \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f{:}","_api_new_version":"2.7.0","_api_tested_up_to":"5.7"},"woocommerce-wpglobus":{"title":"{:en}WPGlobus for WooCommerce{:}{:ru}\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 WooCommerce WPGlobus{:}","_api_new_version":"5.3.0","_api_tested_up_to":"5.7"}}
includes/js/wpglobus-vendor-acf.js CHANGED
@@ -1,263 +1,273 @@
1
- /**
2
- * WPGlobus Administration ACF plugin fields
3
- * Interface JS functions
4
- *
5
- * @since 1.0.5
6
- *
7
- * @package WPGlobus
8
- * @subpackage Administration
9
- */
10
- /*jslint browser: true */
11
- /*global jQuery, console, WPGlobusAcf, WPGlobusDialogApp */
12
-
13
- jQuery(document).ready(function ($) {
14
- "use strict";
15
-
16
- if (typeof WPGlobusAcf === 'undefined') {
17
- return;
18
- }
19
-
20
- var api = {
21
- parseBool: function(b) {
22
- return !(/^(false|0)$/i).test(b) && !!b;
23
- },
24
- isPro: function(){
25
- return api.parseBool( WPGlobusAcf.pro );
26
- },
27
- isBuilder: function(){
28
- return api.parseBool( WPGlobusAcf.builder_id );
29
- },
30
- vendorAcfFields: null,
31
- option: {},
32
- init: function (args) {
33
-
34
- // @since 2.6.6
35
- if ( api.isBuilder() && 'undefined' === typeof WPGlobusDialogApp ) {
36
- return;
37
- }
38
-
39
- api.option = $.extend(api.option, args);
40
- if (api.option.pro) {
41
- api.startAcf('.acf-field');
42
- api.runActions();
43
- } else {
44
- //api.startAcf('.acf_postbox .field');
45
- // @since 1.9.17
46
- if ( $('.acf_postbox .field').length > 0 ) {
47
- api.startAcf('.acf_postbox .field');
48
- }
49
- if ( $('.acf-postbox .acf-field').length > 0 ) {
50
- api.startAcf('.acf-postbox .acf-field');
51
- }
52
- }
53
- api.attachListeners();
54
- },
55
- runActions: function() {
56
- if ( 'undefined' !== typeof WPGlobusAcf.actions.fixTextFields && WPGlobusAcf.actions.fixTextFields ) {
57
- api.fixTextFields();
58
- }
59
- },
60
- fixTextFields: function() {
61
- // fix hidden WPGlobus dialog start icon with ACF Pro from v.5.8
62
- $.each(WPGlobusAcf.fields, function(i, id){
63
- var $tf = $('input[type="text"]#'+id);
64
- if ( $tf.length == 1 ) {
65
- var $tfp = $tf.parent('.acf-input-wrap');
66
- if ( $tfp.length == 1 ) {
67
- if ( $tfp.hasClass('acf-input-wrap') ) {
68
- $tfp.css('height','auto');
69
- }
70
- }
71
- }
72
- });
73
- },
74
- isDisabledField: function(id) {
75
- var res = false;
76
-
77
- /**
78
- * Check for ACF Pro.
79
- */
80
- var parentId = $('#' + id).parents('.acf-field').attr('id');
81
-
82
- if ( 'undefined' !== typeof parentId ) {
83
- $.each(WPGlobusAcf.disabledFields, function (i, e) {
84
- if (e == parentId) {
85
- res = true;
86
- }
87
- });
88
- }
89
-
90
- if ( res ) {
91
- return res;
92
- }
93
-
94
- /**
95
- * Check for ACF.
96
- */
97
- $.each(WPGlobusAcf.disabledFields, function (i, e) {
98
- if (e == id) {
99
- res = true;
100
- }
101
- });
102
-
103
- return res;
104
- },
105
- startAcf: function (acf_class) {
106
- var id;
107
- var style = 'width:90%;';
108
- var element, clone, name;
109
- if ($('.acf_postbox').parents('#postbox-container-2').length == 1) {
110
- style = 'width:97%';
111
- }
112
- //$('.acf_postbox .field').each(function(){
113
- $(acf_class).each(function () {
114
- var $t = $(this), id, h;
115
- if ($t.hasClass('field_type-textarea') || $t.hasClass('acf-field-textarea')) {
116
-
117
- id = $t.find('textarea').attr('id');
118
-
119
- api.registerField(id);
120
- if (api.isDisabledField(id)) {
121
- return true;
122
- }
123
-
124
- // @since 2.6.6
125
- if ( ! api.isVendorAcfField(id) ) {
126
- return true;
127
- }
128
-
129
- h = $('#' + id).height() + 20;
130
- WPGlobusDialogApp.addElement({
131
- id : id,
132
- dialogTitle : 'Edit ACF field',
133
- style : 'width:97%;float:left;',
134
- styleTextareaWrapper: 'height:' + h + 'px;',
135
- sbTitle : 'Click for edit',
136
- onChangeClass : 'wpglobus-on-change-acf-field'
137
- });
138
-
139
- } else if ($t.hasClass('field_type-text') || $t.hasClass('acf-field-text')) {
140
-
141
- id = $t.find('input').attr('id');
142
-
143
- api.registerField(id);
144
- if (api.isDisabledField(id)) {
145
- return true;
146
- }
147
-
148
- // @since 2.6.6
149
- if ( ! api.isVendorAcfField(id) ) {
150
- return true;
151
- }
152
-
153
- WPGlobusDialogApp.addElement({
154
- id : id,
155
- dialogTitle : 'Edit ACF field',
156
- style : 'width:97%;float:left;',
157
- sbTitle : 'Click for edit',
158
- onChangeClass: 'wpglobus-on-change-acf-field'
159
- });
160
-
161
- }
162
- });
163
- },
164
- registerField: function(id, type) {
165
- var register = false;
166
- if ( 'undefined' !== typeof id ) {
167
- if ( -1 == id.indexOf('acfcloneindex') ) {
168
- /**
169
- * Don't register acf clone field.
170
- * e.g. acf-field_5a5734b531031-acfcloneindex-field_5a573503660e9
171
- */
172
- if ( ! api.isRegisteredField(id) ) {
173
- register = true;
174
- WPGlobusAcf.fields.push(id);
175
- }
176
- }
177
- }
178
- if ( register ) {
179
- return id;
180
- }
181
- return false;
182
- },
183
- getFields: function() {
184
- return WPGlobusAcf.fields;
185
- },
186
- getDisabledFields: function() {
187
- return WPGlobusAcf.disabledFields;
188
- },
189
- unificationField: function(field) {
190
- // @since 2.6.6
191
- if ( /acf\[/.test(field) ) {
192
- field = field.replace('[','-');
193
- field = field.replace(']','');
194
- }
195
- return field;
196
- },
197
- getVendorAcfFields: function() {
198
- // @since 2.6.6
199
- if ( api.vendorAcfFields === null ) {
200
- if ( 'undefined' === typeof WPGlobusVendorAcfFields || '' == WPGlobusVendorAcfFields ) {
201
- api.vendorAcfFields = false;
202
- return api.vendorAcfFields;
203
- }
204
- api.vendorAcfFields = WPGlobusVendorAcfFields.split(',');
205
- }
206
- return api.vendorAcfFields;
207
- },
208
- isVendorAcfField: function( field ) {
209
- // @since 2.6.6
210
- if ( 'undefined' === typeof field ) {
211
- return false;
212
- }
213
- // We can receive here `field` in two forms
214
- // 1. acf-field_5f8a8fd1c97f7
215
- // 2. acf[field_5f8a8fd1c97f7]
216
- field = api.unificationField(field);
217
- var _result = false;
218
- var _fields = api.getVendorAcfFields();
219
- if ( ! _fields ) {
220
- return _result;
221
- }
222
- $.each( _fields, function(i,_field){
223
- if ( _field === field ) {
224
- _result = true;
225
- return false;
226
- }
227
- });
228
- return _result;
229
- },
230
- isRegisteredField: function(id) {
231
- var registered = false;
232
- api.getFields().forEach(function(elm) {
233
- if (elm == id) {
234
- registered = true
235
- return false;
236
- }
237
- });
238
- return registered;
239
- },
240
- attachListeners: function() {
241
- if (api.option.pro) {
242
- /**
243
- * Attach listener for new ACF fields that was added in repeater field type.
244
- */
245
- var t = this;
246
- if (acf.add_action) { // ACF v5
247
- acf.add_action('append', function($el) {
248
- t.replaceCloneIndex($el);
249
- });
250
- }
251
- }
252
- },
253
- replaceCloneIndex: function($el) {
254
- var cloneindex = $el.data('id');
255
- $el.find('[data-source-id*="acfcloneindex"]').each(function(){
256
- $(this).attr('data-source-id', $(this).attr('data-source-id').replace('acfcloneindex', cloneindex));
257
- });
258
- }
259
- }
260
-
261
- WPGlobusAcf = $.extend({}, WPGlobusAcf, api);
262
- WPGlobusAcf.init({'pro': WPGlobusAcf.pro});
263
- });
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration ACF plugin fields
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.0.5
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true */
11
+ /*global jQuery, console, WPGlobusAcf, WPGlobusDialogApp */
12
+
13
+ jQuery(document).ready(function ($) {
14
+ "use strict";
15
+
16
+ if (typeof WPGlobusAcf === 'undefined') {
17
+ return;
18
+ }
19
+
20
+ var api = {
21
+ parseBool: function(b) {
22
+ return !(/^(false|0)$/i).test(b) && !!b;
23
+ },
24
+ isPro: function(){
25
+ return api.parseBool( WPGlobusAcf.pro );
26
+ },
27
+ isBuilder: function(){
28
+ return api.parseBool( WPGlobusAcf.builder_id );
29
+ },
30
+ vendorAcfFields: null,
31
+ option: {},
32
+ init: function (args) {
33
+
34
+ // @since 2.6.6
35
+ if ( api.isBuilder() && 'undefined' === typeof WPGlobusDialogApp ) {
36
+ api.setTranslatableClass();
37
+ return;
38
+ }
39
+
40
+ api.option = $.extend(api.option, args);
41
+ if (api.option.pro) {
42
+ api.startAcf('.acf-field');
43
+ api.runActions();
44
+ } else {
45
+ //api.startAcf('.acf_postbox .field');
46
+ // @since 1.9.17
47
+ if ( $('.acf_postbox .field').length > 0 ) {
48
+ api.startAcf('.acf_postbox .field');
49
+ }
50
+ if ( $('.acf-postbox .acf-field').length > 0 ) {
51
+ api.startAcf('.acf-postbox .acf-field');
52
+ }
53
+ }
54
+ api.attachListeners();
55
+ },
56
+ setTranslatableClass: function(){
57
+ // @since 2.7.6
58
+ setTimeout( function(){
59
+ $.each(api.getVendorAcfFields(), function(indx, fieldId){
60
+ $('#'+fieldId).addClass(WPGlobusAcf.translatableClass);
61
+ });
62
+ }, 500);
63
+ },
64
+ runActions: function() {
65
+ if ( 'undefined' !== typeof WPGlobusAcf.actions.fixTextFields && WPGlobusAcf.actions.fixTextFields ) {
66
+ api.fixTextFields();
67
+ }
68
+ },
69
+ fixTextFields: function() {
70
+ // fix hidden WPGlobus dialog start icon with ACF Pro from v.5.8
71
+ $.each(WPGlobusAcf.fields, function(i, id){
72
+ var $tf = $('input[type="text"]#'+id);
73
+ if ( $tf.length == 1 ) {
74
+ var $tfp = $tf.parent('.acf-input-wrap');
75
+ if ( $tfp.length == 1 ) {
76
+ if ( $tfp.hasClass('acf-input-wrap') ) {
77
+ $tfp.css('height','auto');
78
+ }
79
+ }
80
+ }
81
+ });
82
+ },
83
+ isDisabledField: function(id) {
84
+ var res = false;
85
+
86
+ /**
87
+ * Check for ACF Pro.
88
+ */
89
+ var parentId = $('#' + id).parents('.acf-field').attr('id');
90
+
91
+ if ( 'undefined' !== typeof parentId ) {
92
+ $.each(WPGlobusAcf.disabledFields, function (i, e) {
93
+ if (e == parentId) {
94
+ res = true;
95
+ }
96
+ });
97
+ }
98
+
99
+ if ( res ) {
100
+ return res;
101
+ }
102
+
103
+ /**
104
+ * Check for ACF.
105
+ */
106
+ $.each(WPGlobusAcf.disabledFields, function (i, e) {
107
+ if (e == id) {
108
+ res = true;
109
+ }
110
+ });
111
+
112
+ return res;
113
+ },
114
+ startAcf: function (acf_class) {
115
+ var id;
116
+ var style = 'width:90%;';
117
+ var element, clone, name;
118
+ if ($('.acf_postbox').parents('#postbox-container-2').length == 1) {
119
+ style = 'width:97%';
120
+ }
121
+ //$('.acf_postbox .field').each(function(){
122
+ $(acf_class).each(function () {
123
+ var $t = $(this), id, h;
124
+ if ($t.hasClass('field_type-textarea') || $t.hasClass('acf-field-textarea')) {
125
+
126
+ id = $t.find('textarea').attr('id');
127
+
128
+ api.registerField(id);
129
+ if (api.isDisabledField(id)) {
130
+ return true;
131
+ }
132
+
133
+ // @since 2.6.6
134
+ if ( ! api.isVendorAcfField(id) ) {
135
+ return true;
136
+ }
137
+
138
+ h = $('#' + id).height() + 20;
139
+ WPGlobusDialogApp.addElement({
140
+ id : id,
141
+ dialogTitle : 'Edit ACF field',
142
+ style : 'width:97%;float:left;',
143
+ styleTextareaWrapper: 'height:' + h + 'px;',
144
+ sbTitle : 'Click for edit',
145
+ onChangeClass : 'wpglobus-on-change-acf-field'
146
+ });
147
+
148
+ } else if ($t.hasClass('field_type-text') || $t.hasClass('acf-field-text')) {
149
+
150
+ id = $t.find('input').attr('id');
151
+
152
+ api.registerField(id);
153
+ if (api.isDisabledField(id)) {
154
+ return true;
155
+ }
156
+
157
+ // @since 2.6.6
158
+ if ( ! api.isVendorAcfField(id) ) {
159
+ return true;
160
+ }
161
+
162
+ WPGlobusDialogApp.addElement({
163
+ id : id,
164
+ dialogTitle : 'Edit ACF field',
165
+ style : 'width:97%;float:left;',
166
+ sbTitle : 'Click for edit',
167
+ onChangeClass: 'wpglobus-on-change-acf-field'
168
+ });
169
+
170
+ }
171
+ });
172
+ },
173
+ registerField: function(id, type) {
174
+ var register = false;
175
+ if ( 'undefined' !== typeof id ) {
176
+ if ( -1 == id.indexOf('acfcloneindex') ) {
177
+ /**
178
+ * Don't register acf clone field.
179
+ * e.g. acf-field_5a5734b531031-acfcloneindex-field_5a573503660e9
180
+ */
181
+ if ( ! api.isRegisteredField(id) ) {
182
+ register = true;
183
+ WPGlobusAcf.fields.push(id);
184
+ }
185
+ }
186
+ }
187
+ if ( register ) {
188
+ return id;
189
+ }
190
+ return false;
191
+ },
192
+ getFields: function() {
193
+ return WPGlobusAcf.fields;
194
+ },
195
+ getDisabledFields: function() {
196
+ return WPGlobusAcf.disabledFields;
197
+ },
198
+ unificationField: function(field) {
199
+ // @since 2.6.6
200
+ // @since 2.7.6 Perform a global search and replace.
201
+ if ( /acf\[/.test(field) ) {
202
+ field = field.replace(/\[/g,'-');
203
+ field = field.replace(/]/g,'');
204
+ }
205
+ return field;
206
+ },
207
+ getVendorAcfFields: function() {
208
+ // @since 2.6.6
209
+ if ( api.vendorAcfFields === null ) {
210
+ if ( 'undefined' === typeof WPGlobusVendorAcfFields || '' == WPGlobusVendorAcfFields ) {
211
+ api.vendorAcfFields = false;
212
+ return api.vendorAcfFields;
213
+ }
214
+ api.vendorAcfFields = WPGlobusVendorAcfFields.split(',');
215
+ }
216
+ return api.vendorAcfFields;
217
+ },
218
+ isVendorAcfField: function( field ) {
219
+ // @since 2.6.6
220
+ if ( 'undefined' === typeof field ) {
221
+ return false;
222
+ }
223
+ // We can receive here `field` in two forms
224
+ // 1. acf-field_5f8a8fd1c97f7 or repeater field: acf[field_5cda40e0978f9][row-0][field_60900acc19d17]
225
+ // 2. acf[field_5f8a8fd1c97f7] or repeater field: acf-field_5cda40e0978f9-row-0-field_60900acc19d17
226
+ field = api.unificationField(field);
227
+ var _result = false;
228
+ var _fields = api.getVendorAcfFields();
229
+ if ( ! _fields ) {
230
+ return _result;
231
+ }
232
+ $.each( _fields, function(i,_field){
233
+ if ( _field === field ) {
234
+ _result = true;
235
+ return false;
236
+ }
237
+ });
238
+ return _result;
239
+ },
240
+ isRegisteredField: function(id) {
241
+ var registered = false;
242
+ api.getFields().forEach(function(elm) {
243
+ if (elm == id) {
244
+ registered = true
245
+ return false;
246
+ }
247
+ });
248
+ return registered;
249
+ },
250
+ attachListeners: function() {
251
+ if (api.option.pro) {
252
+ /**
253
+ * Attach listener for new ACF fields that was added in repeater field type.
254
+ */
255
+ var t = this;
256
+ if (acf.add_action) { // ACF v5
257
+ acf.add_action('append', function($el) {
258
+ t.replaceCloneIndex($el);
259
+ });
260
+ }
261
+ }
262
+ },
263
+ replaceCloneIndex: function($el) {
264
+ var cloneindex = $el.data('id');
265
+ $el.find('[data-source-id*="acfcloneindex"]').each(function(){
266
+ $(this).attr('data-source-id', $(this).attr('data-source-id').replace('acfcloneindex', cloneindex));
267
+ });
268
+ }
269
+ }
270
+
271
+ WPGlobusAcf = $.extend({}, WPGlobusAcf, api);
272
+ WPGlobusAcf.init({'pro': WPGlobusAcf.pro});
273
+ });
includes/js/wpglobus-vendor-acf.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(d){"use strict";var o;"undefined"!=typeof WPGlobusAcf&&(o={parseBool:function(e){return!/^(false|0)$/i.test(e)&&!!e},isPro:function(){return o.parseBool(WPGlobusAcf.pro)},isBuilder:function(){return o.parseBool(WPGlobusAcf.builder_id)},vendorAcfFields:null,option:{},init:function(e){o.isBuilder()&&"undefined"==typeof WPGlobusDialogApp||(o.option=d.extend(o.option,e),o.option.pro?(o.startAcf(".acf-field"),o.runActions()):(0<d(".acf_postbox .field").length&&o.startAcf(".acf_postbox .field"),0<d(".acf-postbox .acf-field").length&&o.startAcf(".acf-postbox .acf-field")),o.attachListeners())},runActions:function(){void 0!==WPGlobusAcf.actions.fixTextFields&&WPGlobusAcf.actions.fixTextFields&&o.fixTextFields()},fixTextFields:function(){d.each(WPGlobusAcf.fields,function(e,i){i=d('input[type="text"]#'+i);1!=i.length||1==(i=i.parent(".acf-input-wrap")).length&&i.hasClass("acf-input-wrap")&&i.css("height","auto")})},isDisabledField:function(t){var n=!1,o=d("#"+t).parents(".acf-field").attr("id");return void 0!==o&&d.each(WPGlobusAcf.disabledFields,function(e,i){i==o&&(n=!0)}),n||(d.each(WPGlobusAcf.disabledFields,function(e,i){i==t&&(n=!0)}),n)},startAcf:function(e){d(".acf_postbox").parents("#postbox-container-2").length,d(e).each(function(){var e,i,t=d(this);return t.hasClass("field_type-textarea")||t.hasClass("acf-field-textarea")?(e=t.find("textarea").attr("id"),o.registerField(e),!!o.isDisabledField(e)||(!o.isVendorAcfField(e)||(i=d("#"+e).height()+20,void WPGlobusDialogApp.addElement({id:e,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",styleTextareaWrapper:"height:"+i+"px;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"})))):t.hasClass("field_type-text")||t.hasClass("acf-field-text")?(e=t.find("input").attr("id"),o.registerField(e),!!o.isDisabledField(e)||(!o.isVendorAcfField(e)||void WPGlobusDialogApp.addElement({id:e,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"}))):void 0})},registerField:function(e,i){var t=!1;return void 0!==e&&-1==e.indexOf("acfcloneindex")&&(o.isRegisteredField(e)||(t=!0,WPGlobusAcf.fields.push(e))),!!t&&e},getFields:function(){return WPGlobusAcf.fields},getDisabledFields:function(){return WPGlobusAcf.disabledFields},unificationField:function(e){return e=/acf\[/.test(e)?(e=e.replace("[","-")).replace("]",""):e},getVendorAcfFields:function(){if(null===o.vendorAcfFields){if("undefined"==typeof WPGlobusVendorAcfFields||""==WPGlobusVendorAcfFields)return o.vendorAcfFields=!1,o.vendorAcfFields;o.vendorAcfFields=WPGlobusVendorAcfFields.split(",")}return o.vendorAcfFields},isVendorAcfField:function(t){if(void 0===t)return!1;t=o.unificationField(t);var n=!1,e=o.getVendorAcfFields();return e&&d.each(e,function(e,i){if(i===t)return!(n=!0)}),n},isRegisteredField:function(i){var t=!1;return o.getFields().forEach(function(e){if(e==i)return!(t=!0)}),t},attachListeners:function(){var i;o.option.pro&&(i=this,acf.add_action&&acf.add_action("append",function(e){i.replaceCloneIndex(e)}))},replaceCloneIndex:function(e){var i=e.data("id");e.find('[data-source-id*="acfcloneindex"]').each(function(){d(this).attr("data-source-id",d(this).attr("data-source-id").replace("acfcloneindex",i))})}},(WPGlobusAcf=d.extend({},WPGlobusAcf,o)).init({pro:WPGlobusAcf.pro}))});
1
+ jQuery(document).ready(function(l){"use strict";var s;"undefined"!=typeof WPGlobusAcf&&(s={parseBool:function(e){return!/^(false|0)$/i.test(e)&&!!e},isPro:function(){return s.parseBool(WPGlobusAcf.pro)},isBuilder:function(){return s.parseBool(WPGlobusAcf.builder_id)},vendorAcfFields:null,option:{},init:function(e){s.isBuilder()&&"undefined"==typeof WPGlobusDialogApp?s.setTranslatableClass():(s.option=l.extend(s.option,e),s.option.pro?(s.startAcf(".acf-field"),s.runActions()):(0<l(".acf_postbox .field").length&&s.startAcf(".acf_postbox .field"),0<l(".acf-postbox .acf-field").length&&s.startAcf(".acf-postbox .acf-field")),s.attachListeners())},setTranslatableClass:function(){setTimeout(function(){l.each(s.getVendorAcfFields(),function(e,i){l("#"+i).addClass(WPGlobusAcf.translatableClass)})},500)},runActions:function(){void 0!==WPGlobusAcf.actions.fixTextFields&&WPGlobusAcf.actions.fixTextFields&&s.fixTextFields()},fixTextFields:function(){l.each(WPGlobusAcf.fields,function(e,i){i=l('input[type="text"]#'+i);1!=i.length||1==(i=i.parent(".acf-input-wrap")).length&&i.hasClass("acf-input-wrap")&&i.css("height","auto")})},isDisabledField:function(t){var n=!1,s=l("#"+t).parents(".acf-field").attr("id");return void 0!==s&&l.each(WPGlobusAcf.disabledFields,function(e,i){i==s&&(n=!0)}),n||(l.each(WPGlobusAcf.disabledFields,function(e,i){i==t&&(n=!0)}),n)},startAcf:function(e){l(".acf_postbox").parents("#postbox-container-2").length,l(e).each(function(){var e,i,t=l(this);return t.hasClass("field_type-textarea")||t.hasClass("acf-field-textarea")?(e=t.find("textarea").attr("id"),s.registerField(e),!!s.isDisabledField(e)||(!s.isVendorAcfField(e)||(i=l("#"+e).height()+20,void WPGlobusDialogApp.addElement({id:e,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",styleTextareaWrapper:"height:"+i+"px;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"})))):t.hasClass("field_type-text")||t.hasClass("acf-field-text")?(e=t.find("input").attr("id"),s.registerField(e),!!s.isDisabledField(e)||(!s.isVendorAcfField(e)||void WPGlobusDialogApp.addElement({id:e,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"}))):void 0})},registerField:function(e,i){var t=!1;return void 0!==e&&-1==e.indexOf("acfcloneindex")&&(s.isRegisteredField(e)||(t=!0,WPGlobusAcf.fields.push(e))),!!t&&e},getFields:function(){return WPGlobusAcf.fields},getDisabledFields:function(){return WPGlobusAcf.disabledFields},unificationField:function(e){return e=/acf\[/.test(e)?(e=e.replace(/\[/g,"-")).replace(/]/g,""):e},getVendorAcfFields:function(){if(null===s.vendorAcfFields){if("undefined"==typeof WPGlobusVendorAcfFields||""==WPGlobusVendorAcfFields)return s.vendorAcfFields=!1,s.vendorAcfFields;s.vendorAcfFields=WPGlobusVendorAcfFields.split(",")}return s.vendorAcfFields},isVendorAcfField:function(t){if(void 0===t)return!1;t=s.unificationField(t);var n=!1,e=s.getVendorAcfFields();return e&&l.each(e,function(e,i){if(i===t)return!(n=!0)}),n},isRegisteredField:function(i){var t=!1;return s.getFields().forEach(function(e){if(e==i)return!(t=!0)}),t},attachListeners:function(){var i;s.option.pro&&(i=this,acf.add_action&&acf.add_action("append",function(e){i.replaceCloneIndex(e)}))},replaceCloneIndex:function(e){var i=e.data("id");e.find('[data-source-id*="acfcloneindex"]').each(function(){l(this).attr("data-source-id",l(this).attr("data-source-id").replace("acfcloneindex",i))})}},(WPGlobusAcf=l.extend({},WPGlobusAcf,s)).init({pro:WPGlobusAcf.pro}))});
includes/vendor/acf/assets/js/wpglobus-vendor-acf.js CHANGED
@@ -1,191 +1,191 @@
1
- /**
2
- * WPGlobus Vendor Acf
3
- * Interface JS functions
4
- *
5
- * @since 2.6.6
6
- *
7
- * @package WPGlobus
8
- * @subpackage Administration
9
- */
10
- /*jslint browser: true*/
11
- /*global jQuery, console, WPGlobusVendorAcf*/
12
- jQuery(document).ready(function($) {
13
- "use strict";
14
-
15
- if ( 'undefined' === typeof WPGlobusVendorAcf ) {
16
- return;
17
- }
18
-
19
- var api = {
20
- acfFieldObjects: {},
21
- elements: {},
22
- parseBool: function(b) {
23
- return !(/^(false|0)$/i).test(b) && !!b;
24
- },
25
- getAcfFieldObjects: function() {
26
- return api.acfFieldObjects;
27
- },
28
- getFields: function(status) {
29
- var _fields = api.get('fields');
30
- if ( 'undefined' === typeof status ) {
31
- return _fields;
32
- }
33
- if ( 'undefined' === _fields[status] ) {
34
- return undefined;
35
- }
36
- return _fields[status];
37
- },
38
- get: function(key) {
39
- if ( 'undefined' === typeof WPGlobusVendorAcf.data[key] ) {
40
- return undefined;
41
- }
42
- return WPGlobusVendorAcf.data[key];
43
- },
44
- isAcfPro: function() {
45
- if ( api.parseBool( api.get('pro') ) ) {
46
- return true;
47
- }
48
- return false;
49
- },
50
- getName: function(type) {
51
-
52
- if ( '' == type || 'indefined' == typeof(type) ) {
53
- return '';
54
- }
55
-
56
- var statuses, names, statusKey, statusValue;
57
- var fields = api.get('fields');
58
-
59
- $.each(fields, function(_statusValue, types){
60
- if ( ! types ) {
61
- return true;
62
- }
63
- if ( -1 !== types.indexOf(type) ) {
64
- statusValue = _statusValue;
65
- return false;
66
- }
67
- });
68
-
69
- statuses = api.get('fieldStatuses');
70
- $.each(statuses, function(_statusKey, _statusValue){
71
- if ( statusValue == _statusValue ) {
72
- statusKey = _statusKey;
73
- return false;
74
- }
75
- });
76
-
77
- names = api.get('names');
78
- return names[statusKey];
79
- },
80
- getStatus: function(statusKey) {
81
- return api.get('fieldStatuses')[statusKey];
82
- },
83
- runDelayed: function() {
84
- setTimeout(function(){
85
- api.setFieldObjects();
86
- // api.attachListeners();
87
- }, 500);
88
- },
89
- setFieldObjects: function() {
90
-
91
- if ( $('.acf-field-list').length == 0 ) {
92
- return;
93
- }
94
-
95
- var fieldObjects = $('.acf-field-list .acf-field-object');
96
-
97
- $.each( fieldObjects, function(indx, object){
98
-
99
- var $obj = $(object);
100
- var type = $obj.data('type');
101
- var name = api.getName(type);
102
-
103
- // Don't use `name` for `input` element. Maybe more than one element.
104
- var selector = 'input#acf_fields-'+$obj.data('id')+'-'+name;
105
- var $_element = $(selector);
106
-
107
- if ( $_element.length == 1 ) {
108
- api.acfFieldObjects[selector] = {};
109
- api.acfFieldObjects[selector]['innerElement'] = $_element;
110
- api.acfFieldObjects[selector]['type'] = type;
111
- api.acfFieldObjects[selector]['id'] = $obj.data('id');
112
- api.acfFieldObjects[selector]['key'] = $obj.data('key');
113
- api.acfFieldObjects[selector]['name'] = name;
114
- api.acfFieldObjects[selector]['status'] = null;
115
- api.acfFieldObjects[selector]['object'] = null;
116
- api.acfFieldObjects[selector]['mode'] = null;
117
-
118
- if ( -1 !== name.indexOf( api.getStatus('PRETENDER') ) ) {
119
- $obj.addClass( api.get('classes')['PRETENDER']['statusClass'] );
120
- api.acfFieldObjects[selector]['object'] = $obj;
121
- api.acfFieldObjects[selector]['status'] = api.getStatus('PRETENDER');
122
- api.acfFieldObjects[selector]['mode'] = 'on';
123
- api.setStyles(selector);
124
- } else {
125
- if ( -1 !== name.indexOf( api.getStatus('MULTILINGUAL') ) ) {
126
- $obj.addClass( api.get('classes')['MULTILINGUAL']['statusClass'] );
127
- api.acfFieldObjects[selector]['mode'] = 'off';
128
- if ( $_element.prop('checked') ) {
129
- $obj.addClass( api.get('classes')['MULTILINGUAL']['translatableClass'] );
130
- api.acfFieldObjects[selector]['mode'] = 'on';
131
- }
132
- api.acfFieldObjects[selector]['object'] = $obj;
133
- api.acfFieldObjects[selector]['status'] = api.getStatus('MULTILINGUAL');
134
- api.setStyles(selector);
135
- }
136
- }
137
-
138
- }
139
- });
140
- api.fieldObjectsHandler()
141
- },
142
- setStyles: function(selector) {
143
- if ( api.getStatus('PRETENDER') == api.acfFieldObjects[selector]['status'] ) {
144
- $('.'+api.get('classes')['PRETENDER']['statusClass']).css({'border-left':'3px solid #6e6e6e'});
145
- }
146
- if ( api.getStatus('MULTILINGUAL') == api.acfFieldObjects[selector]['status'] ) {
147
- if ( 'off' == api.acfFieldObjects[selector]['mode'] ) {
148
- $('.'+api.get('classes')['MULTILINGUAL']['statusClass']).css({'border-left':'3px solid #ffb900'});
149
- }
150
- }
151
- },
152
- setMode: function(mode, selector) {
153
- if ( 'undefined' === typeof mode ) {
154
- return;
155
- }
156
- if ( 'on' === mode ) {
157
- api.acfFieldObjects[selector]['object'].addClass( api.get('translatableClass') );
158
- api.acfFieldObjects[selector]['mode'] = mode;
159
- } else if ( 'off' === mode ) {
160
- api.acfFieldObjects[selector]['object'].removeClass( api.get('translatableClass') );
161
- api.acfFieldObjects[selector]['mode'] = mode;
162
- }
163
- },
164
- fieldObjectsHandler: function() {
165
- $.each( api.getAcfFieldObjects(), function(selector, object){
166
- if ( object.status == api.getStatus('PRETENDER') ) {
167
- object['innerElement'].attr('disabled', 'disabled');
168
- var pDiv = object['innerElement'].parents('div.acf-true-false');
169
- if ( 'undefined' !== typeof api.get('l10n')['wysiwyg-pretender-tip'] ) {
170
- $('<span class="wpglobus-vendor-acf-tip">'+api.get('l10n')['wysiwyg-pretender-tip']+'</span>').insertAfter(pDiv);
171
- }
172
- } else {
173
- $(document).on('click', selector, function(event){
174
- if ( api.acfFieldObjects[selector]['innerElement'].prop('checked') ) {
175
- api.setMode('on', selector);
176
- } else {
177
- api.setMode('off', selector);
178
- }
179
- api.setStyles(selector);
180
- });
181
- }
182
- });
183
- },
184
- start: function() {
185
- api.runDelayed();
186
- }
187
- }
188
-
189
- WPGlobusVendorAcf = $.extend({}, WPGlobusVendorAcf, api);
190
- WPGlobusVendorAcf.start();
191
  });
1
+ /**
2
+ * WPGlobus Vendor Acf
3
+ * Interface JS functions
4
+ *
5
+ * @since 2.6.6
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration/EditFieldGroup
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusVendorAcf*/
12
+ jQuery(document).ready(function($) {
13
+ "use strict";
14
+
15
+ if ( 'undefined' === typeof WPGlobusVendorAcf ) {
16
+ return;
17
+ }
18
+
19
+ var api = {
20
+ acfFieldObjects: {},
21
+ elements: {},
22
+ parseBool: function(b) {
23
+ return !(/^(false|0)$/i).test(b) && !!b;
24
+ },
25
+ getAcfFieldObjects: function() {
26
+ return api.acfFieldObjects;
27
+ },
28
+ getFields: function(status) {
29
+ var _fields = api.get('fields');
30
+ if ( 'undefined' === typeof status ) {
31
+ return _fields;
32
+ }
33
+ if ( 'undefined' === _fields[status] ) {
34
+ return undefined;
35
+ }
36
+ return _fields[status];
37
+ },
38
+ get: function(key) {
39
+ if ( 'undefined' === typeof WPGlobusVendorAcf.data[key] ) {
40
+ return undefined;
41
+ }
42
+ return WPGlobusVendorAcf.data[key];
43
+ },
44
+ isAcfPro: function() {
45
+ if ( api.parseBool( api.get('pro') ) ) {
46
+ return true;
47
+ }
48
+ return false;
49
+ },
50
+ getName: function(type) {
51
+
52
+ if ( '' == type || 'indefined' == typeof(type) ) {
53
+ return '';
54
+ }
55
+
56
+ var statuses, names, statusKey, statusValue;
57
+ var fields = api.get('fields');
58
+
59
+ $.each(fields, function(_statusValue, types){
60
+ if ( ! types ) {
61
+ return true;
62
+ }
63
+ if ( -1 !== types.indexOf(type) ) {
64
+ statusValue = _statusValue;
65
+ return false;
66
+ }
67
+ });
68
+
69
+ statuses = api.get('fieldStatuses');
70
+ $.each(statuses, function(_statusKey, _statusValue){
71
+ if ( statusValue == _statusValue ) {
72
+ statusKey = _statusKey;
73
+ return false;
74
+ }
75
+ });
76
+
77
+ names = api.get('names');
78
+ return names[statusKey];
79
+ },
80
+ getStatus: function(statusKey) {
81
+ return api.get('fieldStatuses')[statusKey];
82
+ },
83
+ runDelayed: function() {
84
+ setTimeout(function(){
85
+ api.setFieldObjects();
86
+ // api.attachListeners();
87
+ }, 500);
88
+ },
89
+ setFieldObjects: function() {
90
+
91
+ if ( $('.acf-field-list').length == 0 ) {
92
+ return;
93
+ }
94
+
95
+ var fieldObjects = $('.acf-field-list .acf-field-object');
96
+
97
+ $.each( fieldObjects, function(indx, object){
98
+
99
+ var $obj = $(object);
100
+ var type = $obj.data('type');
101
+ var name = api.getName(type);
102
+
103
+ // Don't use `name` for `input` element. Maybe more than one element.
104
+ var selector = 'input#acf_fields-'+$obj.data('id')+'-'+name;
105
+ var $_element = $(selector);
106
+
107
+ if ( $_element.length == 1 ) {
108
+ api.acfFieldObjects[selector] = {};
109
+ api.acfFieldObjects[selector]['innerElement'] = $_element;
110
+ api.acfFieldObjects[selector]['type'] = type;
111
+ api.acfFieldObjects[selector]['id'] = $obj.data('id');
112
+ api.acfFieldObjects[selector]['key'] = $obj.data('key');
113
+ api.acfFieldObjects[selector]['name'] = name;
114
+ api.acfFieldObjects[selector]['status'] = null;
115
+ api.acfFieldObjects[selector]['object'] = null;
116
+ api.acfFieldObjects[selector]['mode'] = null;
117
+
118
+ if ( -1 !== name.indexOf( api.getStatus('PRETENDER') ) ) {
119
+ $obj.addClass( api.get('classes')['PRETENDER']['statusClass'] );
120
+ api.acfFieldObjects[selector]['object'] = $obj;
121
+ api.acfFieldObjects[selector]['status'] = api.getStatus('PRETENDER');
122
+ api.acfFieldObjects[selector]['mode'] = 'on';
123
+ api.setStyles(selector);
124
+ } else {
125
+ if ( -1 !== name.indexOf( api.getStatus('MULTILINGUAL') ) ) {
126
+ $obj.addClass( api.get('classes')['MULTILINGUAL']['statusClass'] );
127
+ api.acfFieldObjects[selector]['mode'] = 'off';
128
+ if ( $_element.prop('checked') ) {
129
+ $obj.addClass( api.get('classes')['MULTILINGUAL']['translatableClass'] );
130
+ api.acfFieldObjects[selector]['mode'] = 'on';
131
+ }
132
+ api.acfFieldObjects[selector]['object'] = $obj;
133
+ api.acfFieldObjects[selector]['status'] = api.getStatus('MULTILINGUAL');
134
+ api.setStyles(selector);
135
+ }
136
+ }
137
+
138
+ }
139
+ });
140
+ api.fieldObjectsHandler()
141
+ },
142
+ setStyles: function(selector) {
143
+ if ( api.getStatus('PRETENDER') == api.acfFieldObjects[selector]['status'] ) {
144
+ $('.'+api.get('classes')['PRETENDER']['statusClass']).css({'border-left':'3px solid #6e6e6e'});
145
+ }
146
+ if ( api.getStatus('MULTILINGUAL') == api.acfFieldObjects[selector]['status'] ) {
147
+ if ( 'off' == api.acfFieldObjects[selector]['mode'] ) {
148
+ $('.'+api.get('classes')['MULTILINGUAL']['statusClass']).css({'border-left':'3px solid #ffb900'});
149
+ }
150
+ }
151
+ },
152
+ setMode: function(mode, selector) {
153
+ if ( 'undefined' === typeof mode ) {
154
+ return;
155
+ }
156
+ if ( 'on' === mode ) {
157
+ api.acfFieldObjects[selector]['object'].addClass( api.get('translatableClass') );
158
+ api.acfFieldObjects[selector]['mode'] = mode;
159
+ } else if ( 'off' === mode ) {
160
+ api.acfFieldObjects[selector]['object'].removeClass( api.get('translatableClass') );
161
+ api.acfFieldObjects[selector]['mode'] = mode;
162
+ }
163
+ },
164
+ fieldObjectsHandler: function() {
165
+ $.each( api.getAcfFieldObjects(), function(selector, object){
166
+ if ( object.status == api.getStatus('PRETENDER') ) {
167
+ object['innerElement'].attr('disabled', 'disabled');
168
+ var pDiv = object['innerElement'].parents('div.acf-true-false');
169
+ if ( 'undefined' !== typeof api.get('l10n')['wysiwyg-pretender-tip'] ) {
170
+ $('<span class="wpglobus-vendor-acf-tip">'+api.get('l10n')['wysiwyg-pretender-tip']+'</span>').insertAfter(pDiv);
171
+ }
172
+ } else {
173
+ $(document).on('click', selector, function(event){
174
+ if ( api.acfFieldObjects[selector]['innerElement'].prop('checked') ) {
175
+ api.setMode('on', selector);
176
+ } else {
177
+ api.setMode('off', selector);
178
+ }
179
+ api.setStyles(selector);
180
+ });
181
+ }
182
+ });
183
+ },
184
+ start: function() {
185
+ api.runDelayed();
186
+ }
187
+ }
188
+
189
+ WPGlobusVendorAcf = $.extend({}, WPGlobusVendorAcf, api);
190
+ WPGlobusVendorAcf.start();
191
  });
includes/vendor/acf/class-wpglobus-acf.php CHANGED
@@ -197,7 +197,20 @@ class WPGlobus_Acf_2 {
197
  require_once( 'class-wpglobus-vendor-acf.php' );
198
  }
199
 
200
- $WPGlobus_Vendor_Acf = WPGlobus_Vendor_Acf::get_instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  $multilingual_field_name = $WPGlobus_Vendor_Acf::get_multilingual_field_name();
203
 
197
  require_once( 'class-wpglobus-vendor-acf.php' );
198
  }
199
 
200
+ $_vendors = array(
201
+ 'ACF' => false,
202
+ 'ACFPRO' => false
203
+ );
204
+
205
+ if ( defined('ACF_PRO') ) {
206
+ $_vendors['ACFPRO'] = true;
207
+ } else if( defined('ACF') ) {
208
+ $_vendors['ACF'] = true;
209
+ }
210
+
211
+ $WPGlobus_Vendor_Acf = WPGlobus_Vendor_Acf::get_instance(
212
+ array( 'vendor_scripts' => $_vendors )
213
+ );
214
 
215
  $multilingual_field_name = $WPGlobus_Vendor_Acf::get_multilingual_field_name();
216
 
includes/vendor/acf/class-wpglobus-vendor-acf.php CHANGED
@@ -1,689 +1,690 @@
1
- <?php
2
- /**
3
- * File: class-wpglobus-vendor-acf.php
4
- *
5
- * @since 2.6.6
6
- * @package WPGlobus\Vendor\ACF.
7
- */
8
-
9
- if ( ! class_exists( 'WPGlobus_Vendor_Acf' ) ) :
10
-
11
- /**
12
- * Class WPGlobus_Vendor_Acf.
13
- */
14
- class WPGlobus_Vendor_Acf {
15
-
16
- /**
17
- * Field post type.
18
- */
19
- const FIELD_POST_TYPE = 'acf-field';
20
-
21
- /**
22
- * Prefix for classes.
23
- */
24
- const CLASS_PREFIX = self::FIELD_POST_TYPE . '-';
25
-
26
- /**
27
- * Field Group's post type.
28
- */
29
- const FIELD_GROUP_POST_TYPE = 'acf-field-group';
30
-
31
- /**
32
- * Status of multilingual field.
33
- */
34
- const MULTILINGUAL = 'multilingual';
35
-
36
- /**
37
- * Multilingual field name.
38
- */
39
- const MULTILINGUAL_FIELD_NAME = 'wpglobus_' . self::MULTILINGUAL . '_field';
40
-
41
- /**
42
- * Status of field that may be or may not be multilingual.
43
- * May be changed in filter.
44
- */
45
- const PRETENDER = 'pretender';
46
-
47
- /**
48
- * Pretender field name.
49
- */
50
- const PRETENDER_FIELD_NAME = 'wpglobus_' . self::PRETENDER . '_field';
51
-
52
- /**
53
- * Set of field types, that WPGlobus handles.
54
- * field_type => field_status
55
- */
56
- protected static $field_types = array();
57
-
58
- /**
59
- * Array of fields that are multilingual on `post.php` page.
60
- */
61
- protected static $field_ids = array();
62
-
63
- /**
64
- * Incoming arguments.
65
- */
66
- protected static $args = array();
67
-
68
- /**
69
- * @var object Instance of this class.
70
- */
71
- protected static $instance;
72
-
73
- /**
74
- * Constructor.
75
- */
76
- protected function __construct( $args = array() ) {
77
-
78
- self::$args = wp_parse_args(
79
- $args,
80
- array(
81
- 'vendor_scripts' => array(
82
- 'ACF' => false,
83
- 'ACFPRO' => false
84
- )
85
- )
86
- );
87
-
88
- // @see wpglobus\includes\wpglobus-controller.php
89
- self::$field_types = array(
90
- 'text' => self::MULTILINGUAL,
91
- 'textarea' => self::MULTILINGUAL,
92
- 'wysiwyg' => self::PRETENDER,
93
- 'table' => self::PRETENDER, #with ACF:Table Field - https://wordpress.org/plugins/advanced-custom-fields-table-field/
94
- #'url',
95
- #'number',
96
- #'image',
97
- #'radio', ?
98
- #'google_map', ?
99
- );
100
-
101
- add_action( 'init', array( __CLASS__, 'on__init' ) );
102
-
103
- /**
104
- * @see advanced-custom-fields\includes\acf-field-group-functions.php
105
- */
106
- add_filter(
107
- 'acf/get_field_group_style',
108
- array(
109
- __CLASS__,
110
- 'filter__get_field_group_style'
111
- ), 10, 2
112
- );
113
-
114
- /**
115
- * Add new setting on Edit Field Group page.
116
- *
117
- * @see advanced-custom-fields\includes\admin\views\field-group-field.php
118
- * to get more info @see https://www.advancedcustomfields.com/resources/adding-custom-settings-fields/
119
- */
120
- add_action(
121
- 'acf/render_field_settings',
122
- array(
123
- __CLASS__,
124
- 'on__render_field_settings'
125
- ), 5, 1
126
- );
127
-
128
- /**
129
- * @W.I.P @since 2.6.6
130
- * @see advanced-custom-fields\includes\acf-field-functions.php
131
- */
132
- /*
133
- add_action(
134
- 'acf/render_field',
135
- array(
136
- __CLASS__,
137
- 'on__render_field'
138
- ), 5, 1
139
- );
140
- // */
141
-
142
- /**
143
- * Filter on post, page and CPT except Edit Field Group page.
144
- *
145
- * @see advanced-custom-fields\includes\acf-field-functions.php
146
- */
147
- add_filter(
148
- 'acf/prepare_field',
149
- array(
150
- __CLASS__,
151
- 'filter__prepare_field'
152
- ), 5, 1
153
- );
154
-
155
- add_action(
156
- 'admin_print_scripts',
157
- array(
158
- __CLASS__,
159
- 'on__field_group_admin_scripts',
160
- )
161
- );
162
-
163
- /**
164
- * Enqueue script for post.php & post-new.php pages except page for CPT Edit Field Group.
165
- */
166
- add_action(
167
- 'admin_print_scripts',
168
- array(
169
- __CLASS__,
170
- 'on__admin_scripts',
171
- )
172
- );
173
-
174
- add_action(
175
- 'admin_footer',
176
- array(
177
- __CLASS__,
178
- 'on__admin_footer',
179
- )
180
- );
181
- }
182
-
183
- /**
184
- * Get instance of this class.
185
- *
186
- * @return WPGlobus_Vendor_Acf || void
187
- */
188
- public static function get_instance( $args = array() ) {
189
-
190
- if ( ! WPGlobus_WP::is_pagenow( array('post.php','post-new.php') ) ) {
191
- return;
192
- }
193
-
194
- if ( ! ( self::$instance instanceof WPGlobus_Vendor_Acf ) ) {
195
- self::$instance = new self( $args );
196
- }
197
-
198
- return self::$instance;
199
- }
200
-
201
- /**
202
- * Init action.
203
- */
204
- public static function on__init() {
205
-
206
- /**
207
- * Filter ACF field types.
208
- * Returning array.
209
- *
210
- * @since 2.6.6
211
- *
212
- * @param self::$field_types Array of field types.
213
- * @param array Field statuses.
214
- */
215
- self::$field_types = apply_filters( 'wpglobus_vendor_acf_field_types', self::$field_types, self::get_field_statuses() );
216
- }
217
-
218
- /**
219
- * @W.I.P @since 2.6.6
220
- */
221
- public static function on__render_field( $field ) {
222
- return;
223
- }
224
-
225
- /**
226
- * Add new setting on Edit Field Group page.
227
- */
228
- public static function on__render_field_settings( $field ) {
229
-
230
- if ( $field['ID'] == 0 ) {
231
- return;
232
- }
233
-
234
- $_name = '';
235
-
236
- if ( ! self::is_enabled_field_type( $field['type'] ) ) {
237
- return;
238
- }
239
-
240
- if ( self::MULTILINGUAL == self::get_field_status( $field ) ) {
241
-
242
- $_name = self::MULTILINGUAL_FIELD_NAME;
243
- $_value = self::is_multilingual_field( $field );
244
-
245
- } elseif ( self::PRETENDER == self::get_field_status( $field ) ) {
246
-
247
- $_name = self::PRETENDER_FIELD_NAME;
248
- $_value = false;
249
-
250
- }
251
-
252
- if ( empty( $_name ) ) {
253
- return;
254
- }
255
-
256
- $_instructions = sprintf( // translators: %s are for A tags.
257
- esc_html__( 'Use as multilingual with %1$sWPGlobus%2$s', 'wpglobus' ),
258
- '<a href="#" target="_blank">',
259
- '</a>'
260
- );
261
-
262
- /**
263
- * @see advanced-custom-fields/includes/acf-field-functions.php
264
- */
265
- acf_render_field_setting( $field, array(
266
- 'label' => esc_html__( 'Multilingual', 'wpglobus' ),
267
- 'instructions' => $_instructions,
268
- 'name' => $_name,
269
- 'type' => 'true_false',
270
- 'ui' => 1,
271
- 'value' => $_value
272
- ), true );
273
- }
274
-
275
- /**
276
- * Check if field is multilingual.
277
- *
278
- * @param array $field Field array.
279
- *
280
- * return boolean
281
- */
282
- public static function is_multilingual_field( $field = array() ) {
283
-
284
- if ( empty( $field ) ) {
285
- return false;
286
- }
287
-
288
- if ( ! self::is_enabled_field_type( $field['type'] ) ) {
289
- /**
290
- * A field with a disabled type cannot be multilingual.
291
- */
292
- return false;
293
- }
294
-
295
- if ( self::MULTILINGUAL != self::$field_types[ $field['type'] ] ) {
296
- return false;
297
- }
298
-
299
- if ( ! isset( $field[ self::MULTILINGUAL_FIELD_NAME ] ) ) {
300
- /**
301
- * Field is multilingual by default.
302
- */
303
- return true;
304
- }
305
-
306
- return $field[ self::MULTILINGUAL_FIELD_NAME ];
307
- }
308
-
309
-
310
- /**
311
- * Get multilingual field ID.
312
- */
313
- public static function filter__prepare_field( $field ) {
314
-
315
- global $post;
316
-
317
- if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
318
- return $field;
319
- }
320
-
321
- if ( ! self::is_multilingual_field( $field ) ) {
322
- return $field;
323
- }
324
-
325
- /**
326
- * $field['id'] may contains clone field like `acf-field_5cda40e0978f9-acfcloneindex-field_5cda42e66249b`.
327
- * to check out @see post with ACF repeater field.
328
- */
329
- self::$field_ids[] = $field['id'];
330
-
331
- return $field;
332
- }
333
-
334
- /**
335
- * Filters the generated CSS styles.
336
- *
337
- * @param string $style The CSS styles.
338
- * @param array $field_group The field group array.
339
- */
340
- public static function filter__get_field_group_style( $style, $field_group ) {
341
-
342
- if( is_array($field_group['hide_on_screen']) ) {
343
-
344
- if ( in_array( 'the_content', $field_group['hide_on_screen'], true ) ) {
345
- /**
346
- * If editor is hidden by ACF, we hide WPGlobus, too.
347
- */
348
- add_filter(
349
- 'wpglobus_postdivrich_style',
350
- array(
351
- __CLASS__,
352
- 'filter__postdivrich_style'
353
- ), 10, 2
354
- );
355
- }
356
-
357
- }
358
-
359
- return $style;
360
- }
361
-
362
- /**
363
- * Callback for admin footer.
364
- *
365
- * @return void
366
- */
367
- public static function on__admin_footer() {
368
-
369
- if ( ! WPGlobus_WP::is_pagenow( array('post.php') ) ) {
370
- return;
371
- }
372
-
373
- global $post;
374
-
375
- if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
376
- return;
377
- }
378
-
379
- if ( empty( self::$field_ids ) ) {
380
- return;
381
- }
382
-
383
- $_ids = implode( ',', self::$field_ids );
384
- ?>
385
- <script type='text/javascript'>
386
- /* <![CDATA[ */
387
- var WPGlobusVendorAcfFields = "<?php echo $_ids; ?>";
388
- /* ]]> */
389
- </script>
390
- <?php
391
- }
392
-
393
- /**
394
- * Enqueue script for post.php & post-new.php pages except page for CPT Edit Field Group.
395
- *
396
- * @since 2.6.6
397
- */
398
- public static function on__admin_scripts() {
399
-
400
- global $post;
401
-
402
- if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
403
- return;
404
- }
405
-
406
- // @see `Enqueue js for ACF support` in wpglobus\includes\class-wpglobus.php
407
-
408
- /**
409
- * Filter to disable translation of selected ACF and ACF Pro fields.
410
- *
411
- * To exclude field in ACF plugin you need to use the field name from Field Group ( usually wp-admin/edit.php?post_type=acf ).
412
- * To exclude field in ACF Pro plugin you need to use id, see Wrapper Attributes section on field's edit page.
413
- *
414
- * @param array $disabled_fields Default is empty array.
415
- * @param boolean $is_acf_pro Type of ACF plugin.
416
- *
417
- * @return array
418
- */
419
- $disabled_fields = apply_filters( 'wpglobus_disabled_acf_fields', array(), self::$args['vendor_scripts'] );
420
-
421
- $actions = array(
422
- 'fixTextFields' => false
423
- );
424
- if ( defined('ACF_VERSION') ) {
425
- if ( version_compare( ACF_VERSION, '5.8.0', '>=' ) ) {
426
- $actions['fixTextFields'] = true;
427
- }
428
- }
429
-
430
- $_source = array();
431
- $_source['class'] = __CLASS__;
432
- $_source['plugin_basename'] = plugin_basename( __FILE__ );
433
-
434
- wp_register_script(
435
- 'wpglobus-acf',
436
- WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-vendor-acf' . WPGlobus::SCRIPT_SUFFIX() . '.js',
437
- array( 'jquery', 'wpglobus-admin' ),
438
- WPGLOBUS_VERSION,
439
- true
440
- );
441
- wp_enqueue_script( 'wpglobus-acf' );
442
- wp_localize_script(
443
- 'wpglobus-acf',
444
- 'WPGlobusAcf',
445
- array(
446
- 'wpglobus_version' => WPGLOBUS_VERSION,
447
- 'acf_version' => defined('ACF_VERSION') ? ACF_VERSION : false,
448
- 'pro' => self::is_acf_pro() ? 'true' : 'false',
449
- 'actions' => $actions,
450
- 'fields' => array(),
451
- 'disabledFields' => $disabled_fields,
452
- 'source' => $_source,
453
- 'builder_id' => WPGlobus::Config()->builder->get_id()
454
- )
455
- );
456
- }
457
-
458
- /**
459
- * Enqueue script for Edit Field Group page.
460
- *
461
- * @since 2.6.6
462
- */
463
- public static function on__field_group_admin_scripts() {
464
-
465
- global $post;
466
-
467
- if ( self::FIELD_GROUP_POST_TYPE != $post->post_type ) {
468
- return;
469
- }
470
-
471
- $_fields = array();
472
- $_classes = array();
473
-
474
- foreach( self::get_field_statuses() as $_key=>$_status ) {
475
- $_fields[ $_status ] = self::get_field_types( $_status );
476
- $_classes[ $_key ]['statusClass'] = 'wpglobus-status-'.$_status;
477
- if ( 'multilingual' == $_status ) {
478
- $_classes[ $_key ]['translatableClass'] = 'wpglobus-translatable';
479
- }
480
- }
481
-
482
- $l10n = array();
483
- $l10n['wysiwyg-pretender-tip'] = sprintf( // translators: %s are for A tags.
484
- esc_html__( 'To use this field, please activate the %1$sACF Plus%2$s module', 'wpglobus' ),
485
- '<a href="'.WPGlobus::URL_WPGLOBUS_SHOP.'wpglobus-plus/#acf" target="_blank" style="text-decoration:underline">',
486
- '</a>'
487
- );
488
-
489
- $data = array(
490
- 'version' => WPGLOBUS_VERSION,
491
- 'acf_version' => defined('ACF_VERSION') ? ACF_VERSION : false,
492
- 'names' => self::get_field_names(),
493
- 'translatableClass' => 'wpglobus-translatable',
494
- 'classes' => $_classes,
495
- 'fields' => $_fields,
496
- 'fieldStatuses' => self::get_field_statuses(),
497
- 'l10n' => $l10n,
498
- 'pro' => self::is_acf_pro() ? 'true' : 'false'
499
- );
500
-
501
- wp_register_script(
502
- 'wpglobus-vendor-acf',
503
- self::url_js( 'wpglobus-vendor-acf' ),
504
- array( 'jquery' ),
505
- WPGLOBUS_VERSION,
506
- true
507
- );
508
- wp_enqueue_script( 'wpglobus-vendor-acf' );
509
- wp_localize_script(
510
- 'wpglobus-vendor-acf',
511
- 'WPGlobusVendorAcf',
512
- array(
513
- 'data' => $data
514
- )
515
- );
516
- }
517
-
518
- /**
519
- * Filter postdivrich style for extra language.
520
- *
521
- * @param string $style Current CSS rule
522
- * @param string $language Unused
523
- * @return string
524
- */
525
- public static function filter__postdivrich_style(
526
- $style,
527
- /** @noinspection PhpUnusedParameterInspection */
528
- $language
529
- ) {
530
- return $style . ' display:none;';
531
- }
532
-
533
- /**
534
- * Check for Pro version.
535
- *
536
- * @return bool
537
- */
538
- public static function is_acf_pro() {
539
- if ( isset( self::$args['vendor_scripts']['ACFPRO'] ) && self::$args['vendor_scripts']['ACFPRO'] ) {
540
- return true;
541
- }
542
- return false;
543
- }
544
-
545
- /**
546
- * Checking if field type is in enabled types array.
547
- *
548
- * @return bool
549
- */
550
- public static function is_enabled_field_type( $field_type = '' ) {
551
-
552
- if ( empty( $field_type ) ) {
553
- return false;
554
- }
555
-
556
- if ( ! in_array( $field_type, self::get_enabled_field_types() ) ) {
557
- return false;
558
- }
559
-
560
- return true;
561
- }
562
-
563
- /**
564
- * Get enabled field types.
565
- *
566
- * @return array
567
- */
568
- public static function get_enabled_field_types() {
569
-
570
- static $_types = null;
571
-
572
- if ( is_null( $_types ) ) {
573
-
574
- $_types = self::get_field_types(
575
- array(
576
- self::MULTILINGUAL,
577
- self::PRETENDER
578
- )
579
- );
580
-
581
- }
582
-
583
- return $_types;
584
- }
585
-
586
- /**
587
- * Get field status.
588
- *
589
- * return string || bool
590
- */
591
- public static function get_field_status( $field ) {
592
-
593
- if ( ! isset( self::$field_types[ $field['type'] ] ) ) {
594
- return false;
595
- }
596
-
597
- return self::$field_types[ $field['type'] ];
598
- }
599
-
600
- /**
601
- * Get field statuses.
602
- *
603
- * @return array
604
- */
605
- public static function get_field_statuses() {
606
- return array(
607
- 'MULTILINGUAL' => self::MULTILINGUAL,
608
- 'PRETENDER' => self::PRETENDER
609
- );
610
- }
611
-
612
- /**
613
- * Get field names.
614
- *
615
- * @return array
616
- */
617
- public static function get_field_names() {
618
- return array(
619
- 'MULTILINGUAL' => self::MULTILINGUAL_FIELD_NAME,
620
- 'PRETENDER' => self::PRETENDER_FIELD_NAME
621
- );
622
- }
623
-
624
- /**
625
- * Get field types.
626
- *
627
- * @return array
628
- */
629
- public static function get_field_types( $status = false ) {
630
-
631
- $_result = array();
632
-
633
- if ( ! $status ) {
634
- return array_keys( self::$field_types );
635
- }
636
-
637
- if ( is_string( $status ) ) {
638
- $status = (array) $status;
639
- }
640
-
641
- foreach( self::$field_types as $field_type=>$_status ) {
642
- if ( in_array( $_status, $status ) ) {
643
- $_result[] = $field_type;
644
- }
645
- }
646
-
647
- if ( empty( $_result ) ) {
648
- return false;
649
- }
650
-
651
- return $_result;
652
- }
653
-
654
- /**
655
- *
656
- */
657
- public static function get_multilingual_field_name() {
658
- return self::MULTILINGUAL_FIELD_NAME;
659
- }
660
-
661
- /**
662
- * Get url's part of vendor folder.
663
- */
664
- protected static function vendor_dir_url() {
665
- return WPGlobus::plugin_dir_url() . 'includes/vendor/acf/';
666
- }
667
-
668
- /**
669
- * URL to the JS script.
670
- *
671
- * @param string $script_name [optional] The script name without extension.
672
- * If not passed, will return the JS root URL.
673
- *
674
- * @return string The URL.
675
- */
676
- protected static function url_js( $script_name = '' ) {
677
- $url = self::vendor_dir_url() . 'assets/js';
678
- if ( $script_name ) {
679
- $url .= '/' . $script_name . WPGlobus::SCRIPT_SUFFIX() . '.js';
680
- }
681
-
682
- return $url;
683
- }
684
-
685
- } // class WPGlobus_Vendor_Acf.
686
-
687
- endif;
688
-
689
- # --- EOF
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-vendor-acf.php
4
+ *
5
+ * @since 2.6.6
6
+ * @package WPGlobus\Vendor\ACF.
7
+ */
8
+
9
+ if ( ! class_exists( 'WPGlobus_Vendor_Acf' ) ) :
10
+
11
+ /**
12
+ * Class WPGlobus_Vendor_Acf.
13
+ */
14
+ class WPGlobus_Vendor_Acf {
15
+
16
+ /**
17
+ * Field post type.
18
+ */
19
+ const FIELD_POST_TYPE = 'acf-field';
20
+
21
+ /**
22
+ * Prefix for classes.
23
+ */
24
+ const CLASS_PREFIX = self::FIELD_POST_TYPE . '-';
25
+
26
+ /**
27
+ * Field Group's post type.
28
+ */
29
+ const FIELD_GROUP_POST_TYPE = 'acf-field-group';
30
+
31
+ /**
32
+ * Status of multilingual field.
33
+ */
34
+ const MULTILINGUAL = 'multilingual';
35
+
36
+ /**
37
+ * Multilingual field name.
38
+ */
39
+ const MULTILINGUAL_FIELD_NAME = 'wpglobus_' . self::MULTILINGUAL . '_field';
40
+
41
+ /**
42
+ * Status of field that may be or may not be multilingual.
43
+ * May be changed in filter.
44
+ */
45
+ const PRETENDER = 'pretender';
46
+
47
+ /**
48
+ * Pretender field name.
49
+ */
50
+ const PRETENDER_FIELD_NAME = 'wpglobus_' . self::PRETENDER . '_field';
51
+
52
+ /**
53
+ * Set of field types, that WPGlobus handles.
54
+ * field_type => field_status
55
+ */
56
+ protected static $field_types = array();
57
+
58
+ /**
59
+ * Array of fields that are multilingual on `post.php` page.
60
+ */
61
+ protected static $field_ids = array();
62
+
63
+ /**
64
+ * Incoming arguments.
65
+ */
66
+ protected static $args = array();
67
+
68
+ /**
69
+ * @var object Instance of this class.
70
+ */
71
+ protected static $instance;
72
+
73
+ /**
74
+ * Constructor.
75
+ */
76
+ protected function __construct( $args = array() ) {
77
+
78
+ self::$args = wp_parse_args(
79
+ $args,
80
+ array(
81
+ 'vendor_scripts' => array(
82
+ 'ACF' => false,
83
+ 'ACFPRO' => false
84
+ )
85
+ )
86
+ );
87
+
88
+ // @see wpglobus\includes\wpglobus-controller.php
89
+ self::$field_types = array(
90
+ 'text' => self::MULTILINGUAL,
91
+ 'textarea' => self::MULTILINGUAL,
92
+ 'wysiwyg' => self::PRETENDER,
93
+ 'table' => self::PRETENDER, #with ACF:Table Field - https://wordpress.org/plugins/advanced-custom-fields-table-field/
94
+ #'url',
95
+ #'number',
96
+ #'image',
97
+ #'radio', ?
98
+ #'google_map', ?
99
+ );
100
+
101
+ add_action( 'init', array( __CLASS__, 'on__init' ) );
102
+
103
+ /**
104
+ * @see advanced-custom-fields\includes\acf-field-group-functions.php
105
+ */
106
+ add_filter(
107
+ 'acf/get_field_group_style',
108
+ array(
109
+ __CLASS__,
110
+ 'filter__get_field_group_style'
111
+ ), 10, 2
112
+ );
113
+
114
+ /**
115
+ * Add new setting on Edit Field Group page.
116
+ *
117
+ * @see advanced-custom-fields\includes\admin\views\field-group-field.php
118
+ * to get more info @see https://www.advancedcustomfields.com/resources/adding-custom-settings-fields/
119
+ */
120
+ add_action(
121
+ 'acf/render_field_settings',
122
+ array(
123
+ __CLASS__,
124
+ 'on__render_field_settings'
125
+ ), 5, 1
126
+ );
127
+
128
+ /**
129
+ * @W.I.P @since 2.6.6
130
+ * @see advanced-custom-fields\includes\acf-field-functions.php
131
+ */
132
+ /*
133
+ add_action(
134
+ 'acf/render_field',
135
+ array(
136
+ __CLASS__,
137
+ 'on__render_field'
138
+ ), 5, 1
139
+ );
140
+ // */
141
+
142
+ /**
143
+ * Filter on post, page and CPT except Edit Field Group page.
144
+ *
145
+ * @see advanced-custom-fields\includes\acf-field-functions.php
146
+ */
147
+ add_filter(
148
+ 'acf/prepare_field',
149
+ array(
150
+ __CLASS__,
151
+ 'filter__prepare_field'
152
+ ), 5, 1
153
+ );
154
+
155
+ add_action(
156
+ 'admin_print_scripts',
157
+ array(
158
+ __CLASS__,
159
+ 'on__field_group_admin_scripts',
160
+ )
161
+ );
162
+
163
+ /**
164
+ * Enqueue script for post.php & post-new.php pages except page for CPT Edit Field Group.
165
+ */
166
+ add_action(
167
+ 'admin_print_scripts',
168
+ array(
169
+ __CLASS__,
170
+ 'on__admin_scripts',
171
+ )
172
+ );
173
+
174
+ add_action(
175
+ 'admin_footer',
176
+ array(
177
+ __CLASS__,
178
+ 'on__admin_footer',
179
+ )
180
+ );
181
+ }
182
+
183
+ /**
184
+ * Get instance of this class.
185
+ *
186
+ * @return WPGlobus_Vendor_Acf || void
187
+ */
188
+ public static function get_instance( $args = array() ) {
189
+
190
+ if ( ! WPGlobus_WP::is_pagenow( array('post.php','post-new.php') ) ) {
191
+ return;
192
+ }
193
+
194
+ if ( ! ( self::$instance instanceof WPGlobus_Vendor_Acf ) ) {
195
+ self::$instance = new self( $args );
196
+ }
197
+
198
+ return self::$instance;
199
+ }
200
+
201
+ /**
202
+ * Init action.
203
+ */
204
+ public static function on__init() {
205
+
206
+ /**
207
+ * Filter ACF field types.
208
+ * Returning array.
209
+ *
210
+ * @since 2.6.6
211
+ *
212
+ * @param self::$field_types Array of field types.
213
+ * @param array Field statuses.
214
+ */
215
+ self::$field_types = apply_filters( 'wpglobus_vendor_acf_field_types', self::$field_types, self::get_field_statuses() );
216
+ }
217
+
218
+ /**
219
+ * @W.I.P @since 2.6.6
220
+ */
221
+ public static function on__render_field( $field ) {
222
+ return;
223
+ }
224
+
225
+ /**
226
+ * Add new setting on Edit Field Group page.
227
+ */
228
+ public static function on__render_field_settings( $field ) {
229
+
230
+ if ( $field['ID'] == 0 ) {
231
+ return;
232
+ }
233
+
234
+ $_name = '';
235
+
236
+ if ( ! self::is_enabled_field_type( $field['type'] ) ) {
237
+ return;
238
+ }
239
+
240
+ if ( self::MULTILINGUAL == self::get_field_status( $field ) ) {
241
+
242
+ $_name = self::MULTILINGUAL_FIELD_NAME;
243
+ $_value = self::is_multilingual_field( $field );
244
+
245
+ } elseif ( self::PRETENDER == self::get_field_status( $field ) ) {
246
+
247
+ $_name = self::PRETENDER_FIELD_NAME;
248
+ $_value = false;
249
+
250
+ }
251
+
252
+ if ( empty( $_name ) ) {
253
+ return;
254
+ }
255
+
256
+ $_instructions = sprintf( // translators: %s are for A tags.
257
+ esc_html__( 'Use as multilingual with %1$sWPGlobus%2$s', 'wpglobus' ),
258
+ '<a href="#" target="_blank">',
259
+ '</a>'
260
+ );
261
+
262
+ /**
263
+ * @see advanced-custom-fields/includes/acf-field-functions.php
264
+ */
265
+ acf_render_field_setting( $field, array(
266
+ 'label' => esc_html__( 'Multilingual', 'wpglobus' ),
267
+ 'instructions' => $_instructions,
268
+ 'name' => $_name,
269
+ 'type' => 'true_false',
270
+ 'ui' => 1,
271
+ 'value' => $_value
272
+ ), true );
273
+ }
274
+
275
+ /**
276
+ * Check if field is multilingual.
277
+ *
278
+ * @param array $field Field array.
279
+ *
280
+ * return boolean
281
+ */
282
+ public static function is_multilingual_field( $field = array() ) {
283
+
284
+ if ( empty( $field ) ) {
285
+ return false;
286
+ }
287
+
288
+ if ( ! self::is_enabled_field_type( $field['type'] ) ) {
289
+ /**
290
+ * A field with a disabled type cannot be multilingual.
291
+ */
292
+ return false;
293
+ }
294
+
295
+ if ( self::MULTILINGUAL != self::$field_types[ $field['type'] ] ) {
296
+ return false;
297
+ }
298
+
299
+ if ( ! isset( $field[ self::MULTILINGUAL_FIELD_NAME ] ) ) {
300
+ /**
301
+ * Field is multilingual by default.
302
+ */
303
+ return true;
304
+ }
305
+
306
+ return $field[ self::MULTILINGUAL_FIELD_NAME ];
307
+ }
308
+
309
+
310
+ /**
311
+ * Get multilingual field ID.
312
+ */
313
+ public static function filter__prepare_field( $field ) {
314
+
315
+ global $post;
316
+
317
+ if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
318
+ return $field;
319
+ }
320
+
321
+ if ( ! self::is_multilingual_field( $field ) ) {
322
+ return $field;
323
+ }
324
+
325
+ /**
326
+ * $field['id'] may contains clone field like `acf-field_5cda40e0978f9-acfcloneindex-field_5cda42e66249b`.
327
+ * to check out @see post with ACF repeater field.
328
+ */
329
+ self::$field_ids[] = $field['id'];
330
+
331
+ return $field;
332
+ }
333
+
334
+ /**
335
+ * Filters the generated CSS styles.
336
+ *
337
+ * @param string $style The CSS styles.
338
+ * @param array $field_group The field group array.
339
+ */
340
+ public static function filter__get_field_group_style( $style, $field_group ) {
341
+
342
+ if( is_array($field_group['hide_on_screen']) ) {
343
+
344
+ if ( in_array( 'the_content', $field_group['hide_on_screen'], true ) ) {
345
+ /**
346
+ * If editor is hidden by ACF, we hide WPGlobus, too.
347
+ */
348
+ add_filter(
349
+ 'wpglobus_postdivrich_style',
350
+ array(
351
+ __CLASS__,
352
+ 'filter__postdivrich_style'
353
+ ), 10, 2
354
+ );
355
+ }
356
+
357
+ }
358
+
359
+ return $style;
360
+ }
361
+
362
+ /**
363
+ * Callback for admin footer.
364
+ *
365
+ * @return void
366
+ */
367
+ public static function on__admin_footer() {
368
+
369
+ if ( ! WPGlobus_WP::is_pagenow( array('post.php') ) ) {
370
+ return;
371
+ }
372
+
373
+ global $post;
374
+
375
+ if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
376
+ return;
377
+ }
378
+
379
+ if ( empty( self::$field_ids ) ) {
380
+ return;
381
+ }
382
+
383
+ $_ids = implode( ',', self::$field_ids );
384
+ ?>
385
+ <script type='text/javascript'>
386
+ /* <![CDATA[ */
387
+ var WPGlobusVendorAcfFields = "<?php echo $_ids; ?>";
388
+ /* ]]> */
389
+ </script>
390
+ <?php
391
+ }
392
+
393
+ /**
394
+ * Enqueue script for post.php & post-new.php pages except page for CPT Edit Field Group.
395
+ *
396
+ * @since 2.6.6
397
+ */
398
+ public static function on__admin_scripts() {
399
+
400
+ global $post;
401
+
402
+ if ( self::FIELD_GROUP_POST_TYPE == $post->post_type ) {
403
+ return;
404
+ }
405
+
406
+ // @see `Enqueue js for ACF support` in wpglobus\includes\class-wpglobus.php
407
+
408
+ /**
409
+ * Filter to disable translation of selected ACF and ACF Pro fields.
410
+ *
411
+ * To exclude field in ACF plugin you need to use the field name from Field Group ( usually wp-admin/edit.php?post_type=acf ).
412
+ * To exclude field in ACF Pro plugin you need to use id, see Wrapper Attributes section on field's edit page.
413
+ *
414
+ * @param array $disabled_fields Default is empty array.
415
+ * @param boolean $is_acf_pro Type of ACF plugin.
416
+ *
417
+ * @return array
418
+ */
419
+ $disabled_fields = apply_filters( 'wpglobus_disabled_acf_fields', array(), self::$args['vendor_scripts'] );
420
+
421
+ $actions = array(
422
+ 'fixTextFields' => false
423
+ );
424
+ if ( defined('ACF_VERSION') ) {
425
+ if ( version_compare( ACF_VERSION, '5.8.0', '>=' ) ) {
426
+ $actions['fixTextFields'] = true;
427
+ }
428
+ }
429
+
430
+ $_source = array();
431
+ $_source['class'] = __CLASS__;
432
+ $_source['plugin_basename'] = plugin_basename( __FILE__ );
433
+
434
+ wp_register_script(
435
+ 'wpglobus-acf',
436
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-vendor-acf' . WPGlobus::SCRIPT_SUFFIX() . '.js',
437
+ array( 'jquery', 'wpglobus-admin' ),
438
+ WPGLOBUS_VERSION,
439
+ true
440
+ );
441
+ wp_enqueue_script( 'wpglobus-acf' );
442
+ wp_localize_script(
443
+ 'wpglobus-acf',
444
+ 'WPGlobusAcf',
445
+ array(
446
+ 'wpglobus_version' => WPGLOBUS_VERSION,
447
+ 'acf_version' => defined('ACF_VERSION') ? ACF_VERSION : false,
448
+ 'pro' => self::is_acf_pro() ? 'true' : 'false',
449
+ 'actions' => $actions,
450
+ 'fields' => array(),
451
+ 'disabledFields' => $disabled_fields,
452
+ 'source' => $_source,
453
+ 'builder_id' => WPGlobus::Config()->builder->get_id(),
454
+ 'translatableClass' => 'wpglobus-translatable',
455
+ )
456
+ );
457
+ }
458
+
459
+ /**
460
+ * Enqueue script for Edit Field Group page.
461
+ *
462
+ * @since 2.6.6
463
+ */
464
+ public static function on__field_group_admin_scripts() {
465
+
466
+ global $post;
467
+
468
+ if ( self::FIELD_GROUP_POST_TYPE != $post->post_type ) {
469
+ return;
470
+ }
471
+
472
+ $_fields = array();
473
+ $_classes = array();
474
+
475
+ foreach( self::get_field_statuses() as $_key=>$_status ) {
476
+ $_fields[ $_status ] = self::get_field_types( $_status );
477
+ $_classes[ $_key ]['statusClass'] = 'wpglobus-status-'.$_status;
478
+ if ( 'multilingual' == $_status ) {
479
+ $_classes[ $_key ]['translatableClass'] = 'wpglobus-translatable';
480
+ }
481
+ }
482
+
483
+ $l10n = array();
484
+ $l10n['wysiwyg-pretender-tip'] = sprintf( // translators: %s are for A tags.
485
+ esc_html__( 'To use this field, please activate the %1$sACF Plus%2$s module', 'wpglobus' ),
486
+ '<a href="'.WPGlobus::URL_WPGLOBUS_SHOP.'wpglobus-plus/#acf" target="_blank" style="text-decoration:underline">',
487
+ '</a>'
488
+ );
489
+
490
+ $data = array(
491
+ 'version' => WPGLOBUS_VERSION,
492
+ 'acf_version' => defined('ACF_VERSION') ? ACF_VERSION : false,
493
+ 'names' => self::get_field_names(),
494
+ 'translatableClass' => 'wpglobus-translatable',
495
+ 'classes' => $_classes,
496
+ 'fields' => $_fields,
497
+ 'fieldStatuses' => self::get_field_statuses(),
498
+ 'l10n' => $l10n,
499
+ 'pro' => self::is_acf_pro() ? 'true' : 'false'
500
+ );
501
+
502
+ wp_register_script(
503
+ 'wpglobus-vendor-acf',
504
+ self::url_js( 'wpglobus-vendor-acf' ),
505
+ array( 'jquery' ),
506
+ WPGLOBUS_VERSION,
507
+ true
508
+ );
509
+ wp_enqueue_script( 'wpglobus-vendor-acf' );
510
+ wp_localize_script(
511
+ 'wpglobus-vendor-acf',
512
+ 'WPGlobusVendorAcf',
513
+ array(
514
+ 'data' => $data
515
+ )
516
+ );
517
+ }
518
+
519
+ /**
520
+ * Filter postdivrich style for extra language.
521
+ *
522
+ * @param string $style Current CSS rule
523
+ * @param string $language Unused
524
+ * @return string
525
+ */
526
+ public static function filter__postdivrich_style(
527
+ $style,
528
+ /** @noinspection PhpUnusedParameterInspection */
529
+ $language
530
+ ) {
531
+ return $style . ' display:none;';
532
+ }
533
+
534
+ /**
535
+ * Check for Pro version.
536
+ *
537
+ * @return bool
538
+ */
539
+ public static function is_acf_pro() {
540
+ if ( isset( self::$args['vendor_scripts']['ACFPRO'] ) && self::$args['vendor_scripts']['ACFPRO'] ) {
541
+ return true;
542
+ }
543
+ return false;
544
+ }
545
+
546
+ /**
547
+ * Checking if field type is in enabled types array.
548
+ *
549
+ * @return bool
550
+ */
551
+ public static function is_enabled_field_type( $field_type = '' ) {
552
+
553
+ if ( empty( $field_type ) ) {
554
+ return false;
555
+ }
556
+
557
+ if ( ! in_array( $field_type, self::get_enabled_field_types() ) ) {
558
+ return false;
559
+ }
560
+
561
+ return true;
562
+ }
563
+
564
+ /**
565
+ * Get enabled field types.
566
+ *
567
+ * @return array
568
+ */
569
+ public static function get_enabled_field_types() {
570
+
571
+ static $_types = null;
572
+
573
+ if ( is_null( $_types ) ) {
574
+
575
+ $_types = self::get_field_types(
576
+ array(
577
+ self::MULTILINGUAL,
578
+ self::PRETENDER
579
+ )
580
+ );
581
+
582
+ }
583
+
584
+ return $_types;
585
+ }
586
+
587
+ /**
588
+ * Get field status.
589
+ *
590
+ * return string || bool
591
+ */
592
+ public static function get_field_status( $field ) {
593
+
594
+ if ( ! isset( self::$field_types[ $field['type'] ] ) ) {
595
+ return false;
596
+ }
597
+
598
+ return self::$field_types[ $field['type'] ];
599
+ }
600
+
601
+ /**
602
+ * Get field statuses.
603
+ *
604
+ * @return array
605
+ */
606
+ public static function get_field_statuses() {
607
+ return array(
608
+ 'MULTILINGUAL' => self::MULTILINGUAL,
609
+ 'PRETENDER' => self::PRETENDER
610
+ );
611
+ }
612
+
613
+ /**
614
+ * Get field names.
615
+ *
616
+ * @return array
617
+ */
618
+ public static function get_field_names() {
619
+ return array(
620
+ 'MULTILINGUAL' => self::MULTILINGUAL_FIELD_NAME,
621
+ 'PRETENDER' => self::PRETENDER_FIELD_NAME
622
+ );
623
+ }
624
+
625
+ /**
626
+ * Get field types.
627
+ *
628
+ * @return array
629
+ */
630
+ public static function get_field_types( $status = false ) {
631
+
632
+ $_result = array();
633
+
634
+ if ( ! $status ) {
635
+ return array_keys( self::$field_types );
636
+ }
637
+
638
+ if ( is_string( $status ) ) {
639
+ $status = (array) $status;
640
+ }
641
+
642
+ foreach( self::$field_types as $field_type=>$_status ) {
643
+ if ( in_array( $_status, $status ) ) {
644
+ $_result[] = $field_type;
645
+ }
646
+ }
647
+
648
+ if ( empty( $_result ) ) {
649
+ return false;
650
+ }
651
+
652
+ return $_result;
653
+ }
654
+
655
+ /**
656
+ *
657
+ */
658
+ public static function get_multilingual_field_name() {
659
+ return self::MULTILINGUAL_FIELD_NAME;
660
+ }
661
+
662
+ /**
663
+ * Get url's part of vendor folder.
664
+ */
665
+ protected static function vendor_dir_url() {
666
+ return WPGlobus::plugin_dir_url() . 'includes/vendor/acf/';
667
+ }
668
+
669
+ /**
670
+ * URL to the JS script.
671
+ *
672
+ * @param string $script_name [optional] The script name without extension.
673
+ * If not passed, will return the JS root URL.
674
+ *
675
+ * @return string The URL.
676
+ */
677
+ protected static function url_js( $script_name = '' ) {
678
+ $url = self::vendor_dir_url() . 'assets/js';
679
+ if ( $script_name ) {
680
+ $url .= '/' . $script_name . WPGlobus::SCRIPT_SUFFIX() . '.js';
681
+ }
682
+
683
+ return $url;
684
+ }
685
+
686
+ } // class WPGlobus_Vendor_Acf.
687
+
688
+ endif;
689
+
690
+ # --- EOF
languages/wpglobus.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2021 WPGlobus 2.7.5
2
- # This file is distributed under the same license as the WPGlobus 2.7.5 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WPGlobus 2.7.5\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
1
+ # Copyright (C) 2021 WPGlobus 2.7.6
2
+ # This file is distributed under the same license as the WPGlobus 2.7.6 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WPGlobus 2.7.6\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
readme.txt CHANGED
@@ -220,6 +220,13 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
220
 
221
  == Changelog ==
222
 
 
 
 
 
 
 
 
223
  = 2.7.5 =
224
  * (Customizer) Added check/uncheck all fields option in Fields Settings section.
225
 
@@ -230,9 +237,6 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
230
  = 2.7.3 =
231
  * (Vendor/Yoast) Fixed issue with meta description when homepage displays latest posts.
232
 
233
- = 2.7.2 =
234
- * (Core/Gutenberg) Activated access to the standard widgets edit page when Gutenberg plugin is active.
235
-
236
  = Earlier versions and Add-ons =
237
 
238
  * [See the complete changelog here](https://github.com/WPGlobus/WPGlobus/blob/master/CHANGELOG.md)
220
 
221
  == Changelog ==
222
 
223
+ = 2.7.6 =
224
+ * (Vendor/ACF) Updated doc.
225
+ * (Vendor/ACF) Added init param for WPGlobus_Vendor_Acf class.
226
+ * (Vendor/ACF) Added `translatableClass` key in localizing script.
227
+ * (Vendor/ACF) Set `translatableClass` for elements in Builder mode.
228
+ * (Vendor/ACF) Perform a global search and replace in JS.
229
+
230
  = 2.7.5 =
231
  * (Customizer) Added check/uncheck all fields option in Fields Settings section.
232
 
237
  = 2.7.3 =
238
  * (Vendor/Yoast) Fixed issue with meta description when homepage displays latest posts.
239
 
 
 
 
240
  = Earlier versions and Add-ons =
241
 
242
  * [See the complete changelog here](https://github.com/WPGlobus/WPGlobus/blob/master/CHANGELOG.md)
wpglobus.php CHANGED
@@ -15,7 +15,7 @@
15
  * Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
16
  * Text Domain: wpglobus
17
  * Domain Path: /languages/
18
- * Version: 2.7.5
19
  * Author: WPGlobus
20
  * Author URI: https://wpglobus.com/
21
  * Network: false
@@ -44,7 +44,7 @@ if ( ! defined( 'ABSPATH' ) ) {
44
  exit;
45
  }
46
 
47
- define( 'WPGLOBUS_VERSION', '2.7.5' );
48
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
49
  define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
50
 
15
  * Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
16
  * Text Domain: wpglobus
17
  * Domain Path: /languages/
18
+ * Version: 2.7.6
19
  * Author: WPGlobus
20
  * Author URI: https://wpglobus.com/
21
  * Network: false
44
  exit;
45
  }
46
 
47
+ define( 'WPGLOBUS_VERSION', '2.7.6' );
48
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
49
  define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
50