PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.16.2
Translate and Go multilingual – Automatic AI translation – wpLingua v2.16.2
2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.2.0 1.2.1 All 109 releases
wplingua / data / json.php

json.php in Translate and Go multilingual – Automatic AI translation – wpLingua 2.16.2, at data/json.php

929 lines 26.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * Retrieves an array of function calls that contain translatable JSON.
11 *
12 * This whitelist is used to identify JavaScript function calls where the
13 * JSON argument should be parsed and translated (e.g., jQuery datepicker).
14 *
15 * @return array Array of function names with dot notation.
16 */
17 function wplng_data_json_in_js_functions() {
18 global $wplng_data_json_in_js_functions;
19
20 if ( null !== $wplng_data_json_in_js_functions ) {
21 return $wplng_data_json_in_js_functions;
22 }
23
24 $wplng_data_json_in_js_functions = apply_filters(
25 'wplng_json_in_js_functions',
26 array(
27 'jQuery.datepicker.setDefaults',
28 '$.datepicker.setDefaults',
29 )
30 );
31
32 return $wplng_data_json_in_js_functions;
33 }
34
35
36 /**
37 * Retrieves an array of exclusion rules for JSON elements.
38 *
39 * Each rule is a callback function that determines whether a JSON element
40 * should be excluded based on its value and its parent elements.
41 *
42 * @return array Array of callback functions defining exclusion rules.
43 */
44 function wplng_data_json_rules_exclusion() {
45 global $wplng_data_json_rules_exclusion;
46
47 if ( null !== $wplng_data_json_rules_exclusion ) {
48 return $wplng_data_json_rules_exclusion;
49 }
50
51 $logical_rules = array();
52
53 // ------------------------------------------------------------------------
54 // Plugin: wpLingua (Ajax edit modal)
55 // ------------------------------------------------------------------------
56
57 $logical_rules[] = function ( $element, $parents ) {
58 return in_array(
59 $parents,
60 array(
61 array( 'data', 'wplng_edit_html' ),
62 array( 'wplngI18nTranslation' ),
63 array( 'wplngI18nSlug' ),
64 array( 'wplngI18nGutenberg' ),
65 )
66 );
67 };
68
69 // ------------------------------------------------------------------------
70 // Plugin: Google Site Kit
71 // ------------------------------------------------------------------------
72
73 $logical_rules[] = function ( $element, $parents ) {
74 return in_array(
75 $parents,
76 array(
77 array( '_googlesitekitBaseData' ),
78 )
79 );
80 };
81
82 // ------------------------------------------------------------------------
83 // Plugin: WooCommerce
84 // ------------------------------------------------------------------------
85
86 $logical_rules[] = function ( $element, $parents ) {
87 return in_array(
88 $parents,
89 array(
90 array( 'encoded_as_url', 'wcSettings', 'wcBlocksConfig', 'pluginUrl' ),
91 array( 'encoded_as_url', 'wcSettings', 'wcBlocksConfig', 'restApiRoutes' ),
92 array( 'encoded_as_url', 'wcSettings', 'wcBlocksConfig', 'defaultAvatar' ),
93 )
94 );
95 };
96
97 $logical_rules[] = function ( $element, $parents ) {
98 return (
99 isset( $parents[0] )
100 && $parents[0] === 'wc_order_attribution'
101 );
102 };
103
104 $wplng_data_json_rules_exclusion = apply_filters(
105 'wplng_json_rules_exclusion',
106 $logical_rules
107 );
108
109 return $wplng_data_json_rules_exclusion;
110 }
111
112
113 /**
114 * Retrieves an array of inclusion rules for JSON elements.
115 *
116 * Each rule is a callback function that determines whether a JSON element
117 * should be included for translation based on its value and its parent elements.
118 *
119 * @return array Array of callback functions defining inclusion rules.
120 */
121 function wplng_data_json_rules_inclusion() {
122 global $wplng_data_json_rules_inclusion;
123
124 if ( null !== $wplng_data_json_rules_inclusion ) {
125 return $wplng_data_json_rules_inclusion;
126 }
127
128 $logical_rules = array();
129
130 // ------------------------------------------------------------------------
131 // Global methods
132 // ------------------------------------------------------------------------
133
134 /**
135 * Some case tagged as label
136 */
137
138 $logical_rules[] = function ( $element, $parents ) {
139 return (
140 ! empty( $parents[ count( $parents ) - 1 ] )
141 && $parents[ count( $parents ) - 1 ] === 'label'
142 );
143 };
144
145 $logical_rules[] = function ( $element, $parents ) {
146 return in_array(
147 $parents,
148 array(
149 array( 'i18n', 'loading' ),
150 array( 'i18n', 'loaded' ),
151 )
152 );
153 };
154
155 /**
156 * i18n scripts
157 */
158
159 $logical_rules[] = function ( $element, $parents ) {
160 return (
161 isset(
162 $parents[0],
163 $parents[1],
164 $parents[2],
165 $parents[3],
166 $parents[4],
167 $parents[5]
168 )
169 && $parents[0] === 'i18n_script'
170 && is_string( $parents[1] )
171 && $parents[2] === 'locale_data'
172 && $parents[3] === 'messages'
173 && is_string( $parents[4] )
174 && is_int( $parents[5] )
175 );
176 };
177
178 // ------------------------------------------------------------------------
179 // schema-graph
180 // ------------------------------------------------------------------------
181
182 /**
183 * Schema-graph: Caption, name, description, etc
184 */
185
186 $logical_rules[] = function ( $element, $parents ) {
187 return (
188 ! empty( $parents[0] )
189 && $parents[0] === '@graph'
190 && count( $parents ) > 2
191 && (
192 (
193 $parents[ count( $parents ) - 2 ] === 'author'
194 && $parents[ count( $parents ) - 1 ] === 'headline'
195 )
196 || (
197 $parents[ count( $parents ) - 2 ] === 'articleSection'
198 && is_int( $parents[ count( $parents ) - 1 ] )
199 )
200 || $parents[ count( $parents ) - 1 ] === 'caption'
201 || $parents[ count( $parents ) - 1 ] === 'name'
202 || $parents[ count( $parents ) - 1 ] === 'alternateName'
203 || $parents[ count( $parents ) - 1 ] === 'description'
204 )
205 );
206 };
207
208 /**
209 * Schema-graph: BreadcrumbList
210 */
211
212 $logical_rules[] = function ( $element, $parents ) {
213 return (
214 isset( $parents[0], $parents[2], $parents[3] )
215 && $parents[0] === 'itemListElement'
216 && $parents[2] === 'item'
217 && $parents[3] === 'name'
218 );
219 };
220
221 // ------------------------------------------------------------------------
222 // Plugin: Elementor
223 // ------------------------------------------------------------------------
224
225 /**
226 * Plugin: Elementor - elementorFrontendConfig
227 */
228
229 $logical_rules[] = function ( $element, $parents ) {
230 return (
231 count( $parents ) === 3
232 && isset( $parents[0], $parents[1] )
233 && $parents[0] === 'elementorFrontendConfig'
234 && $parents[1] === 'i18n'
235 );
236 };
237
238 // ------------------------------------------------------------------------
239 // Plugin: Elementor Essential Addons
240 // ------------------------------------------------------------------------
241
242 /**
243 * Plugin: Elementor - Event Calendar
244 */
245
246 $logical_rules[] = function ( $element, $parents ) {
247 return in_array(
248 $parents,
249 array(
250 array( 'data-translate', 'today' ),
251 array( 'data-translate', 'tomorrow' ),
252 )
253 );
254 };
255
256 $logical_rules[] = function ( $element, $parents ) {
257 return (
258 isset( $parents[0], $parents[1], $parents[2] )
259 && $parents[0] === 'data-events'
260 && is_int( $parents[1] )
261 && (
262 $parents[2] === 'title'
263 || $parents[2] === 'description'
264 )
265 );
266 };
267
268 $logical_rules[] = function ( $element, $parents ) {
269 return (
270 isset( $parents[0], $parents[1] )
271 && $parents[0] === 'jQuery.datepicker.setDefaults'
272 && $parents[1] !== 'dateFormat'
273 );
274 };
275
276 // ------------------------------------------------------------------------
277 // Plugin: WooCommerce
278 // ------------------------------------------------------------------------
279
280 $logical_rules[] = function ( $element, $parents ) {
281 return (
282 isset( $parents[0] )
283 && (
284 $parents[0] === 'wc_add_to_cart_params'
285 || $parents[0] === 'wc_country_select_params'
286 || $parents[0] === 'wc_address_i18n_params'
287 || $parents[0] === 'woocommerce_params'
288 || $parents[0] === 'wc_single_product_params'
289 )
290 && count( $parents ) >= 2
291 && wplng_str_starts_with( $parents[ array_key_last( $parents ) ], 'i18n_' )
292 );
293 };
294
295 $logical_rules[] = function ( $element, $parents ) {
296 return in_array(
297 $parents,
298 array(
299 array( 'config', 'woocommerce', 'messages', 'addedToCartText' ),
300
301 // JSON in attribute data-"wp-context"
302 array( 'data-wp-context', 'addToCartText' ),
303 array( 'data-wp-context', 'ariaLabel' ),
304 array( 'data-wp-context', 'ariaLabelPrevious' ),
305 array( 'data-wp-context', 'ariaLabelNext' ),
306 array( 'data-wp-context', 'addToCartText' ),
307 array( 'data-wp-context', 'inTheCartText' ),
308 array( 'data-wp-context', 'inTheCartText' ),
309
310 // Address placeholder
311 array( 'wc_address_i18n_params', 'locale', 'default', 'address_1', 'placeholder' ),
312 array( 'wc_address_i18n_params', 'locale', 'default', 'address_2', 'placeholder' ),
313
314 // JSON encoded as URL
315 array( 'encoded_as_url', 'wcSettings', 'wcBlocksConfig', 'wordCountType' ),
316 array( 'encoded_as_url', 'wcSettings', 'siteTitle' ),
317
318 array( 'config', 'woocommerce/mini-cart-title-items-counter-block', 'itemsInCartTextTemplate' ),
319 array( 'config', 'woocommerce/mini-cart-products-table-block', 'reduceQuantityLabel' ),
320 array( 'config', 'woocommerce/mini-cart-products-table-block', 'increaseQuantityLabel' ),
321 array( 'config', 'woocommerce/mini-cart-products-table-block', 'quantityDescriptionLabel' ),
322 array( 'config', 'woocommerce/mini-cart-products-table-block', 'removeFromCartLabel' ),
323 array( 'config', 'woocommerce/mini-cart-products-table-block', 'lowInStockLabel' ),
324 array( 'config', 'woocommerce/mini-cart', 'buttonAriaLabelTemplate' ),
325 array( 'state', 'woocommerce/mini-cart-title-items-counter-block', 'itemsInCartText' ),
326 )
327 );
328 };
329
330 /**
331 * Plugin: WooCommerce - Product rating
332 */
333
334 $logical_rules[] = function ( $element, $parents ) {
335 return (
336 isset( $parents[0], $parents[1], $parents[2] )
337 && $parents[0] === 'wc_single_product_params'
338 && $parents[1] === 'i18n_rating_options'
339 && is_int( $parents[2] )
340 );
341 };
342
343 /**
344 * Plugin: WooCommerce - Order Statuses
345 */
346
347 $logical_rules[] = function ( $element, $parents ) {
348 return (
349 isset(
350 $parents[0],
351 $parents[1],
352 $parents[2],
353 $parents[3]
354 )
355 && $parents[0] === 'encoded_as_url'
356 && $parents[1] === 'wcSettings'
357 && $parents[2] === 'orderStatuses'
358 && is_string( $parents[3] )
359 );
360 };
361
362 /**
363 * Plugin: WooCommerce - Item name
364 */
365
366 $logical_rules[] = function ( $element, $parents ) {
367 return (
368 count( $parents ) >= 3
369 && isset(
370 $parents[ count( $parents ) - 3 ],
371 $parents[ count( $parents ) - 2 ],
372 $parents[ count( $parents ) - 1 ],
373 )
374 && $parents[ count( $parents ) - 3 ] === 'items'
375 && is_int( $parents[ count( $parents ) - 2 ] )
376 && $parents[ count( $parents ) - 1 ] === 'name'
377 );
378 };
379
380 /**
381 * Plugin: WooCommerce - Item image name
382 */
383
384 $logical_rules[] = function ( $element, $parents ) {
385 return (
386 count( $parents ) >= 5
387 && isset(
388 $parents[ count( $parents ) - 5 ],
389 $parents[ count( $parents ) - 4 ],
390 $parents[ count( $parents ) - 3 ],
391 $parents[ count( $parents ) - 2 ],
392 $parents[ count( $parents ) - 1 ],
393 )
394 && $parents[ count( $parents ) - 5 ] === 'items'
395 && is_int( $parents[ count( $parents ) - 4 ] )
396 && $parents[ count( $parents ) - 3 ] === 'images'
397 && is_int( $parents[ count( $parents ) - 2 ] )
398 && (
399 $parents[ count( $parents ) - 1 ] === 'name'
400 || $parents[ count( $parents ) - 1 ] === 'alt'
401 )
402 );
403 };
404
405 /**
406 * Plugin: WooCommerce - Form fields
407 */
408
409 $logical_rules[] = function ( $element, $parents ) {
410 return (
411 isset(
412 $parents[0],
413 $parents[1],
414 $parents[2],
415 $parents[3],
416 $parents[4],
417 )
418 && $parents[0] === 'encoded_as_url'
419 && $parents[1] === 'wcSettings'
420 && $parents[2] === 'defaultFields'
421 && is_string( $parents[3] )
422 && (
423 $parents[4] === 'label'
424 || $parents[4] === 'optionalLabel'
425 )
426 );
427 };
428
429 /**
430 * Plugin: WooCommerce - Store pages title
431 */
432
433 $logical_rules[] = function ( $element, $parents ) {
434 return (
435 isset(
436 $parents[0],
437 $parents[1],
438 $parents[2],
439 $parents[3],
440 $parents[4],
441 )
442 && $parents[0] === 'encoded_as_url'
443 && $parents[1] === 'wcSettings'
444 && $parents[2] === 'storePages'
445 && is_string( $parents[3] )
446 && $parents[4] === 'title'
447 );
448 };
449
450 /**
451 * Plugin: WooCommerce - Country select
452 */
453
454 $logical_rules[] = function ( $element, $parents ) {
455 return (
456 isset(
457 $parents[0],
458 $parents[1],
459 $parents[2],
460 $parents[3],
461 )
462 && $parents[0] === 'wc_country_select_params'
463 && $parents[1] === 'countries'
464 && count( $parents ) === 4
465 );
466 };
467
468 /**
469 * Plugin: WooCommerce - Country name
470 */
471
472 $logical_rules[] = function ( $element, $parents ) {
473 return (
474 isset(
475 $parents[0],
476 $parents[1],
477 $parents[2],
478 $parents[3],
479 )
480 && $parents[0] === 'encoded_as_url'
481 && $parents[1] === 'wcSettings'
482 && $parents[2] === 'countries'
483 && is_string( $parents[2] )
484 );
485 };
486
487 /**
488 * Plugin: WooCommerce - Countries label
489 */
490
491 $logical_rules[] = function ( $element, $parents ) {
492 return (
493 isset(
494 $parents[0],
495 $parents[1],
496 $parents[2],
497 $parents[3],
498 $parents[4],
499 $parents[5],
500 )
501 && $parents[0] === 'encoded_as_url'
502 && $parents[1] === 'wcSettings'
503 && $parents[2] === 'countryData'
504 && is_string( $parents[3] )
505 && $parents[4] === 'states'
506 );
507 };
508
509 // ------------------------------------------------------------------------
510 // Plugin: Plugin: woocommerce-paypal-payments
511 // ------------------------------------------------------------------------
512
513 $logical_rules[] = function ( $element, $parents ) {
514 return in_array(
515 $parents,
516 array(
517 array( 'PayPalCommerceGateway', 'hosted_fields', 'labels', 'fields_empty' ),
518 array( 'PayPalCommerceGateway', 'hosted_fields', 'labels', 'fields_not_valid' ),
519 array( 'PayPalCommerceGateway', 'hosted_fields', 'labels', 'card_not_supported' ),
520 array( 'PayPalCommerceGateway', 'hosted_fields', 'labels', 'cardholder_name_required' ),
521 array( 'PayPalCommerceGateway', 'labels', 'error', 'generic' ),
522 array( 'PayPalCommerceGateway', 'labels', 'error', 'required', 'generic' ),
523 array( 'PayPalCommerceGateway', 'labels', 'error', 'required', 'field' ),
524 array( 'PayPalCommerceGateway', 'labels', 'error', 'required', 'elements', 'terms' ),
525 array( 'PayPalCommerceGateway', 'labels', 'billing_field' ),
526 array( 'PayPalCommerceGateway', 'labels', 'shipping_field' ),
527 array( 'PayPalCommerceGateway', 'labels', 'shipping_field' ),
528 )
529 );
530 };
531
532 // ------------------------------------------------------------------------
533 // Plugin: NM Gift Registry and Wishlist Lite (nm-wishlist)
534 // ------------------------------------------------------------------------
535
536 $logical_rules[] = function ( $element, $parents ) {
537 return in_array(
538 $parents,
539 array(
540 array( 'nm_wishlist_vars', 'wlButtonTitleAdd' ),
541 array( 'nm_wishlist_vars', 'wlButtonTitleRemove' ),
542 array( 'nm_wishlist_vars', 'wlButtonTitleRemove' ),
543 )
544 );
545 };
546
547 // ------------------------------------------------------------------------
548 // Plugin: Contact Form 7
549 // ------------------------------------------------------------------------
550
551 $logical_rules[] = function ( $element, $parents ) {
552 return (
553 isset( $parents[0] )
554 && (
555 $parents[0] === 'message'
556 || (
557 isset( $parents[1] )
558 && isset( $parents[2] )
559 && $parents[0] === 'rules'
560 && is_int( $parents[1] )
561 && $parents[2] === 'error'
562 )
563 || (
564 isset( $parents[1] )
565 && isset( $parents[2] )
566 && $parents[0] === 'invalid_fields'
567 && is_int( $parents[1] )
568 && $parents[2] === 'message'
569 )
570 )
571 );
572 };
573
574 // ------------------------------------------------------------------------
575 // Plugin: YITH
576 // ------------------------------------------------------------------------
577
578 $logical_rules[] = function ( $element, $parents ) {
579 return in_array(
580 $parents,
581 array(
582 array( 'yith_wcwl_l10n', 'labels', 'cookie_disabled' ),
583 )
584 );
585 };
586
587 // ------------------------------------------------------------------------
588 // Plugin: WF Cookie Consent
589 // ------------------------------------------------------------------------
590
591 $logical_rules[] = function ( $element, $parents ) {
592 return in_array(
593 $parents,
594 array(
595 array( 'wfCookieConsentSettings', 'wf_cookietext' ),
596 array( 'wfCookieConsentSettings', 'wf_dismisstext' ),
597 array( 'wfCookieConsentSettings', 'wf_linktext' ),
598 )
599 );
600 };
601
602 // ------------------------------------------------------------------------
603 // Plugin: complianz
604 // ------------------------------------------------------------------------
605
606 $logical_rules[] = function ( $element, $parents ) {
607 return in_array(
608 $parents,
609 array(
610 array( 'complianz', 'categories', 'statistics' ),
611 array( 'complianz', 'categories', 'marketing' ),
612 array( 'complianz', 'placeholdertext' ),
613 array( 'complianz', 'page_links', 'eu', 'privacy-statement', 'title' ),
614 array( 'complianz', 'page_links', 'eu', 'cookie-statement', 'title' ),
615 array( 'complianz', 'aria_label' ),
616 )
617 );
618 };
619
620 // ------------------------------------------------------------------------
621 // Plugin: ultimate-post-kit
622 // ------------------------------------------------------------------------
623
624 $logical_rules[] = function ( $element, $parents ) {
625 return in_array(
626 $parents,
627 array(
628 array( 'UltimatePostKitConfig', 'mailchimp', 'subscribing' ),
629 )
630 );
631 };
632
633 // ------------------------------------------------------------------------
634 // Plugin: royal-elementor-addons
635 // ------------------------------------------------------------------------
636
637 $logical_rules[] = function ( $element, $parents ) {
638 return in_array(
639 $parents,
640 array(
641 array( 'WprConfig', 'addedToCartText' ),
642 array( 'WprConfig', 'viewCart' ),
643 array( 'WprConfig', 'chooseQuantityText' ),
644 array( 'WprConfig', 'input_empty' ),
645 array( 'WprConfig', 'select_empty' ),
646 array( 'WprConfig', 'file_empty' ),
647 array( 'WprConfig', 'recaptcha_error' ),
648 )
649 );
650 };
651
652 // ------------------------------------------------------------------------
653 // Plugin: WP Grid Builder
654 // ------------------------------------------------------------------------
655
656 $logical_rules[] = function ( $element, $parents ) {
657 return in_array(
658 $parents,
659 array(
660 array( 'wpgb_settings', 'resultMsg', 'plural' ),
661 array( 'wpgb_settings', 'resultMsg', 'singular' ),
662 array( 'wpgb_settings', 'resultMsg', 'none' ),
663
664 array( 'wpgb_settings', 'lightbox', 'errorMsg' ),
665 array( 'wpgb_settings', 'lightbox', 'prevLabel' ),
666 array( 'wpgb_settings', 'lightbox', 'nextLabel' ),
667 array( 'wpgb_settings', 'lightbox', 'closeLabel' ),
668
669 array( 'wpgb_settings', 'combobox', 'search' ),
670 array( 'wpgb_settings', 'combobox', 'loading' ),
671 array( 'wpgb_settings', 'combobox', 'cleared' ),
672 array( 'wpgb_settings', 'combobox', 'expanded' ),
673 array( 'wpgb_settings', 'combobox', 'noResults' ),
674 array( 'wpgb_settings', 'combobox', 'collapsed' ),
675 array( 'wpgb_settings', 'combobox', 'toggleLabel' ),
676 array( 'wpgb_settings', 'combobox', 'clearLabel' ),
677 array( 'wpgb_settings', 'combobox', 'selected' ),
678 array( 'wpgb_settings', 'combobox', 'deselected' ),
679
680 array( 'wpgb_settings', 'autocomplete', 'open' ),
681 array( 'wpgb_settings', 'autocomplete', 'input' ),
682 array( 'wpgb_settings', 'autocomplete', 'clear' ),
683 array( 'wpgb_settings', 'autocomplete', 'noResults' ),
684 array( 'wpgb_settings', 'autocomplete', 'loading' ),
685 array( 'wpgb_settings', 'autocomplete', 'clearLabel' ),
686 array( 'wpgb_settings', 'autocomplete', 'select' ),
687
688 array( 'wpgb_settings', 'range', 'minLabel' ),
689 array( 'wpgb_settings', 'range', 'maxLabel' ),
690 )
691 );
692 };
693
694 // ------------------------------------------------------------------------
695 // Plugin: WP Amelia
696 // ------------------------------------------------------------------------
697
698 $logical_rules[] = function ( $element, $parents ) {
699 return (
700 // -> wpAmeliaSettings
701 isset( $parents[0] )
702 && $parents[0] === 'wpAmeliaSettings'
703 && (
704 // -> appointments
705 (
706 isset( $parents[1] )
707 && $parents[1] === 'appointments'
708 )
709 // -> roles -> providerBadges -> badges -> content
710 || (
711 isset( $parents[1] )
712 && isset( $parents[2] )
713 && isset( $parents[3] )
714 && isset( $parents[4] )
715 && isset( $parents[5] )
716 && $parents[1] === 'roles'
717 && $parents[2] === 'providerBadges'
718 && $parents[3] === 'badges'
719 && is_int( $parents[4] )
720 && $parents[5] === 'content'
721 )
722 // -> customizedData -> sbsNew -> ... -> ... -> ... -> name
723 || (
724 isset( $parents[1] )
725 && isset( $parents[2] )
726 && isset( $parents[3] )
727 && isset( $parents[4] )
728 && isset( $parents[5] )
729 && isset( $parents[6] )
730 && $parents[1] === 'customizedData'
731 && $parents[2] === 'sbsNew'
732 && $parents[6] === 'name'
733 )
734 )
735 );
736 };
737
738 $logical_rules[] = function ( $element, $parents ) {
739 return (
740 // wpAmeliaLabels -> welcome_back
741 isset( $parents[0] )
742 && $parents[0] === 'wpAmeliaLabels'
743 && isset( $parents[1] )
744 && is_string( $parents[1] )
745 );
746 };
747
748 // ------------------------------------------------------------------------
749 // Plugin: advanced-post-block
750 // ------------------------------------------------------------------------
751
752 $logical_rules[] = function ( $element, $parents ) {
753 return (
754 isset( $parents[0], $parents[1], $parents[2], $parents[3], $parents[4] )
755 && $parents[0] === 'data'
756 && $parents[1] === 'posts'
757 && is_int($parents[2])
758 && $parents[3] === 'thumbnail'
759 && $parents[4] === 'alt'
760 );
761 };
762
763 $logical_rules[] = function ( $element, $parents ) {
764 return (
765 isset( $parents[0], $parents[1], $parents[2], $parents[3] )
766 && $parents[0] === 'data'
767 && $parents[1] === 'posts'
768 && is_int($parents[2])
769 && (
770 $parents[3] === 'title'
771 || $parents[3] === 'date'
772 || $parents[3] === 'excerpt'
773 )
774 );
775 };
776
777 $logical_rules[] = function ( $element, $parents ) {
778 return in_array(
779 $parents,
780 array(
781 array( 'data-attributes', 'readMoreLabel' ),
782 )
783 );
784 };
785
786 // ------------------------------------------------------------------------
787 // Theme: GeneratePress
788 // ------------------------------------------------------------------------
789
790 $logical_rules[] = function ( $element, $parents ) {
791 return in_array(
792 $parents,
793 array(
794 array( 'generatepressMenu', 'openSubMenuLabel' ),
795 array( 'generatepressMenu', 'closeSubMenuLabel' ),
796 )
797 );
798 };
799
800 // ------------------------------------------------------------------------
801 // Theme: Divi
802 // ------------------------------------------------------------------------
803
804 $logical_rules[] = function ( $element, $parents ) {
805 return in_array(
806 $parents,
807 array(
808 array( 'DIVI', 'item_count' ),
809 array( 'DIVI', 'items_count' ),
810
811 array( 'et_pb_custom', 'subscription_failed' ),
812 array( 'et_pb_custom', 'fill_message' ),
813 array( 'et_pb_custom', 'contact_error_message' ),
814 array( 'et_pb_custom', 'invalid' ),
815 array( 'et_pb_custom', 'captcha' ),
816 array( 'et_pb_custom', 'prev' ),
817 array( 'et_pb_custom', 'previous' ),
818 array( 'et_pb_custom', 'next' ),
819 array( 'et_pb_custom', 'wrong_captcha' ),
820 array( 'et_pb_custom', 'wrong_checkbox' ),
821
822 array( 'data-et-multi-view', 'schema', 'content', 'desktop' ),
823 array( 'data-et-multi-view', 'schema', 'content', 'tablet' ),
824 array( 'data-et-multi-view', 'schema', 'content', 'phone' ),
825 )
826 );
827 };
828
829 // ------------------------------------------------------------------------
830 // Theme: My listing
831 // ------------------------------------------------------------------------
832
833 /**
834 * Theme: My listing - JSON in HTML
835 */
836
837 $logical_rules[] = function ( $element, $parents ) {
838 return (
839 isset( $parents[0], $parents[1], $parents[2] )
840 && wplng_str_starts_with( $parents[0], 'CASE' )
841 && $parents[1] === 'l10n'
842 && (
843 $parents[2] === 'selectOption'
844 || $parents[2] === 'errorLoading'
845 || $parents[2] === 'removeAllItems'
846 || $parents[2] === 'loadingMore'
847 || $parents[2] === 'noResults'
848 || $parents[2] === 'searching'
849 || $parents[2] === 'irreversible_action'
850 || $parents[2] === 'delete_listing_confirm'
851 || $parents[2] === 'copied_to_clipboard'
852 || $parents[2] === 'nearby_listings_location_required'
853 || $parents[2] === 'nearby_listings_retrieving_location'
854 || $parents[2] === 'nearby_listings_searching'
855 || $parents[2] === 'geolocation_failed'
856 || $parents[2] === 'something_went_wrong'
857 || $parents[2] === 'all_in_category'
858 || $parents[2] === 'invalid_file_type'
859 || $parents[2] === 'file_limit_exceeded'
860 || $parents[2] === 'file_size_limit'
861 || (
862 $parents[2] === 'datepicker'
863 && isset( $parents[3] )
864 && (
865 $parents[3] === 'applyLabel'
866 || $parents[3] === 'cancelLabel'
867 || $parents[3] === 'customRangeLabel'
868 || $parents[3] === 'daysOfWeek'
869 || $parents[3] === 'monthNames'
870 )
871 )
872 )
873 );
874 };
875
876 /**
877 * Theme: My listing - JSON in AJAX
878 */
879
880 $logical_rules[] = function ( $element, $parents ) {
881 return (
882 isset( $parents[0], $parents[1], $parents[12] )
883 && $parents[0] === 'children'
884 && wplng_str_starts_with( $parents[1], 'term_' )
885 && (
886 $parents[2] === 'name'
887 || $parents[2] === 'description'
888 )
889 );
890 };
891
892 // ------------------------------------------------------------------------
893 // Theme: Briks
894 // ------------------------------------------------------------------------
895
896 $logical_rules[] = function ( $element, $parents ) {
897 return in_array(
898 $parents,
899 array(
900 array( 'data', 'message' ),
901 )
902 );
903 };
904
905 $logical_rules[] = function ( $element, $parents ) {
906 return (
907 isset( $parents[0], $parents[1], $parents[2] )
908 && $parents[0] === 'data'
909 && $parents[1] === 'message'
910 && is_int( $parents[2] )
911 );
912 };
913
914 $logical_rules[] = function ( $element, $parents ) {
915 return (
916 isset( $parents[0], $parents[1], $parents[2] )
917 && $parents[0] === 'bricksData'
918 && $parents[1] === 'i18n'
919 );
920 };
921
922 $wplng_data_json_rules_inclusion = apply_filters(
923 'wplng_json_rules_inclusion',
924 $logical_rules
925 );
926
927 return $wplng_data_json_rules_inclusion;
928 }
929