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 / cache.php

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

42 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Linguise\Vendor\Linguise\Script\Core\Configuration;
4 use Linguise\Vendor\Linguise\Script\Core\Cache;
5 use Linguise\Vendor\Linguise\Script\Core\Database;
6
7 defined('ABSPATH') || die('');
8
9 add_action('wp_ajax_linguise_clear_cache', function () {
10 check_admin_referer('_linguise_nonce_');
11 // check user capabilities
12 if (!current_user_can('manage_options')) {
13 if (!defined('LINGUISE_WP_PLUGIN_TEST_MODE')) {
14 header('Content-Type: application/json; charset=UTF-8;'); // @codeCoverageIgnore
15 }
16 echo wp_json_encode(['success' => false]);
17 if (defined('LINGUISE_WP_PLUGIN_TEST_MODE')) {
18 return;
19 }
20 die(); // @codeCoverageIgnore
21 }
22
23 ini_set('display_errors', false);
24
25 if (!defined('LINGUISE_SCRIPT_TRANSLATION')) {
26 define('LINGUISE_SCRIPT_TRANSLATION', true); // @codeCoverageIgnore
27 }
28
29 require_once(LINGUISE_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
30 // Set token to get correct data_dir
31 Configuration::getInstance()->set('cms', 'wordpress');
32 Configuration::getInstance()->set('base_dir', realpath(LINGUISE_PLUGIN_PATH . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR);
33
34 linguiseSwitchMainSite();
35 $token = Database::getInstance()->retrieveWordpressOption('token', $_SERVER['HTTP_HOST']);
36 Configuration::getInstance()->set('token', $token);
37 Configuration::getInstance()->set('data_dir', wp_upload_dir()['basedir'] . DIRECTORY_SEPARATOR . 'linguise'. DIRECTORY_SEPARATOR . md5('data' . $token));
38 linguiseRestoreMultisite();
39
40 Cache::getInstance()->clearAll();
41 });
42