PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 2.0.0
Backup Migration v2.0.0
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / analyst / main.php
backup-backup / analyst Last commit date
assets 8 months ago src 8 months ago templates 8 months ago autoload.php 8 months ago index.php 8 months ago main.php 8 months ago sdk_resolver.php 8 months ago version.php 8 months ago
main.php
71 lines
1 <?php
2
3 require_once 'sdk_resolver.php';
4
5 /**
6 * Initialize analyst "private"
7 *
8 * @param array $options
9 */
10 if (!function_exists('___analyst_init')) {
11 function ___analyst_init($options) {
12 $capabilities = [
13 'activate_plugins',
14 'edit_plugins',
15 'install_plugins',
16 'update_plugins',
17 'delete_plugins',
18 'manage_network_plugins',
19 'upload_plugins'
20 ];
21
22 // Allow if has any of above permissions
23 $hasPerms = false;
24 foreach ($capabilities as $i => $cap) {
25 if (current_user_can($cap)) {
26 $hasPerms = true;
27 break;
28 }
29 }
30
31 if ($hasPerms == false) {
32 return;
33 }
34
35 // Try resolve latest supported SDK
36 // In case resolving is failed exit the execution
37 try {
38 analyst_resolve_sdk($options['base-dir']);
39 } catch (Exception $exception) {
40 // error_log('[ANALYST] Cannot resolve any supported SDK');
41 return;
42 }
43
44 try {
45 global /** @var Analyst\Analyst $analyst */
46 $analyst;
47
48 // Set global instance of analyst
49 if (!$analyst) {
50 $analyst = Analyst\Analyst::getInstance();
51 }
52
53 $analyst->registerAccount(new Account\Account($options['client-id'], $options['client-secret'], $options['base-dir']));
54 } catch (Exception $e) {
55 // error_log('Analyst SDK receive an error: [' . $e->getMessage() . '] Please contact our support at support@analyst.com');
56 }
57 }
58 }
59
60
61 if (!function_exists('analyst_init')) {
62 function analyst_init($__options) {
63 if (did_action('init') > 0 && function_exists('current_user_can')) ___analyst_init($__options);
64 else {
65 add_action('wp_loaded', function () use ($__options) {
66 ___analyst_init($__options);
67 }, -1000);
68 }
69 }
70 }
71