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