Weglot Translate – Translate your WP website - Version 3.1.0

Version Description

(29/08/2019) = - Add: Better JSON compatiblity - Bugfix: WC password reset mechanism

Download this release

Release Info

Developer remyb92
Plugin Icon 128x128 Weglot Translate – Translate your WP website
Version 3.1.0
Comparing to
See all releases

Code changes from version 3.0.6 to 3.1.0

Files changed (97) hide show
  1. app/images/circular_flag.png +0 -0
  2. app/images/rect_bright.png +0 -0
  3. app/images/rect_mate.png +0 -0
  4. app/images/square_flag.png +0 -0
  5. app/styles/admin.scss +16 -14
  6. app/styles/index.scss +4 -4
  7. bootstrap.php +102 -104
  8. composer.json +3 -3
  9. dist/admin-css.js +1 -1
  10. dist/admin-js.js +1 -1
  11. dist/css/admin-css.css +20 -15
  12. dist/css/front-css.css +4 -4
  13. dist/front-amp-css.js +1 -1
  14. dist/front-css.js +1 -1
  15. dist/front-js.js +1 -1
  16. dist/frontamp-css.js +100 -0
  17. dist/images/circular_flag.png +0 -0
  18. dist/images/rect_bright.png +0 -0
  19. dist/images/rect_mate.png +0 -0
  20. dist/images/square_flag.png +0 -0
  21. dist/metaboxes-js.js +1 -1
  22. dist/nav-js.js +1 -1
  23. readme.txt +6 -2
  24. src/actions/admin/class-customize-menu-weglot.php +0 -3
  25. src/actions/admin/class-pages-weglot.php +1 -1
  26. src/actions/front/class-front-menu-weglot.php +1 -5
  27. src/helpers/class-helper-json-inline-weglot.php +0 -17
  28. src/helpers/class-helper-keys-json-weglot.php +0 -56
  29. src/models/class-third-translate-interface-weglot.php +0 -17
  30. src/services/class-button-service-weglot.php +2 -2
  31. src/services/class-custom-url-service-weglot.php +21 -13
  32. src/services/class-generate-switcher-service-weglot.php +4 -9
  33. src/services/class-option-service-weglot.php +9 -6
  34. src/services/class-other-translate-service-weglot.php +0 -89
  35. src/services/class-parser-service-weglot.php +2 -1
  36. src/services/class-private-language-service-weglot.php +6 -2
  37. src/services/class-redirect-service-weglot.php +13 -1
  38. src/services/class-regex-checkers-service-weglot.php +76 -0
  39. src/services/class-replace-url-service-weglot.php +23 -1
  40. src/services/class-request-url-service-weglot.php +1 -1
  41. src/services/class-translate-json-ld.php +0 -318
  42. src/services/class-translate-json-service.php +0 -238
  43. src/services/class-translate-service-weglot.php +7 -73
  44. src/third/calderaforms/class-caldera-active.php +1 -1
  45. src/third/calderaforms/class-caldera-i18n-inline.php +1 -1
  46. src/third/calderaforms/class-caldera-translate.php +0 -148
  47. src/third/calderaforms/regexcheckers/class-caldera-form-json-fields.php +25 -0
  48. src/third/edd/class-edd-active.php +33 -0
  49. src/third/edd/class-edd-filter-urls.php +36 -0
  50. src/third/gravityforms/class-gf-active.php +1 -1
  51. src/third/gravityforms/class-gf-filter-urls.php +1 -1
  52. src/third/ninjaforms/{class-ninja-active-weglot.php → class-ninja-active.php} +2 -2
  53. src/third/ninjaforms/class-ninja-translate-json-weglot.php +0 -206
  54. src/third/ninjaforms/regexcheckers/class-ninja-form-json-fields.php +25 -0
  55. src/third/ninjaforms/regexcheckers/class-ninja-form-json-nfi18n.php +25 -0
  56. src/third/ninjaforms/regexcheckers/class-ninja-form-json-setting.php +25 -0
  57. src/third/woocommerce/{class-wc-active-weglot.php → class-wc-active.php} +2 -2
  58. src/third/woocommerce/class-wc-cart-reload-weglot.php +8 -46
  59. src/third/woocommerce/class-wc-filter-urls-weglot.php +26 -3
  60. src/third/woocommerce/class-wc-translate-weglot.php +0 -132
  61. src/third/woocommerce/regexcheckers/class-wc-json-add-cart.php +25 -0
  62. src/third/woocommerce/regexcheckers/class-wc-json-address.php +25 -0
  63. src/third/wpforms/class-wpforms-active.php +2 -2
  64. src/third/wpforms/class-wpforms-translate.php +0 -115
  65. src/third/wpforms/regexcheckers/class-wp-form-json-setting.php +25 -0
  66. templates/admin/pages/tabs/advanced.php +0 -25
  67. templates/admin/pages/tabs/settings.php +1 -1
  68. vendor/autoload.php +1 -1
  69. vendor/composer/ClassLoader.php +2 -2
  70. vendor/composer/autoload_namespaces.php +0 -2
  71. vendor/composer/autoload_real.php +7 -7
  72. vendor/composer/autoload_static.php +5 -19
  73. vendor/composer/installed.json +17 -67
  74. vendor/galbar/jsonpath +0 -1
  75. vendor/weglot/translation-definitions/data/cases/cases-v3.json +48 -4
  76. vendor/weglot/translation-definitions/package.json +1 -1
  77. vendor/weglot/weglot-php/.travis.yml +2 -0
  78. vendor/weglot/weglot-php/src/Client/Endpoint/Translate.php +14 -8
  79. vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php +17 -15
  80. vendor/weglot/weglot-php/src/Parser/Check/JsonLdChecker.php +0 -39
  81. vendor/weglot/weglot-php/src/Parser/Check/Regex/JsonChecker.php +130 -0
  82. vendor/weglot/weglot-php/src/Parser/Check/Regex/RegexChecker.php +73 -0
  83. vendor/weglot/weglot-php/src/Parser/Check/RegexCheckerProvider.php +157 -0
  84. vendor/weglot/weglot-php/src/Parser/ConfigProvider/ServerConfigProvider.php +7 -1
  85. vendor/weglot/weglot-php/src/Parser/Formatter/AbstractFormatter.php +2 -1
  86. vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php +5 -4
  87. vendor/weglot/weglot-php/src/Parser/Formatter/JsonFormatter.php +94 -0
  88. vendor/weglot/weglot-php/src/Parser/Formatter/JsonLdFormatter.php +0 -71
  89. vendor/weglot/weglot-php/src/Parser/Parser.php +120 -56
  90. vendor/weglot/weglot-php/src/Util/{JsonLd.php → JsonUtil.php} +38 -3
  91. vendor/weglot/weglot-php/src/Util/SourceType.php +16 -0
  92. vendor/weglot/weglot-php/src/Util/Text.php +9 -0
  93. vendor/weglot/weglot-php/src/Util/Url.php +3 -1
  94. vendor/weglot/weglot-php/tests/unit/Parser/ParserTest.php +2 -1
  95. vendor/weglot/weglot-php/tests/unit/Util/JsonLdTest.php +9 -9
  96. weglot-functions.php +2 -2
  97. weglot.php +2 -2
app/images/circular_flag.png CHANGED
Binary file
app/images/rect_bright.png CHANGED
Binary file
app/images/rect_mate.png CHANGED
Binary file
app/images/square_flag.png CHANGED
Binary file
app/styles/admin.scss CHANGED
@@ -168,33 +168,35 @@ input[type="text"], .wg-input-textarea {
168
  background-color: #fff;
169
  background-color: white;
170
  border: 1px solid #e0e0e0;
 
 
171
  h3 {
172
- color : white;
173
- background-color : #24284C;
174
- padding : 20px;
175
  margin : 0px;
176
  font-size: 23px;
177
  line-height: 1.3;
178
  }
179
  div {
180
- padding: 15px;
181
  }
182
  .weglot-editbtn {
183
- background: #e56b60;
184
- color: white;
185
- font-weight: bold;
186
- border-radius: 0px;
187
- border-bottom: 2px solid #B7564D;
188
- font-size: 18px!important;
189
- height: 37px!important;
190
- line-height: 34px!important;
191
  text-decoration : none;
192
- padding : 10px 15px;
193
  display : inline-block;
194
  transition:all .2s ease-in;
195
  &:hover {
196
  color : white;
197
- background: #E87A70;
198
  }
199
  p {
200
  font-size: 15px;
168
  background-color: #fff;
169
  background-color: white;
170
  border: 1px solid #e0e0e0;
171
+ border-radius: 12px;
172
+ overflow: hidden;
173
  h3 {
174
+ color : rgb(24, 22, 76);
175
+ background-color : white;
176
+ padding: 30px 30px 0 30px;
177
  margin : 0px;
178
  font-size: 23px;
179
  line-height: 1.3;
180
  }
181
  div {
182
+ padding: 15px 30px 30px 30px;
183
  }
184
  .weglot-editbtn {
185
+ box-shadow: 0 2px 4px 0 rgba(1, 1, 2, 0.05);
186
+ background-color: rgb(61, 70, 251);
187
+ color: #fff;
188
+ height: 45px;
189
+ border-radius: 23px;
190
+ line-height: 45px;
191
+
192
+ font-size: 14px!important;
193
  text-decoration : none;
194
+ padding : 0px 30px;
195
  display : inline-block;
196
  transition:all .2s ease-in;
197
  &:hover {
198
  color : white;
199
+ background: rgb(37, 46, 215);
200
  }
201
  p {
202
  font-size: 15px;
app/styles/index.scss CHANGED
@@ -285,7 +285,7 @@ html[dir="rtl"]{
285
  &.fj > a:before, &.fj > span:before { background-position: -1710px 0 !important; }
286
  &.fi > a:before, &.fi > span:before { background-position: -2550px 0 !important; }
287
  &.fr > a:before, &.fr > span:before { background-position: -2520px 0 !important; }
288
- &.gl > a:before, &.gl > span:before { background-position: -480px 0 !important; }
289
  &.ka > a:before, &.ka > span:before { background-position: -5040px 0 !important; }
290
  &.de > a:before, &.de > span:before { background-position: -2490px 0 !important; }
291
  &.el > a:before, &.el > span:before { background-position: -2460px 0 !important; }
@@ -395,7 +395,7 @@ html[dir="rtl"]{
395
  &.fj > a:before, &.fj > span:before { background-position: -2497px 0 !important; }
396
  &.fi > a:before, &.fi > span:before { background-position: -2529px 0 !important; }
397
  &.fr > a:before, &.fr > span:before { background-position: -2561px 0 !important; }
398
- &.gl > a:before, &.gl > span:before { background-position: -7009px 0 !important; }
399
  &.ka > a:before, &.ka > span:before { background-position: -2721px 0 !important; }
400
  &.de > a:before, &.de > span:before { background-position: -2753px 0 !important; }
401
  &.el > a:before, &.el > span:before { background-position: -2881px 0 !important; }
@@ -505,7 +505,7 @@ html[dir="rtl"]{
505
  &.fj > a:before, &.fj > span:before { background-position: -576px 0 !important; }
506
  &.fi > a:before, &.fi > span:before { background-position: -2328px 0 !important; }
507
  &.fr > a:before, &.fr > span:before { background-position: -2304px 0 !important; }
508
- &.gl > a:before, &.gl > span:before { background-position: -96px 0 !important; }
509
  &.ka > a:before, &.ka > span:before { background-position: -3744px 0 !important; }
510
  &.de > a:before, &.de > span:before { background-position: -2256px 0 !important; }
511
  &.el > a:before, &.el > span:before { background-position: -2208px 0 !important; }
@@ -615,7 +615,7 @@ html[dir="rtl"]{
615
  &.fj > a:before, &.fj > span:before { background-position: -0px 0 !important; }
616
  &.fi > a:before, &.fi > span:before { background-position: -2784px 0 !important; }
617
  &.fr > a:before, &.fr > span:before { background-position: -2760px 0 !important; }
618
- &.gl > a:before, &.gl > span:before { background-position: -3576px 0 !important; }
619
  &.ka > a:before, &.ka > span:before { background-position: -1536px 0 !important; }
620
  &.de > a:before, &.de > span:before { background-position: -1488px 0 !important; }
621
  &.el > a:before, &.el > span:before { background-position: -1416px 0 !important; }
285
  &.fj > a:before, &.fj > span:before { background-position: -1710px 0 !important; }
286
  &.fi > a:before, &.fi > span:before { background-position: -2550px 0 !important; }
287
  &.fr > a:before, &.fr > span:before { background-position: -2520px 0 !important; }
288
+ &.gl > a:before, &.gl > span:before { background-position: -7290px 0 !important; }
289
  &.ka > a:before, &.ka > span:before { background-position: -5040px 0 !important; }
290
  &.de > a:before, &.de > span:before { background-position: -2490px 0 !important; }
291
  &.el > a:before, &.el > span:before { background-position: -2460px 0 !important; }
395
  &.fj > a:before, &.fj > span:before { background-position: -2497px 0 !important; }
396
  &.fi > a:before, &.fi > span:before { background-position: -2529px 0 !important; }
397
  &.fr > a:before, &.fr > span:before { background-position: -2561px 0 !important; }
398
+ &.gl > a:before, &.gl > span:before { background-position: -8383px 0 !important; }
399
  &.ka > a:before, &.ka > span:before { background-position: -2721px 0 !important; }
400
  &.de > a:before, &.de > span:before { background-position: -2753px 0 !important; }
401
  &.el > a:before, &.el > span:before { background-position: -2881px 0 !important; }
505
  &.fj > a:before, &.fj > span:before { background-position: -576px 0 !important; }
506
  &.fi > a:before, &.fi > span:before { background-position: -2328px 0 !important; }
507
  &.fr > a:before, &.fr > span:before { background-position: -2304px 0 !important; }
508
+ &.gl > a:before, &.gl > span:before { background-position: -5400px 0 !important; }
509
  &.ka > a:before, &.ka > span:before { background-position: -3744px 0 !important; }
510
  &.de > a:before, &.de > span:before { background-position: -2256px 0 !important; }
511
  &.el > a:before, &.el > span:before { background-position: -2208px 0 !important; }
615
  &.fj > a:before, &.fj > span:before { background-position: -0px 0 !important; }
616
  &.fi > a:before, &.fi > span:before { background-position: -2784px 0 !important; }
617
  &.fr > a:before, &.fr > span:before { background-position: -2760px 0 !important; }
618
+ &.gl > a:before, &.gl > span:before { background-position: -5832px 0 !important; }
619
  &.ka > a:before, &.ka > span:before { background-position: -1536px 0 !important; }
620
  &.de > a:before, &.de > span:before { background-position: -1488px 0 !important; }
621
  &.el > a:before, &.el > span:before { background-position: -1416px 0 !important; }
bootstrap.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php // phpcs:ignore
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
  }
6
 
7
  use WeglotWP\Bootstrap_Weglot;
@@ -13,98 +13,96 @@ use WeglotWP\Bootstrap_Weglot;
13
  */
14
  abstract class Context_Weglot {
15
 
16
- /**
17
- * @static
18
- * @since 2.0
19
- * @var Bootstrap_Weglot|null
20
- */
21
- protected static $context;
22
-
23
- /**
24
- * Create context if not exist
25
- *
26
- * @static
27
- * @since 2.0
28
- * @return void
29
- */
30
- public static function weglot_get_context() {
31
- if ( null !== self::$context ) {
32
- return self::$context;
33
- }
34
-
35
- self::$context = new Bootstrap_Weglot();
36
-
37
- // If PHP > 5.6, it will be possible to autoload the classes without listing them
38
- $services = [
39
- '\WeglotWP\Services\Button_Service_Weglot',
40
- '\WeglotWP\Services\Request_Url_Service_Weglot',
41
- '\WeglotWP\Services\Option_Service_Weglot',
42
- '\WeglotWP\Services\Redirect_Service_Weglot',
43
- '\WeglotWP\Services\Language_Service_Weglot',
44
- '\WeglotWP\Services\Replace_Url_Service_Weglot',
45
- '\WeglotWP\Services\Multisite_Service_Weglot',
46
- '\WeglotWP\Services\Replace_Link_Service_Weglot',
47
- '\WeglotWP\Services\Migration_Service_Weglot',
48
- '\WeglotWP\Services\Dom_Listeners_Service_Weglot',
49
- '\WeglotWP\Services\Parser_Service_Weglot',
50
- '\WeglotWP\Third\Woocommerce\WC_Translate_Weglot',
51
- '\WeglotWP\Third\Woocommerce\WC_Active_Weglot',
52
- '\WeglotWP\Third\NinjaForms\Ninja_Active_Weglot',
53
- '\WeglotWP\Third\NinjaForms\Ninja_Translate_Json_Weglot',
54
- '\WeglotWP\Third\Amp\Amp_Service_Weglot',
55
- '\WeglotWP\Third\CalderaForms\Caldera_Translate',
56
- '\WeglotWP\Third\CalderaForms\Caldera_Active',
57
- '\WeglotWP\Third\Gravityforms\GF_Active',
58
- '\WeglotWP\Third\WPForms\WPForms_Active',
59
- '\WeglotWP\Third\WPForms\WPForms_Translate',
60
- '\WeglotWP\Services\User_Api_Service_Weglot',
61
- '\WeglotWP\Services\Other_Translate_Service_Weglot',
62
- '\WeglotWP\Services\Dom_Checkers_Service_Weglot',
63
- '\WeglotWP\Services\Custom_Url_Service_Weglot',
64
- '\WeglotWP\Services\Generate_Switcher_Service_Weglot',
65
- '\WeglotWP\Services\Email_Translate_Service_Weglot',
66
- '\WeglotWP\Services\Translate_Service_Weglot',
67
- '\WeglotWP\Services\Private_Language_Service_Weglot',
68
- '\WeglotWP\Services\Href_Lang_Service_Weglot',
69
- '\WeglotWP\Services\Menu_Options_Service_Weglot',
70
- '\WeglotWP\Services\Translate_Json_Service',
71
- '\WeglotWP\Services\Translate_Json_Ld',
72
- ];
73
-
74
- self::$context->set_services( $services );
75
-
76
- // If PHP > 5.6, it will be possible to autoload the classes without listing them
77
- $actions = [
78
- '\WeglotWP\Actions\Email_Translate_Weglot',
79
- '\WeglotWP\Actions\Register_Widget_Weglot',
80
- '\WeglotWP\Actions\Admin\Pages_Weglot',
81
- '\WeglotWP\Actions\Admin\Plugin_Links_Weglot',
82
- '\WeglotWP\Actions\Admin\Options_Weglot',
83
- '\WeglotWP\Actions\Admin\Admin_Enqueue_Weglot',
84
- '\WeglotWP\Actions\Admin\Customize_Menu_Weglot',
85
- '\WeglotWP\Actions\Admin\Permalink_Weglot',
86
- '\WeglotWP\Actions\Front\Translate_Page_Weglot',
87
- '\WeglotWP\Actions\Front\Front_Enqueue_Weglot',
88
- '\WeglotWP\Actions\Front\Shortcode_Weglot',
89
- '\WeglotWP\Actions\Front\Redirect_Log_User_Weglot',
90
- '\WeglotWP\Actions\Migration_Weglot',
91
- '\WeglotWP\Third\Woocommerce\WC_Filter_Urls_Weglot',
92
- '\WeglotWP\Third\Gravityforms\GF_Filter_Urls',
93
- '\WeglotWP\Third\Woocommerce\WC_Cart_Reload_Weglot',
94
- '\WeglotWP\Third\CalderaForms\Caldera_I18n_Inline',
95
- '\WeglotWP\Third\Amp\Amp_Enqueue_Weglot',
96
- '\WeglotWP\Actions\Admin\Metabox_Url_Translate_Weglot',
97
- '\WeglotWP\Actions\Front\Front_Menu_Weglot',
98
- '\WeglotWP\Actions\Front\Search_Weglot',
99
- '\WeglotWP\Actions\Front\Redirect_Comment',
100
- '\WeglotWP\Actions\Admin\Ajax_User_Info',
101
- '\WeglotWP\Actions\Front\Clean_Options',
102
- ];
103
-
104
- self::$context->set_actions( $actions );
105
-
106
- return self::$context;
107
- }
108
  }
109
 
110
 
@@ -115,19 +113,19 @@ abstract class Context_Weglot {
115
  * @return void
116
  */
117
  function weglot_init() {
118
- if ( function_exists( 'apache_get_modules' ) && ! in_array( 'mod_rewrite', apache_get_modules() ) ) { //phpcs:ignore
119
- add_action( 'admin_notices', [ '\WeglotWP\Notices\Rewrite_Module_Weglot', 'admin_notice' ] );
120
- }
121
 
122
- if ( ! function_exists( 'curl_version' ) ) {
123
- add_action( 'admin_notices', [ '\WeglotWP\Notices\Curl_Weglot', 'admin_notice' ] );
124
- }
125
 
126
- if ( ! function_exists( 'json_last_error' ) ) {
127
- add_action( 'admin_notices', [ '\WeglotWP\Notices\Json_Function_Weglot', 'admin_notice' ] );
128
- }
129
 
130
- load_plugin_textdomain( 'weglot', false, WEGLOT_DIR_LANGUAGES );
131
 
132
- Context_Weglot::weglot_get_context()->init_plugin();
133
  }
1
  <?php // phpcs:ignore
2
 
3
  if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
  }
6
 
7
  use WeglotWP\Bootstrap_Weglot;
13
  */
14
  abstract class Context_Weglot {
15
 
16
+ /**
17
+ * @static
18
+ * @since 2.0
19
+ * @var Bootstrap_Weglot|null
20
+ */
21
+ protected static $context;
22
+
23
+ /**
24
+ * Create context if not exist
25
+ *
26
+ * @static
27
+ * @since 2.0
28
+ * @return void
29
+ */
30
+ public static function weglot_get_context() {
31
+ if ( null !== self::$context ) {
32
+ return self::$context;
33
+ }
34
+
35
+ self::$context = new Bootstrap_Weglot();
36
+
37
+ // If PHP > 5.6, it will be possible to autoload the classes without listing them
38
+ $services = [
39
+ '\WeglotWP\Services\Button_Service_Weglot',
40
+ '\WeglotWP\Services\Request_Url_Service_Weglot',
41
+ '\WeglotWP\Services\Option_Service_Weglot',
42
+ '\WeglotWP\Services\Redirect_Service_Weglot',
43
+ '\WeglotWP\Services\Language_Service_Weglot',
44
+ '\WeglotWP\Services\Replace_Url_Service_Weglot',
45
+ '\WeglotWP\Services\Multisite_Service_Weglot',
46
+ '\WeglotWP\Services\Replace_Link_Service_Weglot',
47
+ '\WeglotWP\Services\Migration_Service_Weglot',
48
+ '\WeglotWP\Services\Dom_Listeners_Service_Weglot',
49
+ '\WeglotWP\Services\Parser_Service_Weglot',
50
+ '\WeglotWP\Services\User_Api_Service_Weglot',
51
+ '\WeglotWP\Services\Dom_Checkers_Service_Weglot',
52
+ '\WeglotWP\Services\Regex_Checkers_Service_Weglot',
53
+ '\WeglotWP\Services\Custom_Url_Service_Weglot',
54
+ '\WeglotWP\Services\Generate_Switcher_Service_Weglot',
55
+ '\WeglotWP\Services\Email_Translate_Service_Weglot',
56
+ '\WeglotWP\Services\Translate_Service_Weglot',
57
+ '\WeglotWP\Services\Private_Language_Service_Weglot',
58
+ '\WeglotWP\Services\Href_Lang_Service_Weglot',
59
+ '\WeglotWP\Services\Menu_Options_Service_Weglot',
60
+
61
+ '\WeglotWP\Third\Amp\Amp_Service_Weglot',
62
+ '\WeglotWP\Third\Calderaforms\Caldera_Active',
63
+ '\WeglotWP\Third\Edd\Edd_Active',
64
+ '\WeglotWP\Third\Gravityforms\Gf_Active',
65
+ '\WeglotWP\Third\NinjaForms\Ninja_Active',
66
+ '\WeglotWP\Third\Woocommerce\Wc_Active',
67
+ '\WeglotWP\Third\WPForms\Wpforms_Active',
68
+ ];
69
+
70
+ self::$context->set_services( $services );
71
+
72
+ // If PHP > 5.6, it will be possible to autoload the classes without listing them
73
+ $actions = [
74
+ '\WeglotWP\Actions\Email_Translate_Weglot',
75
+ '\WeglotWP\Actions\Register_Widget_Weglot',
76
+ '\WeglotWP\Actions\Admin\Pages_Weglot',
77
+ '\WeglotWP\Actions\Admin\Plugin_Links_Weglot',
78
+ '\WeglotWP\Actions\Admin\Options_Weglot',
79
+ '\WeglotWP\Actions\Admin\Admin_Enqueue_Weglot',
80
+ '\WeglotWP\Actions\Admin\Customize_Menu_Weglot',
81
+ '\WeglotWP\Actions\Admin\Permalink_Weglot',
82
+ '\WeglotWP\Actions\Front\Translate_Page_Weglot',
83
+ '\WeglotWP\Actions\Front\Front_Enqueue_Weglot',
84
+ '\WeglotWP\Actions\Front\Shortcode_Weglot',
85
+ '\WeglotWP\Actions\Front\Redirect_Log_User_Weglot',
86
+ '\WeglotWP\Actions\Migration_Weglot',
87
+ '\WeglotWP\Actions\Admin\Metabox_Url_Translate_Weglot',
88
+ '\WeglotWP\Actions\Front\Front_Menu_Weglot',
89
+ '\WeglotWP\Actions\Front\Search_Weglot',
90
+ '\WeglotWP\Actions\Front\Redirect_Comment',
91
+ '\WeglotWP\Actions\Admin\Ajax_User_Info',
92
+ '\WeglotWP\Actions\Front\Clean_Options',
93
+
94
+ '\WeglotWP\Third\Amp\Amp_Enqueue_Weglot',
95
+ '\WeglotWP\Third\Calderaforms\Caldera_I18n_Inline',
96
+ '\WeglotWP\Third\Edd\Edd_Filter_Urls',
97
+ '\WeglotWP\Third\Gravityforms\GF_Filter_Urls',
98
+ '\WeglotWP\Third\Woocommerce\WC_Filter_Urls_Weglot',
99
+ '\WeglotWP\Third\Woocommerce\WC_Cart_Reload_Weglot',
100
+ ];
101
+
102
+ self::$context->set_actions( $actions );
103
+
104
+ return self::$context;
105
+ }
 
 
106
  }
107
 
108
 
113
  * @return void
114
  */
115
  function weglot_init() {
116
+ if ( function_exists( 'apache_get_modules' ) && ! in_array( 'mod_rewrite', apache_get_modules() ) ) { //phpcs:ignore
117
+ add_action( 'admin_notices', [ '\WeglotWP\Notices\Rewrite_Module_Weglot', 'admin_notice' ] );
118
+ }
119
 
120
+ if ( ! function_exists( 'curl_version' ) ) {
121
+ add_action( 'admin_notices', [ '\WeglotWP\Notices\Curl_Weglot', 'admin_notice' ] );
122
+ }
123
 
124
+ if ( ! function_exists( 'json_last_error' ) ) {
125
+ add_action( 'admin_notices', [ '\WeglotWP\Notices\Json_Function_Weglot', 'admin_notice' ] );
126
+ }
127
 
128
+ load_plugin_textdomain( 'weglot', false, WEGLOT_DIR_LANGUAGES );
129
 
130
+ Context_Weglot::weglot_get_context()->init_plugin();
131
  }
composer.json CHANGED
@@ -1,7 +1,8 @@
1
  {
2
- "name": "weglot",
 
3
  "type": "project",
4
- "license": "GPL",
5
  "authors": [
6
  {
7
  "name": "Thomas DENEULIN",
@@ -14,7 +15,6 @@
14
  ],
15
  "require": {
16
  "weglot/weglot-php": "^0.5",
17
- "galbar/jsonpath": "dev-master",
18
  "gmulti/morphism-php": "^0.3.0"
19
  },
20
  "require-dev": {
1
  {
2
+ "name": "weglot/translate-wordpress",
3
+ "description": "Translate your WordPress website easily.",
4
  "type": "project",
5
+ "license": "GPL-2.0-or-later",
6
  "authors": [
7
  {
8
  "name": "Thomas DENEULIN",
15
  ],
16
  "require": {
17
  "weglot/weglot-php": "^0.5",
 
18
  "gmulti/morphism-php": "^0.3.0"
19
  },
20
  "require-dev": {
dist/admin-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=12)}({12:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=11)}({11:function(e,t){}});
dist/admin-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function o(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(n,a,function(t){return e[t]}.bind(null,a));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=5)}([function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n=arguments[1],a=0;a<o;){var l=t[a];if(e.call(n,l,a,t))return l;a++}},configurable:!0,writable:!0})},function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var o=this.length>>>0,n=new Array(o),a=this,l=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(n[l++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(n[l++]=a[r]);return n.length=l,n})},,,,function(e,t,o){"use strict";o.r(t);var n=function(){const e=jQuery,t=()=>weglot_languages.available.filter(e=>e.code!==weglot_languages.original);let o;const n=()=>{let n=e("#original_language").val();e("#original_language").on("change",function(t){const a=n,l=n;n=t.target.value,o[0].selectize.removeOption(n);const r=weglot_languages.available.find(e=>e.code===l),s=weglot_languages.available.find(e=>e.code===n);o[0].selectize.addOption(r);const c=e("#is_fullname").is(":checked");let i="";e("#with_name").is(":checked")&&(i=c?s.local:s.code.toUpperCase()),e(".wgcurrent.wg-li").removeClass(a).addClass(n).attr("data-code-language",n).find("span").html(i)}),o=e(".weglot-select-destination").selectize({delimiter:"|",persist:!1,valueField:"code",labelField:"local",searchField:["code","english","local"],sortField:[{field:"english",direction:"asc"}],maxItems:weglot_languages.limit,plugins:["remove_button","drag_drop"],options:t(),render:{option:function(e,t){return'<div class="weglot__choice__language"><span class="weglot__choice__language--english">'+t(e.english)+'</span><span class="weglot__choice__language--local">'+t(e.local)+" ["+t(e.code)+"]</span></div>"}}}).on("change",t=>{const n=o[0].selectize.getValue(),a=e("#li-button-tpl");if(0===a.length)return;const l=e("#is_fullname").is(":checked"),r=e("#with_name").is(":checked"),s=e("#with_flags").is(":checked");let c="";s&&(c="weglot-flags");let i="";n.forEach(e=>{const t=weglot_languages.available.find(t=>t.code===e);let o="";r&&(o=l?t.local:e.toUpperCase()),i+=a.html().replace("{LABEL_LANGUAGE}",o).replace(new RegExp("{CODE_LANGUAGE}","g"),e).replace("{CLASSES}",c)}),e(".country-selector ul").html(i)}),window.addEventListener("weglotCheckApi",e=>{let t=1e3;const n=e.detail.plan;n<=0||weglot_languages.plans.starter_free.ids.indexOf(n)>=0?t=weglot_languages.plans.starter_free.limit_language:weglot_languages.plans.business.ids.indexOf(n)>=0&&(t=weglot_languages.plans.business.limit_language),o[0].selectize.settings.maxItems=t})};document.addEventListener("DOMContentLoaded",()=>{n()})};var a=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{e("#weglot-box-first-settings .weglot-btn-close").on("click",function(t){t.preventDefault(),e("#weglot-box-first-settings").hide()})})};var l=function(){const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),n=document.querySelector("#container-exclude_blocks");function a(e){e.preventDefault(),this.parentNode.remove()}document.querySelector("#js-add-exclude-url")&&document.querySelector("#js-add-exclude-url").addEventListener("click",t=>{t.preventDefault();const n=Math.random().toString(36).substring(7);o.insertAdjacentHTML("beforeend",e.innerHTML.replace(new RegExp("{KEY}","g"),n)),document.querySelector("#container-exclude_urls .item-exclude:last-child .js-btn-remove").addEventListener("click",a)}),document.querySelector("#js-add-exclude-block")&&document.querySelector("#js-add-exclude-block").addEventListener("click",e=>{e.preventDefault(),n.insertAdjacentHTML("beforeend",t.innerHTML),document.querySelector("#container-exclude_blocks .item-exclude:last-child .js-btn-remove-exclude").addEventListener("click",a)}),document.querySelectorAll(".js-btn-remove").forEach(e=>{e.addEventListener("click",a)})};document.addEventListener("DOMContentLoaded",()=>{e()})};var r=function(){const e=jQuery,t=()=>{let t=e("#type_flags option:selected").data("value"),o=[];o.push(e(".country-selector label").data("code-language")),e(".country-selector li").each((t,n)=>{o.push(e(n).data("code-language"))});const n=weglot_languages.available.filter(e=>o.indexOf(e.code)>=0);e("#weglot-css-inline").text(weglot_css.inline),e("#is_dropdown").on("change",function(){e(".country-selector").toggleClass("weglot-inline"),e(".country-selector").toggleClass("weglot-dropdown")}),e("#with_flags").on("change",function(){e(".country-selector label, .country-selector li").toggleClass("weglot-flags")}),e("#type_flags").on("change",function(o){e(".country-selector label, .country-selector li").removeClass(`flag-${t}`);const n=e(":selected",this).data("value");e(".country-selector label, .country-selector li").addClass(`flag-${n}`),t=n});const a=()=>{const t=n.find(t=>t.code===e(".country-selector label").data("code-language")),o=e("#is_fullname").is(":checked"),a=o?t.local:t.code.toUpperCase();e(".country-selector label a, .country-selector label span").text(a),e(".country-selector li").each((t,a)=>{const l=n.find(t=>t.code===e(a).data("code-language")),r=o?l.local:l.code.toUpperCase();e(a).find("a").text(r)})};e("#with_name").on("change",function(t){t.target.checked?a():(e(".country-selector label a, .country-selector label span").text(""),e(".country-selector li a, .country-selector li span").each((t,o)=>{e(o).text("")}))}),e("#is_fullname").on("change",function(t){if(e("#with_name").is(":checked"))if(t.target.checked)a();else{const t=n.find(t=>t.code===e(".country-selector label").data("code-language"));e(".country-selector label a, .country-selector label span").text(t.code.toUpperCase()),e(".country-selector li").each((t,o)=>{const a=n.find(t=>t.code===e(o).data("code-language"));e(o).find("a").text(a.code.toUpperCase()),e(o).find("span").text(a.code.toUpperCase())})}}),e("#override_css").on("keyup",function(t){e("#weglot-css-inline").text(t.target.value)})};document.addEventListener("DOMContentLoaded",()=>{0!==e(".weglot-preview").length&&t()})};var s=function(){const e=jQuery,t=()=>{e("#api_key_private").blur(function(){var t=e(this).val();if(0===t.length)return e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-nokkey"></span>'),void e("#wrap-weglot #submit").prop("disabled",!0);function o(){e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-nokkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!0)}e.ajax({method:"POST",url:ajaxurl,data:{action:"get_user_info",api_key:t},success:({data:t,success:n})=>{n?function(t){e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-okkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!1);const o=new CustomEvent("weglotCheckApi",{detail:t});window.dispatchEvent(o)}(t):o()}}).fail(function(){o()})})};document.addEventListener("DOMContentLoaded",()=>{t()})};var c=function(){const e=jQuery;"undefined"!=typeof weglot_css&&e("#weglot-css-flag-css").text(weglot_css.flag_css);const t=()=>{e(".flag-style-openclose").on("click",function(){e(".flag-style-wrapper").toggle()}),e("select.flag-en-type, select.flag-es-type, select.flag-pt-type, select.flag-fr-type, select.flag-ar-type").on("change",function(){!function(){var t=new Array,o=new Array,n=new Array,a=new Array,l=new Array;t[1]=[3570,7841,48,2712],t[2]=[3720,449,3048,4440],t[3]=[3840,1281,2712,4224],t[4]=[3240,5217,1224,2112],t[5]=[4050,3585,1944,2496],t[6]=[2340,3457,2016,2016],o[1]=[4320,4641,3144,3552],o[2]=[3750,353,2880,4656],o[3]=[4200,1601,2568,3192],o[4]=[3990,5793,1032,2232],o[5]=[5460,897,4104,3120],o[6]=[3810,7905,216,3888],o[7]=[3630,8065,192,2376],o[8]=[3780,1473,2496,4104],o[9]=[6120,2145,4680,2568],o[10]=[4440,3009,3240,1176],o[11]=[5280,1825,3936,2976],o[12]=[4770,2081,3624,1008],o[13]=[4080,3201,2160,2544],o[14]=[4590,5761,3432,624],o[15]=[4350,2209,3360,2688],o[16]=[5610,5249,3168,528],o[17]=[5070,1729,3792,2952],o[18]=[6870,5953,96,3408],o[19]=[4020,5697,1056,1224],n[1]=[1740,5921,528,3504],a[1]=[2760,736,2856,4416],a[2]=[3840,1280,2712,4224],a[3]=[5700,7201,5016,2400],a[4]=[2220,4160,1632,1944],l[1]=[1830,129,3096,5664],l[2]=[5100,2177,3840,2904],l[3]=[4890,3425,3648,2136],l[4]=[1320,3681,1896,4080],l[5]=[1260,3841,1824,1200],l[6]=[1020,3969,1608,312],l[7]=[4800,4065,3600,72],l[8]=[4710,4865,3504,480],l[9]=[6720,5984,5112,3792],l[10]=[4500,7233,3288,1800],l[11]=[720,7522,384,3936],l[12]=[690,7745,336,1104],l[13]=[600,8225,120,1272],l[14]=[660,5569,840,576];var r=e("select.flag-en-type").val(),s=e("select.flag-es-type").val(),c=e("select.flag-pt-type").val(),i=e("select.flag-fr-type").val(),g=e("select.flag-ar-type").val(),f=r<=0?"":".weglot-flags.en > a:before, .weglot-flags.en > span:before { background-position: -"+t[r][0]+"px 0 !important; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0 !important; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0 !important; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0 !important; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0 !important; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0 !important; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0 !important; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0 !important; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+n[c][0]+"px 0 !important; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+n[c][1]+"px 0 !important; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+n[c][2]+"px 0 !important; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+n[c][3]+"px 0 !important; } ",p=i<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[i][0]+"px 0 !important; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[i][1]+"px 0 !important; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[i][2]+"px 0 !important; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[i][3]+"px 0 !important; } ",b=g<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+l[g][0]+"px 0 !important; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+l[g][1]+"px 0 !important; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+l[g][2]+"px 0 !important; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+l[g][3]+"px 0 !important; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+b)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var i=function(){jQuery;document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelector("#private_mode");e&&0!=e.length&&(document.querySelector("#private_mode").addEventListener("change",function(e){document.querySelectorAll(".private-mode-lang--input").forEach(t=>{t.checked=e.target.checked})}),document.querySelectorAll(".private-mode-lang--input").forEach(e=>{e.addEventListener("change",function(e){0===document.querySelectorAll(".private-mode-lang--input:checked").length&&(document.querySelector("#private_mode").checked=!1)})}))})};o(0),o(1);n(),l(),a(),r(),s(),c(),i()}]);
1
+ !function(e){var t={};function o(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(n,a,function(t){return e[t]}.bind(null,a));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=4)}([function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var o=this.length>>>0,n=new Array(o),a=this,l=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(n[l++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(n[l++]=a[r]);return n.length=l,n})},function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var n=arguments[1],a=0;a<o;){var l=t[a];if(e.call(n,l,a,t))return l;a++}},configurable:!0,writable:!0})},,,function(e,t,o){"use strict";o.r(t);var n=function(){const e=jQuery;let t;const o=()=>{t=e(".weglot-select-destination").selectize({delimiter:"|",persist:!1,valueField:"code",labelField:"local",searchField:["code","english","local"],sortField:[{field:"english",direction:"asc"}],maxItems:weglot_languages.limit,plugins:["remove_button","drag_drop"],options:(()=>weglot_languages.available.filter(e=>e.code!==weglot_languages.original))(),render:{option:function(e,t){return'<div class="weglot__choice__language"><span class="weglot__choice__language--english">'+t(e.english)+'</span><span class="weglot__choice__language--local">'+t(e.local)+" ["+t(e.code)+"]</span></div>"}}}).on("change",o=>{const n=t[0].selectize.getValue(),a=e("#li-button-tpl");if(0===a.length)return;const l=e("#is_fullname").is(":checked"),r=e("#with_name").is(":checked");let s="";e("#with_flags").is(":checked")&&(s="weglot-flags");let c="";n.forEach(e=>{const t=weglot_languages.available.find(t=>t.code===e);let o="";r&&(o=l?t.local:e.toUpperCase()),c+=a.html().replace("{LABEL_LANGUAGE}",o).replace(new RegExp("{CODE_LANGUAGE}","g"),e).replace("{CLASSES}",s)}),e(".country-selector ul").html(c)})};document.addEventListener("DOMContentLoaded",()=>{(()=>{let n=e("#original_language").val();e("#original_language").on("change",function(o){const a=n,l=n;n=o.target.value,t[0].selectize.removeOption(n);const r=weglot_languages.available.find(e=>e.code===l),s=weglot_languages.available.find(e=>e.code===n);t[0].selectize.addOption(r);const c=e("#is_fullname").is(":checked");let i="";e("#with_name").is(":checked")&&(i=c?s.local:s.code.toUpperCase()),e(".wgcurrent.wg-li").removeClass(a).addClass(n).attr("data-code-language",n).find("span").html(i)}),o(),window.addEventListener("weglotCheckApi",e=>{let o=1e3;const n=e.detail.plan;n<=0||weglot_languages.plans.starter_free.ids.indexOf(n)>=0?o=weglot_languages.plans.starter_free.limit_language:weglot_languages.plans.business.ids.indexOf(n)>=0&&(o=weglot_languages.plans.business.limit_language),t[0].selectize.settings.maxItems=o})})()})};var a=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{e("#weglot-box-first-settings .weglot-btn-close").on("click",function(t){t.preventDefault(),e("#weglot-box-first-settings").hide()})})};var l=function(){const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),n=document.querySelector("#container-exclude_blocks");function a(e){e.preventDefault(),this.parentNode.remove()}document.querySelector("#js-add-exclude-url")&&document.querySelector("#js-add-exclude-url").addEventListener("click",t=>{t.preventDefault();const n=Math.random().toString(36).substring(7);o.insertAdjacentHTML("beforeend",e.innerHTML.replace(new RegExp("{KEY}","g"),n)),document.querySelector("#container-exclude_urls .item-exclude:last-child .js-btn-remove").addEventListener("click",a)}),document.querySelector("#js-add-exclude-block")&&document.querySelector("#js-add-exclude-block").addEventListener("click",e=>{e.preventDefault(),n.insertAdjacentHTML("beforeend",t.innerHTML),document.querySelector("#container-exclude_blocks .item-exclude:last-child .js-btn-remove-exclude").addEventListener("click",a)}),document.querySelectorAll(".js-btn-remove").forEach(e=>{e.addEventListener("click",a)})};document.addEventListener("DOMContentLoaded",()=>{e()})};var r=function(){const e=jQuery,t=()=>{let t=e("#type_flags option:selected").data("value"),o=[];o.push(e(".country-selector label").data("code-language")),e(".country-selector li").each((t,n)=>{o.push(e(n).data("code-language"))});const n=weglot_languages.available.filter(e=>o.indexOf(e.code)>=0);e("#weglot-css-inline").text(weglot_css.inline),e("#is_dropdown").on("change",function(){e(".country-selector").toggleClass("weglot-inline"),e(".country-selector").toggleClass("weglot-dropdown")}),e("#with_flags").on("change",function(){e(".country-selector label, .country-selector li").toggleClass("weglot-flags")}),e("#type_flags").on("change",function(o){e(".country-selector label, .country-selector li").removeClass(`flag-${t}`);const n=e(":selected",this).data("value");e(".country-selector label, .country-selector li").addClass(`flag-${n}`),t=n});const a=()=>{const t=n.find(t=>t.code===e(".country-selector label").data("code-language")),o=e("#is_fullname").is(":checked"),a=o?t.local:t.code.toUpperCase();e(".country-selector label a, .country-selector label span").text(a),e(".country-selector li").each((t,a)=>{const l=n.find(t=>t.code===e(a).data("code-language")),r=o?l.local:l.code.toUpperCase();e(a).find("a").text(r)})};e("#with_name").on("change",function(t){t.target.checked?a():(e(".country-selector label a, .country-selector label span").text(""),e(".country-selector li a, .country-selector li span").each((t,o)=>{e(o).text("")}))}),e("#is_fullname").on("change",function(t){if(e("#with_name").is(":checked"))if(t.target.checked)a();else{const t=n.find(t=>t.code===e(".country-selector label").data("code-language"));e(".country-selector label a, .country-selector label span").text(t.code.toUpperCase()),e(".country-selector li").each((t,o)=>{const a=n.find(t=>t.code===e(o).data("code-language"));e(o).find("a").text(a.code.toUpperCase()),e(o).find("span").text(a.code.toUpperCase())})}}),e("#override_css").on("keyup",function(t){e("#weglot-css-inline").text(t.target.value)})};document.addEventListener("DOMContentLoaded",()=>{0!==e(".weglot-preview").length&&t()})};var s=function(){const e=jQuery,t=()=>{e("#api_key_private").blur(function(){var t=e(this).val();if(0===t.length)return e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-nokkey"></span>'),void e("#wrap-weglot #submit").prop("disabled",!0);function o(){e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-nokkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!0)}e.ajax({method:"POST",url:ajaxurl,data:{action:"get_user_info",api_key:t},success:({data:t,success:n})=>{n?function(t){e(".weglot-keyres").remove(),e("#api_key_private").after('<span class="weglot-keyres weglot-okkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!1);const o=new CustomEvent("weglotCheckApi",{detail:t});window.dispatchEvent(o)}(t):o()}}).fail(function(){o()})})};document.addEventListener("DOMContentLoaded",()=>{t()})};var c=function(){const e=jQuery;"undefined"!=typeof weglot_css&&e("#weglot-css-flag-css").text(weglot_css.flag_css);const t=()=>{e(".flag-style-openclose").on("click",function(){e(".flag-style-wrapper").toggle()}),e("select.flag-en-type, select.flag-es-type, select.flag-pt-type, select.flag-fr-type, select.flag-ar-type").on("change",function(){!function(){var t=new Array,o=new Array,n=new Array,a=new Array,l=new Array;t[1]=[3570,7841,48,2712],t[2]=[3720,449,3048,4440],t[3]=[3840,1281,2712,4224],t[4]=[3240,5217,1224,2112],t[5]=[4050,3585,1944,2496],t[6]=[2340,3457,2016,2016],o[1]=[4320,4641,3144,3552],o[2]=[3750,353,2880,4656],o[3]=[4200,1601,2568,3192],o[4]=[3990,5793,1032,2232],o[5]=[5460,897,4104,3120],o[6]=[3810,7905,216,3888],o[7]=[3630,8065,192,2376],o[8]=[3780,1473,2496,4104],o[9]=[6120,2145,4680,2568],o[10]=[4440,3009,3240,1176],o[11]=[5280,1825,3936,2976],o[12]=[4770,2081,3624,1008],o[13]=[4080,3201,2160,2544],o[14]=[4590,5761,3432,624],o[15]=[4350,2209,3360,2688],o[16]=[5610,5249,3168,528],o[17]=[5070,1729,3792,2952],o[18]=[6870,5953,96,3408],o[19]=[4020,5697,1056,1224],n[1]=[1740,5921,528,3504],a[1]=[2760,736,2856,4416],a[2]=[3840,1280,2712,4224],a[3]=[5700,7201,5016,2400],a[4]=[2220,4160,1632,1944],l[1]=[1830,129,3096,5664],l[2]=[5100,2177,3840,2904],l[3]=[4890,3425,3648,2136],l[4]=[1320,3681,1896,4080],l[5]=[1260,3841,1824,1200],l[6]=[1020,3969,1608,312],l[7]=[4800,4065,3600,72],l[8]=[4710,4865,3504,480],l[9]=[6720,5984,5112,3792],l[10]=[4500,7233,3288,1800],l[11]=[720,7522,384,3936],l[12]=[690,7745,336,1104],l[13]=[600,8225,120,1272],l[14]=[660,5569,840,576];var r=e("select.flag-en-type").val(),s=e("select.flag-es-type").val(),c=e("select.flag-pt-type").val(),i=e("select.flag-fr-type").val(),g=e("select.flag-ar-type").val(),f=r<=0?"":".weglot-flags.en > a:before, .weglot-flags.en > span:before { background-position: -"+t[r][0]+"px 0 !important; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0 !important; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0 !important; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0 !important; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0 !important; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0 !important; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0 !important; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0 !important; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+n[c][0]+"px 0 !important; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+n[c][1]+"px 0 !important; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+n[c][2]+"px 0 !important; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+n[c][3]+"px 0 !important; } ",p=i<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[i][0]+"px 0 !important; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[i][1]+"px 0 !important; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[i][2]+"px 0 !important; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[i][3]+"px 0 !important; } ",b=g<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+l[g][0]+"px 0 !important; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+l[g][1]+"px 0 !important; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+l[g][2]+"px 0 !important; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+l[g][3]+"px 0 !important; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+b)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var i=function(){jQuery;document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelector("#private_mode");e&&0!=e.length&&(document.querySelector("#private_mode").addEventListener("change",function(e){document.querySelectorAll(".private-mode-lang--input").forEach(t=>{t.checked=e.target.checked})}),document.querySelectorAll(".private-mode-lang--input").forEach(e=>{e.addEventListener("change",function(e){0===document.querySelectorAll(".private-mode-lang--input:checked").length&&(document.querySelector("#private_mode").checked=!1)})}))})};o(1),o(0);n(),l(),a(),r(),s(),c(),i()}]);
dist/css/admin-css.css CHANGED
@@ -437,6 +437,9 @@ input[type="text"], .wg-input-textarea {
437
  .wg-input-textarea::-webkit-input-placeholder {
438
  color: #ccc; }
439
 
 
 
 
440
  .wg-input-textarea::-ms-input-placeholder {
441
  color: #ccc; }
442
 
@@ -480,34 +483,36 @@ input[type="text"], .wg-input-textarea {
480
  margin: 10px 20px 0 2px;
481
  background-color: #fff;
482
  background-color: white;
483
- border: 1px solid #e0e0e0; }
 
 
484
  #wrap-weglot .weglot-infobox h3 {
485
- color: white;
486
- background-color: #24284C;
487
- padding: 20px;
488
  margin: 0px;
489
  font-size: 23px;
490
  line-height: 1.3; }
491
  #wrap-weglot .weglot-infobox div {
492
- padding: 15px; }
493
  #wrap-weglot .weglot-infobox .weglot-editbtn {
494
- background: #e56b60;
495
- color: white;
496
- font-weight: bold;
497
- border-radius: 0px;
498
- border-bottom: 2px solid #B7564D;
499
- font-size: 18px !important;
500
- height: 37px !important;
501
- line-height: 34px !important;
502
  text-decoration: none;
503
- padding: 10px 15px;
504
  display: inline-block;
505
  -webkit-transition: all .2s ease-in;
506
  -o-transition: all .2s ease-in;
507
  transition: all .2s ease-in; }
508
  #wrap-weglot .weglot-infobox .weglot-editbtn:hover {
509
  color: white;
510
- background: #E87A70; }
511
  #wrap-weglot .weglot-infobox .weglot-editbtn p {
512
  font-size: 15px; }
513
  #wrap-weglot .selectize-control,
437
  .wg-input-textarea::-webkit-input-placeholder {
438
  color: #ccc; }
439
 
440
+ .wg-input-textarea:-ms-input-placeholder {
441
+ color: #ccc; }
442
+
443
  .wg-input-textarea::-ms-input-placeholder {
444
  color: #ccc; }
445
 
483
  margin: 10px 20px 0 2px;
484
  background-color: #fff;
485
  background-color: white;
486
+ border: 1px solid #e0e0e0;
487
+ border-radius: 12px;
488
+ overflow: hidden; }
489
  #wrap-weglot .weglot-infobox h3 {
490
+ color: #18164c;
491
+ background-color: white;
492
+ padding: 30px 30px 0 30px;
493
  margin: 0px;
494
  font-size: 23px;
495
  line-height: 1.3; }
496
  #wrap-weglot .weglot-infobox div {
497
+ padding: 15px 30px 30px 30px; }
498
  #wrap-weglot .weglot-infobox .weglot-editbtn {
499
+ -webkit-box-shadow: 0 2px 4px 0 rgba(1, 1, 2, 0.05);
500
+ box-shadow: 0 2px 4px 0 rgba(1, 1, 2, 0.05);
501
+ background-color: #3d46fb;
502
+ color: #fff;
503
+ height: 45px;
504
+ border-radius: 23px;
505
+ line-height: 45px;
506
+ font-size: 14px !important;
507
  text-decoration: none;
508
+ padding: 0px 30px;
509
  display: inline-block;
510
  -webkit-transition: all .2s ease-in;
511
  -o-transition: all .2s ease-in;
512
  transition: all .2s ease-in; }
513
  #wrap-weglot .weglot-infobox .weglot-editbtn:hover {
514
  color: white;
515
+ background: #252ed7; }
516
  #wrap-weglot .weglot-infobox .weglot-editbtn p {
517
  font-size: 15px; }
518
  #wrap-weglot .selectize-control,
dist/css/front-css.css CHANGED
@@ -267,7 +267,7 @@ html[dir="rtl"] .weglot-flags a:before, html[dir="rtl"] .weglot-flags span:befor
267
  .weglot-flags.fr > a:before, .weglot-flags.fr > span:before {
268
  background-position: -2520px 0 !important; }
269
  .weglot-flags.gl > a:before, .weglot-flags.gl > span:before {
270
- background-position: -480px 0 !important; }
271
  .weglot-flags.ka > a:before, .weglot-flags.ka > span:before {
272
  background-position: -5040px 0 !important; }
273
  .weglot-flags.de > a:before, .weglot-flags.de > span:before {
@@ -483,7 +483,7 @@ html[dir="rtl"] .weglot-flags a:before, html[dir="rtl"] .weglot-flags span:befor
483
  .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before {
484
  background-position: -2561px 0 !important; }
485
  .weglot-flags.flag-1.gl > a:before, .weglot-flags.flag-1.gl > span:before {
486
- background-position: -7009px 0 !important; }
487
  .weglot-flags.flag-1.ka > a:before, .weglot-flags.flag-1.ka > span:before {
488
  background-position: -2721px 0 !important; }
489
  .weglot-flags.flag-1.de > a:before, .weglot-flags.flag-1.de > span:before {
@@ -701,7 +701,7 @@ html[dir="rtl"] .weglot-flags a:before, html[dir="rtl"] .weglot-flags span:befor
701
  .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before {
702
  background-position: -2304px 0 !important; }
703
  .weglot-flags.flag-2.gl > a:before, .weglot-flags.flag-2.gl > span:before {
704
- background-position: -96px 0 !important; }
705
  .weglot-flags.flag-2.ka > a:before, .weglot-flags.flag-2.ka > span:before {
706
  background-position: -3744px 0 !important; }
707
  .weglot-flags.flag-2.de > a:before, .weglot-flags.flag-2.de > span:before {
@@ -921,7 +921,7 @@ html[dir="rtl"] .weglot-flags a:before, html[dir="rtl"] .weglot-flags span:befor
921
  .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before {
922
  background-position: -2760px 0 !important; }
923
  .weglot-flags.flag-3.gl > a:before, .weglot-flags.flag-3.gl > span:before {
924
- background-position: -3576px 0 !important; }
925
  .weglot-flags.flag-3.ka > a:before, .weglot-flags.flag-3.ka > span:before {
926
  background-position: -1536px 0 !important; }
927
  .weglot-flags.flag-3.de > a:before, .weglot-flags.flag-3.de > span:before {
267
  .weglot-flags.fr > a:before, .weglot-flags.fr > span:before {
268
  background-position: -2520px 0 !important; }
269
  .weglot-flags.gl > a:before, .weglot-flags.gl > span:before {
270
+ background-position: -7290px 0 !important; }
271
  .weglot-flags.ka > a:before, .weglot-flags.ka > span:before {
272
  background-position: -5040px 0 !important; }
273
  .weglot-flags.de > a:before, .weglot-flags.de > span:before {
483
  .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before {
484
  background-position: -2561px 0 !important; }
485
  .weglot-flags.flag-1.gl > a:before, .weglot-flags.flag-1.gl > span:before {
486
+ background-position: -8383px 0 !important; }
487
  .weglot-flags.flag-1.ka > a:before, .weglot-flags.flag-1.ka > span:before {
488
  background-position: -2721px 0 !important; }
489
  .weglot-flags.flag-1.de > a:before, .weglot-flags.flag-1.de > span:before {
701
  .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before {
702
  background-position: -2304px 0 !important; }
703
  .weglot-flags.flag-2.gl > a:before, .weglot-flags.flag-2.gl > span:before {
704
+ background-position: -5400px 0 !important; }
705
  .weglot-flags.flag-2.ka > a:before, .weglot-flags.flag-2.ka > span:before {
706
  background-position: -3744px 0 !important; }
707
  .weglot-flags.flag-2.de > a:before, .weglot-flags.flag-2.de > span:before {
921
  .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before {
922
  background-position: -2760px 0 !important; }
923
  .weglot-flags.flag-3.gl > a:before, .weglot-flags.flag-3.gl > span:before {
924
+ background-position: -5832px 0 !important; }
925
  .weglot-flags.flag-3.ka > a:before, .weglot-flags.flag-3.ka > span:before {
926
  background-position: -1536px 0 !important; }
927
  .weglot-flags.flag-3.de > a:before, .weglot-flags.flag-3.de > span:before {
dist/front-amp-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=15)}({15:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=8)}({8:function(e,t){}});
dist/front-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=7)}({7:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=16)}({16:function(e,t){}});
dist/front-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=3)}({3:function(e,t){document.addEventListener("DOMContentLoaded",function(e){const t=document.querySelector(".country-selector");if(!t)return;const o=(e=>{let t=0,o=0;do{t+=e.offsetTop||0,o+=e.offsetLeft||0,e=e.offsetParent}while(e);return{top:t,left:o}})(t).top,n=document.body,r=document.documentElement,u=Math.max(n.scrollHeight,n.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight),i=window.getComputedStyle(t).getPropertyValue("position");window.getComputedStyle(t).getPropertyValue("bottom"),window.getComputedStyle(t).getPropertyValue("top");return("fixed"!==i&&o>u/2||"fixed"===i&&o>100)&&(t.className+=" weglot-invert"),!1})}});
1
+ !function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=6)}({6:function(e,t){document.addEventListener("DOMContentLoaded",function(e){const t=document.querySelector(".country-selector");if(!t)return;const o=(e=>{let t=0,o=0;do{t+=e.offsetTop||0,o+=e.offsetLeft||0,e=e.offsetParent}while(e);return{top:t,left:o}})(t).top,n=document.body,r=document.documentElement,u=Math.max(n.scrollHeight,n.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight),i=window.getComputedStyle(t).getPropertyValue("position");window.getComputedStyle(t).getPropertyValue("bottom"),window.getComputedStyle(t).getPropertyValue("top");return("fixed"!==i&&o>u/2||"fixed"===i&&o>100)&&(t.className+=" weglot-invert"),!1})}});
dist/frontamp-css.js ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId]) {
10
+ /******/ return installedModules[moduleId].exports;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ i: moduleId,
15
+ /******/ l: false,
16
+ /******/ exports: {}
17
+ /******/ };
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.l = true;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__.d = function(exports, name, getter) {
38
+ /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40
+ /******/ }
41
+ /******/ };
42
+ /******/
43
+ /******/ // define __esModule on exports
44
+ /******/ __webpack_require__.r = function(exports) {
45
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
+ /******/ }
48
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
+ /******/ };
50
+ /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__.t = function(value, mode) {
57
+ /******/ if(mode & 1) value = __webpack_require__(value);
58
+ /******/ if(mode & 8) return value;
59
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
+ /******/ var ns = Object.create(null);
61
+ /******/ __webpack_require__.r(ns);
62
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
+ /******/ return ns;
65
+ /******/ };
66
+ /******/
67
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
68
+ /******/ __webpack_require__.n = function(module) {
69
+ /******/ var getter = module && module.__esModule ?
70
+ /******/ function getDefault() { return module['default']; } :
71
+ /******/ function getModuleExports() { return module; };
72
+ /******/ __webpack_require__.d(getter, 'a', getter);
73
+ /******/ return getter;
74
+ /******/ };
75
+ /******/
76
+ /******/ // Object.prototype.hasOwnProperty.call
77
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78
+ /******/
79
+ /******/ // __webpack_public_path__
80
+ /******/ __webpack_require__.p = "/dist/";
81
+ /******/
82
+ /******/
83
+ /******/ // Load entry module and return exports
84
+ /******/ return __webpack_require__(__webpack_require__.s = "./app/styles/amp.scss");
85
+ /******/ })
86
+ /************************************************************************/
87
+ /******/ ({
88
+
89
+ /***/ "./app/styles/index-amp.scss":
90
+ /*!***********************************!*\
91
+ !*** ./app/styles/amp.scss ***!
92
+ \***********************************/
93
+ /*! no static exports found */
94
+ /***/ (function(module, exports) {
95
+
96
+ eval("throw new Error(\"Module build failed (from ./node_modules/css-loader/index.js):\\nModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):\\nError: Missing binding /Users/remy/DEV/wordpress2/wp-content/plugins/weglot/node_modules/node-sass/vendor/darwin-x64-64/binding.node\\nNode Sass could not find a binding for your current environment: OS X 64-bit with Node.js 10.x\\n\\nFound bindings for the following environments:\\n - OS X 64-bit with Node.js 9.x\\n\\nThis usually happens because your environment has changed since running `npm install`.\\nRun `npm rebuild node-sass` to download the binding for your current environment.\\n at module.exports (/Users/remy/DEV/wordpress2/wp-content/plugins/weglot/node_modules/node-sass/lib/binding.js:15:13)\\n at Object.<anonymous> (/Users/remy/DEV/wordpress2/wp-content/plugins/weglot/node_modules/node-sass/lib/index.js:14:35)\\n at Module._compile (/usr/local/lib/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)\\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)\\n at Module.load (internal/modules/cjs/loader.js:599:32)\\n at tryModuleLoad (internal/modules/cjs/loader.js:538:12)\\n at Function.Module._load (internal/modules/cjs/loader.js:530:3)\\n at Module.require (internal/modules/cjs/loader.js:637:17)\\n at require (/usr/local/lib/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)\\n at Object.sassLoader (/Users/remy/DEV/wordpress2/wp-content/plugins/weglot/node_modules/sass-loader/lib/loader.js:24:22)\\n at runLoaders (/usr/local/lib/node_modules/webpack/lib/NormalModule.js:303:20)\\n at /usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:364:11\\n at /usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:230:18\\n at runSyncOrAsync (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:143:3)\\n at iterateNormalLoaders (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:229:2)\\n at iterateNormalLoaders (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:218:10)\\n at /usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:233:3\\n at context.callback (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:111:13)\\n at postcss.process.then (/Users/remy/DEV/wordpress2/wp-content/plugins/weglot/node_modules/postcss-loader/lib/index.js:187:9)\");\n\n//# sourceURL=webpack:///./app/styles/amp.scss?");
97
+
98
+ /***/ })
99
+
100
+ /******/ });
dist/images/circular_flag.png CHANGED
Binary file
dist/images/rect_bright.png CHANGED
Binary file
dist/images/rect_mate.png CHANGED
Binary file
dist/images/square_flag.png CHANGED
Binary file
dist/metaboxes-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=6)}([function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var a=arguments[1],o=0;o<n;){var r=t[o];if(e.call(a,r,o,t))return r;o++}},configurable:!0,writable:!0})},function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var n=this.length>>>0,a=new Array(n),o=this,r=0,i=-1;if(void 0===t)for(;++i!==n;)i in this&&e(o[i],i,o)&&(a[r++]=o[i]);else for(;++i!==n;)i in this&&e.call(t,o[i],i,o)&&(a[r++]=o[i]);return a.length=r,a})},function(e,t,n){var a;a=function(){var e=JSON.parse('{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","џ":"dz","Ґ":"G","ґ":"g","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","‘":"\'","’":"\'","“":"\\"","”":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₹":"indian rupee","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial"}');function t(t,n){if("string"!=typeof t)throw new Error("slugify: string argument expected");n="string"==typeof n?{replacement:n}:n||{};var a=t.split("").reduce(function(t,a){return t+(e[a]||a).replace(n.remove||/[^\w\s$*_+~.()'"!\-:@]/g,"")},"").trim().replace(/[-\s]+/g,n.replacement||"-");return n.lower?a.toLowerCase():a}return t.extend=function(t){for(var n in t)e[n]=t[n]},t},e.exports=a(),e.exports.default=a()},,,,function(e,t,n){"use strict";n.r(t);n(0),n(1);var a=n(2),o=n.n(a);(()=>{const e=jQuery,t=()=>{let t={};const n=function(n){const a=e(this).data("lang"),r=o()(e(`#lang-${a}`).val(),{lower:!0,replacement:"-"});e(`#text-edit-${a}`).text(r),e(`#lang-${a}`).hide(),e(this).hide(),e(`.button-weglot-lang[data-lang=${a}]`).show(),e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_post_name",lang:a,id:e("#weglot_post_id").data("id"),post_name:r},success:function(n){if(n.data&&n.data.code&&"same_post_name"===n.data.code)return e(`#text-edit-${a}`).text(t[a]),void e(`#lang-${a}`).val("");n.data&&n.data.code&&"not_available"===n.data.code&&(e(`#weglot_permalink_not_available_${a}`).show(),e(`#lang-${a}`).val(""),setTimeout(()=>{e(`#weglot_permalink_not_available_${a}`).hide()},5e3)),e(`#text-edit-${a}`).text(n.data.result.slug)}})};e(".button-weglot-lang").each((a,o)=>{e(o).on("click",function(n){n.preventDefault();const a=e(this).data("lang"),o=e(`#text-edit-${a}`).text();t[a]=o,e(`#text-edit-${a}`).text(" "),e(`#lang-${a}`).val(o).show(),e(`.button-weglot-lang-submit[data-lang=${a}]`).show(),e(this).hide()});const r=e(o).data("lang");e(`.button-weglot-lang-submit[data-lang=${r}]`).on("click",n)}),e(".weglot_reset").each((t,n)=>{e(n).on("click",function(t){t.preventDefault();const n=e(this).data("lang"),a=e(this).attr("href"),o=e(this).data("id");e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_reset_custom_url",code_lang:n,id:o,custom_url:a},success:function(t){e(`#text-edit-${n}`).text(t.data.result.slug)}})})})};document.addEventListener("DOMContentLoaded",()=>{t()})})()}]);
1
+ !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=3)}([function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var n=this.length>>>0,a=new Array(n),o=this,r=0,i=-1;if(void 0===t)for(;++i!==n;)i in this&&e(o[i],i,o)&&(a[r++]=o[i]);else for(;++i!==n;)i in this&&e.call(t,o[i],i,o)&&(a[r++]=o[i]);return a.length=r,a})},function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var a=arguments[1],o=0;o<n;){var r=t[o];if(e.call(a,r,o,t))return r;o++}},configurable:!0,writable:!0})},function(e,t,n){var a;a=function(){var e=JSON.parse('{"$":"dollar","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","џ":"dz","Ґ":"G","ґ":"g","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","‘":"\'","’":"\'","“":"\\"","”":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₹":"indian rupee","₽":"russian ruble","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial"}');function t(t,n){if("string"!=typeof t)throw new Error("slugify: string argument expected");n="string"==typeof n?{replacement:n}:n||{};var a=t.split("").reduce(function(t,a){return t+(e[a]||a).replace(n.remove||/[^\w\s$*_+~.()'"!\-:@]/g,"")},"").trim().replace(/[-\s]+/g,n.replacement||"-").replace("#{replacement}$","");return n.lower?a.toLowerCase():a}return t.extend=function(t){for(var n in t)e[n]=t[n]},t},e.exports=a(),e.exports.default=a()},function(e,t,n){"use strict";n.r(t);n(1),n(0);var a=n(2),o=n.n(a);(()=>{const e=jQuery,t=()=>{let t={};const n=function(n){const a=e(this).data("lang"),r=o()(e(`#lang-${a}`).val(),{lower:!0,replacement:"-"});e(`#text-edit-${a}`).text(r),e(`#lang-${a}`).hide(),e(this).hide(),e(`.button-weglot-lang[data-lang=${a}]`).show(),e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_post_name",lang:a,id:e("#weglot_post_id").data("id"),post_name:r},success:function(n){if(n.data&&n.data.code&&"same_post_name"===n.data.code)return e(`#text-edit-${a}`).text(t[a]),void e(`#lang-${a}`).val("");n.data&&n.data.code&&"not_available"===n.data.code&&(e(`#weglot_permalink_not_available_${a}`).show(),e(`#lang-${a}`).val(""),setTimeout(()=>{e(`#weglot_permalink_not_available_${a}`).hide()},5e3)),e(`#text-edit-${a}`).text(n.data.result.slug)}})};e(".button-weglot-lang").each((a,o)=>{e(o).on("click",function(n){n.preventDefault();const a=e(this).data("lang"),o=e(`#text-edit-${a}`).text();t[a]=o,e(`#text-edit-${a}`).text(" "),e(`#lang-${a}`).val(o).show(),e(`.button-weglot-lang-submit[data-lang=${a}]`).show(),e(this).hide()});const r=e(o).data("lang");e(`.button-weglot-lang-submit[data-lang=${r}]`).on("click",n)}),e(".weglot_reset").each((t,n)=>{e(n).on("click",function(t){t.preventDefault();const n=e(this).data("lang"),a=e(this).attr("href"),o=e(this).data("id");e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_reset_custom_url",code_lang:n,id:o,custom_url:a},success:function(t){e(`#text-edit-${n}`).text(t.data.result.slug)}})})})};document.addEventListener("DOMContentLoaded",()=>{t()})})()}]);
dist/nav-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=4)}({4:function(e,t){jQuery(document).ready(function(e){e("#update-nav-menu").bind("click",function(t){t.target&&t.target.className&&-1!=t.target.className.indexOf("item-edit")&&e("input[value='#weglot_switcher'][type=text]").parents(".menu-item-settings").each(function(){const t=e(this).attr("id").substring(19);e(this).children("p:not( .field-move )").remove(),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+t,name:"menu-item-title["+t+"]",value:weglot_data.title})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+t,name:"menu-item-url["+t+"]",value:"#weglot_switcher"})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-weglot-detect-"+t,name:"menu-item-weglot-detect["+t+"]",value:1})),e.each(weglot_data.list_options,(n,i)=>{const r=e("<p>").attr("class","description"),o=e("<label>").attr("for",`edit-menu-item-${i.key}-${t}`).text(` ${i.title}`);e(this).prepend(r),r.append(o);const u=e("<input>").attr({type:"checkbox",id:`edit-menu-item-${i.key}-${t}`,name:`menu-item-weglot-${i.key}[${t}]`,value:1});weglot_data.options&&weglot_data.options[`menu-item-${t}`]&&1===weglot_data.options[`menu-item-${t}`][i.key]&&u.prop("checked",!0),o.prepend(u)})})})})}});
1
+ !function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=5)}({5:function(e,t){jQuery(document).ready(function(e){e("#update-nav-menu").bind("click",function(t){t.target&&t.target.className&&-1!=t.target.className.indexOf("item-edit")&&e("input[value='#weglot_switcher'][type=text]").parents(".menu-item-settings").each(function(){const t=e(this).attr("id").substring(19);e(this).children("p:not( .field-move )").remove(),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+t,name:"menu-item-title["+t+"]",value:weglot_data.title})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+t,name:"menu-item-url["+t+"]",value:"#weglot_switcher"})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-weglot-detect-"+t,name:"menu-item-weglot-detect["+t+"]",value:1})),e.each(weglot_data.list_options,(n,i)=>{const r=e("<p>").attr("class","description"),o=e("<label>").attr("for",`edit-menu-item-${i.key}-${t}`).text(` ${i.title}`);e(this).prepend(r),r.append(o);const u=e("<input>").attr({type:"checkbox",id:`edit-menu-item-${i.key}-${t}`,name:`menu-item-weglot-${i.key}[${t}]`,value:1});weglot_data.options&&weglot_data.options[`menu-item-${t}`]&&1===weglot_data.options[`menu-item-${t}`][i.key]&&u.prop("checked",!0),o.prepend(u)})})})})}});
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: translate, multilingual, language, translation, localization
4
  Requires at least: 4.5
5
  Tested up to: 5.2
6
  Requires PHP: 5.4
7
- Stable tag: 3.0.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -26,7 +26,7 @@ Check Weglot Translate in video:
26
 
27
  Weglot Translate benefits:
28
 
29
- - Fully compatible with all themes and plugins: Weglot Translate will translate every string in the page.
30
  - 60+ translation languages available
31
  - A unique and single place to manage all your languages and translations
32
  - Content automatically detected and translated: content is the only thing you need to care about.
@@ -153,6 +153,10 @@ See changelog for upgrade changes.
153
 
154
  == Changelog ==
155
 
 
 
 
 
156
  = 3.0.6 (28/05/2019) =
157
  * Add: Compatibility with WP Forms
158
  * Add: Reset postdata filter for custom URLs
4
  Requires at least: 4.5
5
  Tested up to: 5.2
6
  Requires PHP: 5.4
7
+ Stable tag: 3.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
26
 
27
  Weglot Translate benefits:
28
 
29
+ - Fully compatible with all themes and plugins: Weglot Translate will translate every string in the page. Weglot translates WooCommerce products, checkout, order emails...
30
  - 60+ translation languages available
31
  - A unique and single place to manage all your languages and translations
32
  - Content automatically detected and translated: content is the only thing you need to care about.
153
 
154
  == Changelog ==
155
 
156
+ = 3.1.0 (29/08/2019) =
157
+ - Add: Better JSON compatiblity
158
+ - Bugfix: WC password reset mechanism
159
+
160
  = 3.0.6 (28/05/2019) =
161
  * Add: Compatibility with WP Forms
162
  * Add: Reset postdata filter for custom URLs
src/actions/admin/class-customize-menu-weglot.php CHANGED
@@ -37,9 +37,6 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
37
  * @return void
38
  */
39
  public function hooks() {
40
- if ( ! $this->option_services->get_option( 'allowed' ) ) {
41
- return;
42
- }
43
 
44
  add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
45
  add_action( 'admin_enqueue_scripts', [ $this, 'nav_admin_enqueue_scripts' ] );
37
  * @return void
38
  */
39
  public function hooks() {
 
 
 
40
 
41
  add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
42
  add_action( 'admin_enqueue_scripts', [ $this, 'nav_admin_enqueue_scripts' ] );
src/actions/admin/class-pages-weglot.php CHANGED
@@ -27,7 +27,7 @@ class Pages_Weglot implements Hooks_Interface_Weglot {
27
  $this->language_services = weglot_get_service( 'Language_Service_Weglot' );
28
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
29
  $this->user_api_services = weglot_get_service( 'User_Api_Service_Weglot' );
30
- $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
31
  return $this;
32
  }
33
 
27
  $this->language_services = weglot_get_service( 'Language_Service_Weglot' );
28
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
29
  $this->user_api_services = weglot_get_service( 'User_Api_Service_Weglot' );
30
+ $this->wc_active_services = weglot_get_service( 'Wc_Active' );
31
  return $this;
32
  }
33
 
src/actions/front/class-front-menu-weglot.php CHANGED
@@ -38,10 +38,6 @@ class Front_Menu_Weglot implements Hooks_Interface_Weglot {
38
  return;
39
  }
40
 
41
- if ( ! $this->option_services->get_option( 'allowed' ) ) {
42
- return;
43
- }
44
-
45
  add_filter( 'wp_get_nav_menu_items', [ $this, 'weglot_wp_get_nav_menu_items' ], 20 );
46
  add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
47
  add_filter( 'wp_nav_menu_objects', [ $this, 'wp_nav_menu_objects' ] );
@@ -93,7 +89,7 @@ class Front_Menu_Weglot implements Hooks_Interface_Weglot {
93
  $id = $item->ID;
94
  $i = 0;
95
 
96
- $classes = [ 'weglot-lang', 'menu-item-weglot' ];
97
  $options = $this->option_services->get_option( 'menu_switcher' );
98
  $with_flags = $this->option_services->get_option_button( 'with_flags' );
99
  $dropdown = 0;
38
  return;
39
  }
40
 
 
 
 
 
41
  add_filter( 'wp_get_nav_menu_items', [ $this, 'weglot_wp_get_nav_menu_items' ], 20 );
42
  add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
43
  add_filter( 'wp_nav_menu_objects', [ $this, 'wp_nav_menu_objects' ] );
89
  $id = $item->ID;
90
  $i = 0;
91
 
92
+ $classes = [ 'weglot-lang', 'menu-item-weglot' , 'weglot-language' ];
93
  $options = $this->option_services->get_option( 'menu_switcher' );
94
  $with_flags = $this->option_services->get_option_button( 'with_flags' );
95
  $dropdown = 0;
src/helpers/class-helper-json-inline-weglot.php CHANGED
@@ -55,21 +55,4 @@ abstract class Helper_Json_Inline_Weglot {
55
  public static function is_json( $string ) {
56
  return is_string( $string ) && is_array( \json_decode( $string, true ) ) && ( JSON_ERROR_NONE === \json_last_error() ) ? true : false;
57
  }
58
-
59
- /**
60
- * @since 2.3.0
61
- *
62
- * @param string $string
63
- * @return boolean
64
- */
65
- public static function is_ajax_html( $string ) {
66
- $preg_match_ajax_html = apply_filters( 'weglot_is_ajax_html_regex', '/<(a|div|span|p|i|aside|input|textarea|select|h1|h2|h3|h4|meta|button|form|li|strong|ul|option)/' );
67
- $result = preg_match_all( $preg_match_ajax_html, $string, $m, PREG_PATTERN_ORDER );
68
-
69
- if ( isset( $string[0] ) && '{' !== $string[0] && $result && $result >= 1 ) {
70
- return true;
71
- } else {
72
- return false;
73
- }
74
- }
75
  }
55
  public static function is_json( $string ) {
56
  return is_string( $string ) && is_array( \json_decode( $string, true ) ) && ( JSON_ERROR_NONE === \json_last_error() ) ? true : false;
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
src/helpers/class-helper-keys-json-weglot.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Helpers;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- /**
10
- * @since 2.4.0
11
- */
12
- abstract class Helper_Keys_Json_Weglot {
13
- /**
14
- * @var array
15
- */
16
- protected static $keys = [
17
- 'contact-form-7' => [
18
- 'message',
19
- ],
20
- '/' => [
21
- 'post_title',
22
- 'rendered',
23
- ],
24
- ];
25
-
26
- /**
27
- * @since 2.4.0
28
- * @return array
29
- */
30
- public static function get_keys() {
31
- return apply_filters( 'weglot_keys_translate_json', self::$keys );
32
- }
33
-
34
-
35
- /**
36
- * @since 2.4.0
37
- * @param string $key
38
- * @return bool
39
- */
40
- public static function translate_key_for_path( $key ) {
41
- $keys_translate = self::get_keys();
42
- $path = weglot_get_rest_current_url_path();
43
-
44
- foreach ( $keys_translate as $key_translate => $value ) {
45
- if ( empty( $key_translate ) || strpos( $path, $key_translate ) === false ) {
46
- continue;
47
- }
48
-
49
- if ( in_array( $key, $keys_translate[ $key_translate ], true ) ) {
50
- return true;
51
- }
52
- }
53
-
54
- return false;
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/models/class-third-translate-interface-weglot.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Models;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- /**
10
- * Third translate
11
- *
12
- * @since 2.0
13
- *
14
- */
15
- interface Third_Translate_Interface_Weglot {
16
- public function translate_words( $content );
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/services/class-button-service-weglot.php CHANGED
@@ -115,7 +115,7 @@ class Button_Service_Weglot {
115
  $name = $this->get_name_with_language_entry( $current_language_entry );
116
 
117
  $uniq_id = 'wg' . uniqid( strtotime( 'now' ) ) . rand( 1, 1000 );
118
- $button_html .= sprintf( '<input id="%s" class="weglot_choice" type="checkbox" name="menu"/><label for="%s" class="wgcurrent wg-li %s" data-code-language="%s"><span>%s</span></label>', $uniq_id, $uniq_id, $flag_class . $current_language, $current_language_entry->getIso639(), $name );
119
 
120
  $button_html .= '<ul>';
121
 
@@ -126,7 +126,7 @@ class Button_Service_Weglot {
126
  continue;
127
  }
128
 
129
- $button_html .= sprintf( '<li class="wg-li %s" data-code-language="%s">', $flag_class . $key_code, $key_code );
130
 
131
  $current_language_entry = $this->language_services->get_current_language_entry_from_key( $key_code );
132
  $name = $this->get_name_with_language_entry( $current_language_entry );
115
  $name = $this->get_name_with_language_entry( $current_language_entry );
116
 
117
  $uniq_id = 'wg' . uniqid( strtotime( 'now' ) ) . rand( 1, 1000 );
118
+ $button_html .= sprintf( '<input id="%s" class="weglot_choice" type="checkbox" name="menu"/><label for="%s" class="wgcurrent wg-li weglot-lang weglot-language %s" data-code-language="%s"><span>%s</span></label>', $uniq_id, $uniq_id, $flag_class . $current_language, $current_language_entry->getIso639(), $name );
119
 
120
  $button_html .= '<ul>';
121
 
126
  continue;
127
  }
128
 
129
+ $button_html .= sprintf( '<li class="wg-li weglot-lang weglot-language %s" data-code-language="%s">', $flag_class . $key_code, $key_code );
130
 
131
  $current_language_entry = $this->language_services->get_current_language_entry_from_key( $key_code );
132
  $name = $this->get_name_with_language_entry( $current_language_entry );
src/services/class-custom-url-service-weglot.php CHANGED
@@ -33,32 +33,40 @@ class Custom_Url_Service_Weglot {
33
  wp_reset_postdata();
34
  }
35
 
36
- global $post;
37
  $weglot_url = $this->request_url_services->get_weglot_url();
38
  $request_without_language = array_filter( explode( '/', $weglot_url->getPath() ), 'strlen' );
39
  $index_entries = count( $request_without_language );
40
  $custom_urls = $this->option_services->get_option( 'custom_urls' );
41
  $url_lang = $weglot_url->getForLanguage( $key_code );
42
  $original_language = weglot_get_original_language();
43
-
44
  $condition_test_custom_url = isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && ! is_post_type_archive() && ! is_category() && ! is_tax() && ! is_archive() && ! is_front_page() && ! is_home();
45
 
46
  if ( apply_filters( 'weglot_condition_test_custom_url', $condition_test_custom_url, $url_lang, $key_code ) ) {
47
  $slug_in_work = $request_without_language[ $index_entries ];
 
48
 
49
- // Search from original slug
50
- $key_slug = false;
51
- if ( isset( $custom_urls[ $key_code ] ) && $post ) {
52
- $key_slug = array_search( $post->post_name, $custom_urls[ $key_code ] ); //phpcs:ignore
53
- }
54
- if ( false !== $key_slug ) {
55
- $url_lang = str_replace( $slug_in_work, $key_slug, $url_lang );
56
- } else {
57
- if ( $post ) {
58
- $url_lang = str_replace( $slug_in_work, $post->post_name, $url_lang );
59
- }
60
  }
 
 
 
 
 
 
 
 
 
 
 
61
  }
 
62
  $link_button = apply_filters( 'weglot_link_language', $url_lang, $key_code );
63
 
64
  if (
33
  wp_reset_postdata();
34
  }
35
 
 
36
  $weglot_url = $this->request_url_services->get_weglot_url();
37
  $request_without_language = array_filter( explode( '/', $weglot_url->getPath() ), 'strlen' );
38
  $index_entries = count( $request_without_language );
39
  $custom_urls = $this->option_services->get_option( 'custom_urls' );
40
  $url_lang = $weglot_url->getForLanguage( $key_code );
41
  $original_language = weglot_get_original_language();
42
+ $current_language = weglot_get_current_language();
43
  $condition_test_custom_url = isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && ! is_post_type_archive() && ! is_category() && ! is_tax() && ! is_archive() && ! is_front_page() && ! is_home();
44
 
45
  if ( apply_filters( 'weglot_condition_test_custom_url', $condition_test_custom_url, $url_lang, $key_code ) ) {
46
  $slug_in_work = $request_without_language[ $index_entries ];
47
+ $original_slug_in_work = $slug_in_work;
48
 
49
+ if($current_language !== $original_language) {
50
+ if ( isset( $custom_urls[ $current_language ] )) {
51
+ $value_slug = array_key_exists($slug_in_work, $custom_urls[$current_language]) ? $custom_urls[$current_language][$slug_in_work] : false;
52
+ if ( false !== $value_slug ) {
53
+ $original_slug_in_work = $value_slug;
54
+ }
55
+ }
 
 
 
 
56
  }
57
+
58
+ if ( isset( $custom_urls[ $key_code ] )) {
59
+ $key_slug = array_search( $original_slug_in_work, $custom_urls[ $key_code ] ); //phpcs:ignore
60
+ if ( false !== $key_slug ) {
61
+ $url_lang = str_replace($slug_in_work, $key_slug, $url_lang);
62
+ }
63
+ }
64
+ else {
65
+
66
+ $url_lang = str_replace( $slug_in_work, $original_slug_in_work, $url_lang );
67
+ }
68
  }
69
+
70
  $link_button = apply_filters( 'weglot_link_language', $url_lang, $key_code );
71
 
72
  if (
src/services/class-generate-switcher-service-weglot.php CHANGED
@@ -46,14 +46,9 @@ class Generate_Switcher_Service_Weglot {
46
  * @param string $dom
47
  * @return string
48
  */
49
- public function check_weglot_menu( $dom ) {
50
- if ( strpos( $dom, 'menu-item-weglot' ) !== false ) {
51
- $dom .= sprintf( $this->string_version, WEGLOT_VERSION );
52
- return $dom;
53
- }
54
-
55
- return apply_filters( 'weglot_replace_weglot_menu', $dom );
56
- }
57
 
58
  /**
59
  * @since 2.3.0
@@ -62,7 +57,7 @@ class Generate_Switcher_Service_Weglot {
62
  * @return string
63
  */
64
  public function render_default_button( $dom ) {
65
- if ( strpos( $dom, sprintf( $this->string_version, WEGLOT_VERSION ) ) !== false ) {
66
  return $dom;
67
  }
68
 
46
  * @param string $dom
47
  * @return string
48
  */
49
+ public function check_weglot_menu( $dom ) {
50
+ return apply_filters( 'weglot_replace_weglot_menu', $dom );
51
+ }
 
 
 
 
 
52
 
53
  /**
54
  * @since 2.3.0
57
  * @return string
58
  */
59
  public function render_default_button( $dom ) {
60
+ if ( strpos( $dom, 'weglot-language' ) !== false ) {
61
  return $dom;
62
  }
63
 
src/services/class-option-service-weglot.php CHANGED
@@ -28,8 +28,6 @@ class Option_Service_Weglot {
28
  protected $options_default = [
29
  'api_key_private' => '',
30
  'api_key' => '',
31
- 'has_first_settings' => true,
32
- 'show_box_first_settings' => false,
33
  'language_from' => 'en',
34
  'languages' => [],
35
  'auto_switch' => false,
@@ -48,13 +46,13 @@ class Option_Service_Weglot {
48
  'flag_type' => Helper_Flag_Type::RECTANGLE_MAT,
49
  'custom_css' => '',
50
  ],
51
- 'has_first_settings' => true,
52
- 'show_box_first_settings' => false,
53
  'rtl_ltr_style' => '',
54
- 'active_wc_reload' => false,
55
  'flag_css' => '',
56
  ],
57
  'allowed' => true,
 
 
58
  ];
59
 
60
  /**
@@ -66,7 +64,7 @@ class Option_Service_Weglot {
66
  'menu_switcher' => [],
67
  'custom_urls' => [],
68
  'flag_css' => '',
69
- 'active_wc_reload' => false,
70
  ];
71
 
72
  /**
@@ -387,6 +385,10 @@ class Option_Service_Weglot {
387
  $exclude_blocks[] = '#query-monitor';
388
  $exclude_blocks[] = '.menu-item-weglot';
389
  $exclude_blocks[] = '.menu-item-weglot a';
 
 
 
 
390
 
391
  return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
392
  }
@@ -424,6 +426,7 @@ class Option_Service_Weglot {
424
  $exclude_urls[] = '/sitemaps.xml';
425
  $exclude_urls[] = 'wp-comments-post.php';
426
  $exclude_urls[] = '/ct_template'; // Compatibility Oxygen
 
427
 
428
  $translate_amp = weglot_get_translate_amp_translation();
429
  if ( ! $translate_amp ) {
28
  protected $options_default = [
29
  'api_key_private' => '',
30
  'api_key' => '',
 
 
31
  'language_from' => 'en',
32
  'languages' => [],
33
  'auto_switch' => false,
46
  'flag_type' => Helper_Flag_Type::RECTANGLE_MAT,
47
  'custom_css' => '',
48
  ],
 
 
49
  'rtl_ltr_style' => '',
50
+ 'active_wc_reload' => true,
51
  'flag_css' => '',
52
  ],
53
  'allowed' => true,
54
+ 'has_first_settings' => true,
55
+ 'show_box_first_settings' => false,
56
  ];
57
 
58
  /**
64
  'menu_switcher' => [],
65
  'custom_urls' => [],
66
  'flag_css' => '',
67
+ 'active_wc_reload' => true,
68
  ];
69
 
70
  /**
385
  $exclude_blocks[] = '#query-monitor';
386
  $exclude_blocks[] = '.menu-item-weglot';
387
  $exclude_blocks[] = '.menu-item-weglot a';
388
+ $exclude_blocks[] = '.mini-cart-counter';
389
+ $exclude_blocks[] = '.material-icons';
390
+ $exclude_blocks[] = '.fas';
391
+ $exclude_blocks[] = '.amount'; //Added to prevent prices to pass
392
 
393
  return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
394
  }
426
  $exclude_urls[] = '/sitemaps.xml';
427
  $exclude_urls[] = 'wp-comments-post.php';
428
  $exclude_urls[] = '/ct_template'; // Compatibility Oxygen
429
+ $exclude_urls[] = '/main-sitemap.xsl'; // SEO by Rank Math
430
 
431
  $translate_amp = weglot_get_translate_amp_translation();
432
  if ( ! $translate_amp ) {
src/services/class-other-translate-service-weglot.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Services;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- use Weglot\Client\Api\WordEntry;
10
- use Weglot\Client\Api\Enum\WordType;
11
- use Weglot\Client\Client;
12
- use Weglot\Client\Endpoint\Translate;
13
- use Weglot\Client\Api\TranslateEntry;
14
- use Weglot\Client\Api\Enum\BotType;
15
-
16
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
17
-
18
-
19
- /**
20
- *
21
- * @since 2.0
22
- */
23
- class Other_Translate_Service_Weglot {
24
- protected $max_chars = 500;
25
-
26
- /**
27
- * @since 3.0.0
28
- */
29
- public function __construct() {
30
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
31
- }
32
-
33
- /**
34
- * @since 2.0
35
- *
36
- * @param string $content
37
- * @return string
38
- */
39
- public function translate_words( $content ) {
40
- $words = apply_filters( 'weglot_words_translate', [] );
41
-
42
- if ( empty( $words ) || ! is_array( $words ) ) {
43
- return $content;
44
- }
45
-
46
- // TranslateEntry
47
- $params = [
48
- 'language_from' => weglot_get_original_language(),
49
- 'language_to' => weglot_get_current_language(),
50
- 'request_url' => weglot_get_current_full_url(),
51
- 'bot' => BotType::HUMAN,
52
- ];
53
-
54
- $translate = new TranslateEntry( $params );
55
-
56
- $word_collection = $translate->getInputWords();
57
-
58
- foreach ( $words as $value ) {
59
- if ( strlen( $value ) > $this->max_chars && preg_match( '/\s|。|。|︒/u', $value ) === false ) {
60
- continue;
61
- }
62
-
63
- $value = Helper_Json_Inline_Weglot::format_for_api( $value );
64
- $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
65
- }
66
-
67
- $client = $this->parser_services->get_client();
68
- $translate = new Translate( $translate, $client );
69
-
70
- $object = $translate->handle();
71
-
72
- foreach ( $object->getInputWords() as $key => $input_word ) {
73
- $from_input = Helper_Json_Inline_Weglot::unformat_from_api( $input_word->getWord() );
74
-
75
- $output_unformat_from_api = apply_filters( 'weglot_other_words_unformat_from_api', true );
76
- $to_output = $object->getOutputWords()[ $key ]->getWord();
77
- if ( $output_unformat_from_api ) {
78
- $to_output = Helper_Json_Inline_Weglot::unformat_from_api( $object->getOutputWords()[ $key ]->getWord() );
79
- }
80
-
81
- $from_input = preg_quote( $from_input ); // To avoid special char like | to be interpreted as regex.
82
- if ( ! preg_match( "#<[^>\"']*" . $from_input . "[^>\"']*>#", $content ) ) {
83
- $content = preg_replace( "#\b$from_input\b#", $to_output, $content );
84
- }
85
- }
86
-
87
- return $content;
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/services/class-parser-service-weglot.php CHANGED
@@ -36,7 +36,7 @@ class Parser_Service_Weglot {
36
  } else {
37
  $this->dom_checkers_services = weglot_get_service( 'Dom_Checkers_Service_Weglot' );
38
  }
39
-
40
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
41
  }
42
 
@@ -89,6 +89,7 @@ class Parser_Service_Weglot {
89
  } else {
90
  $parser = new Parser( $client, $config, $exclude_blocks );
91
  $parser->getDomCheckerProvider()->addCheckers( $this->dom_checkers_services->get_dom_checkers() );
 
92
  $ignored_nodes = apply_filters( 'weglot_get_parser_ignored_nodes', $parser->getIgnoredNodesFormatter()->getIgnoredNodes() );
93
 
94
  $parser->getIgnoredNodesFormatter()->setIgnoredNodes( $ignored_nodes );
36
  } else {
37
  $this->dom_checkers_services = weglot_get_service( 'Dom_Checkers_Service_Weglot' );
38
  }
39
+ $this->regex_checkers_services = weglot_get_service( 'Regex_Checkers_Service_Weglot' );
40
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
41
  }
42
 
89
  } else {
90
  $parser = new Parser( $client, $config, $exclude_blocks );
91
  $parser->getDomCheckerProvider()->addCheckers( $this->dom_checkers_services->get_dom_checkers() );
92
+ $parser->getRegexCheckerProvider()->addCheckers( $this->regex_checkers_services->get_regex_checkers() );
93
  $ignored_nodes = apply_filters( 'weglot_get_parser_ignored_nodes', $parser->getIgnoredNodesFormatter()->getIgnoredNodes() );
94
 
95
  $parser->getIgnoredNodesFormatter()->setIgnoredNodes( $ignored_nodes );
src/services/class-private-language-service-weglot.php CHANGED
@@ -44,7 +44,7 @@ class Private_Language_Service_Weglot {
44
 
45
  unset( $private_mode_languages['active'] );
46
  foreach ( $private_mode_languages as $lang => $lang_active ) {
47
- if ( $key_lang === $lang && $lang_active && ! current_user_can( $this->role_private_mode ) ) {
48
  return true;
49
  }
50
  }
@@ -52,13 +52,17 @@ class Private_Language_Service_Weglot {
52
  return false;
53
  }
54
 
 
 
 
 
55
  /**
56
  * @since 2.4.0
57
  * @return bool
58
  */
59
  public function private_mode_for_all_languages() {
60
  $private_mode_languages = $this->option_services->get_option( 'private_mode' );
61
- if ( current_user_can( $this->role_private_mode ) ) { // No check if admin
62
  return false;
63
  }
64
 
44
 
45
  unset( $private_mode_languages['active'] );
46
  foreach ( $private_mode_languages as $lang => $lang_active ) {
47
+ if ( $key_lang === $lang && $lang_active && ! $this->is_allowed_view_private() ) {
48
  return true;
49
  }
50
  }
52
  return false;
53
  }
54
 
55
+ public function is_allowed_view_private() {
56
+ return current_user_can( $this->role_private_mode ) || strpos(weglot_get_current_full_url(), 'weglot-private=1') !== false;
57
+ }
58
+
59
  /**
60
  * @since 2.4.0
61
  * @return bool
62
  */
63
  public function private_mode_for_all_languages() {
64
  $private_mode_languages = $this->option_services->get_option( 'private_mode' );
65
+ if ( $this->is_allowed_view_private() ) { // No check if admin
66
  return false;
67
  }
68
 
src/services/class-redirect-service-weglot.php CHANGED
@@ -93,7 +93,19 @@ class Redirect_Service_Weglot {
93
  header( "Location: $url_auto_redirect", true, 302 );
94
  exit();
95
  }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  /**
99
  * @since 2.0
93
  header( "Location: $url_auto_redirect", true, 302 );
94
  exit();
95
  }
96
+
97
+ if (
98
+ !in_array( $server_lang, $destination_languages ) && // phpcs:ignore
99
+ $server_lang !== weglot_get_original_language() &&
100
+ weglot_get_original_language() === $this->request_url_services->get_current_language() &&
101
+ ! $this->private_services->is_active_private_mode_for_lang( $server_lang ) &&
102
+ $this->option_services->get_option('autoswitch_fallback') !== null
103
+ ) {
104
+ $url_auto_redirect = apply_filters( 'weglot_url_auto_redirect', $this->request_url_services->get_weglot_url()->getForLanguage( $this->option_services->get_option('autoswitch_fallback') ) );
105
+ header( "Location: $url_auto_redirect", true, 302 );
106
+ exit();
107
+ }
108
+ }
109
 
110
  /**
111
  * @since 2.0
src/services/class-regex-checkers-service-weglot.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Services;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use Weglot\Parser\Check\Regex\RegexChecker;
10
+ use Weglot\Util\SourceType;
11
+ use Weglot\Util\Text;
12
+
13
+ /**
14
+ * Dom Checkers
15
+ *
16
+ * @since 2.0
17
+ * @version 2.0.6
18
+ */
19
+ class Regex_Checkers_Service_Weglot {
20
+
21
+ /**
22
+ * @since 2.3.0
23
+ */
24
+ public function __construct() {
25
+
26
+ }
27
+
28
+ /**
29
+ * @since 2.0
30
+ * @return array
31
+ */
32
+ public function get_regex_checkers() {
33
+
34
+ $checkers = array();
35
+
36
+ $other_words = apply_filters( 'weglot_words_translate', [] );
37
+ foreach ($other_words as $other_word) {
38
+ array_push($checkers, new RegexChecker( '#\b' . $other_word . '\b#' , SourceType::SOURCE_TEXT , 0));
39
+ }
40
+
41
+
42
+ $thirds = array_diff( scandir( WEGLOT_DIR . '/src/third' ), [ '..', '.' ] );
43
+ foreach ($thirds as $third) {
44
+ $files = array_diff( scandir( WEGLOT_DIR . '/src/third/' . $third ), [ '..', '.' ] );
45
+
46
+ foreach ($files as $file) {
47
+ if (strpos($file, 'active.php') !== false) {
48
+ $file = Text::removeFileExtension( $file );
49
+ $file = str_replace( 'class-', '', $file );
50
+ $file = implode( '_', array_map( 'ucfirst', explode( '-', $file ) ) );
51
+ $service = weglot_get_service( $file );
52
+ if(isset($service)) {
53
+ $active = $service->is_active();
54
+ if($active) {
55
+ $regexDir = WEGLOT_DIR . '/src/third/' . $third . '/regexcheckers/';
56
+ if(is_dir($regexDir)) {
57
+ $regexFiles = array_diff( scandir( WEGLOT_DIR . '/src/third/' . $third . '/regexcheckers/' ), [ '..', '.' ] );
58
+
59
+ foreach ($regexFiles as $regexFile) {
60
+ $filename = Text::removeFileExtension( $regexFile );
61
+ $filename = str_replace( 'class-', '', $filename );
62
+ $filename = implode( '_', array_map( 'ucfirst', explode( '-', $filename ) ) );
63
+ $class = '\\WeglotWP\\Third\\' . implode( '', array_map( 'ucfirst', explode( '-', $third ) ) ) . '\\Regexcheckers\\' . $filename;
64
+ array_push($checkers, new RegexChecker( $class::REGEX , $class::TYPE, $class::VAR_NUMBER , $class::$KEYS));
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ return apply_filters( 'weglot_get_regex_checkers', $checkers );
74
+ }
75
+
76
+ }
src/services/class-replace-url-service-weglot.php CHANGED
@@ -6,6 +6,8 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
7
  }
8
 
 
 
9
  use WeglotWP\Helpers\Helper_Replace_Url_Weglot;
10
 
11
  /**
@@ -43,6 +45,26 @@ class Replace_Url_Service_Weglot {
43
  return apply_filters( 'weglot_replace_link', $dom );
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  /**
47
  * Replace link
48
  *
@@ -107,7 +129,7 @@ class Replace_Url_Service_Weglot {
107
  return (
108
  (
109
  ( 'h' === $current_url[0] && $parsed_url['host'] === $server_host ) ||
110
- ( isset( $current_url[0] ) && $current_url[0] === '/' && ( isset( $current_url[1] ) ) && '/' !== $current_url[1] ) //phpcs:ignore
111
  ) &&
112
  strpos( $current_url, $admin_url ) === false
113
  && strpos( $current_url, 'wp-login' ) === false
6
  exit;
7
  }
8
 
9
+ use Weglot\Parser\Parser;
10
+ use Weglot\Util\SourceType;
11
  use WeglotWP\Helpers\Helper_Replace_Url_Weglot;
12
 
13
  /**
45
  return apply_filters( 'weglot_replace_link', $dom );
46
  }
47
 
48
+ public function replace_link_in_json( $json ) {
49
+
50
+ $replace_urls = apply_filters( 'weglot_ajax_replace_urls', [ 'redirecturl', 'url', 'link' ] );
51
+ foreach ( $json as $key => $val ) {
52
+ if ( is_array( $val ) ) {
53
+ $json[ $key ] = $this->replace_link_in_json( $val );
54
+ } else {
55
+ if ( Parser::getSourceType( $val ) == SourceType::SOURCE_HTML ) {
56
+ $json[ $key ] = $this->replace_link_in_dom( $val );
57
+ } else {
58
+ if ( in_array( $key, $replace_urls, true ) ) {
59
+ $json[ $key ] = $this->replace_link_service->replace_url( $val );
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ return $json;
66
+ }
67
+
68
  /**
69
  * Replace link
70
  *
129
  return (
130
  (
131
  ( 'h' === $current_url[0] && $parsed_url['host'] === $server_host ) ||
132
+ ( isset( $current_url[0] ) && $current_url[0] === '/' && ( !isset( $current_url[1]) || ( isset( $current_url[1] ) ) && '/' !== $current_url[1] )) //phpcs:ignore
133
  ) &&
134
  strpos( $current_url, $admin_url ) === false
135
  && strpos( $current_url, 'wp-login' ) === false
src/services/class-request-url-service-weglot.php CHANGED
@@ -36,7 +36,7 @@ class Request_Url_Service_Weglot {
36
  * Use for abstract \Weglot\Util\Url
37
  *
38
  * @param string $url
39
- * @return Weglot\Util\Url
40
  */
41
  public function create_url_object( $url ) {
42
  return new Url(
36
  * Use for abstract \Weglot\Util\Url
37
  *
38
  * @param string $url
39
+ * @return Url
40
  */
41
  public function create_url_object( $url ) {
42
  return new Url(
src/services/class-translate-json-ld.php DELETED
@@ -1,318 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Services;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
10
- use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
11
-
12
- use Weglot\Client\Api\WordCollection;
13
- use Weglot\Client\Api\TranslateEntry;
14
- use Weglot\Client\Endpoint\Translate;
15
- use Weglot\Client\Api\WordEntry;
16
- use Weglot\Client\Api\Enum\WordType;
17
- use JsonPath\JsonObject;
18
- use Weglot\Parser\ConfigProvider\ServerConfigProvider;
19
-
20
- /**
21
- * @since 3.0.3
22
- */
23
- class Translate_Json_Ld {
24
-
25
- /**
26
- * @since 3.0.3
27
- * @var integer
28
- */
29
- protected $index = 0;
30
-
31
- /**
32
- * @since 3.0.3
33
- * @var integer
34
- */
35
- protected $limit = 0;
36
-
37
- /**
38
- * @since 3.0.3
39
- * @var array
40
- */
41
- protected $indexes = [];
42
-
43
- /**
44
- * @since 3.0.3
45
- * @var array
46
- */
47
- protected $collections = [];
48
-
49
- /**
50
- * @since 3.0.3
51
- * @var integer
52
- */
53
- protected $index_json_collections = [];
54
-
55
- /**
56
- * @since 3.0.3
57
- * @var integer
58
- */
59
- protected $limit_json_collections = [];
60
-
61
- /**
62
- * @since 3.0.3
63
- * @var array
64
- */
65
- protected $keys_json_ld_translate = [
66
- 'name',
67
- 'description',
68
- 'headline',
69
- 'articleSection'
70
- ];
71
-
72
- /**
73
- * @since 3.0.3
74
- */
75
- public function __construct() {
76
- $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
77
- $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
78
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
79
- }
80
-
81
- /**
82
- * @since 3.0.3
83
- *
84
- * @param array $json
85
- * @param string $path
86
- * @return array
87
- */
88
- protected function check_json_to_translate( $json, $path = '$' ) {
89
- foreach ( $json as $key => $val ) {
90
- if ( is_array( $val ) ) {
91
- if ( is_string( $key ) ) {
92
- if ( false === strpos( $key, '.' ) && false === strpos( $key, '@' ) ) {
93
- $newpath = "$path.$key";
94
- } else {
95
- $newpath = sprintf( '%s["%s"]', $path, $key );
96
- }
97
- } else {
98
- $newpath = sprintf( '%s[%s]', $path, $key );
99
- }
100
-
101
- $this->check_json_to_translate( $val, $newpath );
102
- } else {
103
- if ( false === strpos( $key, '.' ) ) {
104
- $newpath = "$path.$key";
105
- } else {
106
- $newpath = sprintf( '%s["%s"]', $path, $key );
107
- }
108
-
109
- if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
110
- try {
111
- $parser = $this->parser_services->get_parser();
112
- $words = $parser->parse( $val );
113
- if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
114
- continue;
115
- }
116
- $this->collections = array_merge( $this->collections, $words->jsonSerialize() );
117
- $this->limit = $this->index + $words->count();
118
- $this->indexes[ $newpath ] = [
119
- 'start' => $this->index,
120
- 'limit' => $this->limit,
121
- ]; //phpcs:ignore
122
- $this->index += $words->count();
123
- } catch ( \Exception $e ) {
124
- continue;
125
- }
126
- } else {
127
- if ( in_array( $key, $this->keys_json_ld_translate, true ) ) {
128
- try {
129
- $parser = $this->parser_services->get_parser();
130
- $words = $parser->parse( $val );
131
- if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
132
- continue;
133
- }
134
- $this->collections = array_merge( $this->collections, $words->jsonSerialize() );
135
- $this->limit = $this->index + $words->count();
136
- $this->indexes[ $newpath ] = [
137
- 'start' => $this->index,
138
- 'limit' => $this->limit,
139
- ];
140
- $this->index += $words->count();
141
- } catch ( \Exception $e ) {
142
- continue;
143
- }
144
- }
145
- }
146
- }
147
- }
148
-
149
- return [
150
- $this->indexes,
151
- $this->collections,
152
- ];
153
- }
154
-
155
- /**
156
- * @since 3.0.3
157
- * @return string
158
- */
159
- protected function handle_translate_jsons() {
160
- $parser = $this->parser_services->get_parser();
161
-
162
- // Translate endpoint parameters
163
- $params = [
164
- 'language_from' => weglot_get_original_language(),
165
- 'language_to' => weglot_get_current_language(),
166
- ];
167
-
168
- if ( $parser->getConfigProvider() instanceof ServerConfigProvider ) {
169
- $parser->getConfigProvider()->loadFromServer();
170
- }
171
-
172
- $params = array_merge( $params, $parser->getConfigProvider()->asArray() );
173
-
174
- $translate = new TranslateEntry( $params );
175
- $word_collection = $translate->getInputWords();
176
- foreach ( $this->collections as $value ) {
177
- $word_collection->addOne( new WordEntry( $value['w'], $value['t'] ) );
178
- }
179
-
180
- $translate = new Translate( $translate, $parser->getClient() );
181
- return $translate->handle();
182
-
183
- }
184
-
185
- /**
186
- *
187
- * @param string $json
188
- * @param string $key
189
- * @param array $data
190
- * @return void
191
- */
192
- protected function replace_json_content( $json, $key, $data ){
193
-
194
- $json_object = new JsonObject( $json );
195
-
196
- list( $output_words, $input_words ) = $data;
197
-
198
- $array_keys_indexes = array_keys($this->indexes);
199
- for ( $i= $this->index_json_collections[$key]; $i < $this->limit_json_collections[$key] ; $i++) {
200
- try {
201
- if( !array_key_exists($i, $array_keys_indexes)){
202
- continue;
203
- }
204
-
205
- $path = $array_keys_indexes[$i];
206
- $index = $this->indexes[ $path ];
207
- $y = 0;
208
-
209
- do {
210
- if ( is_null( $input_words[ $y ] ) || is_null( $output_words[ $y ] ) ) {
211
- $y++;
212
- continue;
213
- }
214
-
215
- $input_word = $input_words[ $y ]->getWord();
216
- $output_word = $output_words[ $y ]->getWord();
217
- $str = $json_object->get( $path )[0];
218
-
219
- $json_object->set( $path, str_replace( $input_word, $output_word, $str ) );
220
- $y++;
221
- } while ( $y < $index['limit'] );
222
- } catch (\Exception $e) {
223
- continue;
224
- }
225
- }
226
-
227
- return json_decode( $json_object->getJson(), JSON_PRETTY_PRINT );
228
- }
229
-
230
- /**
231
- * @since 3.0.3
232
- * @param array simple_html_dom_node $jsons
233
- * @param array $translated_words
234
- * @return array simple_html_dom_node
235
- */
236
- public function replace_jsons_translated( $jsons, $translated_words ){
237
- $output_words = $translated_words->getOutputWords();
238
-
239
- if ( $output_words->count() !== count( $this->collections ) || $output_words->count() === 0 ) {
240
- return $jsons;
241
- }
242
-
243
- $input_words = $translated_words->getInputWords();
244
- $i = 0;
245
-
246
- foreach ( $jsons as $key => $row ) {
247
- $json = json_decode($row->innertext, true);
248
- if ( json_last_error() !== JSON_ERROR_NONE) {
249
- continue;
250
- }
251
-
252
- $json = $this->replace_json_content($json, $key, [
253
- $output_words,
254
- $input_words
255
- ]);
256
-
257
- $row->innertext = json_encode($json, JSON_PRETTY_PRINT);
258
-
259
- }
260
-
261
- return $jsons;
262
-
263
- }
264
-
265
- /**
266
- * @since 3.0.3
267
- * @param string $dom
268
- * @return string
269
- */
270
- public function handle( $domString ) {
271
-
272
- $dom = \WGSimpleHtmlDom\str_get_html(
273
- $domString,
274
- true,
275
- true,
276
- WG_DEFAULT_TARGET_CHARSET,
277
- false
278
- );
279
-
280
- if ($dom === false) {
281
- return $domString;
282
- }
283
-
284
- $this->keys_json_ld_translate = apply_filters( 'weglot_keys_json_ld_translate', $this->keys_json_ld_translate );
285
-
286
- $jsons = $dom->find( 'script[type="application/ld+json"]' );
287
- foreach ( $jsons as $key => $row ) {
288
- $json = json_decode($row->innertext, true);
289
- if ( json_last_error() !== JSON_ERROR_NONE) {
290
- continue;
291
- }
292
-
293
- $this->index_json_collections[$key] = count($this->collections);
294
- $this->check_json_to_translate($json);
295
- $this->limit_json_collections[$key] = count($this->collections);
296
-
297
- }
298
-
299
- $translated_words = null;
300
- try {
301
- $translated_words = $this->handle_translate_jsons();
302
- } catch (\Exception $e) {
303
- return $dom->save();
304
- }
305
-
306
-
307
- try {
308
- $translated_jsons = $this->replace_jsons_translated( $jsons, $translated_words );
309
- } catch (\Exception $e) {
310
- return $dom->save();
311
- }
312
-
313
- return $dom->save();
314
- }
315
- }
316
-
317
-
318
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/services/class-translate-json-service.php DELETED
@@ -1,238 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Services;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
10
- use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
11
-
12
- use Weglot\Client\Api\WordCollection;
13
- use Weglot\Client\Api\TranslateEntry;
14
- use Weglot\Client\Endpoint\Translate;
15
- use Weglot\Client\Api\WordEntry;
16
- use Weglot\Client\Api\Enum\WordType;
17
- use JsonPath\JsonObject;
18
- use Weglot\Parser\ConfigProvider\ServerConfigProvider;
19
-
20
- /**
21
- * @since 2.6.0
22
- */
23
- class Translate_Json_Service {
24
-
25
- /**
26
- * @since 2.6.0
27
- * @var integer
28
- */
29
- protected $index = 0;
30
-
31
- /**
32
- * @since 2.6.0
33
- * @var integer
34
- */
35
- protected $limit = 0;
36
-
37
- /**
38
- * @since 2.6.0
39
- * @var array
40
- */
41
- protected $indexes = [];
42
-
43
- /**
44
- * @since 2.6.0
45
- * @var array
46
- */
47
- protected $collections = [];
48
-
49
- /**
50
- * @since 2.6.0
51
- */
52
- public function __construct() {
53
- $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
54
- $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
55
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
56
- }
57
-
58
- /**
59
- * @since 2.6.0
60
- *
61
- * @param array $json
62
- * @param string $path
63
- * @return array
64
- */
65
- protected function check_json_to_translate( $json, $path = '$' ) {
66
- foreach ( $json as $key => $val ) {
67
- if ( is_array( $val ) ) {
68
- if ( is_string( $key ) ) {
69
- if ( false === strpos( $key, '.' ) ) {
70
- $newpath = "$path.$key";
71
- } else {
72
- $newpath = sprintf( '%s["%s"]', $path, $key );
73
- }
74
- } else {
75
- $newpath = sprintf( '%s[%s]', $path, $key );
76
- }
77
-
78
- $this->check_json_to_translate( $val, $newpath );
79
- } else {
80
- if ( false === strpos( $key, '.' ) ) {
81
- $newpath = "$path.$key";
82
- } else {
83
- $newpath = sprintf( '%s["%s"]', $path, $key );
84
- }
85
-
86
- if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
87
- try {
88
- $parser = $this->parser_services->get_parser();
89
- $words = $parser->parse( $val );
90
- if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
91
- continue;
92
- }
93
- $this->collections = array_merge( $this->collections, $words->jsonSerialize() );
94
- $this->limit = $this->index + $words->count();
95
- $this->indexes[ $newpath ] = [
96
- 'start' => $this->index,
97
- 'limit' => $this->limit,
98
- ]; //phpcs:ignore
99
- $this->index += $words->count();
100
- } catch ( \Exception $e ) {
101
- continue;
102
- }
103
- } else {
104
- if ( Helper_Keys_Json_Weglot::translate_key_for_path( $key ) ) {
105
- try {
106
- $parser = $this->parser_services->get_parser();
107
- $words = $parser->parse( $val );
108
- if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
109
- continue;
110
- }
111
- $this->collections = array_merge( $this->collections, $words->jsonSerialize() );
112
- $this->limit = $this->index + $words->count();
113
- $this->indexes[ $newpath ] = [
114
- 'start' => $this->index,
115
- 'limit' => $this->limit,
116
- ];
117
- $this->index += $words->count();
118
- } catch ( \Exception $e ) {
119
- continue;
120
- }
121
- }
122
- }
123
- }
124
- }
125
-
126
- return [
127
- $this->indexes,
128
- $this->collections,
129
- ];
130
- }
131
-
132
- /**
133
- * @since 2.6.0
134
- * @param array $json
135
- * @return JsonObject
136
- */
137
- protected function translate_json_strings( $json ) {
138
- $parser = $this->parser_services->get_parser();
139
-
140
- // Translate endpoint parameters
141
- $params = [
142
- 'language_from' => weglot_get_original_language(),
143
- 'language_to' => weglot_get_current_language(),
144
- ];
145
-
146
- if ( $parser->getConfigProvider() instanceof ServerConfigProvider ) {
147
- $parser->getConfigProvider()->loadFromServer();
148
- }
149
-
150
- $params = array_merge( $params, $parser->getConfigProvider()->asArray() );
151
- $json_object = new JsonObject( $json );
152
- try {
153
- $translate = new TranslateEntry( $params );
154
- $word_collection = $translate->getInputWords();
155
- foreach ( $this->collections as $value ) {
156
- $word_collection->addOne( new WordEntry( $value['w'], $value['t'] ) );
157
- }
158
- } catch ( \Exception $e ) {
159
- return $json_object;
160
- }
161
-
162
- $translate = new Translate( $translate, $parser->getClient() );
163
- $translated = $translate->handle();
164
-
165
- $output_words = $translated->getOutputWords();
166
-
167
- if ( $output_words->count() !== count( $this->collections ) || $output_words->count() === 0 ) {
168
- return $json_object;
169
- }
170
-
171
- $input_words = $translated->getInputWords();
172
- $i = 0;
173
-
174
- foreach ( $this->indexes as $path => $index ) {
175
- do {
176
- if ( is_null( $input_words[ $i ] ) || is_null( $output_words[ $i ] ) ) {
177
- $i++;
178
- continue;
179
- }
180
-
181
- $input_word = $input_words[ $i ]->getWord();
182
- $output_word = $output_words[ $i ]->getWord();
183
- $str = $json_object->get( $path )[0];
184
-
185
- $json_object->set( $path, str_replace( $input_word, $output_word, $str ) );
186
- $i++;
187
- } while ( $i < $index['limit'] );
188
- }
189
-
190
- return $json_object;
191
- }
192
-
193
-
194
- /**
195
- * @since 2.6.0
196
- * @param array $json
197
- * @return array
198
- */
199
- public function replace_json_links( $json ) {
200
- $replace_urls = apply_filters( 'weglot_ajax_replace_urls', [ 'redirecturl', 'url', 'link' ] );
201
-
202
- foreach ( $json as $key => $val ) {
203
- if ( is_array( $val ) ) {
204
- $json[ $key ] = $this->replace_json_links( $val );
205
- } else {
206
- if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
207
- $json[ $key ] = $this->replace_url_services->replace_link_in_dom( $val );
208
- } else {
209
- if ( in_array( $key, $replace_urls, true ) ) {
210
- $json[ $key ] = $this->replace_link_services->replace_url( $val );
211
- }
212
- }
213
- }
214
- }
215
-
216
- return $json;
217
- }
218
-
219
-
220
- /**
221
- * @since 2.6.0
222
- * @param array $json
223
- * @param mixed $path
224
- * @return JsonObject
225
- */
226
- public function translate_json( $json ) {
227
- $this->check_json_to_translate( $json );
228
- $json_object = $this->translate_json_strings( $json );
229
- $json = json_decode( $json_object->getJson(), true );
230
-
231
- $json = $this->replace_json_links( $json );
232
-
233
- return $json;
234
- }
235
- }
236
-
237
-
238
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/services/class-translate-service-weglot.php CHANGED
@@ -6,6 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
7
  }
8
 
 
9
  use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
10
  use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
11
 
@@ -25,14 +26,7 @@ class Translate_Service_Weglot {
25
  $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
26
  $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
27
  $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
28
- $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
29
- $this->ninja_active_services = weglot_get_service( 'Ninja_Active_Weglot' );
30
- $this->caldera_active_services = weglot_get_service( 'Caldera_Active' );
31
- $this->wpforms_active_services = weglot_get_service( 'WPForms_Active' );
32
- $this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
33
- $this->translate_json_service = weglot_get_service( 'Translate_Json_Service' );
34
  $this->generate_switcher_service = weglot_get_service( 'Generate_Switcher_Service_Weglot' );
35
- $this->translate_json_ld_services = weglot_get_service( 'Translate_Json_Ld' );
36
  }
37
 
38
 
@@ -100,38 +94,14 @@ class Translate_Service_Weglot {
100
  try {
101
  switch ( $type ) {
102
  case 'json':
103
- $json = \json_decode( $content, true );
104
- $content = $this->translate_json_service->translate_json( $json );
105
- $content = apply_filters( 'weglot_json_treat_page', $content );
106
-
107
- return wp_json_encode( $content );
108
  case 'html':
109
- $translated_content = $parser->translate( $content, $this->original_language, $this->current_language ); // phpcs:ignore
110
- if ( $this->wc_active_services->is_active() ) {
111
- // Improve this with multiple service
112
- $translated_content = weglot_get_service( 'WC_Translate_Weglot' )->translate_words( $translated_content );
113
- }
114
- if ( $this->ninja_active_services->is_active() ) {
115
- // Improve this with multiple service
116
- $translated_content = weglot_get_service( 'Ninja_Translate_Json_Weglot' )->translate_words( $translated_content );
117
- }
118
- if ( $this->caldera_active_services->is_active() ) {
119
- // Improve this with multiple service
120
- $translated_content = weglot_get_service( 'Caldera_Translate' )->translate_words( $translated_content );
121
- }
122
- if ( $this->wpforms_active_services->is_active() ) {
123
- // Improve this with multiple service
124
- $translated_content = weglot_get_service( 'WPForms_Translate' )->translate_words( $translated_content );
125
- }
126
-
127
- if( apply_filters( 'weglot_translate_json_ld', false ) ) {
128
- $translated_content = $this->translate_json_ld_services->handle( $translated_content );
129
- }
130
-
131
- $translated_content = $this->other_translate_services->translate_words( $translated_content );
132
-
133
  $translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
134
-
135
  return $this->weglot_render_dom( $translated_content );
136
  default:
137
  $name_filter = sprintf( 'weglot_%s_treat_page', $type );
@@ -154,42 +124,6 @@ class Translate_Service_Weglot {
154
  }
155
  }
156
 
157
- /**
158
- * @since 2.3.0
159
- * @version 2.4.0
160
- * @param array $array
161
- * @return array
162
- */
163
- public function translate_array( $array ) {
164
- $array_not_ajax_html = apply_filters( 'weglot_array_not_ajax_html', [ 'redirecturl', 'url' ] );
165
- foreach ( $array as $key => $val ) {
166
- if ( is_array( $val ) ) {
167
- $array[ $key ] = $this->translate_array( $val );
168
- } else {
169
- if ( $this->is_ajax_html( $val ) ) {
170
- try {
171
- $parser = $this->parser_services->get_parser();
172
- $array[ $key ] = $parser->translate( $val, $this->original_language, $this->current_language ); //phpcs:ignore
173
- } catch ( \Exception $e ) {
174
- continue;
175
- }
176
- } elseif ( in_array( $key, $array_not_ajax_html, true ) ) {
177
- $array[$key] = $this->replace_link_services->replace_url( $val ); //phpcs:ignore
178
- } else {
179
- if ( Helper_Keys_Json_Weglot::translate_key_for_path( $key ) ) {
180
- try {
181
- $parser = $this->parser_services->get_parser();
182
- $array[ $key ] = $parser->translate( $val, $this->original_language, $this->current_language ); //phpcs:ignore
183
- } catch ( \Exception $e ) {
184
- continue;
185
- }
186
- }
187
- }
188
- }
189
- }
190
- return $array;
191
- }
192
-
193
 
194
  /**
195
  * @since 2.3.0
6
  exit;
7
  }
8
 
9
+ use Weglot\Client\Api\Exception\ApiError;
10
  use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
11
  use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
12
 
26
  $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
27
  $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
28
  $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
 
 
 
 
 
 
29
  $this->generate_switcher_service = weglot_get_service( 'Generate_Switcher_Service_Weglot' );
 
30
  }
31
 
32
 
94
  try {
95
  switch ( $type ) {
96
  case 'json':
97
+ $extraKeys = apply_filters( 'weglot_add_json_keys' , array() );
98
+ $translated_content = $parser->translate( $content, $this->original_language, $this->current_language, $extraKeys );
99
+ $translated_content = json_encode($this->replace_url_services->replace_link_in_json( json_decode($translated_content , true) ));
100
+ $translated_content = apply_filters( 'weglot_json_treat_page', $translated_content );
101
+ return $translated_content;
102
  case 'html':
103
+ $translated_content = $parser->translate( $content, $this->original_language, $this->current_language ); // phpcs:ignore
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  $translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
 
105
  return $this->weglot_render_dom( $translated_content );
106
  default:
107
  $name_filter = sprintf( 'weglot_%s_treat_page', $type );
124
  }
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
  /**
129
  * @since 2.3.0
src/third/calderaforms/class-caldera-active.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace WeglotWP\Third\CalderaForms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
1
  <?php
2
 
3
+ namespace WeglotWP\Third\Calderaforms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
src/third/calderaforms/class-caldera-i18n-inline.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace WeglotWP\Third\CalderaForms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
1
  <?php
2
 
3
+ namespace WeglotWP\Third\Calderaforms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
src/third/calderaforms/class-caldera-translate.php DELETED
@@ -1,148 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Third\CalderaForms;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
-
10
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
11
-
12
- use Weglot\Client\Api\WordEntry;
13
- use Weglot\Client\Api\Enum\WordType;
14
- use Weglot\Client\Client;
15
- use Weglot\Client\Endpoint\Translate;
16
- use Weglot\Client\Api\TranslateEntry;
17
- use Weglot\Client\Api\Enum\BotType;
18
-
19
- /**
20
- * Caldera_Translate
21
- *
22
- * @since 2.6.0
23
- */
24
- class Caldera_Translate {
25
-
26
- /**
27
- * @since 2.6.0
28
- * @param string $dom
29
- * @return string
30
- */
31
- protected function translate_entries( $dom ) {
32
- $parser = weglot_get_service( 'Parser_Service_Weglot' )->get_parser();
33
- return $parser->translate( $dom, weglot_get_original_language(), weglot_get_current_language() ); // phpcs:ignore
34
- }
35
-
36
- /**
37
- * @since 2.7.0
38
- * @param array $all_words
39
- * @return array
40
- */
41
- protected function translate_words_inline( $all_words ) {
42
- // TranslateEntry
43
- $params = [
44
- 'language_from' => weglot_get_original_language(),
45
- 'language_to' => weglot_get_current_language(),
46
- 'request_url' => weglot_get_current_full_url(),
47
- 'bot' => BotType::HUMAN,
48
- ];
49
-
50
- $translate = new TranslateEntry( $params );
51
-
52
- $word_collection = $translate->getInputWords();
53
- foreach ( $all_words as $value ) {
54
- $value = Helper_Json_Inline_Weglot::format_for_api( $value );
55
- $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
56
- }
57
-
58
- $client = weglot_get_service( 'Parser_Service_Weglot' )->get_client();
59
- $translate = new Translate( $translate, $client );
60
-
61
- return $translate->handle();
62
- }
63
-
64
- /**
65
- * @since 2.7.0
66
- * @param string $content
67
- * @return string
68
- */
69
- protected function translate_i18n_inline( $content ) {
70
- $regex = apply_filters( 'weglot_caldera_forms_match_validator_settings', '#CF_VALIDATOR_STRINGS(.*?);#' );
71
- preg_match( $regex, $content, $match );
72
- if ( ! isset( $match[1] ) ) {
73
- return $content;
74
- }
75
-
76
- $regex = apply_filters( 'weglot_caldera_forms_translate_validator_settings', '#(defaultMessage|email|url|number|integer|digits|alphanum|required|pattern|min|max|range|minlength|maxlength|length|mincheck|maxcheck|check|equalto|notblank)":"(.*?)"#' );
77
- preg_match_all( $regex, $match[1], $all );
78
-
79
- if ( empty( $all[2] ) ) {
80
- return $content;
81
- }
82
- $current_language = weglot_get_current_language();
83
-
84
- $object = $this->translate_words_inline( $all[2] );
85
-
86
- foreach ( $object->getInputWords() as $key => $input_word ) {
87
- $from_input_encoding = apply_filters( 'weglot_caldera_translate_need_json_encode', true );
88
-
89
- $encoded = true;
90
-
91
- if ( in_array( $current_language, apply_filters( 'weglot_caldera_translate_languages_encoded_output', [ 'fr' ] ), true ) ) {
92
- $encoded = false;
93
- }
94
-
95
- $to_output_encoding = apply_filters( 'weglot_caldera_translate_need_json_encode', $encoded );
96
- $from_input = $input_word->getWord();
97
- $to_output = $object->getOutputWords()[ $key ]->getWord();
98
- if ( '' === $from_input ) {
99
- continue;
100
- }
101
-
102
- if ( $from_input_encoding ) {
103
- $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
104
- }
105
- if ( $to_output_encoding ) {
106
- $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
107
- }
108
-
109
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
110
- }
111
-
112
- return $content;
113
- }
114
-
115
- /**
116
- * @since 2.6.0
117
- *
118
- * @param string $content
119
- * @return array
120
- */
121
- protected function translate_script_html_template( $content ) {
122
- preg_match_all( '#<script type="text\/html"(.*?)>([\s\S]*)<\/script>#mU', $content, $match );
123
-
124
- if ( ! isset( $match[2] ) || empty( $match[2][0] ) ) {
125
- return $content;
126
- }
127
-
128
- foreach ( $match[2] as $key => $template_html ) {
129
- $dom_translate = $this->translate_entries( $template_html );
130
- $content = str_replace( $match[2][$key], $dom_translate, $content );
131
- }
132
-
133
- return $content;
134
- }
135
-
136
- /**
137
- * @since 2.6.0
138
- *
139
- * @param string $content
140
- * @return string
141
- */
142
- public function translate_words( $content ) {
143
- $content = $this->translate_script_html_template( $content );
144
- $content = $this->translate_i18n_inline( $content );
145
-
146
- return $content;
147
- }
148
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/third/calderaforms/regexcheckers/class-caldera-form-json-fields.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Calderaforms\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Caldera_Form_Json_Fields
17
+ {
18
+ const REGEX = '#CF_VALIDATOR_STRINGS = (.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "defaultMessage","email","url","number","integer","digits","alphanum","required","pattern","min","max","range","minlength","maxlength","length","mincheck","maxcheck","check","equalto","notblank" );
25
+ }
src/third/edd/class-edd-active.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Edd;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+
10
+ use WeglotWP\Models\Third_Active_Interface_Weglot;
11
+
12
+
13
+
14
+ class Edd_Active implements Third_Active_Interface_Weglot {
15
+
16
+ /**
17
+ * WooCommerce is active ?
18
+ * @since 2.0
19
+ *
20
+ * @return boolean
21
+ */
22
+ public function is_active() {
23
+ if ( ! function_exists( 'is_plugin_active' ) ) {
24
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
25
+ }
26
+
27
+ if ( ! is_plugin_active( 'easy-digital-downloads/easy-digital-downloads.php' ) ) {
28
+ return false;
29
+ }
30
+
31
+ return true;
32
+ }
33
+ }
src/third/edd/class-edd-filter-urls.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Edd;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use WeglotWP\Models\Hooks_Interface_Weglot;
10
+ use WeglotWP\Helpers\Helper_Filter_Url_Weglot;
11
+
12
+ class Edd_Filter_Urls implements Hooks_Interface_Weglot {
13
+
14
+ /**
15
+ * @return void
16
+ */
17
+ public function __construct() {
18
+ $this->edd_active_services = weglot_get_service( 'Edd_Active' );
19
+ }
20
+
21
+ /**
22
+ * @see Hooks_Interface_Weglot
23
+ *
24
+ * @return void
25
+ */
26
+ public function hooks() {
27
+ if ( ! $this->edd_active_services->is_active() ) {
28
+ return;
29
+ }
30
+
31
+ add_filter( 'edd_get_success_page_uri', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
32
+ add_filter( 'edd_get_checkout_uri', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
33
+ }
34
+
35
+
36
+ }
src/third/gravityforms/class-gf-active.php CHANGED
@@ -14,7 +14,7 @@ use WeglotWP\Models\Third_Active_Interface_Weglot;
14
  /**
15
  * @since 3.0
16
  */
17
- class GF_Active implements Third_Active_Interface_Weglot {
18
 
19
  /**
20
  * @since 3.0.0
14
  /**
15
  * @since 3.0
16
  */
17
+ class Gf_Active implements Third_Active_Interface_Weglot {
18
 
19
  /**
20
  * @since 3.0.0
src/third/gravityforms/class-gf-filter-urls.php CHANGED
@@ -19,7 +19,7 @@ class GF_Filter_Urls implements Hooks_Interface_Weglot {
19
  * @return void
20
  */
21
  public function __construct() {
22
- $this->gf_active_services = weglot_get_service( 'GF_Active' );
23
  }
24
 
25
  /**
19
  * @return void
20
  */
21
  public function __construct() {
22
+ $this->gf_active_services = weglot_get_service( 'Gf_Active' );
23
  }
24
 
25
  /**
src/third/ninjaforms/{class-ninja-active-weglot.php → class-ninja-active.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace WeglotWP\Third\NinjaForms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
@@ -16,7 +16,7 @@ use WeglotWP\Models\Third_Active_Interface_Weglot;
16
  *
17
  * @since 2.5.0
18
  */
19
- class Ninja_Active_Weglot implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * Ninja forms is active ?
1
  <?php
2
 
3
+ namespace WeglotWP\Third\Ninjaforms;
4
 
5
  if ( ! defined( 'ABSPATH' ) ) {
6
  exit;
16
  *
17
  * @since 2.5.0
18
  */
19
+ class Ninja_Active implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * Ninja forms is active ?
src/third/ninjaforms/class-ninja-translate-json-weglot.php DELETED
@@ -1,206 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Third\NinjaForms;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- use Weglot\Client\Api\WordEntry;
10
- use Weglot\Client\Api\Enum\WordType;
11
- use Weglot\Client\Client;
12
- use Weglot\Client\Endpoint\Translate;
13
- use Weglot\Client\Api\TranslateEntry;
14
- use Weglot\Client\Api\Enum\BotType;
15
-
16
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
17
-
18
-
19
-
20
- /**
21
- * Ninja_Translate_Json_Weglot
22
- *
23
- * @since 2.5.0
24
- * @version 3.0.0
25
- */
26
- class Ninja_Translate_Json_Weglot {
27
-
28
- /**
29
- * @since 3.0.0
30
- */
31
- public function __construct() {
32
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
33
- }
34
-
35
- protected function translate_entries( $all_words ) {
36
- // TranslateEntry
37
- $params = [
38
- 'language_from' => weglot_get_original_language(),
39
- 'language_to' => weglot_get_current_language(),
40
- 'request_url' => weglot_get_current_full_url(),
41
- 'bot' => BotType::HUMAN,
42
- ];
43
-
44
- $translate = new TranslateEntry( $params );
45
-
46
- $word_collection = $translate->getInputWords();
47
- foreach ( $all_words as $value ) {
48
- $value = Helper_Json_Inline_Weglot::format_for_api( $value );
49
- $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
50
- }
51
-
52
- $client = $this->parser_services->get_client();
53
- $translate = new Translate( $translate, $client );
54
-
55
- return $translate->handle();
56
- }
57
-
58
- /**
59
- * @since 2.5.0
60
- *
61
- * @param string $content
62
- * @return array
63
- */
64
- protected function translate_i18n( $content ) {
65
- if ( ! apply_filters( 'weglot_ninja_forms_translate_i18n', false ) ) {
66
- return $content;
67
- }
68
-
69
- preg_match( '#nfi18n(.*?);#', $content, $match );
70
-
71
- if ( ! isset( $match[1] ) ) {
72
- return $content;
73
- }
74
-
75
- $regex = apply_filters( 'weglot_ninja_forms_translate_i18n', '#(title|changeEmailErrorMsg|changeDateErrorMsg|confirmFieldErrorMsg|fieldNumberNumMinError|fieldNumberNumMaxError|fieldNumberIncrementBy|fieldTextareaRTEInsertLink|fieldTextareaRTEInsertMedia|fieldTextareaRTESelectAFile|formErrorsCorrectErrors|validateRequiredField|honeypotHoneypotError|fileUploadOldCodeFileUploadInProgress|previousMonth|nextMonth|fieldsMarkedRequired|fileUploadOldCodeFileUpload)":"(.*?)",#' );
76
- preg_match_all( $regex, $match[1], $all );
77
-
78
- if ( empty( $all[2] ) ) {
79
- return $content;
80
- }
81
-
82
- $object = $this->translate_entries( $all[2] );
83
-
84
- foreach ( $object->getInputWords() as $key => $input_word ) {
85
- $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
86
- $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
87
- $from_input = $input_word->getWord();
88
- $to_output = $object->getOutputWords()[ $key ]->getWord();
89
-
90
- if ( '' === $from_input ) {
91
- continue;
92
- }
93
-
94
- if ( $from_input_encoding ) {
95
- $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
96
- }
97
- if ( $to_output_encoding ) {
98
- $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
99
- }
100
-
101
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
102
- }
103
-
104
- return $content;
105
- }
106
-
107
- /**
108
- * @since 2.5.0
109
- * @param string $content
110
- * @return array
111
- */
112
- protected function translate_form_settings( $content ) {
113
- $regex = apply_filters( 'weglot_ninja_forms_match_form_settings', '#form\.settings=(.*?);#' );
114
- preg_match( $regex, $content, $match );
115
- if ( ! isset( $match[1] ) ) {
116
- return $content;
117
- }
118
-
119
- $regex = apply_filters( 'weglot_ninja_forms_translate_form_settings', '#(title|changeEmailErrorMsg|changeDateErrorMsg|confirmFieldErrorMsg|fieldNumberNumMinError|fieldNumberNumMaxError|fieldNumberIncrementBy|fieldTextareaRTEInsertLink|fieldTextareaRTEInsertMedia|fieldTextareaRTESelectAFile|formErrorsCorrectErrors|validateRequiredField|honeypotHoneypotError|fileUploadOldCodeFileUploadInProgress|previousMonth|nextMonth|fieldsMarkedRequired)":"(.*?)",#' );
120
- preg_match_all( $regex, $match[1], $all );
121
-
122
- if ( empty( $all[2] ) ) {
123
- return $content;
124
- }
125
-
126
- $object = $this->translate_entries( $all[2] );
127
-
128
- foreach ( $object->getInputWords() as $key => $input_word ) {
129
- $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
130
- $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
131
- $from_input = $input_word->getWord();
132
- $to_output = $object->getOutputWords()[ $key ]->getWord();
133
- if ( '' === $from_input ) {
134
- continue;
135
- }
136
-
137
- if ( $from_input_encoding ) {
138
- $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
139
- }
140
- if ( $to_output_encoding ) {
141
- $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
142
- }
143
-
144
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
145
- }
146
-
147
- return $content;
148
- }
149
-
150
-
151
- /**
152
- * @since 2.5.0
153
- * @param string $content
154
- * @return array
155
- */
156
- protected function translate_form_fields( $content ) {
157
- $regex = apply_filters( 'weglot_ninja_forms_match_form_fields', '#form\.fields=(.*?);#' );
158
- preg_match( $regex, $content, $match );
159
-
160
- if ( ! isset( $match[1] ) ) {
161
- return $content;
162
- }
163
-
164
- $regex = apply_filters( 'weglot_ninja_forms_translate_form_fields', '#(label|help_text|value)":"(.*?)",#' );
165
- preg_match_all( $regex, $match[1], $all );
166
- if ( empty( $all[1] ) ) {
167
- return $content;
168
- }
169
-
170
- $object = $this->translate_entries( $all[2] );
171
-
172
- foreach ( $object->getInputWords() as $key => $input_word ) {
173
- $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
174
- $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
175
- $from_input = $input_word->getWord();
176
- $to_output = $object->getOutputWords()[ $key ]->getWord();
177
- if ( '' === $from_input ) {
178
- continue;
179
- }
180
-
181
- if ( $from_input_encoding ) {
182
- $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
183
- }
184
- if ( $to_output_encoding ) {
185
- $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
186
- }
187
-
188
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
189
- }
190
-
191
- return $content;
192
- }
193
-
194
- /**
195
- * @since 2.5.0
196
- * @param string $content
197
- * @return string
198
- */
199
- public function translate_words( $content ) {
200
- $content = $this->translate_form_settings( $content );
201
- $content = $this->translate_form_fields( $content );
202
- $content = $this->translate_i18n( $content );
203
-
204
- return $content;
205
- }
206
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/third/ninjaforms/regexcheckers/class-ninja-form-json-fields.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Ninjaforms\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Ninja_Form_Json_Fields
17
+ {
18
+ const REGEX = '#form.fields=(.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "label" , "help_text" , "value" );
25
+ }
src/third/ninjaforms/regexcheckers/class-ninja-form-json-nfi18n.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Ninjaforms\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Ninja_Form_Json_Nfi18n
17
+ {
18
+ const REGEX = '#nfi18n = (.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "title" , "changeEmailErrorMsg" , "changeDateErrorMsg" , "confirmFieldErrorMsg" , "fieldNumberNumMinError" , "fieldNumberNumMaxError" , "fieldNumberIncrementBy" , "fieldTextareaRTEInsertLink" , "fieldTextareaRTEInsertMedia" , "fieldTextareaRTESelectAFile" , "formErrorsCorrectErrors" , "validateRequiredField" , "honeypotHoneypotError" , "fileUploadOldCodeFileUploadInProgress" , "previousMonth" , "nextMonth" , "fieldsMarkedRequired" , "fileUploadOldCodeFileUpload" );
25
+ }
src/third/ninjaforms/regexcheckers/class-ninja-form-json-setting.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Ninjaforms\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Ninja_Form_Json_Setting
17
+ {
18
+ const REGEX = '#form.settings=(.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "title" , "changeEmailErrorMsg" , "changeDateErrorMsg" , "confirmFieldErrorMsg" , "fieldNumberNumMinError" , "fieldNumberNumMaxError" , "fieldNumberIncrementBy" , "fieldTextareaRTEInsertLink" , "fieldTextareaRTEInsertMedia" , "fieldTextareaRTESelectAFile" , "formErrorsCorrectErrors" , "validateRequiredField" , "honeypotHoneypotError" , "fileUploadOldCodeFileUploadInProgress" , "previousMonth" , "nextMonth" , "fieldsMarkedRequired");
25
+ }
src/third/woocommerce/{class-wc-active-weglot.php → class-wc-active.php} RENAMED
@@ -12,11 +12,11 @@ use WeglotWP\Models\Third_Active_Interface_Weglot;
12
 
13
 
14
  /**
15
- * WC_Active_Weglot
16
  *
17
  * @since 2.0
18
  */
19
- class WC_Active_Weglot implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * WooCommerce is active ?
12
 
13
 
14
  /**
15
+ * Wc_Active
16
  *
17
  * @since 2.0
18
  */
19
+ class Wc_Active implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * WooCommerce is active ?
src/third/woocommerce/class-wc-cart-reload-weglot.php CHANGED
@@ -21,7 +21,7 @@ class WC_Cart_Reload_Weglot implements Hooks_Interface_Weglot {
21
  * @return void
22
  */
23
  public function __construct() {
24
- $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
25
  }
26
 
27
  /**
@@ -40,70 +40,32 @@ class WC_Cart_Reload_Weglot implements Hooks_Interface_Weglot {
40
  return;
41
  }
42
 
43
- add_action( 'wp_ajax_weglot_wc_reload_cart', [ $this, 'weglot_wc_reload_cart' ] );
44
- add_action( 'wp_ajax_nopriv_weglot_wc_reload_cart', [ $this, 'weglot_wc_reload_cart' ] );
45
-
46
- add_action( 'wp_enqueue_scripts', [ $this, 'weglot_wc_wp_enqueue_scripts' ] );
47
  add_action( 'wp_footer', [ $this, 'weglot_wc_footer' ] );
48
  }
49
 
50
- /**
51
- * @since 2.4.0
52
- * @return void
53
- */
54
- public function weglot_wc_reload_cart() {
55
- set_transient( $this->name_transient, 'true', 12 * HOUR_IN_SECONDS );
56
- wp_send_json_success();
57
- }
58
-
59
- /**
60
- * @since 2.4.0
61
- * @return void
62
- */
63
- public function weglot_wc_wp_enqueue_scripts() {
64
- wp_enqueue_script( 'jquery' );
65
- }
66
-
67
  /**
68
  * @since 2.4.0
69
  * @return void
70
  */
71
  public function weglot_wc_footer() {
72
- $click_selector = apply_filters( 'weglot_wc_reload_selector', '.weglot-flags a' );
73
- $ajaxurl = admin_url( 'admin-ajax.php' );
74
- $load = apply_filters( 'weglot_load_script_reload_selector', true );
75
- if ( ! $load ) {
76
- return;
77
- } ?>
78
  <script>
79
  document.addEventListener('DOMContentLoaded', function(){
80
 
81
  jQuery( '<?php echo esc_attr( $click_selector ); ?>' ).on('click', function(e) {
82
  e.preventDefault();
83
  var href = jQuery(this).attr('href')
84
- jQuery.ajax({
85
- url: '<?php echo esc_url( $ajaxurl ); ?>',
86
- data:{
87
- action :'weglot_wc_reload_cart'
88
- }
89
- })
90
 
 
 
 
 
 
91
  window.location.href = href
92
-
93
  })
94
  })
95
  </script>
96
  <?php
97
- $transient = get_transient( $this->name_transient );
98
-
99
- if ( false !== $transient ) {
100
- delete_transient( $this->name_transient ); //phpcs:ignore ?>
101
- <script>
102
- document.addEventListener('DOMContentLoaded', function(){
103
- jQuery(document.body).trigger('wc_fragment_refresh');
104
- })
105
- </script>
106
- <?php
107
- }
108
  }
109
  }
21
  * @return void
22
  */
23
  public function __construct() {
24
+ $this->wc_active_services = weglot_get_service( 'Wc_Active' );
25
  }
26
 
27
  /**
40
  return;
41
  }
42
 
 
 
 
 
43
  add_action( 'wp_footer', [ $this, 'weglot_wc_footer' ] );
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  /**
47
  * @since 2.4.0
48
  * @return void
49
  */
50
  public function weglot_wc_footer() {
51
+ $click_selector = apply_filters( 'weglot_wc_reload_selector', '.weglot-lang a' );
52
+ ?>
 
 
 
 
53
  <script>
54
  document.addEventListener('DOMContentLoaded', function(){
55
 
56
  jQuery( '<?php echo esc_attr( $click_selector ); ?>' ).on('click', function(e) {
57
  e.preventDefault();
58
  var href = jQuery(this).attr('href')
 
 
 
 
 
 
59
 
60
+ Object.keys(window.sessionStorage).forEach(function(element) {
61
+ if(element.startsWith("wc_cart_hash_") || element.startsWith("wc_fragments_")) {
62
+ window.sessionStorage.removeItem(element);
63
+ }
64
+ });
65
  window.location.href = href
 
66
  })
67
  })
68
  </script>
69
  <?php
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
  }
src/third/woocommerce/class-wc-filter-urls-weglot.php CHANGED
@@ -23,7 +23,7 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
23
  public function __construct() {
24
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
25
  $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
26
- $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
27
  $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
28
  }
29
 
@@ -54,6 +54,9 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
54
  * @since 2.6.0
55
  */
56
  add_filter( 'woocommerce_get_cart_page_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
 
 
 
57
  }
58
 
59
  /**
@@ -90,12 +93,29 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
90
  return $url_filter;
91
  }
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  /**
94
  * Filter array woocommerce filter with optional Ajax
95
  *
96
  * @since 2.0
97
  * @param array $result
98
- * @return string
99
  */
100
  public function woocommerce_filter_url_array( $result ) {
101
  $current_and_original_language = weglot_get_current_and_original_language();
@@ -111,7 +131,9 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
111
  }
112
  }
113
  if ( $this->replace_url_services->check_link( $result['redirect'] ) ) { // We must not add language code if external link
114
- $result['redirect'] = $url->getForLanguage( $choose_current_language );
 
 
115
  }
116
  return $result;
117
  }
@@ -122,6 +144,7 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
122
  * @since 2.0
123
  * @version 2.0.4
124
  * @param mixed $url
 
125
  */
126
  public function woocommerce_filter_reset_password( $url ) {
127
  $current_and_original_language = weglot_get_current_and_original_language();
23
  public function __construct() {
24
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
25
  $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
26
+ $this->wc_active_services = weglot_get_service( 'Wc_Active' );
27
  $this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
28
  }
29
 
54
  * @since 2.6.0
55
  */
56
  add_filter( 'woocommerce_get_cart_page_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
57
+
58
+
59
+ add_filter( 'woocommerce_get_endpoint_url', [ $this, 'last_password_url_filter' ] , 10, 4);
60
  }
61
 
62
  /**
93
  return $url_filter;
94
  }
95
 
96
+ public function last_password_url_filter($url, $endpoint, $value, $permalink) {
97
+
98
+ if($endpoint === 'lost-password') {
99
+ $current_headers = headers_list();
100
+ foreach ($current_headers as $header) {
101
+ if (strpos($header, 'wp-resetpass') !== false) {
102
+ preg_match("#wp-resetpass-(.*?)=(.*?);#" , $header , $matchesName);
103
+ preg_match("#path=(.*?);#" , $header , $matchesPath);
104
+ if(isset($matchesName[0]) && isset($matchesPath[0]) && isset($matchesPath[1])) {
105
+ setcookie( "wp-resetpass-". $matchesName[1], urldecode($matchesName[2]), 0, '/' . weglot_get_current_language() . $matchesPath[1], '' , is_ssl(), true );
106
+ }
107
+ }
108
+ }
109
+ }
110
+ return $url;
111
+ }
112
+
113
  /**
114
  * Filter array woocommerce filter with optional Ajax
115
  *
116
  * @since 2.0
117
  * @param array $result
118
+ * @return array
119
  */
120
  public function woocommerce_filter_url_array( $result ) {
121
  $current_and_original_language = weglot_get_current_and_original_language();
131
  }
132
  }
133
  if ( $this->replace_url_services->check_link( $result['redirect'] ) ) { // We must not add language code if external link
134
+ if(isset($url) && $url) {
135
+ $result['redirect'] = $url->getForLanguage( $choose_current_language );
136
+ }
137
  }
138
  return $result;
139
  }
144
  * @since 2.0
145
  * @version 2.0.4
146
  * @param mixed $url
147
+ * @return void
148
  */
149
  public function woocommerce_filter_reset_password( $url ) {
150
  $current_and_original_language = weglot_get_current_and_original_language();
src/third/woocommerce/class-wc-translate-weglot.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Third\Woocommerce;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- use Weglot\Client\Api\WordEntry;
10
- use Weglot\Client\Api\Enum\WordType;
11
- use Weglot\Client\Client;
12
- use Weglot\Client\Endpoint\Translate;
13
- use Weglot\Client\Api\TranslateEntry;
14
- use Weglot\Client\Api\Enum\BotType;
15
-
16
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
17
-
18
-
19
-
20
- /**
21
- * WC_Translate_Weglot
22
- * @since 2.0
23
- * @version 3.0.0
24
- */
25
- class WC_Translate_Weglot {
26
-
27
- /**
28
- * @since 3.0.0
29
- */
30
- public function __construct() {
31
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
32
- }
33
-
34
- protected function translate_entries( $all_words ) {
35
- // TranslateEntry
36
- $params = [
37
- 'language_from' => weglot_get_original_language(),
38
- 'language_to' => weglot_get_current_language(),
39
- 'request_url' => weglot_get_current_full_url(),
40
- 'bot' => BotType::HUMAN,
41
- ];
42
-
43
- $translate = new TranslateEntry( $params );
44
-
45
- $word_collection = $translate->getInputWords();
46
- foreach ( $all_words as $value ) {
47
- $value = Helper_Json_Inline_Weglot::format_for_api( $value );
48
- $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
49
- }
50
-
51
- $client = $this->parser_services->get_client();
52
- $translate = new Translate( $translate, $client );
53
-
54
- return $translate->handle();
55
- }
56
-
57
- /**
58
- * @since 2.0
59
- *
60
- * @param string $content
61
- * @return array
62
- */
63
- protected function translate_adresse_i18n( $content ) {
64
- preg_match( '#wc_address_i18n_params(.*?);#', $content, $match );
65
-
66
- if ( ! isset( $match[1] ) ) {
67
- return $content;
68
- }
69
-
70
- preg_match_all( '#(label|placeholder)\\\":\\\"(.*?)\\\"#', $match[1], $all );
71
-
72
- if ( empty( $all[2] ) ) {
73
- return $content;
74
- }
75
-
76
- $object = $this->translate_entries( $all[2] );
77
-
78
- foreach ( $object->getInputWords() as $key => $input_word ) {
79
- $from_input = Helper_Json_Inline_Weglot::unformat_from_api( $input_word->getWord() );
80
- $to_output = Helper_Json_Inline_Weglot::unformat_from_api( $object->getOutputWords()[ $key ]->getWord() );
81
-
82
- $content = str_replace( '\"' . $from_input . '\"', '\"' . $to_output . '\"', $content );
83
- }
84
-
85
- return $content;
86
- }
87
-
88
-
89
- /**
90
- * @since 2.0
91
- *
92
- * @param string $content
93
- * @return array
94
- */
95
- protected function translate_add_to_cart_params( $content ) {
96
- preg_match( '#wc_add_to_cart_params(.*?);#', $content, $match );
97
-
98
- if ( ! isset( $match[1] ) ) {
99
- return $content;
100
- }
101
-
102
- preg_match_all( '#i18n_view_cart\":\"(.*?)\"#', $match[1], $all );
103
-
104
- if ( empty( $all[1] ) ) {
105
- return $content;
106
- }
107
-
108
- $object = $this->translate_entries( $all[1] );
109
-
110
- foreach ( $object->getInputWords() as $key => $input_word ) {
111
- $from_input = Helper_Json_Inline_Weglot::unformat_from_api( $input_word->getWord() );
112
- $to_output = Helper_Json_Inline_Weglot::unformat_from_api( $object->getOutputWords()[ $key ]->getWord() );
113
-
114
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
115
- }
116
-
117
- return $content;
118
- }
119
-
120
- /**
121
- * @since 2.0
122
- *
123
- * @param string $content
124
- * @return string
125
- */
126
- public function translate_words( $content ) {
127
- $content = $this->translate_adresse_i18n( $content );
128
- $content = $this->translate_add_to_cart_params( $content );
129
-
130
- return $content;
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/third/woocommerce/regexcheckers/class-wc-json-add-cart.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Woocommerce\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Wc_Json_Add_Cart
17
+ {
18
+ const REGEX = '#wc_add_to_cart_params = (.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "i18n_view_cart" );
25
+ }
src/third/woocommerce/regexcheckers/class-wc-json-address.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Woocommerce\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Wc_Json_Address
17
+ {
18
+ const REGEX = '#wc_address_i18n_params = (.*?);#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "label" , "placeholder" , "i18n_required_text" , "i18n_optional_text" );
25
+ }
src/third/wpforms/class-wpforms-active.php CHANGED
@@ -12,11 +12,11 @@ use WeglotWP\Models\Third_Active_Interface_Weglot;
12
 
13
 
14
  /**
15
- * WPForms_Active
16
  *
17
  * @since 3.0.5
18
  */
19
- class WPForms_Active implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * @since 3.0.5
12
 
13
 
14
  /**
15
+ * Wpforms_Active
16
  *
17
  * @since 3.0.5
18
  */
19
+ class Wpforms_Active implements Third_Active_Interface_Weglot {
20
 
21
  /**
22
  * @since 3.0.5
src/third/wpforms/class-wpforms-translate.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- namespace WeglotWP\Third\WPForms;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
-
10
- use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
11
-
12
- use Weglot\Client\Api\WordEntry;
13
- use Weglot\Client\Api\Enum\WordType;
14
- use Weglot\Client\Client;
15
- use Weglot\Client\Endpoint\Translate;
16
- use Weglot\Client\Api\TranslateEntry;
17
- use Weglot\Client\Api\Enum\BotType;
18
-
19
- /**
20
- * WPForms_Translate
21
- *
22
- * @since 3.0.5
23
- */
24
- class WPForms_Translate {
25
-
26
- /**
27
- * @since 3.0.5
28
- */
29
- public function __construct() {
30
- $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
31
- }
32
-
33
- /**
34
- * @since 3.0.5
35
- * @param array $all_words
36
- * @return array
37
- */
38
- protected function translate_entries( $all_words ) {
39
- // TranslateEntry
40
- $params = [
41
- 'language_from' => weglot_get_original_language(),
42
- 'language_to' => weglot_get_current_language(),
43
- 'request_url' => weglot_get_current_full_url(),
44
- 'bot' => BotType::HUMAN,
45
- ];
46
-
47
- $translate = new TranslateEntry( $params );
48
-
49
- $word_collection = $translate->getInputWords();
50
- foreach ( $all_words as $value ) {
51
- $value = Helper_Json_Inline_Weglot::format_for_api( $value );
52
- $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
53
- }
54
-
55
- $client = $this->parser_services->get_client();
56
- $translate = new Translate( $translate, $client );
57
-
58
- return $translate->handle();
59
- }
60
-
61
-
62
- /**
63
- * @since 3.0.5
64
- * @param string $content
65
- * @return array
66
- */
67
- protected function translate_json_inline( $content ) {
68
- $regex = apply_filters( 'weglot_wpforms_match_form_fields', '#wpforms_settings(.*)(\s*)\/\* ]]> \*\/#' );
69
- preg_match( $regex, $content, $match );
70
-
71
- if ( ! isset( $match[1] ) ) {
72
- return $content;
73
- }
74
-
75
- $regex = apply_filters( 'weglot_wpforms_translate_json_inline', '#(val_required|val_url|val_email|val_email_suggestion|val_email_suggestion_title|val_number|val_confirm|val_fileextension|val_filesize|val_time12h|val_time24h|val_requiredpayment|val_creditcard|val_smart_phone|val_post_max_size|val_checklimit|val_checklimit)":"(.*?)",#' );
76
- preg_match_all( $regex, $match[1], $all );
77
- if ( empty( $all[1] ) ) {
78
- return $content;
79
- }
80
-
81
- $object = $this->translate_entries( $all[2] );
82
-
83
- foreach ( $object->getInputWords() as $key => $input_word ) {
84
- $from_input_encoding = apply_filters( 'weglot_wpforms_translate_need_json_encode', true );
85
- $to_output_encoding = apply_filters( 'weglot_wpforms_translate_need_json_encode', true );
86
- $from_input = $input_word->getWord();
87
- $to_output = $object->getOutputWords()[ $key ]->getWord();
88
- if ( '' === $from_input ) {
89
- continue;
90
- }
91
-
92
- if ( $from_input_encoding ) {
93
- $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
94
- }
95
- if ( $to_output_encoding ) {
96
- $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
97
- }
98
-
99
- $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
100
- }
101
-
102
- return $content;
103
- }
104
-
105
- /**
106
- * @since 2.5.0
107
- * @param string $content
108
- * @return string
109
- */
110
- public function translate_words( $content ) {
111
- $content = $this->translate_json_inline( $content );
112
-
113
- return $content;
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/third/wpforms/regexcheckers/class-wp-form-json-setting.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Wpforms\Regexcheckers;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @since 2.0.7
15
+ */
16
+ class Wp_Form_Json_Setting
17
+ {
18
+ const REGEX = '#wpforms_settings = (.*?)(\n)(\/\* ]]> \*\/)#';
19
+
20
+ const TYPE = SourceType::SOURCE_JSON;
21
+
22
+ const VAR_NUMBER = 1;
23
+
24
+ public static $KEYS = array( "val_required","val_url","val_email","val_email_suggestion","val_email_suggestion_title","val_number","val_confirm","val_fileextension","val_filesize","val_time12h","val_time24h","val_requiredpayment","val_creditcard","val_smart_phone","val_post_max_size","val_checklimit","val_checklimit");
25
+ }
templates/admin/pages/tabs/advanced.php CHANGED
@@ -273,31 +273,6 @@ $languages = array_values( $languages );
273
  </tbody>
274
  </table>
275
 
276
- <div class="notice notice-info is-dismissible">
277
- <p>
278
- <?php esc_html_e( 'If you need any help, you can contact us via email us at support@weglot.com.', 'weglot' ); ?>
279
- </p>
280
- <p>
281
- <?php
282
- // translators: 1 Latest weglot version
283
- $text = __( 'You can also return to version %s by clicking on the button below', 'weglot' );
284
- $text = sprintf( $text, WEGLOT_LATEST_VERSION );
285
-
286
- echo esc_html( $text );
287
- ?>
288
- </p>
289
- <p>
290
- <a href="<?php echo wp_nonce_url( admin_url( 'admin-post.php?action=weglot_rollback' ), 'weglot_rollback' ); //phpcs:ignore ?>" class="button">
291
- <?php
292
- // translators: 1 Latest weglot version
293
- $text = __( 'Re-install version %s', 'weglot' );
294
- $text = sprintf( $text, WEGLOT_LATEST_VERSION );
295
- echo esc_html( $text );
296
- ?>
297
- </a>
298
- </p>
299
- </div>
300
-
301
  <template id="tpl-exclusion-url">
302
  <div class="item-exclude">
303
  <select
273
  </tbody>
274
  </table>
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  <template id="tpl-exclusion-url">
277
  <div class="item-exclude">
278
  <select
templates/admin/pages/tabs/settings.php CHANGED
@@ -19,7 +19,7 @@ $options_available = [
19
  'languages' => [
20
  'key' => 'destination_language',
21
  'label' => __( 'Destination languages', 'weglot' ),
22
- 'description' => 'Choose languages you want to translate into. Supported languages can be found <a target="_blank" href="https://weglot.com/translation-api#languages_code">here</a>.',
23
  ],
24
  ];
25
 
19
  'languages' => [
20
  'key' => 'destination_language',
21
  'label' => __( 'Destination languages', 'weglot' ),
22
+ 'description' => 'Choose languages you want to translate into. Supported languages can be found <a target="_blank" href="https://weglot.com/documentation/available-languages/">here</a>.',
23
  ],
24
  ];
25
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitf5265850c3d873e108b5abc992d12723::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
- $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
  }
284
 
285
  /**
@@ -377,7 +377,7 @@ class ClassLoader
377
  $subPath = $class;
378
  while (false !== $lastPos = strrpos($subPath, '\\')) {
379
  $subPath = substr($subPath, 0, $lastPos);
380
- $search = $subPath.'\\';
381
  if (isset($this->prefixDirsPsr4[$search])) {
382
  $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
  foreach ($this->prefixDirsPsr4[$search] as $dir) {
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
  }
284
 
285
  /**
377
  $subPath = $class;
378
  while (false !== $lastPos = strrpos($subPath, '\\')) {
379
  $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
  if (isset($this->prefixDirsPsr4[$search])) {
382
  $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
  foreach ($this->prefixDirsPsr4[$search] as $dir) {
vendor/composer/autoload_namespaces.php CHANGED
@@ -7,6 +7,4 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'WGSimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
10
- 'Utilities\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar'),
11
- 'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar'),
12
  );
7
 
8
  return array(
9
  'WGSimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
 
 
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitb9057a853289224ea9fa1d5dcedb206d
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequireb9057a853289224ea9fa1d5dcedb206d($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequireb9057a853289224ea9fa1d5dcedb206d($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitf5265850c3d873e108b5abc992d12723
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitf5265850c3d873e108b5abc992d12723', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitf5265850c3d873e108b5abc992d12723', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitf5265850c3d873e108b5abc992d12723::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInitf5265850c3d873e108b5abc992d12723::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequiref5265850c3d873e108b5abc992d12723($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequiref5265850c3d873e108b5abc992d12723($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
@@ -48,20 +48,6 @@ class ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d
48
  0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
49
  ),
50
  ),
51
- 'U' =>
52
- array (
53
- 'Utilities\\' =>
54
- array (
55
- 0 => __DIR__ . '/..' . '/galbar/jsonpath/src/Galbar',
56
- ),
57
- ),
58
- 'J' =>
59
- array (
60
- 'JsonPath\\' =>
61
- array (
62
- 0 => __DIR__ . '/..' . '/galbar/jsonpath/src/Galbar',
63
- ),
64
- ),
65
  );
66
 
67
  public static $classMap = array (
@@ -71,10 +57,10 @@ class ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d
71
  public static function getInitializer(ClassLoader $loader)
72
  {
73
  return \Closure::bind(function () use ($loader) {
74
- $loader->prefixLengthsPsr4 = ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::$prefixLengthsPsr4;
75
- $loader->prefixDirsPsr4 = ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::$prefixDirsPsr4;
76
- $loader->prefixesPsr0 = ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::$prefixesPsr0;
77
- $loader->classMap = ComposerStaticInitb9057a853289224ea9fa1d5dcedb206d::$classMap;
78
 
79
  }, null, ClassLoader::class);
80
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitf5265850c3d873e108b5abc992d12723
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
48
  0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
49
  ),
50
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  );
52
 
53
  public static $classMap = array (
57
  public static function getInitializer(ClassLoader $loader)
58
  {
59
  return \Closure::bind(function () use ($loader) {
60
+ $loader->prefixLengthsPsr4 = ComposerStaticInitf5265850c3d873e108b5abc992d12723::$prefixLengthsPsr4;
61
+ $loader->prefixDirsPsr4 = ComposerStaticInitf5265850c3d873e108b5abc992d12723::$prefixDirsPsr4;
62
+ $loader->prefixesPsr0 = ComposerStaticInitf5265850c3d873e108b5abc992d12723::$prefixesPsr0;
63
+ $loader->classMap = ComposerStaticInitf5265850c3d873e108b5abc992d12723::$classMap;
64
 
65
  }, null, ClassLoader::class);
66
  }
vendor/composer/installed.json CHANGED
@@ -1,54 +1,4 @@
1
  [
2
- {
3
- "name": "galbar/jsonpath",
4
- "version": "dev-master",
5
- "version_normalized": "9999999-dev",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/Galbar/JsonPath-PHP.git",
9
- "reference": "3820fd4da177f5cf180aa47260d57086e4e4ba29"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/Galbar/JsonPath-PHP/zipball/3820fd4da177f5cf180aa47260d57086e4e4ba29",
14
- "reference": "3820fd4da177f5cf180aa47260d57086e4e4ba29",
15
- "shasum": ""
16
- },
17
- "require": {
18
- "php": ">=5.4"
19
- },
20
- "require-dev": {
21
- "phpunit/phpunit": "~4.0",
22
- "sami/sami": ">=3.3.0",
23
- "satooshi/php-coveralls": ">=1.0.1"
24
- },
25
- "time": "2019-05-06T10:17:27+00:00",
26
- "type": "library",
27
- "installation-source": "source",
28
- "autoload": {
29
- "psr-0": {
30
- "JsonPath\\": "src/Galbar/",
31
- "Utilities\\": "src/Galbar/"
32
- }
33
- },
34
- "notification-url": "https://packagist.org/downloads/",
35
- "license": [
36
- "Apache-2.0"
37
- ],
38
- "authors": [
39
- {
40
- "name": "Alessio Linares",
41
- "email": "alessio@alessio.cc",
42
- "role": "Software Engineer"
43
- }
44
- ],
45
- "description": "JSONPath implementation for querying and updating JSON objects",
46
- "keywords": [
47
- "json",
48
- "jsonpath",
49
- "path"
50
- ]
51
- },
52
  {
53
  "name": "gmulti/morphism-php",
54
  "version": "0.3.0",
@@ -183,23 +133,23 @@
183
  },
184
  {
185
  "name": "weglot/translation-definitions",
186
- "version": "v2.1.4",
187
- "version_normalized": "2.1.4.0",
188
  "source": {
189
  "type": "git",
190
  "url": "https://github.com/weglot/weglot-translation-definitions.git",
191
- "reference": "d2d1ef460c8b7d690e3699569dd08ab631b1308e"
192
  },
193
  "dist": {
194
  "type": "zip",
195
- "url": "https://api.github.com/repos/weglot/weglot-translation-definitions/zipball/d2d1ef460c8b7d690e3699569dd08ab631b1308e",
196
- "reference": "d2d1ef460c8b7d690e3699569dd08ab631b1308e",
197
  "shasum": ""
198
  },
199
  "require": {
200
  "php": ">=5"
201
  },
202
- "time": "2019-05-17T09:36:33+00:00",
203
  "type": "library",
204
  "installation-source": "dist",
205
  "autoload": {
@@ -221,17 +171,17 @@
221
  },
222
  {
223
  "name": "weglot/weglot-php",
224
- "version": "0.5.24",
225
- "version_normalized": "0.5.24.0",
226
  "source": {
227
  "type": "git",
228
  "url": "https://github.com/weglot/weglot-php.git",
229
- "reference": "49e1a559d2b1e73539148ec00c701a87065b3d31"
230
  },
231
  "dist": {
232
  "type": "zip",
233
- "url": "https://api.github.com/repos/weglot/weglot-php/zipball/49e1a559d2b1e73539148ec00c701a87065b3d31",
234
- "reference": "49e1a559d2b1e73539148ec00c701a87065b3d31",
235
  "shasum": ""
236
  },
237
  "require": {
@@ -244,7 +194,7 @@
244
  "codeception/codeception": "^2.4",
245
  "vlucas/phpdotenv": "^2.4"
246
  },
247
- "time": "2019-05-17T13:01:34+00:00",
248
  "type": "library",
249
  "installation-source": "dist",
250
  "autoload": {
@@ -257,16 +207,16 @@
257
  "MIT"
258
  ],
259
  "authors": [
260
- {
261
- "name": "Thomas Deneulin",
262
- "email": "thomas@weglot.com",
263
- "role": "Review"
264
- },
265
  {
266
  "name": "Baptiste Leduc",
267
  "email": "baptiste@weglot.com",
268
  "homepage": "https://baptiste-leduc.now.sh/",
269
  "role": "Developer"
 
 
 
 
 
270
  }
271
  ],
272
  "description": "PHP library for the Weglot API",
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "name": "gmulti/morphism-php",
4
  "version": "0.3.0",
133
  },
134
  {
135
  "name": "weglot/translation-definitions",
136
+ "version": "v2.1.6",
137
+ "version_normalized": "2.1.6.0",
138
  "source": {
139
  "type": "git",
140
  "url": "https://github.com/weglot/weglot-translation-definitions.git",
141
+ "reference": "e547040d25fd90d502628416fa4b359bb5c78b1c"
142
  },
143
  "dist": {
144
  "type": "zip",
145
+ "url": "https://api.github.com/repos/weglot/weglot-translation-definitions/zipball/e547040d25fd90d502628416fa4b359bb5c78b1c",
146
+ "reference": "e547040d25fd90d502628416fa4b359bb5c78b1c",
147
  "shasum": ""
148
  },
149
  "require": {
150
  "php": ">=5"
151
  },
152
+ "time": "2019-06-28T09:22:32+00:00",
153
  "type": "library",
154
  "installation-source": "dist",
155
  "autoload": {
171
  },
172
  {
173
  "name": "weglot/weglot-php",
174
+ "version": "0.5.31",
175
+ "version_normalized": "0.5.31.0",
176
  "source": {
177
  "type": "git",
178
  "url": "https://github.com/weglot/weglot-php.git",
179
+ "reference": "8e3369a8d09b6ee8c75d1172516db2f56260ced9"
180
  },
181
  "dist": {
182
  "type": "zip",
183
+ "url": "https://api.github.com/repos/weglot/weglot-php/zipball/8e3369a8d09b6ee8c75d1172516db2f56260ced9",
184
+ "reference": "8e3369a8d09b6ee8c75d1172516db2f56260ced9",
185
  "shasum": ""
186
  },
187
  "require": {
194
  "codeception/codeception": "^2.4",
195
  "vlucas/phpdotenv": "^2.4"
196
  },
197
+ "time": "2019-09-02T12:15:58+00:00",
198
  "type": "library",
199
  "installation-source": "dist",
200
  "autoload": {
207
  "MIT"
208
  ],
209
  "authors": [
 
 
 
 
 
210
  {
211
  "name": "Baptiste Leduc",
212
  "email": "baptiste@weglot.com",
213
  "homepage": "https://baptiste-leduc.now.sh/",
214
  "role": "Developer"
215
+ },
216
+ {
217
+ "name": "Thomas Deneulin",
218
+ "email": "thomas@weglot.com",
219
+ "role": "Review"
220
  }
221
  ],
222
  "description": "PHP library for the Weglot API",
vendor/galbar/jsonpath DELETED
@@ -1 +0,0 @@
1
- Subproject commit 3820fd4da177f5cf180aa47260d57086e4e4ba29
 
vendor/weglot/translation-definitions/data/cases/cases-v3.json CHANGED
@@ -220,7 +220,37 @@
220
  ]
221
  },
222
  {
223
- "name": "tag with br",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  "body": "<p>Hello, <br> a test!</p>",
225
  "expected": [
226
  {
@@ -230,7 +260,7 @@
230
  ]
231
  },
232
  {
233
- "name": "tag with br",
234
  "body": "<p>Hello, <br> a test! how are <b>you</b></p>",
235
  "expected": [
236
  {
@@ -337,7 +367,7 @@
337
  },
338
  {
339
  "name": "Link tag with pdf",
340
- "body": "<p><a href='/my-document.pdf'>Click here!</a></p>",
341
  "expected": [
342
  {
343
  "t": 8,
@@ -349,6 +379,20 @@
349
  }
350
  ]
351
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  {
353
  "name": "Tag with new line and blanks",
354
  "body": "<p> \n\n <strong>test</strong> \n\n </p>",
@@ -359,4 +403,4 @@
359
  }
360
  ]
361
  }
362
- ]
220
  ]
221
  },
222
  {
223
+ "name": "Nested tags 15",
224
+ "body": "<p> <b> This is another nested test </b><br></p>",
225
+ "expected": [
226
+ {
227
+ "t": 1,
228
+ "w": " This is another nested test "
229
+ }
230
+ ]
231
+ },
232
+ {
233
+ "name": "Nested tags 16",
234
+ "body": "<p>This <strong>is</strong> another nested test<br></p>",
235
+ "expected": [
236
+ {
237
+ "t": 1,
238
+ "w": "This <strong wg-1=\"\">is</strong> another nested test<br wg-2=\"\">"
239
+ }
240
+ ]
241
+ },
242
+ {
243
+ "name": "Nested tags 17",
244
+ "body": "<p>This ending tag must not be here<br></p>",
245
+ "expected": [
246
+ {
247
+ "t": 1,
248
+ "w": "This ending tag must not be here"
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "name": "Tag with br",
254
  "body": "<p>Hello, <br> a test!</p>",
255
  "expected": [
256
  {
260
  ]
261
  },
262
  {
263
+ "name": "Tag with br",
264
  "body": "<p>Hello, <br> a test! how are <b>you</b></p>",
265
  "expected": [
266
  {
367
  },
368
  {
369
  "name": "Link tag with pdf",
370
+ "body": "<p><a href=\"/my-document.pdf\">Click here!</a></p>",
371
  "expected": [
372
  {
373
  "t": 8,
379
  }
380
  ]
381
  },
382
+ {
383
+ "name": "Link tag with pdf 2",
384
+ "body": "<p>Hello! <a href=\"/my-document.pdf\">Click here!</a></p>",
385
+ "expected": [
386
+ {
387
+ "t": 8,
388
+ "w": "/my-document.pdf"
389
+ },
390
+ {
391
+ "t": 1,
392
+ "w": "Hello! <a wg-1=\"\">Click here!</a>"
393
+ }
394
+ ]
395
+ },
396
  {
397
  "name": "Tag with new line and blanks",
398
  "body": "<p> \n\n <strong>test</strong> \n\n </p>",
403
  }
404
  ]
405
  }
406
+ ]
vendor/weglot/translation-definitions/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "weglot-translation-definitions",
3
- "version": "2.1.4",
4
  "main": "index.js",
5
  "private": true,
6
  "repository": "https://github.com/weglot/weglot-translation-definitions.git",
1
  {
2
  "name": "weglot-translation-definitions",
3
+ "version": "2.1.5",
4
  "main": "index.js",
5
  "private": true,
6
  "repository": "https://github.com/weglot/weglot-translation-definitions.git",
vendor/weglot/weglot-php/.travis.yml CHANGED
@@ -3,6 +3,8 @@ language: php
3
  services:
4
  - redis-server
5
 
 
 
6
  notifications:
7
  email:
8
  on_failure: change
3
  services:
4
  - redis-server
5
 
6
+ dist: trusty
7
+
8
  notifications:
9
  email:
10
  on_failure: change
vendor/weglot/weglot-php/src/Client/Endpoint/Translate.php CHANGED
@@ -175,17 +175,23 @@ class Translate extends Endpoint
175
  $asArray['words'] = $beforeRequest[0];
176
  }
177
 
178
- list($rawBody, $httpStatusCode, $httpHeader) = $this->request($asArray, false);
179
- if ($httpStatusCode !== 200) {
180
- throw new ApiError($rawBody, $asArray);
181
- }
 
 
 
 
 
182
 
183
- $response = json_decode($rawBody, true);
184
- if ($this->getCache()->enabled()) {
185
- $response = $this->afterRequest($response, $beforeRequest);
 
186
  }
187
 
188
  $factory = new TranslateFactory($response);
189
  return $factory->handle();
190
  }
191
- }
175
  $asArray['words'] = $beforeRequest[0];
176
  }
177
 
178
+ if (empty($asArray['words'])) {
179
+ if ($this->getCache()->enabled()) {
180
+ $response = $this->afterRequest($asArray, $beforeRequest);
181
+ }
182
+ } else {
183
+ list($rawBody, $httpStatusCode) = $this->request($asArray, false);
184
+ if ($httpStatusCode !== 200) {
185
+ throw new ApiError($rawBody, $asArray);
186
+ }
187
 
188
+ $response = json_decode($rawBody, true);
189
+ if ($this->getCache()->enabled()) {
190
+ $response = $this->afterRequest($response, $beforeRequest);
191
+ }
192
  }
193
 
194
  $factory = new TranslateFactory($response);
195
  return $factory->handle();
196
  }
197
+ }
vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php CHANGED
@@ -256,6 +256,8 @@ class DomCheckerProvider
256
 
257
  $node = $node->parentNode();
258
  $shift = $number - 1;
 
 
259
  }
260
 
261
  // We descend the node to see if we can take a child instead, in the case there are wrapping node or empty nodes. For instance, In that case <p><b>Hello</b></p>, it's better to chose node "b" than "p"
@@ -314,26 +316,26 @@ class DomCheckerProvider
314
  $count++;
315
  }
316
 
 
 
317
 
318
- foreach($node->nodes as $n) {
319
-
320
- if($this->containsBlock($n) || $n->hasAttribute(Parser::ATTRIBUTE_NO_TRANSLATE)) {
321
- return false;
322
- }
323
 
324
 
325
- if($child != null && $n->outertext() == $child->outertext()) {
326
- $child = null;
327
- }
328
 
329
 
330
- if($child == null) {
331
- $number = $this->numberOfTextNodeInParentAfterChild($n);
332
- if($number === false) {
333
- return false;
334
- }
335
- else {
336
- $count += $number;
337
  }
338
  }
339
  }
256
 
257
  $node = $node->parentNode();
258
  $shift = $number - 1;
259
+ if($node->tag === 'root')
260
+ break;
261
  }
262
 
263
  // We descend the node to see if we can take a child instead, in the case there are wrapping node or empty nodes. For instance, In that case <p><b>Hello</b></p>, it's better to chose node "b" than "p"
316
  $count++;
317
  }
318
 
319
+ if (is_array($node) || is_object($node)) {
320
+ foreach ($node->nodes as $n) {
321
 
322
+ if ($this->containsBlock($n) || $n->hasAttribute(Parser::ATTRIBUTE_NO_TRANSLATE)) {
323
+ return false;
324
+ }
 
 
325
 
326
 
327
+ if ($child != null && $n->outertext() == $child->outertext()) {
328
+ $child = null;
329
+ }
330
 
331
 
332
+ if ($child == null) {
333
+ $number = $this->numberOfTextNodeInParentAfterChild($n);
334
+ if ($number === false) {
335
+ return false;
336
+ } else {
337
+ $count += $number;
338
+ }
339
  }
340
  }
341
  }
vendor/weglot/weglot-php/src/Parser/Check/JsonLdChecker.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Weglot\Parser\Check;
4
-
5
- use Weglot\Client\Api\Exception\InvalidWordTypeException;
6
- use Weglot\Util\JsonLd;
7
-
8
- /**
9
- * Class JsonLdChecker
10
- * @package Weglot\Parser\Check
11
- */
12
- class JsonLdChecker extends AbstractChecker
13
- {
14
- /**
15
- * @return array
16
- * @throws InvalidWordTypeException
17
- */
18
- public function handle()
19
- {
20
- $jsons = [];
21
-
22
- foreach ($this->dom->find('script[type="application/ld+json"]') as $k => $row) {
23
- $json = json_decode($row->innertext, true);
24
- if (json_last_error() === JSON_ERROR_NONE) {
25
- $value = JsonLd::get($json, 'description');
26
-
27
- if ($value !== null) {
28
- JsonLd::add($this->getParser()->getWords(), $value);
29
- $jsons[] = [
30
- 'node' => $row,
31
- 'json' => $json
32
- ];
33
- }
34
- }
35
- }
36
-
37
- return $jsons;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/weglot/weglot-php/src/Parser/Check/Regex/JsonChecker.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Weglot\Parser\Check\Regex;
4
+
5
+ use Weglot\Client\Api\Exception\InvalidWordTypeException;
6
+ use Weglot\Parser\Parser;
7
+ use Weglot\Util\JsonUtil;
8
+ use Weglot\Util\Text;
9
+
10
+ /**
11
+ * Class JsonLdChecker
12
+ * @package Weglot\Parser\Check
13
+ */
14
+ class JsonChecker
15
+ {
16
+ protected $default_keys = array( 'description' , 'name' );
17
+
18
+ protected $jsonString;
19
+ protected $parser;
20
+ protected $extraKeys;
21
+
22
+ /**
23
+ * @param Parser $parser
24
+ * @return $this
25
+ */
26
+ public function setParser(Parser $parser)
27
+ {
28
+ $this->parser = $parser;
29
+
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * @return Parser
35
+ */
36
+ public function getParser()
37
+ {
38
+ return $this->parser;
39
+ }
40
+
41
+ public function __construct(Parser $parser, $jsonString, $extraKeys)
42
+ {
43
+ $this
44
+ ->setParser($parser)
45
+ ->setJSonString($jsonString)
46
+ ->setExtraKeys($extraKeys);
47
+ }
48
+
49
+ /**
50
+ * @param string $jsonString
51
+ * @return $this
52
+ */
53
+ public function setJsonString($jsonString)
54
+ {
55
+ $this->jsonString = $jsonString;
56
+
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * @return string
62
+ */
63
+ public function getJsonString()
64
+ {
65
+ return $this->jsonString;
66
+ }
67
+
68
+ /**
69
+ * @param array $extraKeys
70
+ * @return $this
71
+ */
72
+ public function setExtraKeys($extraKeys)
73
+ {
74
+ $this->extraKeys = $extraKeys;
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * @return array
81
+ */
82
+ public function getExtraKeys()
83
+ {
84
+ return $this->extraKeys;
85
+ }
86
+
87
+ /**
88
+ * @return array
89
+ * @throws InvalidWordTypeException
90
+ */
91
+ public function handle()
92
+ {
93
+ $json = json_decode($this->jsonString, true);
94
+
95
+ $paths = [];
96
+ $this->findWords($json, "", $paths);
97
+
98
+ return array(
99
+ "type" => "JSON",
100
+ "source" => $this->jsonString,
101
+ "jsonArray" => $json,
102
+ "paths" => $paths);
103
+
104
+ }
105
+
106
+ public function findWords($json, $currentKey, &$paths) {
107
+
108
+ foreach ($json as $key => $value) {
109
+ if(is_array($value)) {
110
+ $this->findWords($value, ltrim($currentKey.JsonUtil::SEPARATOR.$key, JsonUtil::SEPARATOR), $paths);
111
+ }
112
+ else {
113
+ $k = ltrim($currentKey.JsonUtil::SEPARATOR.$key, JsonUtil::SEPARATOR);
114
+ if(Text::isJSON($value)) {
115
+ $parsed = $this->getParser()->parseJSON($value, $this->getExtraKeys());
116
+ array_push($paths, array( "key" => $k, "parsed" => $parsed));
117
+ }
118
+ elseif(Text::isHTML($value)) {
119
+ $parsed = $this->getParser()->parseHTML($value);
120
+ array_push($paths, array( "key" => $k , "parsed" => $parsed));
121
+
122
+ }
123
+ elseif(in_array($key, array_unique(array_merge($this->default_keys , $this->getExtraKeys())) , true)) {
124
+ $parsed = $this->getParser()->parseText($value);
125
+ array_push($paths, array( "key" => $k , "parsed" => $parsed));
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
vendor/weglot/weglot-php/src/Parser/Check/Regex/RegexChecker.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Remy Berda
4
+ * User: remy
5
+ * Date: 12/06/2019
6
+ * Time: 16:52
7
+ */
8
+
9
+ namespace Weglot\Parser\Check\Regex;
10
+
11
+ use Weglot\Parser\Parser;
12
+
13
+
14
+ /**
15
+ * Class RegexChecker
16
+ * @package Weglot\Parser\Check
17
+ */
18
+ class RegexChecker
19
+ {
20
+ /**
21
+ * DOM node to match
22
+ *
23
+ * @var string
24
+ */
25
+ public $regex = '';
26
+
27
+ /**
28
+ * DOM node to match
29
+ *
30
+ * @var string
31
+ */
32
+ public $type = '';
33
+
34
+
35
+ public $var_number = 1;
36
+
37
+
38
+ /**
39
+ * DOM node to match
40
+ *
41
+ * @var string
42
+ */
43
+ public $keys = '';
44
+
45
+
46
+
47
+ /**
48
+ * DomChecker constructor.
49
+ * @param Parser $parser
50
+ */
51
+ public function __construct($regex = '' , $type = '' , $var_number = 0 , $keys = array())
52
+ {
53
+ $this->regex = $regex;
54
+ $this->type = $type;
55
+ $this->var_number = $var_number;
56
+ $this->keys = $keys;
57
+ }
58
+
59
+
60
+ /**
61
+ * @return array
62
+ */
63
+
64
+ public function toArray()
65
+ {
66
+ return [
67
+ $this->regex,
68
+ $this->type,
69
+ $this->var_number,
70
+ $this->keys
71
+ ];
72
+ }
73
+ }
vendor/weglot/weglot-php/src/Parser/Check/RegexCheckerProvider.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Weglot\Parser\Check;
4
+
5
+ use Weglot\Parser\Check\Regex\RegexChecker;
6
+ use Weglot\Util\SourceType;
7
+ use WGSimpleHtmlDom\simple_html_dom;
8
+ use WGSimpleHtmlDom\simple_html_dom_node;
9
+ use Weglot\Client\Api\Exception\InvalidWordTypeException;
10
+ use Weglot\Client\Api\WordEntry;
11
+ use Weglot\Parser\Check\Dom\AbstractDomChecker;
12
+ use Weglot\Parser\Parser;
13
+ use Weglot\Util\Text;
14
+
15
+ class RegexCheckerProvider
16
+ {
17
+
18
+ const DEFAULT_CHECKERS_NAMESPACE = '\\Weglot\\Parser\\Check\\Regex\\';
19
+
20
+ /**
21
+ * @var Parser
22
+ */
23
+ protected $parser = null;
24
+
25
+ /**
26
+ * @var array
27
+ */
28
+ protected $checkers = [];
29
+
30
+ /**
31
+ * @var array
32
+ */
33
+ protected $discoverCaching = [];
34
+
35
+
36
+ /**
37
+ * DomChecker constructor.
38
+ * @param Parser $parser
39
+ * @param int $translationEngine
40
+ */
41
+ public function __construct(Parser $parser)
42
+ {
43
+ $this->setParser($parser);
44
+ $this->loadDefaultCheckers();
45
+ }
46
+
47
+ /**
48
+ * @param Parser $parser
49
+ * @return $this
50
+ */
51
+ public function setParser(Parser $parser)
52
+ {
53
+ $this->parser = $parser;
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * @return Parser
60
+ */
61
+ public function getParser()
62
+ {
63
+ return $this->parser;
64
+ }
65
+
66
+
67
+ /**
68
+ * @param $checker
69
+ * @return $this
70
+ */
71
+ public function addChecker($checker)
72
+ {
73
+ $this->checkers[] = $checker;
74
+
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * @param array $checkers
80
+ * @return $this
81
+ */
82
+ public function addCheckers(array $checkers)
83
+ {
84
+ $this->checkers = array_merge($this->checkers, $checkers);
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * @return array
91
+ */
92
+ public function getCheckers()
93
+ {
94
+ return $this->checkers;
95
+ }
96
+
97
+ /**
98
+ * Load default checkers
99
+ */
100
+ protected function loadDefaultCheckers()
101
+ {
102
+ /* Add JSON LD checker */
103
+ $this->addChecker(new RegexChecker("#<script type=('|\")application\/ld\+json('|\")([^\>]+?)?>((.|\n)*?)<\/script>#" , SourceType::SOURCE_JSON, 4 , array( "description" , "name" , "headline" , "articleSection" )));
104
+
105
+ /* Add HTML template checker */
106
+ $this->addChecker(new RegexChecker( "#<script type=('|\")text/html('|\")([^\>]+?)?>((.|\n)*?)<\/script>#" , SourceType::SOURCE_HTML, 4));
107
+ }
108
+
109
+ /**
110
+ * @param string $checker Class of the Checker to add
111
+ * @return bool
112
+ */
113
+ public function register($checker)
114
+ {
115
+ if ($checker instanceof RegexChecker) {
116
+ $this->addChecker($checker);
117
+ return true;
118
+ }
119
+ return false;
120
+ }
121
+
122
+
123
+ /**
124
+ * @param string $domString
125
+ * @return array
126
+ * @throws InvalidWordTypeException
127
+ */
128
+ public function handle($domString)
129
+ {
130
+ $checkers = $this->getCheckers();
131
+ $regexes = [];
132
+ foreach ($checkers as $class) {
133
+ list($regex, $type, $varNumber, $extraKeys) = $class->toArray();
134
+ preg_match_all($regex, $domString, $matches);
135
+ if(isset($matches[$varNumber])) {
136
+ $matches0 = $matches[0];
137
+ $matches1 = $matches[$varNumber];
138
+ foreach ($matches1 as $k => $match) {
139
+
140
+ if($type === SourceType::SOURCE_JSON) {
141
+ $regex = $this->getParser()->parseJSON($match, $extraKeys);
142
+ }
143
+ if($type === SourceType::SOURCE_TEXT) {
144
+ $regex = $this->getParser()->parseText($match, $matches0[$k]);
145
+ }
146
+ if($type === SourceType::SOURCE_HTML) {
147
+ $regex = $this->getParser()->parseHTML($match);
148
+ }
149
+ array_push($regexes, $regex);
150
+ }
151
+ }
152
+ }
153
+ return $regexes;
154
+ }
155
+
156
+
157
+ }
vendor/weglot/weglot-php/src/Parser/ConfigProvider/ServerConfigProvider.php CHANGED
@@ -25,8 +25,14 @@ class ServerConfigProvider extends AbstractConfigProvider
25
  */
26
  public function loadFromServer()
27
  {
 
 
 
 
 
 
28
  $this
29
- ->setUrl(Server::fullUrl($_SERVER))
30
  ->setBot(Server::detectBot($_SERVER));
31
  }
32
  }
25
  */
26
  public function loadFromServer()
27
  {
28
+ if( http_response_code() !== 200) {
29
+ $url = '/404';
30
+ } else {
31
+ $url = Server::fullUrl($_SERVER);
32
+ }
33
+
34
  $this
35
+ ->setUrl($url)
36
  ->setBot(Server::detectBot($_SERVER));
37
  }
38
  }
vendor/weglot/weglot-php/src/Parser/Formatter/AbstractFormatter.php CHANGED
@@ -73,7 +73,8 @@ abstract class AbstractFormatter
73
 
74
  /**
75
  * @param array $array
 
76
  * @return void
77
  */
78
- abstract public function handle(array $array);
79
  }
73
 
74
  /**
75
  * @param array $array
76
+ * @param int $index
77
  * @return void
78
  */
79
+ abstract public function handle(array $array, &$index);
80
  }
vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php CHANGED
@@ -40,7 +40,7 @@ class DomFormatter extends AbstractFormatter
40
  /**
41
  * {@inheritdoc}
42
  */
43
- public function handle(array $nodes)
44
  {
45
  $translatable_attributes = $this->getTranslatableAttributes();
46
 
@@ -50,13 +50,14 @@ class DomFormatter extends AbstractFormatter
50
  for ($i = 0; $i < \count($nodes); ++$i) {
51
  $currentNode = $nodes[$i];
52
 
53
- if ($translated_words[$i] !== null) {
54
- $currentTranslated = $translated_words[$i];
55
 
56
  $this->metaContent($currentNode, $currentTranslated, $translatable_attributes, $original_words, $translated_words);
57
  $this->imageSource($currentNode, $currentTranslated, $i);
58
  }
59
  }
 
60
  }
61
 
62
  /**
@@ -68,7 +69,7 @@ class DomFormatter extends AbstractFormatter
68
 
69
  if ($details['class']::ESCAPE_SPECIAL_CHAR) {
70
  $details['node']->$property = htmlspecialchars($translated);
71
- } else {
72
  $details['node']->$property = $translated;
73
  }
74
 
40
  /**
41
  * {@inheritdoc}
42
  */
43
+ public function handle(array $nodes, &$index)
44
  {
45
  $translatable_attributes = $this->getTranslatableAttributes();
46
 
50
  for ($i = 0; $i < \count($nodes); ++$i) {
51
  $currentNode = $nodes[$i];
52
 
53
+ if ($translated_words[$i+$index] !== null) {
54
+ $currentTranslated = $translated_words[$i+$index];
55
 
56
  $this->metaContent($currentNode, $currentTranslated, $translatable_attributes, $original_words, $translated_words);
57
  $this->imageSource($currentNode, $currentTranslated, $i);
58
  }
59
  }
60
+ $index = $index + count($nodes);
61
  }
62
 
63
  /**
69
 
70
  if ($details['class']::ESCAPE_SPECIAL_CHAR) {
71
  $details['node']->$property = htmlspecialchars($translated);
72
+ } else {
73
  $details['node']->$property = $translated;
74
  }
75
 
vendor/weglot/weglot-php/src/Parser/Formatter/JsonFormatter.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Weglot\Parser\Formatter;
4
+
5
+ use Weglot\Client\Api\TranslateEntry;
6
+ use Weglot\Parser\Parser;
7
+ use Weglot\Util\JsonUtil;
8
+ use Weglot\Util\SourceType;
9
+
10
+ /**
11
+ * Class JsonFormatter
12
+ * @package Weglot\Parser\Formatter
13
+ */
14
+ class JsonFormatter extends AbstractFormatter
15
+ {
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ protected $source;
21
+
22
+ /**
23
+ * JsonLdFormatter constructor.
24
+ * @param Parser $parser
25
+ * @param string $source
26
+ * @param TranslateEntry $translated
27
+ * @param int $nodesCount
28
+ */
29
+ public function __construct(Parser $parser, $source, TranslateEntry $translated)
30
+ {
31
+ $this->setSource($source);
32
+ parent::__construct($parser, $translated);
33
+ }
34
+
35
+ /**
36
+ * @param string $source
37
+ * @return $this
38
+ */
39
+ public function setSource($source)
40
+ {
41
+ $this->source = $source;
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * @return string
47
+ */
48
+ public function getSource()
49
+ {
50
+ return $this->source;
51
+ }
52
+
53
+ /**
54
+ * {@inheritdoc}
55
+ */
56
+ public function handle(array $tree, &$index)
57
+ {
58
+ $translated_words = $this->getTranslated()->getOutputWords();
59
+
60
+ $jsonString = $tree['source'];
61
+ $jsonArray = $tree['jsonArray'];
62
+ $paths = $tree['paths'];
63
+
64
+ foreach ($paths as $path) {
65
+ $key = $path['key'];
66
+ $parsed = $path['parsed'];
67
+
68
+
69
+ if($parsed['type'] === SourceType::SOURCE_TEXT) {
70
+ $jsonArray = JsonUtil::set($translated_words, $jsonArray, $key, $index);
71
+ }
72
+ if($parsed['type'] === SourceType::SOURCE_JSON) {
73
+ $source = $this->getParser()->formatters($parsed['source'], $this->getTranslated(), $parsed, $index);
74
+ $jsonArray = JsonUtil::setJSONString($source, $jsonArray, $key);
75
+ }
76
+ if($parsed['type'] === SourceType::SOURCE_HTML) {
77
+ if($parsed['nodes']) {
78
+ $formatter = new DomFormatter($this->getParser(), $this->getTranslated());
79
+ $formatter->handle($parsed['nodes'], $index);
80
+ $jsonArray= JsonUtil::setHTML($parsed['dom']->save(), $jsonArray, $key);
81
+
82
+ foreach ($parsed['regexes'] as $regex) {
83
+ $translatedRegex = $this->getParser()->formatters($regex['source'], $this->getTranslated(), $regex, $index);
84
+ $source = str_replace($regex['source'] , $translatedRegex, $parsed['source']);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ $this->setSource(str_replace($jsonString, json_encode($jsonArray ), $this->getSource()));
90
+
91
+
92
+ return $this->getSource();
93
+ }
94
+ }
vendor/weglot/weglot-php/src/Parser/Formatter/JsonLdFormatter.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
-
3
- namespace Weglot\Parser\Formatter;
4
-
5
- use Weglot\Client\Api\TranslateEntry;
6
- use Weglot\Parser\Parser;
7
- use Weglot\Util\JsonLd;
8
-
9
- /**
10
- * Class JsonLdFormatter
11
- * @package Weglot\Parser\Formatter
12
- */
13
- class JsonLdFormatter extends AbstractFormatter
14
- {
15
- /**
16
- * @var int
17
- */
18
- protected $nodesCount;
19
-
20
- /**
21
- * JsonLdFormatter constructor.
22
- * @param Parser $parser
23
- * @param TranslateEntry $translated
24
- * @param int $nodesCount
25
- */
26
- public function __construct(Parser $parser, TranslateEntry $translated, $nodesCount)
27
- {
28
- $this->setNodesCount($nodesCount);
29
- parent::__construct($parser, $translated);
30
- }
31
-
32
- /**
33
- * @param int $nodesCount
34
- * @return $this
35
- */
36
- public function setNodesCount($nodesCount)
37
- {
38
- $this->nodesCount = $nodesCount;
39
-
40
- return $this;
41
- }
42
-
43
- /**
44
- * @return int
45
- */
46
- public function getNodesCount()
47
- {
48
- return $this->nodesCount;
49
- }
50
-
51
- /**
52
- * {@inheritdoc}
53
- */
54
- public function handle(array $jsons)
55
- {
56
- $translated_words = $this->getTranslated()->getOutputWords();
57
-
58
- for ($j = 0; $j < \count($jsons); $j++) {
59
- $data = $jsons[$j]['json'];
60
- $node = $jsons[$j]['node'];
61
-
62
- $value = JsonLd::get($data, 'description');
63
-
64
- if ($value !== null) {
65
- $data = JsonLd::set($translated_words, $data, 'description', $this->nodesCount);
66
- }
67
-
68
- $node->innertext = json_encode($data, JSON_PRETTY_PRINT);
69
- }
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/weglot/weglot-php/src/Parser/Parser.php CHANGED
@@ -2,6 +2,14 @@
2
 
3
  namespace Weglot\Parser;
4
 
 
 
 
 
 
 
 
 
5
  use WGSimpleHtmlDom\simple_html_dom;
6
  use Weglot\Client\Api\Exception\ApiError;
7
  use Weglot\Client\Api\Exception\InputAndOutputCountMatchException;
@@ -12,9 +20,8 @@ use Weglot\Client\Api\TranslateEntry;
12
  use Weglot\Client\Api\WordCollection;
13
  use Weglot\Client\Client;
14
  use Weglot\Client\Endpoint\Translate;
15
- use Weglot\Parser\Check\DomChecker;
16
  use Weglot\Parser\Check\DomCheckerProvider;
17
- use Weglot\Parser\Check\JsonLdChecker;
18
  use Weglot\Parser\ConfigProvider\ConfigProviderInterface;
19
  use Weglot\Parser\ConfigProvider\ServerConfigProvider;
20
  use Weglot\Parser\Formatter\DomFormatter;
@@ -33,6 +40,7 @@ class Parser
33
  */
34
  const ATTRIBUTE_NO_TRANSLATE = 'data-wg-notranslate';
35
 
 
36
  /**
37
  * @var Client
38
  */
@@ -68,6 +76,11 @@ class Parser
68
  */
69
  protected $domCheckerProvider;
70
 
 
 
 
 
 
71
  /**
72
  * @var IgnoredNodes
73
  */
@@ -87,6 +100,7 @@ class Parser
87
  ->setExcludeBlocks($excludeBlocks)
88
  ->setWords(new WordCollection())
89
  ->setDomCheckerProvider(new DomCheckerProvider($this, $client->getProfile()->getTranslationEngine()))
 
90
  ->setIgnoredNodesFormatter(new IgnoredNodes());
91
  }
92
 
@@ -204,6 +218,24 @@ class Parser
204
  return $this->words;
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * @param DomCheckerProvider $domCheckerProvider
209
  * @return $this
@@ -223,7 +255,7 @@ class Parser
223
  }
224
 
225
  /**
226
- * @param IgnoredNodes $ignoredNodes
227
  * @return $this
228
  */
229
  public function setIgnoredNodesFormatter(IgnoredNodes $ignoredNodesFormatter)
@@ -244,6 +276,7 @@ class Parser
244
  * @param string $source
245
  * @param string $languageFrom
246
  * @param string $languageTo
 
247
  * @return string
248
  * @throws ApiError
249
  * @throws InputAndOutputCountMatchException
@@ -251,62 +284,57 @@ class Parser
251
  * @throws MissingRequiredParamException
252
  * @throws MissingWordsOutputException
253
  */
254
- public function translate($source, $languageFrom, $languageTo)
255
  {
256
  // setters
257
  $this
258
  ->setLanguageFrom($languageFrom)
259
  ->setLanguageTo($languageTo);
260
 
261
- if ($this->client->getProfile()->getTranslationEngine() === 2) {
262
- $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
263
 
264
- $ignoredNodesFormatter->setSource($source)
265
- ->handle();
266
 
267
- $source = $ignoredNodesFormatter->getSource();
 
268
  }
269
-
270
- // simple_html_dom
271
- $dom = \WGSimpleHtmlDom\str_get_html(
272
- $source,
273
- true,
274
- true,
275
- WG_DEFAULT_TARGET_CHARSET,
276
- false
277
- );
278
-
279
- // if simple_html_dom can't parse the $source, it returns false
280
- // so we just return raw $source
281
- if ($dom === false) {
282
- return $source;
283
  }
284
 
285
- // exclude blocks
286
- if (!empty($this->excludeBlocks)) {
287
- $excludeBlocks = new ExcludeBlocksFormatter($dom, $this->excludeBlocks);
288
- $dom = $excludeBlocks->getDom();
289
- }
290
-
291
- // checkers
292
- list($nodes, $jsons) = $this->checkers($dom);
293
-
294
  // api communication
295
- $translated = $this->apiTranslate($dom);
296
-
297
- // formatters
298
- $this->formatters($translated, $nodes, $jsons);
299
 
300
- $source = $dom->save();
 
301
  return $source;
302
  }
303
 
304
  /**
305
  * @param $source
306
- * @return string|WordCollection
 
307
  * @throws InvalidWordTypeException
308
  */
309
- public function parse($source)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  {
311
  if ($this->client->getProfile()->getTranslationEngine() == 2) {
312
  $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
@@ -339,13 +367,24 @@ class Parser
339
  }
340
 
341
  // checkers
342
- $this->checkers($dom);
343
 
344
- return $this->getWords();
 
 
 
 
 
 
 
 
 
 
 
345
  }
346
 
347
  /**
348
- * @param simple_html_dom $dom
349
  * @return TranslateEntry
350
  * @throws ApiError
351
  * @throws InputAndOutputCountMatchException
@@ -353,7 +392,7 @@ class Parser
353
  * @throws MissingRequiredParamException
354
  * @throws MissingWordsOutputException
355
  */
356
- protected function apiTranslate(simple_html_dom $dom)
357
  {
358
  // Translate endpoint parameters
359
  $params = [
@@ -367,7 +406,7 @@ class Parser
367
  }
368
 
369
  if ($this->getConfigProvider()->getAutoDiscoverTitle()) {
370
- $params['title'] = $this->getTitle($dom);
371
  }
372
  $params = array_merge($params, $this->getConfigProvider()->asArray());
373
 
@@ -401,33 +440,58 @@ class Parser
401
 
402
  /**
403
  * @param $dom
 
404
  * @return array
405
  * @throws InvalidWordTypeException
406
  */
407
- protected function checkers($dom)
408
  {
409
  $nodes = $this->getDomCheckerProvider()->handle($dom);
410
-
411
- $checker = new JsonLdChecker($this, $dom);
412
- $jsons = $checker->handle();
413
 
414
  return [
415
  $nodes,
416
- $jsons
417
  ];
418
  }
419
 
420
  /**
 
421
  * @param TranslateEntry $translateEntry
422
- * @param array $nodes
423
- * @param array $jsons
 
424
  */
425
- protected function formatters(TranslateEntry $translateEntry, array $nodes, array $jsons)
426
  {
427
- $formatter = new DomFormatter($this, $translateEntry);
428
- $formatter->handle($nodes);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
 
430
- $formatter = new JsonLdFormatter($this, $translateEntry, count($nodes));
431
- $formatter->handle($jsons);
 
 
 
 
 
432
  }
433
  }
2
 
3
  namespace Weglot\Parser;
4
 
5
+ use phpDocumentor\Reflection\DocBlock\Tags\Source;
6
+ use Weglot\Client\Api\Enum\WordType;
7
+ use Weglot\Client\Api\WordEntry;
8
+ use Weglot\Parser\Check\Regex\JsonChecker;
9
+ use Weglot\Parser\Check\RegexCheckerProvider;
10
+ use Weglot\Parser\Formatter\JsonFormatter;
11
+ use Weglot\Util\SourceType;
12
+ use Weglot\Util\Text;
13
  use WGSimpleHtmlDom\simple_html_dom;
14
  use Weglot\Client\Api\Exception\ApiError;
15
  use Weglot\Client\Api\Exception\InputAndOutputCountMatchException;
20
  use Weglot\Client\Api\WordCollection;
21
  use Weglot\Client\Client;
22
  use Weglot\Client\Endpoint\Translate;
 
23
  use Weglot\Parser\Check\DomCheckerProvider;
24
+
25
  use Weglot\Parser\ConfigProvider\ConfigProviderInterface;
26
  use Weglot\Parser\ConfigProvider\ServerConfigProvider;
27
  use Weglot\Parser\Formatter\DomFormatter;
40
  */
41
  const ATTRIBUTE_NO_TRANSLATE = 'data-wg-notranslate';
42
 
43
+
44
  /**
45
  * @var Client
46
  */
76
  */
77
  protected $domCheckerProvider;
78
 
79
+ /**
80
+ * @var RegexCheckerProvider
81
+ */
82
+ protected $regexCheckerProvider;
83
+
84
  /**
85
  * @var IgnoredNodes
86
  */
100
  ->setExcludeBlocks($excludeBlocks)
101
  ->setWords(new WordCollection())
102
  ->setDomCheckerProvider(new DomCheckerProvider($this, $client->getProfile()->getTranslationEngine()))
103
+ ->setRegexCheckerProvider(new RegexCheckerProvider($this))
104
  ->setIgnoredNodesFormatter(new IgnoredNodes());
105
  }
106
 
218
  return $this->words;
219
  }
220
 
221
+ /**
222
+ * @param RegexCheckerProvider $regexCheckerProvider
223
+ * @return $this
224
+ */
225
+ public function setRegexCheckerProvider(RegexCheckerProvider $regexCheckerProvider)
226
+ {
227
+ $this->regexCheckerProvider = $regexCheckerProvider;
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * @return RegexCheckerProvider
233
+ */
234
+ public function getRegexCheckerProvider()
235
+ {
236
+ return $this->regexCheckerProvider;
237
+ }
238
+
239
  /**
240
  * @param DomCheckerProvider $domCheckerProvider
241
  * @return $this
255
  }
256
 
257
  /**
258
+ * @param IgnoredNodes $ignoredNodesFormatter
259
  * @return $this
260
  */
261
  public function setIgnoredNodesFormatter(IgnoredNodes $ignoredNodesFormatter)
276
  * @param string $source
277
  * @param string $languageFrom
278
  * @param string $languageTo
279
+ * @param array $extraKeys
280
  * @return string
281
  * @throws ApiError
282
  * @throws InputAndOutputCountMatchException
284
  * @throws MissingRequiredParamException
285
  * @throws MissingWordsOutputException
286
  */
287
+ public function translate($source, $languageFrom, $languageTo, $extraKeys = [])
288
  {
289
  // setters
290
  $this
291
  ->setLanguageFrom($languageFrom)
292
  ->setLanguageTo($languageTo);
293
 
294
+ $results = $this->parse($source, $extraKeys);
 
295
 
296
+ $tree = $results['tree'];
 
297
 
298
+ if($tree['type'] === SourceType::SOURCE_HTML) {
299
+ $title = $this->getTitle($tree['dom']);
300
  }
301
+ else {
302
+ $title = "";
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
 
 
 
 
 
 
 
 
 
 
305
  // api communication
306
+ if(count($this->getWords()) === 0) {
307
+ return $source;
308
+ }
 
309
 
310
+ $translated = $this->apiTranslate($title);
311
+ $source = $this->formatters($source, $translated, $tree);
312
  return $source;
313
  }
314
 
315
  /**
316
  * @param $source
317
+ * @param $extraKeys
318
+ * @return array
319
  * @throws InvalidWordTypeException
320
  */
321
+ public function parse($source, $extraKeys = [])
322
+ {
323
+ $type = self::getSourceType($source);
324
+
325
+ if($type === SourceType::SOURCE_HTML) {
326
+ $tree = $this->parseHTML($source);
327
+ }
328
+ elseif($type === SourceType::SOURCE_JSON) {
329
+ $tree = $this->parseJSON($source, $extraKeys);
330
+ }
331
+ else {
332
+ $tree = $this->parseText($source);
333
+ }
334
+ return array( 'tree' => $tree, 'words' => $this->getWords());
335
+ }
336
+
337
+ public function parseHTML($source)
338
  {
339
  if ($this->client->getProfile()->getTranslationEngine() == 2) {
340
  $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
367
  }
368
 
369
  // checkers
370
+ list($nodes, $regexes) = $this->checkers($dom, $source);
371
 
372
+ return [ 'type' => SourceType::SOURCE_HTML , 'source' => $source , 'dom' => $dom, 'nodes' => $nodes, 'regexes' => $regexes ];
373
+ }
374
+
375
+ public function parseJSON($jsonString, $extraKeys = []) {
376
+ $checker = new JsonChecker($this, $jsonString, $extraKeys);
377
+ return $checker->handle();
378
+ }
379
+
380
+ public function parseText($text, $regex = null) {
381
+
382
+ $this->getWords()->addOne(new WordEntry($text, WordType::TEXT));
383
+ return array( "type" => SourceType::SOURCE_TEXT, "source" => $regex , "text" => $text );
384
  }
385
 
386
  /**
387
+ * @param string $title
388
  * @return TranslateEntry
389
  * @throws ApiError
390
  * @throws InputAndOutputCountMatchException
392
  * @throws MissingRequiredParamException
393
  * @throws MissingWordsOutputException
394
  */
395
+ protected function apiTranslate($title = null)
396
  {
397
  // Translate endpoint parameters
398
  $params = [
406
  }
407
 
408
  if ($this->getConfigProvider()->getAutoDiscoverTitle()) {
409
+ $params['title'] = $title;
410
  }
411
  $params = array_merge($params, $this->getConfigProvider()->asArray());
412
 
440
 
441
  /**
442
  * @param $dom
443
+ * @param $source
444
  * @return array
445
  * @throws InvalidWordTypeException
446
  */
447
+ protected function checkers($dom, $source)
448
  {
449
  $nodes = $this->getDomCheckerProvider()->handle($dom);
450
+ $regexes = $this->getRegexCheckerProvider()->handle($source);
 
 
451
 
452
  return [
453
  $nodes,
454
+ $regexes
455
  ];
456
  }
457
 
458
  /**
459
+ * @param string $source
460
  * @param TranslateEntry $translateEntry
461
+ * @param mixed $tree
462
+ * @param int $index
463
+ * @return string $source
464
  */
465
+ public function formatters($source, TranslateEntry $translateEntry, $tree, &$index = 0)
466
  {
467
+ if($tree['type'] === SourceType::SOURCE_TEXT) {
468
+ $source = str_replace($tree['text'] , $translateEntry->getOutputWords()[$index]->getWord(), $source);
469
+ $index++;
470
+ }
471
+ if($tree['type'] === SourceType::SOURCE_JSON) {
472
+ $formatter = new JsonFormatter($this, $source, $translateEntry);
473
+ $source = $formatter->handle($tree, $index);
474
+ }
475
+ if($tree['type'] === SourceType::SOURCE_HTML) {
476
+ $formatter = new DomFormatter($this, $translateEntry);
477
+ $formatter->handle($tree['nodes'], $index);
478
+ $source = $tree['dom']->save();
479
+ foreach ($tree['regexes'] as $regex) {
480
+ $translatedRegex = $this->formatters($regex['source'], $translateEntry, $regex, $index);
481
+ $source = str_replace($regex['source'] , $translatedRegex, $source);
482
+ }
483
+ }
484
+ return $source;
485
+ }
486
+
487
+
488
 
489
+ public static function getSourceType($source) {
490
+ if(Text::isJSON($source))
491
+ return SourceType::SOURCE_JSON;
492
+ elseif(Text::isHTML($source))
493
+ return SourceType::SOURCE_HTML;
494
+ else
495
+ return SourceType::SOURCE_TEXT;
496
  }
497
  }
vendor/weglot/weglot-php/src/Util/{JsonLd.php → JsonUtil.php} RENAMED
@@ -8,11 +8,12 @@ use Weglot\Client\Api\WordCollection;
8
  use Weglot\Client\Api\WordEntry;
9
 
10
  /**
11
- * Class JsonLd
12
  * @package Weglot\Parser\Util
13
  */
14
- class JsonLd
15
  {
 
16
  /**
17
  * @param array $data
18
  * @param string $key
@@ -45,9 +46,43 @@ class JsonLd
45
  */
46
  public static function set(WordCollection $words, $data, $index, &$nextJson)
47
  {
48
- $data[$index] = $words[$nextJson]->getWord();
 
 
 
 
 
 
49
  ++$nextJson;
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  return $data;
52
  }
53
  }
8
  use Weglot\Client\Api\WordEntry;
9
 
10
  /**
11
+ * Class JsonUtil
12
  * @package Weglot\Parser\Util
13
  */
14
+ class JsonUtil
15
  {
16
+ const SEPARATOR = "##";
17
  /**
18
  * @param array $data
19
  * @param string $key
46
  */
47
  public static function set(WordCollection $words, $data, $index, &$nextJson)
48
  {
49
+ $keys = explode( self::SEPARATOR , $index);
50
+ $current = &$data;
51
+ foreach ($keys as $key) {
52
+ $current = &$current[$key];
53
+ }
54
+
55
+ $current = $words[$nextJson]->getWord();
56
  ++$nextJson;
57
 
58
+ return $data;
59
+ }
60
+
61
+ public static function setHTML($newHTML, $data, $key)
62
+ {
63
+ $keys = explode(self::SEPARATOR , $key);
64
+ $current = &$data;
65
+ foreach ($keys as $key) {
66
+ $current = &$current[$key];
67
+ }
68
+
69
+ $current = $newHTML;
70
+
71
+
72
+ return $data;
73
+ }
74
+
75
+ public static function setJSONString($jsonString, $data, $key)
76
+ {
77
+ $keys = explode(self::SEPARATOR , $key);
78
+ $current = &$data;
79
+ foreach ($keys as $key) {
80
+ $current = &$current[$key];
81
+ }
82
+
83
+ $current = $jsonString;
84
+
85
+
86
  return $data;
87
  }
88
  }
vendor/weglot/weglot-php/src/Util/SourceType.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Weglot\Util;
4
+
5
+ /**
6
+ * Enum SourceType
7
+ * Used to define what the source type is
8
+ *
9
+ * @package
10
+ */
11
+ abstract class SourceType
12
+ {
13
+ const SOURCE_HTML = 'HTML';
14
+ const SOURCE_JSON = 'JSON';
15
+ const SOURCE_TEXT = 'TEXT';
16
+ }
vendor/weglot/weglot-php/src/Util/Text.php CHANGED
@@ -44,4 +44,13 @@ class Text
44
  {
45
  return str_replace('\\\\/', '\/', str_replace('/', '\/', $regex));
46
  }
 
 
 
 
 
 
 
 
 
47
  }
44
  {
45
  return str_replace('\\\\/', '\/', str_replace('/', '\/', $regex));
46
  }
47
+
48
+ public static function isJSON($string) {
49
+ $json = json_decode($string);
50
+ return (json_last_error() == JSON_ERROR_NONE && in_array(substr($string, 0 , 1), array('{' , '[')) );
51
+ }
52
+
53
+ public static function isHTML($string) {
54
+ return strip_tags($string) !== $string && is_string($string);
55
+ }
56
  }
vendor/weglot/weglot-php/src/Util/Url.php CHANGED
@@ -195,7 +195,9 @@ class Url
195
  $fullUrl = preg_replace('#' . $escapedPathPrefix . '\/(' . $languages . ')/#i', '/', $fullUrl);
196
  $parsed = parse_url($fullUrl);
197
 
198
- $this->host = $parsed['scheme'] . '://' . $parsed['host'] . (isset($parsed['port']) ? ':'.$parsed['port'] : '');
 
 
199
  $this->path = isset($parsed['path']) ? $parsed['path'] : '/';
200
  $this->query = isset($parsed['query']) ? $parsed['query'] : null;
201
 
195
  $fullUrl = preg_replace('#' . $escapedPathPrefix . '\/(' . $languages . ')/#i', '/', $fullUrl);
196
  $parsed = parse_url($fullUrl);
197
 
198
+ if(isset($parsed['scheme'])) {
199
+ $this->host = $parsed['scheme'] . '://' . $parsed['host'] . (isset($parsed['port']) ? ':'.$parsed['port'] : '');
200
+ }
201
  $this->path = isset($parsed['path']) ? $parsed['path'] : '/';
202
  $this->query = isset($parsed['query']) ? $parsed['query'] : null;
203
 
vendor/weglot/weglot-php/tests/unit/Parser/ParserTest.php CHANGED
@@ -112,7 +112,8 @@ class ParserTest extends \Codeception\Test\Unit
112
  $this->parser = new Parser($client, $this->config['server']);
113
 
114
  // Run the Parser
115
- $strings = $this->parser->parse($test['body']);
 
116
  foreach ($strings as $k => $string) {
117
  $this->assertEquals( $test['expected'][$k]['w'], $string->getWord());
118
  $this->assertEquals( $test['expected'][$k]['t'], $string->getType());
112
  $this->parser = new Parser($client, $this->config['server']);
113
 
114
  // Run the Parser
115
+ $parsed = $this->parser->parse($test['body']);
116
+ $strings = $parsed['words'];
117
  foreach ($strings as $k => $string) {
118
  $this->assertEquals( $test['expected'][$k]['w'], $string->getWord());
119
  $this->assertEquals( $test['expected'][$k]['t'], $string->getType());
vendor/weglot/weglot-php/tests/unit/Util/JsonLdTest.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
 
3
- use Weglot\Util\JsonLd;
4
  use Weglot\Client\Api\WordCollection;
5
  use Weglot\Client\Api\WordEntry;
6
 
7
- class JsonLdTest extends \Codeception\Test\Unit
8
  {
9
  /**
10
  * @var \UnitTester
@@ -14,7 +14,7 @@ class JsonLdTest extends \Codeception\Test\Unit
14
  /**
15
  * @var array
16
  */
17
- protected $jsonLd = [];
18
 
19
  protected function _before()
20
  {
@@ -34,15 +34,15 @@ class JsonLdTest extends \Codeception\Test\Unit
34
  "homepage": "http://www.example.com/"
35
  }
36
  EOT;
37
- $this->jsonLd = json_decode($raw, true);
38
  }
39
 
40
 
41
  // tests
42
  public function testGet()
43
  {
44
- $this->assertNull(JsonLd::get($this->jsonLd, 'description'));
45
- $this->assertEquals('John Smith', JsonLd::get($this->jsonLd, 'name'));
46
  }
47
 
48
  public function testAdd()
@@ -52,8 +52,8 @@ EOT;
52
 
53
  $this->assertEquals(1, $words->count());
54
 
55
- $value = JsonLd::get($this->jsonLd, 'name');
56
- JsonLd::add($words, $value);
57
 
58
  $this->assertEquals(2, $words->count());
59
  $this->assertEquals(new WordEntry($value), $words[1]);
@@ -68,7 +68,7 @@ EOT;
68
  $this->assertEquals(0, $nextJson);
69
  $this->assertEquals(1, $words->count());
70
 
71
- $data = JsonLd::set($words, $this->jsonLd, 'name', $nextJson);
72
 
73
  $this->assertEquals(1, $nextJson);
74
  $this->assertEquals($data['name'], $words[0]->getWord());
1
  <?php
2
 
3
+ use Weglot\Util\JsonUtil;
4
  use Weglot\Client\Api\WordCollection;
5
  use Weglot\Client\Api\WordEntry;
6
 
7
+ class JsonUtilTest extends \Codeception\Test\Unit
8
  {
9
  /**
10
  * @var \UnitTester
14
  /**
15
  * @var array
16
  */
17
+ protected $json = [];
18
 
19
  protected function _before()
20
  {
34
  "homepage": "http://www.example.com/"
35
  }
36
  EOT;
37
+ $this->json = json_decode($raw, true);
38
  }
39
 
40
 
41
  // tests
42
  public function testGet()
43
  {
44
+ $this->assertNull(JsonUtil::get($this->json, 'description'));
45
+ $this->assertEquals('John Smith', JsonUtil::get($this->json, 'name'));
46
  }
47
 
48
  public function testAdd()
52
 
53
  $this->assertEquals(1, $words->count());
54
 
55
+ $value = JsonUtil::get($this->json, 'name');
56
+ JsonUtil::add($words, $value);
57
 
58
  $this->assertEquals(2, $words->count());
59
  $this->assertEquals(new WordEntry($value), $words[1]);
68
  $this->assertEquals(0, $nextJson);
69
  $this->assertEquals(1, $words->count());
70
 
71
+ $data = JsonUtil::set($words, $this->json, 'name', $nextJson);
72
 
73
  $this->assertEquals(1, $nextJson);
74
  $this->assertEquals($data['name'], $words[0]->getWord());
weglot-functions.php CHANGED
@@ -148,7 +148,7 @@ function weglot_get_translate_amp_translation() {
148
  * @return string
149
  */
150
  function weglot_get_current_full_url() {
151
- return Context_Weglot::weglot_get_context()->get_service( 'Request_Url_Service_Weglot' )->get_full_url();
152
  }
153
 
154
  /**
@@ -185,7 +185,7 @@ function weglot_has_auto_redirect() {
185
  * @return boolean
186
  */
187
  function weglot_current_url_is_eligible() {
188
- $full_url = weglot_get_current_full_url();
189
  return weglot_is_eligible_url( $full_url );
190
  }
191
 
148
  * @return string
149
  */
150
  function weglot_get_current_full_url() {
151
+ return weglot_create_url_object( weglot_get_request_url_service()->get_full_url() )->getForLanguage( weglot_get_current_language() );
152
  }
153
 
154
  /**
185
  * @return boolean
186
  */
187
  function weglot_current_url_is_eligible() {
188
+ $full_url = weglot_get_full_url_no_language();
189
  return weglot_is_eligible_url( $full_url );
190
  }
191
 
weglot.php CHANGED
@@ -7,7 +7,7 @@ Author: Weglot Translate team
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
- Version: 3.0.6
11
  */
12
 
13
  /**
@@ -22,7 +22,7 @@ if ( ! defined('ABSPATH')) {
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
- define('WEGLOT_VERSION', '3.0.6');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
+ Version: 3.1.0
11
  */
12
 
13
  /**
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
+ define('WEGLOT_VERSION', '3.1.0');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );