Automatic Translate Addon For Loco Translate - Version 2.0.1

Version Description

Download this release

Release Info

Developer Narinder singh
Plugin Icon 128x128 Automatic Translate Addon For Loco Translate
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

automatic-translator-addon-for-loco-translate.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
- Description:Auto language translator add-on for Loco Translate official plugin version 2.4+ to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
- Version:2.0
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
@@ -11,9 +11,10 @@ Author URI:https://coolplugins.net/
11
  */
12
  namespace LocoAutoTranslateAddon;
13
  use LocoAutoTranslateAddon\Helpers\Helpers;
 
14
  /**
15
  * @package Loco Automatic Translate Addon
16
- * @version 2.0
17
  */
18
  if (!defined('ABSPATH')) {
19
  die('WordPress Environment Not Found!');
@@ -22,7 +23,7 @@ if (!defined('ABSPATH')) {
22
  define('ATLT_FILE', __FILE__);
23
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
24
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
25
- define('ATLT_VERSION', '2.0');
26
 
27
  class LocoAutoTranslate
28
  {
@@ -32,6 +33,7 @@ class LocoAutoTranslate
32
  register_deactivation_hook( ATLT_FILE, array( $this, 'atlt_deactivate' ) );
33
  if(is_admin()){
34
 
 
35
  // Only loged in user can perform this AJAX request
36
  add_action('plugins_loaded', array($this, 'atlt_check_required_loco_plugin'));
37
  /*** Template Setting Page Link inside Plugins List */
@@ -65,18 +67,14 @@ class LocoAutoTranslate
65
  if( !file_exists( WP_PLUGIN_DIR . '/loco-translate/loco.php' ) ){
66
  return $link;
67
  }
68
- $site_url = get_site_url();
69
- $loco_info = get_plugin_data( WP_PLUGIN_DIR . '/loco-translate/loco.php' , false, false );
70
- $loco_ver = $loco_info['Version'];
71
- $urls = array(
72
- $site_url.'/wp-content/plugins/loco-translate/pub/js/min/editor.js?ver='.$loco_ver.''
73
- );
74
  foreach ($urls as $url) {
75
  if (strstr($link, $url)) {$link = '';}
76
  }
77
  return $link;
78
  }
79
-
80
  /*
81
  |----------------------------------------------------------------------
82
  | Yandex Translate Widget Integartions
@@ -84,7 +82,10 @@ class LocoAutoTranslate
84
  */
85
  // load google translate widget scripts
86
  function load_ytranslate_scripts() {
87
- echo"<script>document.getElementsByTagName('html')[0].setAttribute('translate', 'no');</script>";
 
 
 
88
  }
89
 
90
  // update settings
@@ -241,13 +242,18 @@ class LocoAutoTranslate
241
  */
242
  function atlt_enqueue_scripts(){
243
 
244
- wp_deregister_script('loco-js-editor');
245
- // copy object
246
- wp_add_inline_script( 'loco-translate-js-admin', 'var loco = window.locoScope;
247
- var target={};
 
 
 
248
  var returnedTarget = Object.assign(target, window.locoConf);
249
  window.conf=returnedTarget;' );
250
-
 
 
251
  // load yandex widget
252
  wp_register_script( 'atlt-yandex-widget', ATLT_URL.'assets/js/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=light&autoMode=false',array('jquery'),ATLT_VERSION, true);
253
 
@@ -261,12 +267,17 @@ class LocoAutoTranslate
261
  }else{
262
  // if PRO version is installed then load assets
263
  if(Helpers::proInstalled() && version_compare(ATLT_PRO_VERSION,'1.1', '>=')){
264
- wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
265
- ATLT_VERSION,'all');
266
- wp_register_script( 'loco-addon-custom', ATLT_PRO_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_PRO_VERSION, true);
267
- wp_register_script( 'custom-loco-js-editor', ATLT_PRO_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_PRO_VERSION, true);
268
- wp_register_script( 'sweet-alert', ATLT_PRO_URL.'assets/sweetalert/sweetalert.min.js', array('jquery'),ATLT_PRO_VERSION, true);
269
- }else{
 
 
 
 
 
270
  // wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
271
  wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
272
  wp_register_script( 'custom-loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_VERSION, true);
@@ -285,9 +296,7 @@ class LocoAutoTranslate
285
  if(Helpers::userType()=="pro"){
286
  wp_enqueue_script('sweet-alert');
287
  }
288
-
289
- $status=Helpers::atltVerification();
290
-
291
  $extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
292
  $extraData['gt_preview']=ATLT_URL.'/assets/images/powered-by-google.png';
293
  $extraData['dpl_preview']=ATLT_URL.'/assets/images/powered-by-deepl.png';
@@ -298,6 +307,45 @@ class LocoAutoTranslate
298
  }
299
  }
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
  /*
303
  |------------------------------------------------------
1
  <?php
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
+ Description:Auto language translator add-on for Loco Translate official plugin version 2.4.0 to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
+ Version:2.0.1
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
11
  */
12
  namespace LocoAutoTranslateAddon;
13
  use LocoAutoTranslateAddon\Helpers\Helpers;
14
+ use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
+ * @version 2.0.1
18
  */
19
  if (!defined('ABSPATH')) {
20
  die('WordPress Environment Not Found!');
23
  define('ATLT_FILE', __FILE__);
24
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
25
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
26
+ define('ATLT_VERSION', '2.0.1');
27
 
28
  class LocoAutoTranslate
29
  {
33
  register_deactivation_hook( ATLT_FILE, array( $this, 'atlt_deactivate' ) );
34
  if(is_admin()){
35
 
36
+ add_action('admin_notices', array($this,'atlt_plugins_compatibility_check') );
37
  // Only loged in user can perform this AJAX request
38
  add_action('plugins_loaded', array($this, 'atlt_check_required_loco_plugin'));
39
  /*** Template Setting Page Link inside Plugins List */
67
  if( !file_exists( WP_PLUGIN_DIR . '/loco-translate/loco.php' ) ){
68
  return $link;
69
  }
70
+ $urls = array(
71
+ plugins_url().'/loco-translate/pub/js/min/editor.js?ver=2.4.0'
72
+ );
 
 
 
73
  foreach ($urls as $url) {
74
  if (strstr($link, $url)) {$link = '';}
75
  }
76
  return $link;
77
  }
 
78
  /*
79
  |----------------------------------------------------------------------
80
  | Yandex Translate Widget Integartions
82
  */
83
  // load google translate widget scripts
84
  function load_ytranslate_scripts() {
85
+ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
86
+ {
87
+ echo"<script>document.getElementsByTagName('html')[0].setAttribute('translate', 'no');</script>";
88
+ }
89
  }
90
 
91
  // update settings
242
  */
243
  function atlt_enqueue_scripts(){
244
 
245
+ // load assets only on editor page
246
+ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
247
+ {
248
+ wp_deregister_script('loco-js-editor');
249
+ // copy object
250
+ wp_add_inline_script( 'loco-translate-js-admin', 'var loco = window.locoScope;
251
+ var target={};
252
  var returnedTarget = Object.assign(target, window.locoConf);
253
  window.conf=returnedTarget;' );
254
+ }
255
+
256
+
257
  // load yandex widget
258
  wp_register_script( 'atlt-yandex-widget', ATLT_URL.'assets/js/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=light&autoMode=false',array('jquery'),ATLT_VERSION, true);
259
 
267
  }else{
268
  // if PRO version is installed then load assets
269
  if(Helpers::proInstalled() && version_compare(ATLT_PRO_VERSION,'1.1', '>=')){
270
+ $key=Helpers::getLicenseKey();
271
+ if(Helpers::validKey( $key)){
272
+ wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
273
+ ATLT_VERSION,'all');
274
+ wp_register_script( 'loco-addon-custom', ATLT_PRO_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_PRO_VERSION, true);
275
+ wp_register_script( 'custom-loco-js-editor', ATLT_PRO_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_PRO_VERSION, true);
276
+ wp_register_script( 'sweet-alert', ATLT_PRO_URL.'assets/sweetalert/sweetalert.min.js', array('jquery'),ATLT_PRO_VERSION, true);
277
+ }
278
+ }else{
279
+ wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
280
+ ATLT_VERSION,'all');
281
  // wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
282
  wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
283
  wp_register_script( 'custom-loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_VERSION, true);
296
  if(Helpers::userType()=="pro"){
297
  wp_enqueue_script('sweet-alert');
298
  }
299
+
 
 
300
  $extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
301
  $extraData['gt_preview']=ATLT_URL.'/assets/images/powered-by-google.png';
302
  $extraData['dpl_preview']=ATLT_URL.'/assets/images/powered-by-deepl.png';
307
  }
308
  }
309
 
310
+ /**
311
+ * Show Admin notice to users for Rollback if compatibility issue is raised by other plugin.
312
+ * This function is unaccessable from non-admin users
313
+ */
314
+ function atlt_plugins_compatibility_check(){
315
+
316
+ $atlt = get_plugin_data(__FILE__, false);
317
+ $loco = get_plugin_data( WP_PLUGIN_DIR . '/loco-translate/loco.php',false);
318
+ $pages = array('loco-plugin');
319
+
320
+ if( isset( $_GET['atlt_rollback'] ) && $_GET['atlt_rollback'] == true && version_compare($loco['Version'] ,'2.4.0','>' )){
321
+
322
+ $_POST['key'] = (isset( $_GET['hash'] ) && !empty( $_GET['hash'] ) ) ? $_GET['hash'] : null;
323
+ // forbid direct access.
324
+ if( $_POST['key'] == null ){
325
+ echo sprintf(__('<div class="error" style="padding:5px;margin-top:50px;">Nonce verification failed! Click to <a href="'. admin_url('admin.php?page='.$_GET['page']) . '">refresh</a> this page.</div>','loco-translate-addon'));
326
+ die();
327
+ }
328
+
329
+ require_once ATLT_PATH . 'includes/Helpers/Atlt_downloader.php';
330
+ $request = new Atlt_downloader();
331
+ echo $request->rollback( $url = 'https://downloads.wordpress.org/plugin/loco-translate.2.4.0.zip');
332
+
333
+ echo sprintf(__('<br/><br/><a href="'. admin_url('admin.php?page='.$_GET['page']) . '">%s</a>','loco-translate-addon' ),'Refresh this page' );
334
+ die();
335
+
336
+ }else if( (isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'file-edit' ) && version_compare($loco['Version'] ,'2.4.0','>' ) ){
337
+
338
+ $plugin_name = $atlt['Name'];
339
+ // create nonce
340
+ $hash = wp_create_nonce('atlt_nounce_rollback_loco');
341
+ echo '<div class="notice notice-error" style="margin-top:50px;">' .
342
+ sprintf(__('<p style="font-size:16px;"><strong>Notice: %s</strong> is currently compatible with Loco Translate official plugin version <strong>2.4.0</strong>. If you want to use this addon features then you can <a class="button button-primary" href="?page='.$_GET['page'].'&atlt_rollback=true&hash='.$hash.'" action="atlt_rollback" id="atlt_rollback240">Roll Back</a> Loco Translate official plugin to version 2.4.0 or you can just uninstall this addon to use Loco Translate latest version without this addon.<br/><br/><i>*We are working on an update to make <strong>Automatic Translate Addon For Loco Translate</strong> compatible with all future updates of Loco Translate official plugin and it will available soon.</i></p></div>',
343
+ 'loco-translate-addon') ,
344
+ $plugin_name ) ;
345
+
346
+ }
347
+
348
+ }
349
 
350
  /*
351
  |------------------------------------------------------
includes/Helpers/Helpers.php CHANGED
@@ -11,35 +11,7 @@ class Helpers{
11
  return false;
12
  }
13
  }
14
- // verifiy user limit
15
- public static function atltVerification(){
16
- $allowed='';
17
- $info=array();
18
- $info['type']=Helpers::userType();
19
- $today_timing = get_transient('atlt_translation_day');
20
- $monthly_timing = get_transient('atlt_translation_day');
21
- $all_translated_chars = intval(get_option('atlt_month_translated_chars',0));
22
- $info['total']= $all_translated_chars;
23
- if($today_timing===false){
24
- if($all_translated_chars>10000000){
25
- $allowed='no';
26
- }else{
27
- $allowed='yes';
28
- }
29
- }else{
30
- $today_chars=(int)get_option('atlt_perday_translated_chars');
31
- $info['today']= $today_chars;
32
- if($today_chars>300000){
33
- $allowed='no';
34
- }else if($all_translated_chars>10000000){
35
- $allowed='no';
36
- }else{
37
- $allowed='yes';
38
- }
39
- }
40
- $info['allowed']= $allowed;
41
- return $info;
42
- }
43
  // return user type
44
  public static function userType(){
45
  $type='';
11
  return false;
12
  }
13
  }
14
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  // return user type
16
  public static function userType(){
17
  $type='';
includes/Register/LocoAutomaticTranslateAddonPro.php CHANGED
@@ -269,7 +269,7 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
269
  <tr style="background:#fffb7a;font-weight: bold;">
270
  <td>DeepL Doc Translator Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-deepl.png' ?>"/></td>
271
  <td>❌ Not Available</td>
272
- <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
273
  </tr>
274
 
275
  <tr>
@@ -289,6 +289,7 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
289
  <strong style="color:#e00b0b;">*Important Points</strong>
290
  <ol>
291
  <li>DeepL Translate provides better translations than Google, Yandex or other machine translation providers.<br/><a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank"><b>Read review by Techcrunch!</b></a></li>
 
292
  <li>Currently automatic translate providers do not support HTML and special characters translations.<br/>So plugin will not translate any string that contains HTML or special characters.</li>
293
  <li>If any auto-translation provider stops any of its free translation service then plugin will not<br/>support that translation service provider.</li>
294
  </ol>
269
  <tr style="background:#fffb7a;font-weight: bold;">
270
  <td>DeepL Doc Translator Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-deepl.png' ?>"/></td>
271
  <td>❌ Not Available</td>
272
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Limited Free Docs Translations / Day)</span></td>
273
  </tr>
274
 
275
  <tr>
289
  <strong style="color:#e00b0b;">*Important Points</strong>
290
  <ol>
291
  <li>DeepL Translate provides better translations than Google, Yandex or other machine translation providers.<br/><a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank"><b>Read review by Techcrunch!</b></a></li>
292
+ <li>Currently DeepL Doc Translator provides limited number of free docs translations per day.<br/>You can purchase to <a href="https://www.deepl.com/pro?cta=homepage-free-trial#pricing" target="_blank">DeepL Pro</a> to increase this limit.</li>
293
  <li>Currently automatic translate providers do not support HTML and special characters translations.<br/>So plugin will not translate any string that contains HTML or special characters.</li>
294
  <li>If any auto-translation provider stops any of its free translation service then plugin will not<br/>support that translation service provider.</li>
295
  </ol>
readme.txt CHANGED
@@ -13,11 +13,11 @@ Automatic language translator add-on for Loco Translate official plugin to trans
13
 
14
  == Description ==
15
 
16
- > **Important Notice:-** This addon is only compatible with Loco Translate official plugin latest version(2.4.0 or upper). If you are using Loco Translate older version then update it to latest version to use this addon.
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
- Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)**(2.4.0+) plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
21
 
22
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
@@ -54,11 +54,14 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
54
  (Yandex, Google & DeepL Support)
55
  * ✅ **Google Translate Widget Support:** Available
56
  * ✅ **DeepL Doc Translator Support:** Available
 
57
  * ✅ **Reset Translations:** Available
58
  * ✅ **Premium Support:** Quick Email Support
59
  (contact@coolplugins.net -**Support time:- 24-48 hours**)
60
  * **Buy Premium License:** [$18 - $88 🛒](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
61
 
 
 
62
  **❗ Important Notice:** This addon only provides settings to use third party auto-translation widgets and services(Yandex, Google, DeepL etc.), it does not provide any translation service. So we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site. If any auto-translate provider stops providing auto-translation widget or service in future, in that case plugin will not support that translation provider.
63
 
64
  **🎬 Unlimited Translations(no API) - Pro Version Video**
@@ -134,9 +137,14 @@ There is no limit. Yes, you can translate unlimited characters without any API k
134
 
135
  == Changelog ==
136
 
 
 
 
 
 
137
  <strong>Version 2.0 | 31 JULY 2020</strong>
138
  <pre>
139
- Improved: Addon is now compatible with Loco Translate latest version (2.4.0 +)
140
  Added: Yandex Page Translate Widget (unlimited translations without API)
141
  Removed: API settings panel (now you can use plugin without API key)
142
  Removed: IBM watson translator support
13
 
14
  == Description ==
15
 
16
+ > **Important Notice:-** This addon is currently only compatible with Loco Translate official plugin latest version(2.4.0). We are working on an update to make this addon compatible with all future updates of Loco Translate official plugin without any conflict, it will available soon.
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
+ Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)**(2.4.0) plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
21
 
22
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
54
  (Yandex, Google & DeepL Support)
55
  * ✅ **Google Translate Widget Support:** Available
56
  * ✅ **DeepL Doc Translator Support:** Available
57
+ (limited free docs translations / day or purchase DeepL Pro)
58
  * ✅ **Reset Translations:** Available
59
  * ✅ **Premium Support:** Quick Email Support
60
  (contact@coolplugins.net -**Support time:- 24-48 hours**)
61
  * **Buy Premium License:** [$18 - $88 🛒](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
62
 
63
+ > DeepL Doc Translator has limitations for number of docs translations per day free of cost, you can purchase their pro license to increase this limit.
64
+
65
  **❗ Important Notice:** This addon only provides settings to use third party auto-translation widgets and services(Yandex, Google, DeepL etc.), it does not provide any translation service. So we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site. If any auto-translate provider stops providing auto-translation widget or service in future, in that case plugin will not support that translation provider.
66
 
67
  **🎬 Unlimited Translations(no API) - Pro Version Video**
137
 
138
  == Changelog ==
139
 
140
+ <strong>Version 2.0.1 | 07 AUG 2020</strong>
141
+ <pre>
142
+ Notice Added: Addon is currently compatible with only Loco Translate official plugin version 2.4.0, new compatible update will available soon.
143
+ </pre>
144
+
145
  <strong>Version 2.0 | 31 JULY 2020</strong>
146
  <pre>
147
+ Improved: Addon is now compatible with only Loco Translate version 2.4.0
148
  Added: Yandex Page Translate Widget (unlimited translations without API)
149
  Removed: API settings panel (now you can use plugin without API key)
150
  Removed: IBM watson translator support