Test_Extensions.php
3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace Wpo\Tests;
use \Wpo\Core\Extensions_Helpers;
// Prevent public access to this script
defined('ABSPATH') or die();
if (!class_exists('\Wpo\Tests\Test_Extensions')) {
class Test_Extensions
{
private $extensions = [];
public function __construct()
{
$extensions = Extensions_Helpers::get_extensions();
foreach ($extensions as $slug => $extension) {
if ($extension['activated']) {
$this->extensions[$slug] = $extension;
}
}
}
public function test_wpo365_premium()
{
return $this->get_test_result_for_extensions('wpo365-login-premium/wpo365-login.php', 'WPO365 | SYNC', 23.0);
}
public function test_wpo365_intranet()
{
return $this->get_test_result_for_extensions('wpo365-login-intranet/wpo365-login.php', 'WPO365 | INTRANET', 23.0);
}
public function test_wpo365_profile_plus()
{
return $this->get_test_result_for_extensions('wpo365-login-plus/wpo365-login.php', 'WPO365 | PROFILE+', 23.0);
}
public function test_wpo365_mail()
{
return $this->get_test_result_for_extensions('wpo365-mail/wpo365-mail.php', 'WPO365 | MAIL', 23.0);
}
public function test_wpo365_login_plus()
{
return $this->get_test_result_for_extensions('wpo365-login-professional/wpo365-login.php', 'WPO365 | LOGIN+', 23.0);
}
public function test_wpo365_avatar()
{
return $this->get_test_result_for_extensions('wpo365-avatar/wpo365-avatar.php', 'WPO365 | AVATAR', 23.0);
}
public function test_wpo365_custom_user_fields()
{
return $this->get_test_result_for_extensions('wpo365-custom-fields/wpo365-custom-fields.php', 'WPO365 | CUSTOM USER FIELDS', 23.0);
}
public function test_wpo365_groups()
{
return $this->get_test_result_for_extensions('wpo365-groups/wpo365-groups.php', 'WPO365 | GROUPS', 23.0);
}
public function test_wpo365_apps()
{
return $this->get_test_result_for_extensions('wpo365-apps/wpo365-apps.php', 'WPO365 | APPS', 23.0);
}
public function test_wpo365_documents()
{
return $this->get_test_result_for_extensions('wpo365-documents/wpo365-documents.php', 'WPO365 | DOCUMENTS', 2.0);
}
public function test_wpo365_roles_access()
{
return $this->get_test_result_for_extensions('wpo365-roles-access/wpo365-roles-access.php', 'WPO365 | ROLES + ACCESS', 23.0);
}
private function get_test_result_for_extensions($slug, $title, $version)
{
$test_result = new Test_Result("Latest version $title is installed", Test_Result::CAPABILITY_EXTENSIONS, Test_Result::SEVERITY_CRITICAL);
$test_result->passed = true;
if (!array_key_exists($slug, $this->extensions)) {
return;
}
if ($this->extensions[$slug]['version'] < $version) {
$test_result->passed = false;
$test_result->message = "There is a newer version available for the <em>$title</em> plugin. Please update now.";
$test_result->more_info = 'https://docs.wpo365.com/article/13-update-the-wpo365-plugin-to-the-latest-version';
}
return $test_result;
}
}
}