-
-
Notifications
You must be signed in to change notification settings - Fork 827
/
Copy pathCms.php
100 lines (95 loc) · 2.88 KB
/
Cms.php
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
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
class CRM_Utils_Check_Component_Cms extends CRM_Utils_Check_Component {
/**
* For sites running in WordPress, make sure the configured base page exists.
*
* @return array
* Instances of CRM_Utils_Check_Message
*/
public static function checkWpBasePage() {
$config = CRM_Core_Config::singleton();
if ($config->userFramework != 'WordPress') {
return [];
}
$messages = [];
$slug = $config->wpBasePage;
$pageArgs = [
'name' => $slug,
'post_type' => 'page',
'post_status' => 'publish',
'numberposts' => 1,
];
$basePage = get_posts($pageArgs);
if (!$basePage) {
$cmsSettings = CRM_Utils_System::url(
'civicrm/admin/setting',
$query = ['reset' => 1],
FALSE,
NULL,
TRUE,
FALSE,
TRUE
);
$messageText = [
ts(
'CiviCRM relies upon a base page in WordPress at %1%2, but it is missing.',
[
1 => $config->userFrameworkBaseURL,
2 => $slug,
]
),
];
if ($slug == 'civicrm') {
$messageText[] = ts(
'If you have an alternative base page, it can be set in the <a href="%2">WordPress integration settings</a>.',
[
1 => $config->userFrameworkBaseURL,
2 => $cmsSettings,
]
);
}
else {
$pageArgs['name'] = 'civicrm';
$defaultBasePage = get_posts($pageArgs);
if ($defaultBasePage) {
$messageText[] = ts(
'The default is %1civicrm, which <a href="%1civicrm">does exist on this site</a>.',
[1 => $config->userFrameworkBaseURL]
);
}
else {
$messageText[] = ts(
'The default is %1civicrm, but that does not exist on this site either.',
[1 => $config->userFrameworkBaseURL]
);
}
$messageText[] = ts(
'You can set the correct base page in the <a href="%1">WordPress integration settings</a>.',
[1 => $cmsSettings]
);
}
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
implode(' ', $messageText),
ts('WordPress Base Page Missing'),
\Psr\Log\LogLevel::ERROR,
'fa-wordpress'
);
}
return $messages;
}
}