PluginProbe
Linguise – AI Automatic Multilingual Translation / trunk
Linguise – AI Automatic Multilingual Translation vtrunk
2.2.64 2.2.63 2.2.62 2.2.61 2.2.60 2.2.59 2.2.58 2.2.57 2.2.56 2.2.55 2.2.54 2.2.53 2.2.52 2.2.51 2.2.50 2.2.49 2.2.47 2.2.48 2.2.46 2.2.45 2.2.44 2.2.43 2.2.42 1.9.7 1.9.8 All 255 releases
linguise / src / install.php

install.php in Linguise – AI Automatic Multilingual Translation trunk, at src/install.php

129 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_action('admin_init', function () {
4 $installed_version = get_option('linguise_version', null);
5
6 if (!$installed_version) {
7 /**
8 * When https://wordpress.org/plugins/backup-backup/ is installed
9 * Linguise throw error on first install.
10 */
11 if (!defined('LINGUISE_SCRIPT_TRANSLATION')) {
12 define('LINGUISE_SCRIPT_TRANSLATION', 1); // @codeCoverageIgnore
13 }
14 require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'linguise' . DIRECTORY_SEPARATOR . 'script-php' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Databases' . DIRECTORY_SEPARATOR . 'Mysql.php');
15
16 global $wpdb;
17 $mysql_instance = \Linguise\Vendor\Linguise\Script\Core\Databases\Mysql::getInstance();
18 $install_query = $mysql_instance->getInstallQuery($wpdb->base_prefix . 'linguise_urls');
19 $wpdb->query($install_query);
20 } else {
21 // This is an update
22 if (version_compare($installed_version, '1.7.6') === -1) {
23 // Do not add flag on already installed versions
24 $linguise_options = get_option('linguise_options');
25 $linguise_options['add_flag_automatically'] = 0;
26 update_option('linguise_options', $linguise_options);
27 }
28 }
29 $installed_at = get_option('linguise_install_time', false);
30 if ($installed_at !== false && (int) $installed_at + (60 * DAY_IN_SECONDS) < time()) {
31 // Check dismiss flag and showing feedback notification
32 $dismissed = get_option('linguise_feedback_notify_dismissed', false);
33
34 if (false === $dismissed) {
35 // Show notification
36 add_action('admin_notices', 'linguise_feedback_notice');
37 }
38 }
39
40 if ($installed_version !== LINGUISE_VERSION) {
41 update_option('linguise_version', LINGUISE_VERSION);
42 }
43 });
44
45 /**
46 * Displays a notice on WordPress backend
47 *
48 * @return void
49 */
50 function linguise_feedback_notice()
51 {
52 ?>
53 <style>
54 #linguise_admin_notice {
55 display: flex;
56 align-items: center;
57 }
58 #linguise_admin_notice img {
59 margin-right: 20px;
60 }
61 @media only screen and (max-width: 767px) {
62 #linguise_admin_notice {
63 flex-direction: column;
64 }
65 #linguise_admin_notice .linguise_feedback_content {
66 text-align: center;
67 }
68 }
69 </style>
70 <div id="linguise_admin_notice" class="notice notice-success is-dismissible">
71 <img src="data:image/webp;base64,UklGRqYDAABXRUJQVlA4TJkDAAAvx8AOEF8wRuM1vgraRkLxS2CGABzhWDwQjMOjUEBQmrZtbd08loxJQeWGVeZWM+GUvCrDWZVBYcYtM2lzTleZUZnbsPnz/fP0SZZ0XFxF9H8C9P/v9qrKX0CHyJ3k1IV1U6d3gagyQZfdKZ5TFt8palDbOF6UW++KUw5vFFUKGrn6Ks7Lh1Y5QqgVhOSN6zkFsLAcJ6BZjB9L6i7OyYcF5QihVkz7sKQTb+ekwRW3HJ6JKsWEn0pqH87Lv0cl9R0VO/uipCDKa2reXChJhQXb1lRS/C2vOQVs3vZIir95jZOh25Lk5zaingjHsKtiCQxEbqLLAskfX3Ekf3zFkeT9CjxpCUYQu2n9hqSggKYkzwAssgwB3k4MWCgF4EoBuJLmSFYTPYDDacOapHB3MSdIxokQq5uTsTwjKcBaTzGupBMvFtODS2OoS+pAbGBxPm3gMkSSfoDYwIspSNL3S4ox7NYMtCQNiZ3A8HY+J+AB/QSO1CN2fMNhWxAnOq1CPGhKQ56RZFgkdYjyuUkkzUBVGvGMNMcV28zhRLdZSACu1OVFSVCXThDntVvyoC4ZmlIItgNvJwb1Etxid1oIeR2WdOGCK0E90+wziZFbgpslOAFV2Se5uTAxrkyFGTjsZJrjiq3blOTHmgoycNjNEBgO2/p1SUE0JeaAyLVZn7ENq5LC3VPCGwJRJUvVZkiN3SkgfwgsyvCW7GR8cRrI/w3itJ1OSqzUA7ungrwhVBN1ZfQztKdAsNKV2tCcSKSFn5boRF5dnpFkaKXMcMVm3JQTL2boEOdnWCR1LH2ekdoTvC1pxELJ0JROgG3QTLm5MMMsNHIbEjuBsXTZLZ0Apd0ikmRoSiOWSD8Q2TovpnRaGUKIVq5c6eTSgdhg+Z4rrvrEGWahoQPQkPrEjmf41BZecWy9RgZvTLKZS4hd0gGIL8PbGdpw5cIYXOkHiEaw2OaZt2yDWgZ1C9Awgzcm2cqgEclI0gzWmk1zvOEkRm6W9riAwMB2i35MxJUsc5ZFkjRMHFb6r9iV+dA4rSH54CTeTsjf8mho80fA/ZLkgyNJvwK7lAwMxG4G7+w4EWWTv3LlSke5p8jfuu1RTbh525qKRcG2ba4mHLzGgxPkv2VbJUvZR6PDKinU58+YWnka0gni+eDzlspqWCx1iOZDcMUpzYDY8Q2fzgc9otJ2IDaweF6UOMRam24aJg5rygcGYnfayd/6gaP/BQMA" width="200" height="60" />
72 <div class="linguise_feedback_content">
73 <p>
74 <?php esc_html_e('You\'re using Linguise for 2 months now. We hope you enjoyed our service. If you have 2 minutes to help us to grow, please drop us a quick review. We\'d really appreciate.', 'linguise'); ?>
75 <br />
76 <?php esc_html_e('Thanks again for using Linguise', 'linguise'); ?>
77 </p>
78 <p class="linguise_notice_buttons">
79 <a href="<?php echo esc_url(wp_nonce_url(admin_url('admin-ajax.php?action=linguise_feedback_dismiss'), '_linguise_feedback_nonce_')); ?>" class="button" id="linguise_feedback_notice_dismiss" ><?php esc_html_e('I already left a review', 'linguise') ?></a>
80 <a target="_blank" class="button button-primary" href="https://wordpress.org/support/plugin/linguise/reviews/" title="<?php esc_html_e('Leave a review', 'linguise') ?>"><?php esc_html_e('Leave a review', 'linguise') ?></a>
81 </p>
82 </div>
83
84 </div>
85 <script type="text/javascript">
86 jQuery(function($) {
87 $(document).ready(function() {
88 $(document)
89 .on('click', '#linguise_admin_notice .notice-dismiss', function(e) {
90 e.preventDefault();
91
92 $('#linguise_feedback_notice_dismiss').trigger('click');
93 return false;
94 })
95 .on('click', '#linguise_feedback_notice_dismiss', function(e) {
96 e.preventDefault();
97 // Send ajax to dismiss URL
98 $.ajax({
99 url: $(this).prop('href'),
100 method: 'GET',
101 success: function(data) {
102 $('#linguise_admin_notice').fadeOut('fast', function() {
103 $(this).remove();
104 })
105 }
106 });
107 return false;
108 });
109 });
110 });
111 </script>
112 <?php
113 }
114
115 add_action('wp_ajax_linguise_feedback_dismiss', function () {
116 check_admin_referer('_linguise_feedback_nonce_');
117 // check user capabilities
118 if (!current_user_can('manage_options')) {
119 // @codeCoverageIgnoreStart
120 header('Content-Type: application/json; charset=UTF-8;');
121 echo wp_json_encode(['success' => false]);
122 die();
123 // @codeCoverageIgnoreEnd
124 }
125
126 update_option('linguise_feedback_notify_dismissed', true);
127 wp_send_json_success();
128 });
129