Health Check - Version 1.3.0

Version Description

Download this release

Release Info

Developer Clorith
Plugin Icon 128x128 Health Check
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.6 to 1.3.0

assets/css/health-check-troubleshooting-mode.css CHANGED
@@ -1,24 +1,45 @@
 
 
 
 
 
 
 
 
 
1
  @media all and (min-width: 783px) {
2
  #health-check-dashboard-widget {
3
  margin-top: 3rem;
 
4
  }
5
  }
6
 
 
 
 
 
7
  #health-check-dashboard-widget .welcome-panel-content {
8
  max-width: initial;
9
  }
10
 
11
- #health-check-dashboard-widget .notices .no-notices p {
12
- color: #bfc3c7;
13
  font-size: 1.2rem;
14
  }
15
 
16
- #health-check-dashboard-widget .notices .notice {
 
17
  margin-left: 0;
18
  }
19
 
20
- #health-check-dashboard-widget .notices .dismiss-notices {
21
- float: right;
 
 
 
 
 
 
22
  margin-right: 1rem;
23
  }
24
 
@@ -34,49 +55,143 @@
34
  }
35
  }
36
 
37
- #health-check-dashboard-widget .toggle-visibility {
38
- display: none;
39
  }
40
 
41
- #health-check-dashboard-widget .toggle-visibility.visible {
42
- display: block;
 
 
 
43
  }
44
 
45
- #health-check-dashboard-widget .welcome-panel-column-container {
46
- position: initial;
 
 
47
  }
48
 
49
- #health-check-dashboard-widget .welcome-panel-column-container .welcome-panel-column.is-standalone-button {
50
- width: 100%;
51
- text-align: right;
52
  }
53
 
54
- #health-check-dashboard-widget .welcome-panel-column-container .welcome-panel-column.is-standalone-button .disable-troubleshooting-mode {
55
- position: relative;
56
  }
57
 
58
- #health-check-dashboard-widget .about-description {
59
- margin: 1em 0;
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
- #health-check-dashboard-widget .health-check-toggle-visibility {
 
 
 
 
 
 
 
 
63
  position: relative;
64
- padding-right: 1.5rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
- #health-check-dashboard-widget .health-check-toggle-visibility .icon {
68
- border: solid #9e9e9e;
69
  border-width: 0 2px 2px 0;
70
- height: 0.3rem;
71
  pointer-events: none;
72
  position: absolute;
73
- right: 0.5em;
74
  top: 50%;
75
- transform: translateY(-60%) rotate(45deg);
76
- width: 0.3rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
- #health-check-dashboard-widget .health-check-toggle-visibility .icon.icon-up {
80
- transform: translateY(-50%) rotate(-135deg);
81
- top: 60%;
82
  }
1
+ #health-check-dashboard-widget {
2
+ display: grid;
3
+ grid-gap: 2%;
4
+ grid-template-columns: 100%;
5
+ padding: 13px;
6
+ background: #fff;
7
+ /* Accordion styles */
8
+ }
9
+
10
  @media all and (min-width: 783px) {
11
  #health-check-dashboard-widget {
12
  margin-top: 3rem;
13
+ grid-template-columns: 49% 49%;
14
  }
15
  }
16
 
17
+ #health-check-dashboard-widget h2 .green {
18
+ color: #40860a;
19
+ }
20
+
21
  #health-check-dashboard-widget .welcome-panel-content {
22
  max-width: initial;
23
  }
24
 
25
+ #health-check-dashboard-widget #health-check-accordion-block-notices .no-notices p {
26
+ color: #72777c;
27
  font-size: 1.2rem;
28
  }
29
 
30
+ #health-check-dashboard-widget #health-check-accordion-block-notices .notice {
31
+ color: #72777c;
32
  margin-left: 0;
33
  }
34
 
35
+ #health-check-dashboard-widget #health-check-accordion-block-notices .notice p {
36
+ font-size: 13px;
37
+ }
38
+
39
+ #health-check-dashboard-widget #health-check-accordion-block-notices .dismiss-notices {
40
+ display: block;
41
+ width: 100%;
42
+ text-align: right;
43
  margin-right: 1rem;
44
  }
45
 
55
  }
56
  }
57
 
58
+ #health-check-dashboard-widget ul li {
59
+ font-size: 13px;
60
  }
61
 
62
+ @media all and (max-width: 870px) {
63
+ #health-check-dashboard-widget ul li {
64
+ display: inline-block;
65
+ width: 100%;
66
+ }
67
  }
68
 
69
+ #health-check-dashboard-widget .about-description {
70
+ margin: 1em 0;
71
+ max-width: 700px;
72
+ display: inline-block;
73
  }
74
 
75
+ #health-check-dashboard-widget .about-description p {
76
+ color: inherit;
77
+ font-size: 16px;
78
  }
79
 
80
+ #health-check-dashboard-widget .health-check-accordion {
81
+ border: 1px solid #e2e4e7;
82
  }
83
 
84
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-heading {
85
+ margin: 0;
86
+ border-top: 1px solid #e2e4e7;
87
+ font-size: inherit;
88
+ line-height: inherit;
89
+ font-weight: 600;
90
+ color: inherit;
91
+ }
92
+
93
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-heading:first-child {
94
+ border-top: none;
95
  }
96
 
97
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger {
98
+ background: #fff;
99
+ border: 0;
100
+ color: #32373c;
101
+ cursor: pointer;
102
+ display: block;
103
+ font-weight: 400;
104
+ margin: 0;
105
+ padding: 1em 3.5em 1em 1.5em;
106
  position: relative;
107
+ text-align: left;
108
+ width: 100%;
109
+ }
110
+
111
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger:hover, #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger:active {
112
+ background: #f8f9f9;
113
+ }
114
+
115
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger:focus {
116
+ color: #191e23;
117
+ border: none;
118
+ box-shadow: none;
119
+ outline-offset: -2px;
120
+ outline: 1px dotted #555d66;
121
+ }
122
+
123
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .title {
124
+ display: inline-block;
125
+ pointer-events: none;
126
+ font-weight: 600;
127
  }
128
 
129
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .icon {
130
+ border: solid #555d66;
131
  border-width: 0 2px 2px 0;
132
+ height: 0.5rem;
133
  pointer-events: none;
134
  position: absolute;
135
+ right: 1.5em;
136
  top: 50%;
137
+ transform: translateY(-70%) rotate(45deg);
138
+ width: 0.5rem;
139
+ }
140
+
141
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge {
142
+ float: right;
143
+ padding: 0.1rem 0.5rem 0.15rem;
144
+ color: #32373c;
145
+ font-weight: 600;
146
+ margin-left: 0.5rem;
147
+ }
148
+
149
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.blue {
150
+ border: 1px solid #bfe7f3;
151
+ }
152
+
153
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.orange {
154
+ border: 1px solid #ffb900;
155
+ }
156
+
157
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.red {
158
+ border: 1px solid #dc3232;
159
+ }
160
+
161
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.green {
162
+ border: 1px solid #46b450;
163
+ }
164
+
165
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.purple {
166
+ border: 1px solid #826eb4;
167
+ }
168
+
169
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger .badge.gray {
170
+ border: 1px solid #ccd0d4;
171
+ }
172
+
173
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-trigger[aria-expanded="true"] .icon {
174
+ transform: translateY(-30%) rotate(-135deg);
175
+ }
176
+
177
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-panel {
178
+ margin: 0;
179
+ padding: 1em 1.5em;
180
+ background: #fff;
181
+ }
182
+
183
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-panel > div {
184
+ display: block;
185
+ }
186
+
187
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-panel[hidden] {
188
+ display: none;
189
+ }
190
+
191
+ #health-check-dashboard-widget .health-check-accordion .health-check-accordion-panel a .dashicons {
192
+ text-decoration: none;
193
  }
194
 
195
+ #health-check-dashboard-widget .health-check-accordion dl dd {
196
+ margin: 0 0 0.5em 2em;
 
197
  }
assets/css/health-check.css CHANGED
@@ -1,100 +1,316 @@
1
- body.dashboard_page_health-check {
 
 
 
 
 
 
 
2
  /* Tools screen styles */
3
  /* Diff viewer styles */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- body.dashboard_page_health-check .health-check-table thead th:first-child,
7
- body.dashboard_page_health-check .health-check-table thead td:first-child {
8
- width: 20%;
 
 
9
  }
10
 
11
- body.dashboard_page_health-check .health-check-table tbody td {
12
- width: 80%;
 
 
 
13
  }
14
 
15
- body.dashboard_page_health-check .health-check-table tbody td:first-child {
16
- width: 20%;
 
 
 
 
 
 
17
  }
18
 
19
- body.dashboard_page_health-check .health-check-table tbody td ul,
20
- body.dashboard_page_health-check .health-check-table tbody td ol {
 
 
21
  margin: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
23
 
24
- body.dashboard_page_health-check .pass:before,
25
- body.dashboard_page_health-check .good:before {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  content: "\f147";
27
  display: inline-block;
28
  color: #46b450;
29
  font-family: dashicons;
30
  }
31
 
32
- body.dashboard_page_health-check .warning:before {
33
  content: "\f460";
34
  display: inline-block;
35
  color: #ffb900;
36
  font-family: dashicons;
37
  }
38
 
39
- body.dashboard_page_health-check .info:before {
40
  content: "\f348";
41
  display: inline-block;
42
  color: #00a0d2;
43
  font-family: dashicons;
44
  }
45
 
46
- body.dashboard_page_health-check .fail:before,
47
- body.dashboard_page_health-check .error:before {
48
  content: "\f335";
49
  display: inline-block;
50
  color: #dc3232;
51
  font-family: dashicons;
52
  }
53
 
54
- body.dashboard_page_health-check .spinner {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  float: none;
 
56
  }
57
 
58
- body.dashboard_page_health-check .file-integrity-table thead th:first-child,
59
- body.dashboard_page_health-check .file-integrity-table thead td:first-child,
60
- body.dashboard_page_health-check .file-integrity-table tbody th:first-child,
61
- body.dashboard_page_health-check .file-integrity-table tbody td:first-child,
62
- body.dashboard_page_health-check .file-integrity-table tfoot th:first-child,
63
- body.dashboard_page_health-check .file-integrity-table tfoot td:first-child {
64
  text-align: center;
65
  width: 60px;
66
  }
67
 
68
- body.dashboard_page_health-check .tools-email-table {
69
  border: 0;
70
  box-shadow: none;
71
  }
72
 
73
- body.dashboard_page_health-check .tools-email-table td:first-child {
74
  width: 280px;
75
  }
76
 
77
  @media (max-width: 768px) {
78
- body.dashboard_page_health-check .tools-email-table td {
79
  display: block;
80
  }
81
  }
82
 
83
- body.dashboard_page_health-check .tools-email-table input {
84
  width: 100%;
85
  }
86
 
87
- body.dashboard_page_health-check .tools-email-table label {
88
  display: block;
89
  clear: both;
90
  }
91
 
92
- body.dashboard_page_health-check #health-check-mail-check,
93
- body.dashboard_page_health-check #health-check-file-integrity {
94
  margin-bottom: 15px;
95
  }
96
 
97
- body.dashboard_page_health-check #health-check-diff-modal {
98
  width: 100vw;
99
  height: 100%;
100
  position: fixed;
@@ -105,7 +321,7 @@ body.dashboard_page_health-check #health-check-diff-modal {
105
  z-index: 99999;
106
  }
107
 
108
- body.dashboard_page_health-check #health-check-diff-modal #health-check-diff-modal-content {
109
  background: #fff;
110
  height: calc(100% - 120px);
111
  width: calc(100% - 120px);
@@ -115,7 +331,7 @@ body.dashboard_page_health-check #health-check-diff-modal #health-check-diff-mod
115
  display: block;
116
  }
117
 
118
- body.dashboard_page_health-check #health-check-diff-modal #health-check-diff-modal-diff {
119
  width: 100%;
120
  height: calc(100% - 80px);
121
  overflow-y: auto;
@@ -123,11 +339,11 @@ body.dashboard_page_health-check #health-check-diff-modal #health-check-diff-mod
123
  position: relative;
124
  }
125
 
126
- body.dashboard_page_health-check #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2) {
127
  background: #f3f3f3;
128
  }
129
 
130
- body.dashboard_page_health-check #health-check-diff-modal-close-ref {
131
  position: relative;
132
  display: block;
133
  float: right;
@@ -135,79 +351,211 @@ body.dashboard_page_health-check #health-check-diff-modal-close-ref {
135
  text-decoration: none;
136
  }
137
 
138
- /* Accordion styles */
139
- .health-check-accordion {
140
- border: 1px solid #d1d1d1;
141
- border-radius: 0.3em;
142
- box-shadow: 0 1px 2px #d1d1d1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
 
145
- .health-check-accordion > * + * {
146
- border-top: 1px solid #d1d1d1;
 
 
147
  }
148
 
149
- .health-check-accordion dt {
 
 
150
  font-weight: 600;
151
  }
152
 
153
- .health-check-accordion dt:first-child {
154
- border-radius: 0.3em 0.3em 0 0;
155
  }
156
 
157
- .health-check-accordion .health-check-accordion-trigger {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  background: #fff;
159
  border: 0;
160
- color: #212121;
 
161
  display: block;
162
- font-size: 1rem;
163
  font-weight: 400;
164
  margin: 0;
165
- padding: 1em 1.5em;
166
  position: relative;
167
  text-align: left;
168
  width: 100%;
169
  }
170
 
171
- .health-check-accordion .health-check-accordion-trigger:hover, .health-check-accordion .health-check-accordion-trigger:focus, .health-check-accordion .health-check-accordion-trigger:active {
172
- background: #dedede;
173
  }
174
 
175
- .health-check-accordion .health-check-accordion-trigger .title {
176
- display: block;
 
 
 
 
 
 
 
 
177
  pointer-events: none;
 
178
  }
179
 
180
- .health-check-accordion .health-check-accordion-trigger .icon {
181
- border: solid #9e9e9e;
182
  border-width: 0 2px 2px 0;
183
  height: 0.5rem;
184
  pointer-events: none;
185
  position: absolute;
186
  right: 1.5em;
187
  top: 50%;
188
- transform: translateY(-60%) rotate(45deg);
189
  width: 0.5rem;
190
  }
191
 
192
- .health-check-accordion .health-check-accordion-trigger[aria-expanded="true"] .icon {
193
- transform: translateY(-50%) rotate(-135deg);
 
 
 
 
 
 
 
 
194
  }
195
 
196
- .health-check-accordion .health-check-accordion-panel {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  margin: 0;
198
  padding: 1em 1.5em;
199
  background: #fff;
200
  }
201
 
202
- .health-check-accordion .health-check-accordion-panel > div {
203
  display: block;
204
  }
205
 
206
- .health-check-accordion .health-check-accordion-panel[hidden] {
207
  display: none;
208
  }
209
 
210
- .health-check-accordion dl dd {
 
 
 
 
211
  margin: 0 0 0.5em 2em;
212
  }
213
 
1
+ @charset "UTF-8";
2
+ body {
3
+ /* Accordion styles */
4
+ }
5
+
6
+ body.tools_page_health-check {
7
+ /* Better position for the WordPress admin notices and update nag. */
8
+ /* Info screen styles */
9
  /* Tools screen styles */
10
  /* Diff viewer styles */
11
+ /* Site Status styles */
12
+ }
13
+
14
+ body.tools_page_health-check #wpcontent {
15
+ padding-left: 0;
16
+ }
17
+
18
+ body.tools_page_health-check .notice {
19
+ margin: 5px 20px 15px 22px;
20
+ }
21
+
22
+ body.tools_page_health-check .update-nag {
23
+ margin-bottom: 20px;
24
+ margin-left: 22px;
25
+ }
26
+
27
+ body.tools_page_health-check h2 {
28
+ padding: 1rem 0;
29
+ line-height: 1.4;
30
+ }
31
+
32
+ body.tools_page_health-check .wrap {
33
+ margin-right: 0;
34
+ margin-left: 0;
35
+ }
36
+
37
+ body.tools_page_health-check .wrap h2 {
38
+ padding: 1rem 0.5rem;
39
+ font-size: 1.3rem;
40
+ font-weight: 600;
41
+ font-family: inherit;
42
+ }
43
+
44
+ @media all and (min-width: 960px) {
45
+ body.tools_page_health-check .wrap h2 {
46
+ padding: 1rem 0;
47
+ }
48
+ }
49
+
50
+ body.tools_page_health-check ul li,
51
+ body.tools_page_health-check ol li {
52
+ font-size: 13px;
53
+ line-height: 1.5;
54
+ }
55
+
56
+ body.tools_page_health-check .wp-core-ui .button {
57
+ font-size: 13px;
58
  }
59
 
60
+ body.tools_page_health-check .health-check-header {
61
+ text-align: center;
62
+ margin: 0 0 1rem;
63
+ background: #fff;
64
+ border-bottom: 1px solid #e2e4e7;
65
  }
66
 
67
+ body.tools_page_health-check .health-check-header .health-check-title-section {
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ clear: both;
72
  }
73
 
74
+ body.tools_page_health-check .health-check-header .health-check-title-section h1 {
75
+ display: inline-block;
76
+ font-weight: 600;
77
+ font-size: 23px;
78
+ margin: 1rem 0.8rem;
79
+ padding: 9px 0 4px;
80
+ line-height: 1.3;
81
+ font-family: inherit;
82
  }
83
 
84
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress {
85
+ display: inline-block;
86
+ height: 40px;
87
+ width: 40px;
88
  margin: 0;
89
+ border-radius: 100%;
90
+ position: relative;
91
+ font-weight: 600;
92
+ font-size: 0.4rem;
93
+ }
94
+
95
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress.loading .site-health-progress-count:after {
96
+ content: "···";
97
+ }
98
+
99
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress.loading svg #bar {
100
+ stroke-dashoffset: 0;
101
+ stroke: #adc5d2;
102
+ animation: loadingPulse 3s infinite ease-in-out;
103
+ }
104
+
105
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress .site-health-progress-count {
106
+ position: absolute;
107
+ display: block;
108
+ height: 80px;
109
+ width: 80px;
110
+ left: 50%;
111
+ top: 50%;
112
+ margin-top: -40px;
113
+ margin-left: -40px;
114
+ border-radius: 100%;
115
+ line-height: 6.3;
116
+ font-size: 2em;
117
  }
118
 
119
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress .site-health-progress-count:after {
120
+ content: "";
121
+ }
122
+
123
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress svg circle {
124
+ stroke-dashoffset: 0;
125
+ transition: stroke-dashoffset 1s linear;
126
+ stroke: #ccc;
127
+ stroke-width: 2em;
128
+ }
129
+
130
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress svg #bar {
131
+ stroke-dashoffset: 565;
132
+ stroke: #dc3232;
133
+ }
134
+
135
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress svg #bar.green {
136
+ stroke: #46b450;
137
+ }
138
+
139
+ body.tools_page_health-check .health-check-header .health-check-title-section .site-health-progress svg #bar.orange {
140
+ stroke: #ffb900;
141
+ }
142
+
143
+ @keyframes loadingPulse {
144
+ 0% {
145
+ stroke: #adc5d2;
146
+ }
147
+ 50% {
148
+ stroke: #00a0d2;
149
+ }
150
+ 100% {
151
+ stroke: #adc5d2;
152
+ }
153
+ }
154
+
155
+ body.tools_page_health-check .health-check-header .health-check-tabs-wrapper {
156
+ display: block;
157
+ }
158
+
159
+ body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab {
160
+ display: inline-block;
161
+ text-decoration: none;
162
+ color: inherit;
163
+ padding: 0.5rem 1rem 1rem;
164
+ margin: 0 1rem;
165
+ transition: box-shadow 0.5s ease-in-out;
166
+ }
167
+
168
+ body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab.active {
169
+ box-shadow: inset 0 -3px #007cba;
170
+ font-weight: 600;
171
+ }
172
+
173
+ body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:focus {
174
+ color: #191e23;
175
+ outline: 1px solid #6c7781;
176
+ box-shadow: none;
177
+ }
178
+
179
+ body.tools_page_health-check .health-check-body {
180
+ max-width: 800px;
181
+ margin: 0 auto;
182
+ }
183
+
184
+ body.tools_page_health-check .health-check-table thead th,
185
+ body.tools_page_health-check .health-check-table thead td {
186
+ font-size: 13px;
187
+ }
188
+
189
+ body.tools_page_health-check .health-check-table thead th:first-child,
190
+ body.tools_page_health-check .health-check-table thead td:first-child {
191
+ width: 30%;
192
+ }
193
+
194
+ body.tools_page_health-check .health-check-table tbody td {
195
+ width: 70%;
196
+ font-size: 13px;
197
+ }
198
+
199
+ body.tools_page_health-check .health-check-table tbody td:first-child {
200
+ width: 30%;
201
+ }
202
+
203
+ body.tools_page_health-check .health-check-table tbody td ul,
204
+ body.tools_page_health-check .health-check-table tbody td ol {
205
+ margin: 0;
206
+ }
207
+
208
+ body.tools_page_health-check .pass:before,
209
+ body.tools_page_health-check .good:before {
210
  content: "\f147";
211
  display: inline-block;
212
  color: #46b450;
213
  font-family: dashicons;
214
  }
215
 
216
+ body.tools_page_health-check .warning:before {
217
  content: "\f460";
218
  display: inline-block;
219
  color: #ffb900;
220
  font-family: dashicons;
221
  }
222
 
223
+ body.tools_page_health-check .info:before {
224
  content: "\f348";
225
  display: inline-block;
226
  color: #00a0d2;
227
  font-family: dashicons;
228
  }
229
 
230
+ body.tools_page_health-check .fail:before,
231
+ body.tools_page_health-check .error:before {
232
  content: "\f335";
233
  display: inline-block;
234
  color: #dc3232;
235
  font-family: dashicons;
236
  }
237
 
238
+ body.tools_page_health-check .spinner {
239
+ float: none;
240
+ }
241
+
242
+ body.tools_page_health-check .site-health-copy-buttons {
243
+ display: block;
244
+ margin: 1rem 0;
245
+ }
246
+
247
+ body.tools_page_health-check .site-health-copy-buttons .copy-button-wrapper {
248
+ margin: 0.5rem 0 1rem;
249
+ }
250
+
251
+ body.tools_page_health-check .site-health-copy-buttons .success {
252
+ display: none;
253
+ color: #40860a;
254
+ height: 28px;
255
+ line-height: 2.2;
256
+ margin-left: 0.5rem;
257
+ }
258
+
259
+ body.tools_page_health-check .site-health-copy-buttons .success.visible {
260
+ display: inline-block;
261
+ }
262
+
263
+ body.tools_page_health-check #health-check-debug {
264
+ margin-bottom: 3rem;
265
+ }
266
+
267
+ body.tools_page_health-check .health-check-wp-paths-sizes.spinner {
268
+ position: absolute;
269
+ visibility: visible;
270
  float: none;
271
+ margin: 0 4px;
272
  }
273
 
274
+ body.tools_page_health-check .file-integrity-table thead th:first-child,
275
+ body.tools_page_health-check .file-integrity-table thead td:first-child,
276
+ body.tools_page_health-check .file-integrity-table tbody th:first-child,
277
+ body.tools_page_health-check .file-integrity-table tbody td:first-child,
278
+ body.tools_page_health-check .file-integrity-table tfoot th:first-child,
279
+ body.tools_page_health-check .file-integrity-table tfoot td:first-child {
280
  text-align: center;
281
  width: 60px;
282
  }
283
 
284
+ body.tools_page_health-check .tools-email-table {
285
  border: 0;
286
  box-shadow: none;
287
  }
288
 
289
+ body.tools_page_health-check .tools-email-table td:first-child {
290
  width: 280px;
291
  }
292
 
293
  @media (max-width: 768px) {
294
+ body.tools_page_health-check .tools-email-table td {
295
  display: block;
296
  }
297
  }
298
 
299
+ body.tools_page_health-check .tools-email-table input {
300
  width: 100%;
301
  }
302
 
303
+ body.tools_page_health-check .tools-email-table label {
304
  display: block;
305
  clear: both;
306
  }
307
 
308
+ body.tools_page_health-check #health-check-mail-check,
309
+ body.tools_page_health-check #health-check-file-integrity {
310
  margin-bottom: 15px;
311
  }
312
 
313
+ body.tools_page_health-check #health-check-diff-modal {
314
  width: 100vw;
315
  height: 100%;
316
  position: fixed;
321
  z-index: 99999;
322
  }
323
 
324
+ body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-content {
325
  background: #fff;
326
  height: calc(100% - 120px);
327
  width: calc(100% - 120px);
331
  display: block;
332
  }
333
 
334
+ body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff {
335
  width: 100%;
336
  height: calc(100% - 80px);
337
  overflow-y: auto;
339
  position: relative;
340
  }
341
 
342
+ body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2) {
343
  background: #f3f3f3;
344
  }
345
 
346
+ body.tools_page_health-check #health-check-diff-modal-close-ref {
347
  position: relative;
348
  display: block;
349
  float: right;
351
  text-decoration: none;
352
  }
353
 
354
+ body.tools_page_health-check .site-health-issues-wrapper {
355
+ margin-bottom: 3rem;
356
+ margin-top: 2rem;
357
+ }
358
+
359
+ body.tools_page_health-check .site-health-issues-wrapper:first-of-type {
360
+ margin-top: 3rem;
361
+ }
362
+
363
+ body.tools_page_health-check .site-status-has-issues {
364
+ display: block;
365
+ }
366
+
367
+ body.tools_page_health-check .site-status-has-issues.hide {
368
+ display: none;
369
+ }
370
+
371
+ body.tools_page_health-check h3 {
372
+ padding: 0;
373
+ font-weight: 400;
374
+ }
375
+
376
+ body.tools_page_health-check .site-health-view-more {
377
+ text-align: center;
378
+ }
379
+
380
+ body.tools_page_health-check .issues-wrapper {
381
+ margin-bottom: 5rem;
382
+ }
383
+
384
+ body.tools_page_health-check .site-status-all-clear {
385
+ display: flex;
386
+ flex-direction: column;
387
+ align-items: center;
388
+ justify-content: center;
389
+ text-align: center;
390
+ height: 100%;
391
+ width: 100%;
392
+ margin-top: 0;
393
+ }
394
+
395
+ @media all and (min-width: 784px) {
396
+ body.tools_page_health-check .site-status-all-clear {
397
+ margin: 5rem 0;
398
+ }
399
+ }
400
+
401
+ body.tools_page_health-check .site-status-all-clear.hide {
402
+ display: none;
403
  }
404
 
405
+ body.tools_page_health-check .site-status-all-clear .dashicons {
406
+ font-size: 150px;
407
+ height: 130px;
408
+ width: 150px;
409
  }
410
 
411
+ body.tools_page_health-check .site-status-all-clear .encouragement {
412
+ font-family: inherit;
413
+ font-size: 1.5rem;
414
  font-weight: 600;
415
  }
416
 
417
+ body.tools_page_health-check .site-status-all-clear p {
418
+ margin: 0;
419
  }
420
 
421
+ body.tools_page_health-check .site-health-view-passed {
422
+ position: relative;
423
+ padding-right: 40px;
424
+ padding-left: 20px;
425
+ }
426
+
427
+ body.tools_page_health-check .site-health-view-passed .icon {
428
+ border: solid #555d66;
429
+ border-width: 0 2px 2px 0;
430
+ height: 0.5rem;
431
+ pointer-events: none;
432
+ position: absolute;
433
+ right: 1.5em;
434
+ top: 50%;
435
+ transform: translateY(-70%) rotate(45deg);
436
+ width: 0.5rem;
437
+ }
438
+
439
+ body.tools_page_health-check .site-health-view-passed[aria-expanded="true"] .icon {
440
+ transform: translateY(-30%) rotate(-135deg);
441
+ }
442
+
443
+ body .health-check-accordion {
444
+ border: 1px solid #e2e4e7;
445
+ }
446
+
447
+ body .health-check-accordion .health-check-accordion-heading {
448
+ margin: 0;
449
+ border-top: 1px solid #e2e4e7;
450
+ font-size: inherit;
451
+ line-height: inherit;
452
+ font-weight: 600;
453
+ color: inherit;
454
+ }
455
+
456
+ body .health-check-accordion .health-check-accordion-heading:first-child {
457
+ border-top: none;
458
+ }
459
+
460
+ body .health-check-accordion .health-check-accordion-trigger {
461
  background: #fff;
462
  border: 0;
463
+ color: #32373c;
464
+ cursor: pointer;
465
  display: block;
 
466
  font-weight: 400;
467
  margin: 0;
468
+ padding: 1em 3.5em 1em 1.5em;
469
  position: relative;
470
  text-align: left;
471
  width: 100%;
472
  }
473
 
474
+ body .health-check-accordion .health-check-accordion-trigger:hover, body .health-check-accordion .health-check-accordion-trigger:active {
475
+ background: #f8f9f9;
476
  }
477
 
478
+ body .health-check-accordion .health-check-accordion-trigger:focus {
479
+ color: #191e23;
480
+ border: none;
481
+ box-shadow: none;
482
+ outline-offset: -2px;
483
+ outline: 1px dotted #555d66;
484
+ }
485
+
486
+ body .health-check-accordion .health-check-accordion-trigger .title {
487
+ display: inline-block;
488
  pointer-events: none;
489
+ font-weight: 600;
490
  }
491
 
492
+ body .health-check-accordion .health-check-accordion-trigger .icon {
493
+ border: solid #555d66;
494
  border-width: 0 2px 2px 0;
495
  height: 0.5rem;
496
  pointer-events: none;
497
  position: absolute;
498
  right: 1.5em;
499
  top: 50%;
500
+ transform: translateY(-70%) rotate(45deg);
501
  width: 0.5rem;
502
  }
503
 
504
+ body .health-check-accordion .health-check-accordion-trigger .badge {
505
+ float: right;
506
+ padding: 0.1rem 0.5rem 0.15rem;
507
+ color: #32373c;
508
+ font-weight: 600;
509
+ margin-left: 0.5rem;
510
+ }
511
+
512
+ body .health-check-accordion .health-check-accordion-trigger .badge.blue {
513
+ border: 1px solid #bfe7f3;
514
  }
515
 
516
+ body .health-check-accordion .health-check-accordion-trigger .badge.orange {
517
+ border: 1px solid #ffb900;
518
+ }
519
+
520
+ body .health-check-accordion .health-check-accordion-trigger .badge.red {
521
+ border: 1px solid #dc3232;
522
+ }
523
+
524
+ body .health-check-accordion .health-check-accordion-trigger .badge.green {
525
+ border: 1px solid #46b450;
526
+ }
527
+
528
+ body .health-check-accordion .health-check-accordion-trigger .badge.purple {
529
+ border: 1px solid #826eb4;
530
+ }
531
+
532
+ body .health-check-accordion .health-check-accordion-trigger .badge.gray {
533
+ border: 1px solid #ccd0d4;
534
+ }
535
+
536
+ body .health-check-accordion .health-check-accordion-trigger[aria-expanded="true"] .icon {
537
+ transform: translateY(-30%) rotate(-135deg);
538
+ }
539
+
540
+ body .health-check-accordion .health-check-accordion-panel {
541
  margin: 0;
542
  padding: 1em 1.5em;
543
  background: #fff;
544
  }
545
 
546
+ body .health-check-accordion .health-check-accordion-panel > div {
547
  display: block;
548
  }
549
 
550
+ body .health-check-accordion .health-check-accordion-panel[hidden] {
551
  display: none;
552
  }
553
 
554
+ body .health-check-accordion .health-check-accordion-panel a .dashicons {
555
+ text-decoration: none;
556
+ }
557
+
558
+ body .health-check-accordion dl dd {
559
  margin: 0 0 0.5em 2em;
560
  }
561
 
assets/javascript/health-check.js CHANGED
@@ -1,5 +1,5 @@
1
  jQuery( document ).ready(function( $ ) {
2
- $( '.health-check-accordion-trigger' ).click(function() {
3
  var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
4
 
5
  if ( isExpanded ) {
@@ -9,47 +9,110 @@ jQuery( document ).ready(function( $ ) {
9
  $( this ).attr( 'aria-expanded', 'true' );
10
  $( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
11
  }
12
- });
13
-
14
- $( '.health-check-accordion' ).on( 'keyup', '.health-check-accordion-trigger', function( e ) {
15
- if ( '38' === e.keyCode.toString() ) {
16
- $( '.health-check-accordion-trigger', $( this ).closest( 'dt' ).prevAll( 'dt' ) ).focus();
17
- } else if ( '40' === e.keyCode.toString() ) {
18
- $( '.health-check-accordion-trigger', $( this ).closest( 'dt' ).nextAll( 'dt' ) ).focus();
19
- }
20
- });
21
  });
22
 
23
- /* global HealthCheck */
24
- jQuery( document ).ready(function( $ ) {
25
- $( '.health-check-copy-field' ).click(function( e ) {
26
- var $textarea = $( 'textarea', $( this ).closest( 'div' ) ),
27
- $button = $( this ),
28
- copied = false;
29
 
30
- e.preventDefault();
 
31
 
32
- $textarea.select();
 
 
33
 
34
- copied = document.execCommand( 'copy' );
35
- if ( copied ) {
36
- $button.text( HealthCheck.string.copied );
37
- }
38
- });
39
  });
40
 
 
41
  jQuery( document ).ready(function( $ ) {
42
- $( '.health-check-toc' ).click(function( e ) {
43
-
44
- // Remove the height of the admin bar, and an extra 10px for better positioning.
45
- var offset = $( $( this ).attr( 'href' ) ).offset().top - $( '#wpadminbar' ).height() - 10;
46
-
47
- e.preventDefault();
48
-
49
- $( 'html, body' ).animate({
50
- scrollTop: offset
51
- }, 1200 );
52
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  });
54
 
55
  /* global ajaxurl */
@@ -90,13 +153,13 @@ jQuery( document ).ready(function( $ ) {
90
  });
91
  });
92
 
93
- /* global HealthCheck, ajaxurl, healthCheckFailureModal */
94
  jQuery( document ).ready(function( $ ) {
95
  function testDefaultTheme() {
96
  var $parent = $( '.individual-loopback-test-status', '#test-single-no-theme' ),
97
  data = {
98
  'action': 'health-check-loopback-default-theme',
99
- '_wpnonce': HealthCheck.nonce.loopback_default_theme
100
  };
101
 
102
  $.post(
@@ -128,12 +191,12 @@ jQuery( document ).ready(function( $ ) {
128
  data = {
129
  'action': 'health-check-loopback-individual-plugins',
130
  'plugin': $testLine.data( 'test-plugin' ),
131
- '_wpnonce': HealthCheck.nonce.loopback_individual_plugins
132
  };
133
 
134
  $parentField = $( '.individual-loopback-test-status', $testLine );
135
 
136
- $parentField.html( HealthCheck.string.running_tests );
137
 
138
  $.post(
139
  ajaxurl,
@@ -153,15 +216,15 @@ jQuery( document ).ready(function( $ ) {
153
 
154
  $( '.dashboard_page_health-check' ).on( 'click', '#loopback-no-plugins', function( e ) {
155
  var $trigger = $( this ),
156
- $parent = $( this ).closest( 'td' ),
157
  data = {
158
  'action': 'health-check-loopback-no-plugins',
159
- '_wpnonce': HealthCheck.nonce.loopback_no_plugins
160
  };
161
 
162
  e.preventDefault();
163
 
164
- $( this ).html( '<span class="spinner" style="visibility: visible;"></span> ' + HealthCheck.string.please_wait );
165
 
166
  $.post(
167
  ajaxurl,
@@ -179,36 +242,211 @@ jQuery( document ).ready(function( $ ) {
179
  }).on( 'click', '#loopback-individual-plugins', function( e ) {
180
  e.preventDefault();
181
 
 
 
182
  testSinglePlugin();
183
  });
184
  });
185
 
186
- /* global ajaxurl, HealthCheck */
187
  jQuery( document ).ready(function( $ ) {
188
- $( '.health-check-site-status-test' ).each( function() {
189
- var $check = $( this ),
190
- data = {
191
- 'action': 'health-check-site-status',
192
- 'feature': $( this ).data( 'site-status' ),
193
- '_wpnonce': HealthCheck.nonce.site_status
194
- };
195
 
196
- $.post(
197
- ajaxurl,
198
- data,
199
- function( response ) {
200
- $check.html( response );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
202
- );
203
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  });
205
 
206
- /* global ajaxurl, HealthCheck */
207
  jQuery( document ).ready(function( $ ) {
208
  $( '#health-check-file-integrity' ).submit( function( e ) {
209
  var data = {
210
  'action': 'health-check-files-integrity-check',
211
- '_wpnonce': HealthCheck.nonce.files_integrity_check
212
  };
213
 
214
  e.preventDefault();
@@ -239,7 +477,7 @@ jQuery( document ).ready(function( $ ) {
239
  data = {
240
  'action': 'health-check-view-file-diff',
241
  'file': file,
242
- '_wpnonce': HealthCheck.nonce.view_file_diff
243
  };
244
 
245
  $.post(
@@ -271,7 +509,7 @@ jQuery( document ).ready(function( $ ) {
271
  });
272
  });
273
 
274
- /* global ajaxurl, HealthCheck */
275
  jQuery( document ).ready(function( $ ) {
276
  $( '#health-check-mail-check' ).submit( function( e ) {
277
  var email = $( '#health-check-mail-check #email' ).val(),
@@ -287,7 +525,7 @@ jQuery( document ).ready(function( $ ) {
287
  'action': 'health-check-mail-check',
288
  'email': email,
289
  'email_message': emailMessage,
290
- '_wpnonce': HealthCheck.nonce.mail_check
291
  };
292
 
293
  $.post(
1
  jQuery( document ).ready(function( $ ) {
2
+ $( '.health-check-accordion' ).on( 'click', '.health-check-accordion-trigger', function() {
3
  var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
4
 
5
  if ( isExpanded ) {
9
  $( this ).attr( 'aria-expanded', 'true' );
10
  $( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
11
  }
12
+ } );
 
 
 
 
 
 
 
 
13
  });
14
 
15
+ /* global ClipboardJS, SiteHealth, wp */
16
+ jQuery( document ).ready( function( $ ) {
17
+ var clipboard;
 
 
 
18
 
19
+ if ( 'undefined' !== typeof ClipboardJS ) {
20
+ clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' );
21
 
22
+ // Debug information copy section.
23
+ clipboard.on( 'success', function( e ) {
24
+ var $wrapper = $( e.trigger ).closest( 'div' );
25
 
26
+ $( '.success', $wrapper ).addClass( 'visible' );
27
+
28
+ wp.a11y.speak( SiteHealth.string.site_info_copied );
29
+ });
30
+ }
31
  });
32
 
33
+ /* global ajaxurl, SiteHealth */
34
  jQuery( document ).ready(function( $ ) {
35
+ var isDebugTab = $( '.health-check-debug-tab.active' ).length;
36
+ var pathsSizesSection = $( '#health-check-accordion-block-wp-paths-sizes' );
37
+
38
+ function getDirectorySizes() {
39
+ var data = {
40
+ action: 'health-check-get-sizes',
41
+ _wpnonce: SiteHealth.nonce.site_status_result
42
+ };
43
+
44
+ var timestamp = ( new Date().getTime() );
45
+
46
+ // After 3 seconds announce that we're still waiting for directory sizes.
47
+ var timeout = window.setTimeout( function() {
48
+ wp.a11y.speak( SiteHealth.string.please_wait );
49
+ }, 3000 );
50
+
51
+ $.post( {
52
+ type: 'POST',
53
+ url: ajaxurl,
54
+ data: data,
55
+ dataType: 'json'
56
+ } ).done( function( response ) {
57
+ updateDirSizes( response.data || {} );
58
+ } ).always( function() {
59
+ var delay = ( new Date().getTime() ) - timestamp;
60
+
61
+ $( '.health-check-wp-paths-sizes.spinner' ).css( 'visibility', 'hidden' );
62
+
63
+ if ( delay > 3000 ) {
64
+
65
+ // We have announced that we're waiting.
66
+ // Announce that we're ready after giving at least 3 seconds for the first announcement
67
+ // to be read out, or the two may collide.
68
+ if ( delay > 6000 ) {
69
+ delay = 0;
70
+ } else {
71
+ delay = 6500 - delay;
72
+ }
73
+
74
+ window.setTimeout( function() {
75
+ wp.a11y.speak( SiteHealth.string.site_health_complete );
76
+ }, delay );
77
+ } else {
78
+
79
+ // Cancel the announcement.
80
+ window.clearTimeout( timeout );
81
+ }
82
+
83
+ $( document ).trigger( 'site-health-info-dirsizes-done' );
84
+ } );
85
+ }
86
+
87
+ function updateDirSizes( data ) {
88
+ var copyButton = $( 'button.button.copy-button' );
89
+ var clipdoardText = copyButton.attr( 'data-clipboard-text' );
90
+
91
+ $.each( data, function( name, value ) {
92
+ var text = value.debug || value.size;
93
+
94
+ if ( 'undefined' !== typeof text ) {
95
+ clipdoardText = clipdoardText.replace( name + ': loading...', name + ': ' + text );
96
+ }
97
+ } );
98
+
99
+ copyButton.attr( 'data-clipboard-text', clipdoardText );
100
+
101
+ pathsSizesSection.find( 'td[class]' ).each( function( i, element ) {
102
+ var td = $( element );
103
+ var name = td.attr( 'class' );
104
+
105
+ if ( data.hasOwnProperty( name ) && data[ name ].size ) {
106
+ td.text( data[ name ].size );
107
+ }
108
+ } );
109
+ }
110
+
111
+ if ( isDebugTab ) {
112
+ if ( pathsSizesSection.length ) {
113
+ getDirectorySizes();
114
+ }
115
+ }
116
  });
117
 
118
  /* global ajaxurl */
153
  });
154
  });
155
 
156
+ /* global SiteHealth, ajaxurl, healthCheckFailureModal */
157
  jQuery( document ).ready(function( $ ) {
158
  function testDefaultTheme() {
159
  var $parent = $( '.individual-loopback-test-status', '#test-single-no-theme' ),
160
  data = {
161
  'action': 'health-check-loopback-default-theme',
162
+ '_wpnonce': SiteHealth.nonce.loopback_default_theme
163
  };
164
 
165
  $.post(
191
  data = {
192
  'action': 'health-check-loopback-individual-plugins',
193
  'plugin': $testLine.data( 'test-plugin' ),
194
+ '_wpnonce': SiteHealth.nonce.loopback_individual_plugins
195
  };
196
 
197
  $parentField = $( '.individual-loopback-test-status', $testLine );
198
 
199
+ $parentField.html( SiteHealth.string.running_tests );
200
 
201
  $.post(
202
  ajaxurl,
216
 
217
  $( '.dashboard_page_health-check' ).on( 'click', '#loopback-no-plugins', function( e ) {
218
  var $trigger = $( this ),
219
+ $parent = $( this ).closest( 'p' ),
220
  data = {
221
  'action': 'health-check-loopback-no-plugins',
222
+ '_wpnonce': SiteHealth.nonce.loopback_no_plugins
223
  };
224
 
225
  e.preventDefault();
226
 
227
+ $( this ).html( '<span class="spinner" style="visibility: visible;"></span> ' + SiteHealth.string.please_wait );
228
 
229
  $.post(
230
  ajaxurl,
242
  }).on( 'click', '#loopback-individual-plugins', function( e ) {
243
  e.preventDefault();
244
 
245
+ $( this ).remove();
246
+
247
  testSinglePlugin();
248
  });
249
  });
250
 
251
+ /* global ajaxurl, SiteHealth, wp */
252
  jQuery( document ).ready(function( $ ) {
253
+ var data;
254
+ var isDebugTab = $( '.health-check-debug-tab.active' ).length;
 
 
 
 
 
255
 
256
+ $( '.site-health-view-passed' ).on( 'click', function() {
257
+ var goodIssuesWrapper = $( '#health-check-issues-good' );
258
+
259
+ goodIssuesWrapper.toggleClass( 'hidden' );
260
+ $( this ).attr( 'aria-expanded', ! goodIssuesWrapper.hasClass( 'hidden' ) );
261
+ } );
262
+
263
+ function AppendIssue( issue ) {
264
+ var template = wp.template( 'health-check-issue' ),
265
+ issueWrapper = $( '#health-check-issues-' + issue.status ),
266
+ heading,
267
+ count;
268
+
269
+ SiteHealth.site_status.issues[ issue.status ]++;
270
+
271
+ count = SiteHealth.site_status.issues[ issue.status ];
272
+
273
+ if ( 'critical' === issue.status ) {
274
+ if ( count <= 1 ) {
275
+ heading = SiteHealth.string.site_info_heading_critical_single.replace( '%s', '<span class="issue-count">' + count + '</span>' );
276
+ } else {
277
+ heading = SiteHealth.string.site_info_heading_critical_plural.replace( '%s', '<span class="issue-count">' + count + '</span>' );
278
  }
279
+ } else if ( 'recommended' === issue.status ) {
280
+ if ( count <= 1 ) {
281
+ heading = SiteHealth.string.site_info_heading_recommended_single.replace( '%s', '<span class="issue-count">' + count + '</span>' );
282
+ } else {
283
+ heading = SiteHealth.string.site_info_heading_recommended_plural.replace( '%s', '<span class="issue-count">' + count + '</span>' );
284
+ }
285
+ } else if ( 'good' === issue.status ) {
286
+ if ( count <= 1 ) {
287
+ heading = SiteHealth.string.site_info_heading_good_single.replace( '%s', '<span class="issue-count">' + count + '</span>' );
288
+ } else {
289
+ heading = SiteHealth.string.site_info_heading_good_plural.replace( '%s', '<span class="issue-count">' + count + '</span>' );
290
+ }
291
+ }
292
+
293
+ if ( heading ) {
294
+ $( '.site-health-issue-count-title', issueWrapper ).html( heading );
295
+ }
296
+
297
+ $( '.issues', '#health-check-issues-' + issue.status ).append( template( issue ) );
298
+ }
299
+
300
+ function RecalculateProgression() {
301
+ var r, c, pct;
302
+ var $progress = $( '.site-health-progress' );
303
+ var $progressCount = $progress.find( '.site-health-progress-count' );
304
+ var $circle = $( '.site-health-progress svg #bar' );
305
+ var totalTests = parseInt( SiteHealth.site_status.issues.good, 0 ) + parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
306
+ var failedTests = parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
307
+ var val = 100 - Math.ceil( ( failedTests / totalTests ) * 100 );
308
+
309
+ if ( 0 === totalTests ) {
310
+ $progress.addClass( 'hidden' );
311
+ return;
312
+ }
313
+
314
+ $progress.removeClass( 'loading' );
315
+
316
+ r = $circle.attr( 'r' );
317
+ c = Math.PI * ( r * 2 );
318
+
319
+ if ( 0 > val ) {
320
+ val = 0;
321
+ }
322
+ if ( 100 < val ) {
323
+ val = 100;
324
+ }
325
+
326
+ pct = ( ( 100 - val ) / 100 ) * c;
327
+
328
+ $circle.css( { strokeDashoffset: pct } );
329
+
330
+ if ( 1 > parseInt( SiteHealth.site_status.issues.critical, 0 ) ) {
331
+ $( '#health-check-issues-critical' ).addClass( 'hidden' );
332
+ }
333
+
334
+ if ( 1 > parseInt( SiteHealth.site_status.issues.recommended, 0 ) ) {
335
+ $( '#health-check-issues-recommended' ).addClass( 'hidden' );
336
+ }
337
+
338
+ if ( 50 <= val ) {
339
+ $circle.addClass( 'orange' ).removeClass( 'red' );
340
+ }
341
+
342
+ if ( 90 <= val ) {
343
+ $circle.addClass( 'green' ).removeClass( 'orange' );
344
+ }
345
+
346
+ if ( 100 === val ) {
347
+ $( '.site-status-all-clear' ).removeClass( 'hide' );
348
+ $( '.site-status-has-issues' ).addClass( 'hide' );
349
+ }
350
+
351
+ $progressCount.text( val + '%' );
352
+
353
+ if ( ! isDebugTab ) {
354
+ $.post(
355
+ ajaxurl,
356
+ {
357
+ 'action': 'health-check-site-status-result',
358
+ '_wpnonce': SiteHealth.nonce.site_status_result,
359
+ 'counts': SiteHealth.site_status.issues
360
+ }
361
+ );
362
+ }
363
+
364
+ wp.a11y.speak( SiteHealth.string.site_health_complete_screen_reader.replace( '%s', val + '%' ) );
365
+ }
366
+
367
+ function maybeRunNextAsyncTest() {
368
+ var doCalculation = true;
369
+
370
+ if ( 1 <= SiteHealth.site_status.async.length ) {
371
+ $.each( SiteHealth.site_status.async, function() {
372
+ var data = {
373
+ 'action': 'health-check-site-status',
374
+ 'feature': this.test,
375
+ '_wpnonce': SiteHealth.nonce.site_status
376
+ };
377
+
378
+ if ( this.completed ) {
379
+ return true;
380
+ }
381
+
382
+ doCalculation = false;
383
+
384
+ this.completed = true;
385
+
386
+ $.post(
387
+ ajaxurl,
388
+ data,
389
+ function( response ) {
390
+ AppendIssue( response.data );
391
+ maybeRunNextAsyncTest();
392
+ }
393
+ );
394
+
395
+ return false;
396
+ } );
397
+ }
398
+
399
+ if ( doCalculation ) {
400
+ RecalculateProgression();
401
+ }
402
+ }
403
+
404
+ if ( 'undefined' !== typeof SiteHealth ) {
405
+ if ( 0 === SiteHealth.site_status.direct.length && 0 === SiteHealth.site_status.async.length ) {
406
+ RecalculateProgression();
407
+ } else {
408
+ SiteHealth.site_status.issues = {
409
+ 'good': 0,
410
+ 'recommended': 0,
411
+ 'critical': 0
412
+ };
413
+ }
414
+
415
+ if ( 0 < SiteHealth.site_status.direct.length ) {
416
+ $.each( SiteHealth.site_status.direct, function() {
417
+ AppendIssue( this );
418
+ } );
419
+ }
420
+
421
+ if ( 0 < SiteHealth.site_status.async.length ) {
422
+ data = {
423
+ 'action': 'health-check-site-status',
424
+ 'feature': SiteHealth.site_status.async[0].test,
425
+ '_wpnonce': SiteHealth.nonce.site_status
426
+ };
427
+
428
+ SiteHealth.site_status.async[0].completed = true;
429
+
430
+ $.post(
431
+ ajaxurl,
432
+ data,
433
+ function( response ) {
434
+ AppendIssue( response.data );
435
+ maybeRunNextAsyncTest();
436
+ }
437
+ );
438
+ } else {
439
+ RecalculateProgression();
440
+ }
441
+ }
442
  });
443
 
444
+ /* global ajaxurl, SiteHealth */
445
  jQuery( document ).ready(function( $ ) {
446
  $( '#health-check-file-integrity' ).submit( function( e ) {
447
  var data = {
448
  'action': 'health-check-files-integrity-check',
449
+ '_wpnonce': SiteHealth.nonce.files_integrity_check
450
  };
451
 
452
  e.preventDefault();
477
  data = {
478
  'action': 'health-check-view-file-diff',
479
  'file': file,
480
+ '_wpnonce': SiteHealth.nonce.view_file_diff
481
  };
482
 
483
  $.post(
509
  });
510
  });
511
 
512
+ /* global ajaxurl, SiteHealth */
513
  jQuery( document ).ready(function( $ ) {
514
  $( '#health-check-mail-check' ).submit( function( e ) {
515
  var email = $( '#health-check-mail-check #email' ).val(),
525
  'action': 'health-check-mail-check',
526
  'email': email,
527
  'email_message': emailMessage,
528
+ '_wpnonce': SiteHealth.nonce.mail_check
529
  };
530
 
531
  $.post(
assets/mu-plugin/health-check-troubleshooting-mode.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Health Check Troubleshooting Mode
4
  Description: Conditionally disabled themes or plugins on your site for a given session, used to rule out conflicts during troubleshooting.
5
- Version: 1.5.1
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  // Set the MU plugin version.
13
- define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.5.1' );
14
 
15
  class Health_Check_Troubleshooting_MU {
16
  private $disable_hash = null;
@@ -23,7 +23,7 @@ class Health_Check_Troubleshooting_MU {
23
  private $self_fetching_theme = false;
24
 
25
  private $available_query_args = array(
26
- 'health-check-disable-plugins',
27
  'health-check-disable-plugins-hash',
28
  'health-check-disable-troubleshooting',
29
  'health-check-change-active-theme',
@@ -75,7 +75,7 @@ class Health_Check_Troubleshooting_MU {
75
  add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) );
76
  add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) );
77
 
78
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
79
 
80
  /*
81
  * Plugin activations can be forced by other tools in things like themes, so let's
@@ -102,16 +102,17 @@ class Health_Check_Troubleshooting_MU {
102
  }
103
 
104
  /**
105
- * Enqueue styles used by the MU plugin if applicable.
106
  *
107
  * @return void
108
  */
109
- public function enqueue_styles() {
110
  if ( ! $this->is_troubleshooting() || ! is_admin() ) {
111
  return;
112
  }
113
 
114
  wp_enqueue_style( 'health-check-troubleshooting-mode', plugins_url( '/health-check/assets/css/health-check-troubleshooting-mode.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION );
 
115
  }
116
 
117
  /**
@@ -277,8 +278,8 @@ class Health_Check_Troubleshooting_MU {
277
  */
278
  public function is_troubleshooting() {
279
  // Check if a session cookie to disable plugins has been set.
280
- if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
281
- $_GET['health-check-disable-plugin-hash'] = $_COOKIE['health-check-disable-plugins'] . md5( $_SERVER['REMOTE_ADDR'] );
282
  }
283
 
284
  // If the disable hash isn't set, no need to interact with things.
@@ -462,14 +463,14 @@ class Health_Check_Troubleshooting_MU {
462
  return;
463
  }
464
 
465
- if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
466
  $this->disable_troubleshooting_mode();
467
  }
468
  }
469
 
470
  function disable_troubleshooting_mode() {
471
- unset( $_COOKIE['health-check-disable-plugins'] );
472
- setcookie( 'health-check-disable-plugins', null, 0, COOKIEPATH, COOKIE_DOMAIN );
473
  delete_option( 'health-check-allowed-plugins' );
474
  delete_option( 'health-check-default-theme' );
475
  delete_option( 'health-check-current-theme' );
@@ -622,6 +623,7 @@ class Health_Check_Troubleshooting_MU {
622
  $wp_menu->add_menu( array(
623
  'id' => 'health-check',
624
  'title' => esc_html__( 'Troubleshooting Mode', 'health-check' ),
 
625
  ) );
626
 
627
  // Add a link to manage plugins if there are more than 20 set to be active.
@@ -637,6 +639,7 @@ class Health_Check_Troubleshooting_MU {
637
  'id' => 'health-check-plugins',
638
  'title' => esc_html__( 'Plugins', 'health-check' ),
639
  'parent' => 'health-check',
 
640
  ) );
641
 
642
  $wp_menu->add_group( array(
@@ -699,6 +702,7 @@ class Health_Check_Troubleshooting_MU {
699
  'id' => 'health-check-theme',
700
  'title' => esc_html__( 'Themes', 'health-check' ),
701
  'parent' => 'health-check',
 
702
  ) );
703
 
704
  $themes = wp_prepare_themes_for_js();
@@ -711,8 +715,7 @@ class Health_Check_Troubleshooting_MU {
711
  ),
712
  'title' => sprintf(
713
  '%s %s',
714
- // translators: Prefix for the active theme in a listing.
715
- ( $theme['active'] ? esc_html__( 'Active:', 'health-check' ) : '' ),
716
  $theme['name']
717
  ),
718
  'parent' => 'health-check-theme',
@@ -773,21 +776,6 @@ class Health_Check_Troubleshooting_MU {
773
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
774
  return;
775
  }
776
- ?>
777
- <script type="text/javascript">
778
- jQuery( document ).ready(function( $ ) {
779
- $( '.health-check-toggle-visibility' ).click(function() {
780
- var $elements = $( '.toggle-visibility', $( '#' + $ ( this ).data( 'element' ) ).closest( '.welcome-panel-column' ) );
781
-
782
- if ( $elements.is( ':visible' ) ) {
783
- $elements.attr( 'aria-hidden', 'false' ).toggle();
784
- } else {
785
- $elements.attr( 'aria-hidden', 'true' ).toggle();
786
- }
787
- });
788
- });
789
- </script>
790
- <?php
791
  }
792
 
793
  public function display_dashboard_widget() {
@@ -802,231 +790,237 @@ class Health_Check_Troubleshooting_MU {
802
  }
803
 
804
  $notices = get_option( 'health-check-dashboard-notices', array() );
 
 
 
 
 
805
  ?>
806
  <div class="wrap">
807
- <div id="health-check-dashboard-widget" class="welcome-panel">
808
- <div class="welcome-panel-content">
809
  <h2>
810
- <?php esc_html_e( 'Health Check &mdash; Troubleshooting Mode', 'health-check' ); ?>
811
- </h2>
812
-
813
- <p class="about-description">
814
- <?php _e( 'Your site is currently in Troubleshooting Mode. This has <strong>no effect on your site visitors</strong>, they will continue to view your site as usual, but for you it will look as if you had just installed WordPress for the first time.', 'health-check' ); ?>
815
- </p>
816
-
817
- <p class="about-description">
818
- <?php _e( 'Here you can enable individual plugins or themes, helping you to find out what might be causing strange behaviors on your site. Do note that <strong>any changes you make to settings will be kept</strong> when you disable Troubleshooting Mode.', 'health-check' ); ?>
819
- </p>
820
-
821
- <div class="notices">
822
- <h3>
823
- <span class="dashicons dashicons-flag"></span>
824
- <?php esc_html_e( 'Notices', 'health-check' ); ?>
825
- </h3>
826
-
827
- <?php if ( empty( $notices ) && 'plugins' !== $screen->id ) : ?>
828
- <div class="no-notices">
829
- <p>
830
- <?php esc_html_e( 'There are no notices to show.', 'health-check' ); ?>
831
- </p>
832
- </div>
833
- <?php endif; ?>
834
-
835
- <?php if ( 'plugins' === $screen->id ) : ?>
836
- <div class="notice notice-warning inline">
837
- <p>
838
- <?php esc_html_e( 'Plugin actions, such as activating and deactivating, are not available while in Troubleshooting Mode.', 'health-check' ); ?>
839
- </p>
840
- </div>
841
- <?php endif; ?>
842
-
843
- <?php
844
- foreach ( $notices as $notice ) {
845
- printf(
846
- '<div class="notice notice-%s inline"><p>%s</p></div>',
847
- esc_attr( $notice['severity'] ),
848
- esc_html( $notice['message'] )
849
- );
850
- }
851
- ?>
852
-
853
  <?php
854
- if ( ! empty( $notices ) ) {
855
  printf(
856
- '<a href="%s" class="dismiss-notices">%s</a>',
857
- esc_url( add_query_arg( array(
858
- 'health-check-dismiss-notices' => true,
859
- ) ) ),
860
- esc_html__( 'Dismiss notices', 'health-check' )
 
861
  );
862
- }
863
  ?>
864
- </div>
865
 
866
- <div class="welcome-panel-column-container">
867
- <div class="welcome-panel-column">
868
- <?php if ( 'plugins' !== $screen->id ) : ?>
869
- <h3>
870
- <span class="dashicons dashicons-admin-plugins"></span>
871
- <?php esc_html_e( 'Available Plugins', 'health-check' ); ?>
872
- </h3>
 
 
873
 
874
- <ul id="health-check-plugins">
875
- <?php
876
- $active_plugins = array();
877
- $inactive_plugins = array();
878
-
879
- foreach ( $this->active_plugins as $count => $single_plugin ) {
880
- $plugin_slug = explode( '/', $single_plugin );
881
- $plugin_slug = $plugin_slug[0];
882
-
883
- $plugin_is_visible = true;
884
- if ( $count >= 5 ) {
885
- $plugin_is_visible = false;
886
- }
887
-
888
- $plugin_data = get_plugin_data( trailingslashit( WP_PLUGIN_DIR ) . $single_plugin );
889
-
890
- $actions = array();
891
-
892
- if ( in_array( $plugin_slug, $this->allowed_plugins ) ) {
893
- $actions[] = sprintf(
894
- '<a href="%s" aria-label="%s">%s</a>',
895
- esc_url( add_query_arg( array(
896
- 'health-check-troubleshoot-disable-plugin' => $plugin_slug,
897
- ) ) ),
898
- esc_attr(
899
- sprintf(
900
- // translators: %s: Plugin name.
901
- __( 'Disable the plugin, %s, while troubleshooting.', 'health-check' ),
902
- $plugin_data['Name']
903
- )
904
- ),
905
- esc_html__( 'Disable', 'health-check' )
906
- );
907
- } else {
908
- $actions[] = sprintf(
909
- '<a href="%s" aria-label="%s">%s</a>',
910
- esc_url( add_query_arg( array(
911
- 'health-check-troubleshoot-enable-plugin' => $plugin_slug,
912
- ) ) ),
913
- esc_attr(
914
- sprintf(
915
- // translators: %s: Plugin name.
916
- __( 'Enable the plugin, %s, while troubleshooting.', 'health-check' ),
917
- $plugin_data['Name']
918
- )
919
- ),
920
- esc_html__( 'Enable', 'health-check' )
921
- );
922
- }
923
-
924
- printf(
925
- '<li class="%s" aria-hidden="%s">%s - %s</li>',
926
- ( ! $plugin_is_visible ? 'toggle-visibility' : '' ),
927
- ( ! $plugin_is_visible ? 'true' : 'false' ),
928
- esc_html( $plugin_data['Name'] ),
929
- implode( ' | ', $actions )
930
- );
931
- }
932
- ?>
933
- </ul>
934
-
935
- <?php if ( count( $this->active_plugins ) > 5 ) : ?>
936
- <p>
937
- <button type="button" class="button button-link health-check-toggle-visibility toggle-visibility visible" aria-hidden="false" data-element="health-check-plugins">
938
- <?php esc_html_e( 'Show all plugins', 'health-check' ); ?> <span class="icon"></span>
939
- </button>
940
-
941
- <button type="button" class="button button-link health-check-toggle-visibility toggle-visibility" aria-hidden="true" data-element="health-check-plugins">
942
- <?php esc_html_e( 'Show fewer plugins', 'health-check' ); ?> <span class="icon icon-up"></span>
943
- </button>
944
- </p>
945
- <?php endif; ?>
946
- <?php endif; ?>
947
- </div>
948
 
949
- <div class="welcome-panel-column">
950
- <?php if ( 'plugins' !== $screen->id ) : ?>
951
- <h3>
952
- <span class="dashicons dashicons-admin-appearance"></span>
953
- <?php esc_html_e( 'Available Themes', 'health-check' ); ?>
954
- </h3>
955
 
956
- <ul id="health-check-themes">
 
 
 
 
957
  <?php
958
- $themes = wp_prepare_themes_for_js();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
959
 
960
- foreach ( $themes as $count => $theme ) {
961
- $active = $theme['active'];
962
 
963
- $theme_is_visible = true;
964
- if ( $count >= 5 ) {
965
- $theme_is_visible = false;
966
- }
967
 
968
- $actions = sprintf(
 
969
  '<a href="%s" aria-label="%s">%s</a>',
970
  esc_url( add_query_arg( array(
971
- 'health-check-change-active-theme' => $theme['id'],
972
  ) ) ),
973
  esc_attr(
974
  sprintf(
975
- // translators: %s: Theme name.
976
- __( 'Switch the active theme to %s', 'health-check' ),
977
- $theme['name']
978
  )
979
  ),
980
- esc_html__( 'Switch to this theme', 'health-check' )
981
  );
982
-
983
- $plugin_label = sprintf(
984
- '%s %s',
985
- // translators: Prefix for the active theme in a listing.
986
- ( $theme['active'] ? esc_html__( 'Active:', 'health-check' ) : '' ),
987
- $theme['name']
 
 
 
 
 
 
 
 
988
  );
 
989
 
990
- if ( ! $theme['active'] ) {
991
- $plugin_label .= ' - ' . $actions;
992
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
993
 
994
- printf(
995
- '<li class="%s" aria-hidden="%s">%s</li>',
996
- ( $theme_is_visible ? '' : 'toggle-visibility' ),
997
- ( $theme_is_visible ? 'false' : 'true' ),
998
- $plugin_label
999
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1000
  }
1001
- ?>
1002
- </ul>
1003
 
1004
- <?php if ( count( $themes ) > 5 ) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1005
  <p>
1006
- <button type="button" class="button button-link health-check-toggle-visibility toggle-visibility visible" aria-hidden="false" data-element="health-check-themes">
1007
- <?php esc_html_e( 'Show all themes', 'health-check' ); ?> <span class="icon"></span>
1008
- </button>
 
1009
 
1010
- <button type="button" class="button button-link health-check-toggle-visibility toggle-visibility" aria-hidden="true" data-element="health-check-themes">
1011
- <?php esc_html_e( 'Show fewer themes', 'health-check' ); ?> <span class="icon icon-up"></span>
1012
- </button>
 
1013
  </p>
1014
- <?php endif; ?>
1015
  <?php endif; ?>
1016
- </div>
1017
 
1018
- <div class="welcome-panel-column <?php echo ( 'plugins' === $screen->id ? 'is-standalone-button' : '' ); ?>">
1019
  <?php
1020
- printf(
1021
- '<a href="%s" class="button button-primary button-hero disable-troubleshooting-mode">%s</a>',
1022
- esc_url( add_query_arg( array(
1023
- 'health-check-disable-troubleshooting' => true,
1024
- ) ) ),
1025
- esc_html__( 'Disable Troubleshooting Mode', 'health-check' )
1026
- );
1027
  ?>
1028
- </div>
1029
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
1030
  </div>
1031
  </div>
1032
  </div>
2
  /*
3
  Plugin Name: Health Check Troubleshooting Mode
4
  Description: Conditionally disabled themes or plugins on your site for a given session, used to rule out conflicts during troubleshooting.
5
+ Version: 1.6.0
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  // Set the MU plugin version.
13
+ define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.6.0' );
14
 
15
  class Health_Check_Troubleshooting_MU {
16
  private $disable_hash = null;
23
  private $self_fetching_theme = false;
24
 
25
  private $available_query_args = array(
26
+ 'wp-health-check-disable-plugins',
27
  'health-check-disable-plugins-hash',
28
  'health-check-disable-troubleshooting',
29
  'health-check-change-active-theme',
75
  add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) );
76
  add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) );
77
 
78
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
79
 
80
  /*
81
  * Plugin activations can be forced by other tools in things like themes, so let's
102
  }
103
 
104
  /**
105
+ * Enqueue styles and scripts used by the MU plugin if applicable.
106
  *
107
  * @return void
108
  */
109
+ public function enqueue_assets() {
110
  if ( ! $this->is_troubleshooting() || ! is_admin() ) {
111
  return;
112
  }
113
 
114
  wp_enqueue_style( 'health-check-troubleshooting-mode', plugins_url( '/health-check/assets/css/health-check-troubleshooting-mode.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION );
115
+ wp_enqueue_script( 'health-check', plugins_url( '/health-check/assets/javascript/health-check.js' ), array( 'jquery' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true );
116
  }
117
 
118
  /**
278
  */
279
  public function is_troubleshooting() {
280
  // Check if a session cookie to disable plugins has been set.
281
+ if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
282
+ $_GET['health-check-disable-plugin-hash'] = $_COOKIE['wp-health-check-disable-plugins'] . md5( $_SERVER['REMOTE_ADDR'] );
283
  }
284
 
285
  // If the disable hash isn't set, no need to interact with things.
463
  return;
464
  }
465
 
466
+ if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
467
  $this->disable_troubleshooting_mode();
468
  }
469
  }
470
 
471
  function disable_troubleshooting_mode() {
472
+ unset( $_COOKIE['wp-health-check-disable-plugins'] );
473
+ setcookie( 'wp-health-check-disable-plugins', null, 0, COOKIEPATH, COOKIE_DOMAIN );
474
  delete_option( 'health-check-allowed-plugins' );
475
  delete_option( 'health-check-default-theme' );
476
  delete_option( 'health-check-current-theme' );
623
  $wp_menu->add_menu( array(
624
  'id' => 'health-check',
625
  'title' => esc_html__( 'Troubleshooting Mode', 'health-check' ),
626
+ 'href' => admin_url( '/' ),
627
  ) );
628
 
629
  // Add a link to manage plugins if there are more than 20 set to be active.
639
  'id' => 'health-check-plugins',
640
  'title' => esc_html__( 'Plugins', 'health-check' ),
641
  'parent' => 'health-check',
642
+ 'href' => admin_url( 'plugins.php' ),
643
  ) );
644
 
645
  $wp_menu->add_group( array(
702
  'id' => 'health-check-theme',
703
  'title' => esc_html__( 'Themes', 'health-check' ),
704
  'parent' => 'health-check',
705
+ 'href' => admin_url( 'themes.php' ),
706
  ) );
707
 
708
  $themes = wp_prepare_themes_for_js();
715
  ),
716
  'title' => sprintf(
717
  '%s %s',
718
+ ( $theme['active'] ? esc_html_x( 'Active:', 'Prefix for the active theme in troubleshooting mode', 'health-check' ) : esc_html_x( 'Switch to', 'Prefix for inactive themes in troubleshooting mode', 'health-check' ) ),
 
719
  $theme['name']
720
  ),
721
  'parent' => 'health-check-theme',
776
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
777
  return;
778
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
779
  }
780
 
781
  public function display_dashboard_widget() {
790
  }
791
 
792
  $notices = get_option( 'health-check-dashboard-notices', array() );
793
+
794
+ $active_plugins = array();
795
+ $inactive_plugins = array();
796
+
797
+ $themes = wp_prepare_themes_for_js();
798
  ?>
799
  <div class="wrap">
800
+ <div id="health-check-dashboard-widget">
801
+ <div class="welcome-panel-content health-check-column">
802
  <h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
803
  <?php
 
804
  printf(
805
+ // translators: %s: The running status of Troubleshooting Mode.
806
+ esc_html__( 'Troubleshooting Mode - %s', 'health-check' ),
807
+ sprintf(
808
+ '<span class="green">%s</span>',
809
+ esc_html__( 'enabled', 'health-check' )
810
+ )
811
  );
 
812
  ?>
813
+ </h2>
814
 
815
+ <?php
816
+ printf(
817
+ '<a href="%s" class="button button-primary">%s</a>',
818
+ esc_url( add_query_arg( array(
819
+ 'health-check-disable-troubleshooting' => true,
820
+ ) ) ),
821
+ esc_html__( 'Disable Troubleshooting Mode', 'health-check' )
822
+ );
823
+ ?>
824
 
825
+ <div class="about-description">
826
+ <p>
827
+ <?php _e( 'Your site is currently in Troubleshooting Mode. This has <strong>no effect on your site visitors</strong>, they will continue to view your site as usual, but for you it will look as if you had just installed WordPress for the first time.', 'health-check' ); ?>
828
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
829
 
830
+ <p>
831
+ <?php _e( 'Here you can enable individual plugins or themes, helping you to find out what might be causing strange behaviors on your site. Do note that <strong>any changes you make to settings will be kept</strong> when you disable Troubleshooting Mode.', 'health-check' ); ?>
832
+ </p>
833
+ </div>
834
+ </div>
 
835
 
836
+ <div class="health-check-column">
837
+ <dl role="presentation" class="health-check-accordion">
838
+ <dt role="heading" aria-level="3">
839
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-plugins" id="health-check-accordion-heading-plugins" type="button">
840
+ <span class="title">
841
  <?php
842
+ printf(
843
+ // translators: %d: The amount of available plugins.
844
+ esc_html__( 'Available plugins (%d)', 'health-check' ),
845
+ esc_html( is_countable( $this->active_plugins ) ? count( $this->active_plugins ) : 0 )
846
+ );
847
+ ?>
848
+ </span>
849
+ <span class="icon"></span>
850
+ </button>
851
+ </dt>
852
+ <dd id="health-check-accordion-block-plugins" role="region" aria-labelledby="health-check-accordion-heading-plugins" class="health-check-accordion-panel" hidden="hidden">
853
+ <ul id="health-check-plugins" role="list">
854
+ <?php
855
+ foreach ( $this->active_plugins as $count => $single_plugin ) {
856
+ $plugin_slug = explode( '/', $single_plugin );
857
+ $plugin_slug = $plugin_slug[0];
858
+
859
+ $plugin_is_visible = true;
860
+ if ( $count >= 5 ) {
861
+ $plugin_is_visible = false;
862
+ }
863
 
864
+ $plugin_data = get_plugin_data( trailingslashit( WP_PLUGIN_DIR ) . $single_plugin );
 
865
 
866
+ $actions = array();
 
 
 
867
 
868
+ if ( in_array( $plugin_slug, $this->allowed_plugins ) ) {
869
+ $actions[] = sprintf(
870
  '<a href="%s" aria-label="%s">%s</a>',
871
  esc_url( add_query_arg( array(
872
+ 'health-check-troubleshoot-disable-plugin' => $plugin_slug,
873
  ) ) ),
874
  esc_attr(
875
  sprintf(
876
+ // translators: %s: Plugin name.
877
+ __( 'Disable the plugin, %s, while troubleshooting.', 'health-check' ),
878
+ $plugin_data['Name']
879
  )
880
  ),
881
+ esc_html__( 'Disable', 'health-check' )
882
  );
883
+ } else {
884
+ $actions[] = sprintf(
885
+ '<a href="%s" aria-label="%s">%s</a>',
886
+ esc_url( add_query_arg( array(
887
+ 'health-check-troubleshoot-enable-plugin' => $plugin_slug,
888
+ ) ) ),
889
+ esc_attr(
890
+ sprintf(
891
+ // translators: %s: Plugin name.
892
+ __( 'Enable the plugin, %s, while troubleshooting.', 'health-check' ),
893
+ $plugin_data['Name']
894
+ )
895
+ ),
896
+ esc_html__( 'Enable', 'health-check' )
897
  );
898
+ }
899
 
900
+ printf(
901
+ '<li class="%s">%s - %s</li>',
902
+ ( ! $plugin_is_visible ? 'toggle-visibility hidden' : '' ),
903
+ esc_html( $plugin_data['Name'] ),
904
+ implode( ' | ', $actions )
905
+ );
906
+ }
907
+ ?>
908
+ </ul>
909
+ </dd>
910
+
911
+ <dt role="heading" aria-level="3">
912
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-themes" id="health-check-accordion-heading-themes" type="button">
913
+ <span class="title">
914
+ <?php
915
+ printf(
916
+ // translators: %d: The amount of available themes.
917
+ esc_html__( 'Available themes (%d)', 'health-check' ),
918
+ esc_html( is_countable( $themes ) ? count( $themes ) : 0 )
919
+ );
920
+ ?>
921
+ </span>
922
+ <span class="icon"></span>
923
+ </button>
924
+ </dt>
925
+ <dd id="health-check-accordion-block-themes" role="region" aria-labelledby="health-check-accordion-heading-themes" class="health-check-accordion-panel" hidden="hidden">
926
+ <ul id="health-check-themes" role="list">
927
+ <?php
928
+ foreach ( $themes as $count => $theme ) {
929
+ $theme_is_visible = true;
930
+ if ( $count >= 5 ) {
931
+ $theme_is_visible = false;
932
+ }
933
 
934
+ $actions = sprintf(
935
+ '<a href="%s" aria-label="%s">%s</a>',
936
+ esc_url( add_query_arg( array(
937
+ 'health-check-change-active-theme' => $theme['id'],
938
+ ) ) ),
939
+ esc_attr(
940
+ sprintf(
941
+ // translators: %s: Theme name.
942
+ __( 'Switch the active theme to %s', 'health-check' ),
943
+ $theme['name']
944
+ )
945
+ ),
946
+ esc_html__( 'Switch to this theme', 'health-check' )
947
+ );
948
+
949
+ $plugin_label = sprintf(
950
+ '%s %s',
951
+ // translators: Prefix for the active theme in a listing.
952
+ ( $theme['active'] ? esc_html__( 'Active:', 'health-check' ) : '' ),
953
+ $theme['name']
954
+ );
955
+
956
+ if ( ! $theme['active'] ) {
957
+ $plugin_label .= ' - ' . $actions;
958
  }
 
 
959
 
960
+ printf(
961
+ '<li class="%s">%s</li>',
962
+ ( ! $theme_is_visible ? 'toggle-visibility hidden' : '' ),
963
+ $plugin_label
964
+ );
965
+ }
966
+ ?>
967
+ </ul>
968
+ </dd>
969
+
970
+ <dt role="heading" aria-level="3">
971
+ <button aria-expanded="true" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-notices" id="health-check-accordion-heading-notices" type="button">
972
+ <span class="title">
973
+ <?php
974
+ printf(
975
+ // translators: %d: The amount of notices that are visible.
976
+ esc_html__( 'Notices (%d)', 'health-check' ),
977
+ esc_html( is_countable( $notices ) ? count( $notices ) : 0 )
978
+ );
979
+ ?>
980
+ </span>
981
+ <span class="icon"></span>
982
+ </button>
983
+ </dt>
984
+ <dd id="health-check-accordion-block-notices" role="region" aria-labelledby="health-check-accordion-heading-notices" class="health-check-accordion-panel">
985
+ <?php if ( empty( $notices ) && 'plugins' !== $screen->id ) : ?>
986
+ <div class="no-notices">
987
  <p>
988
+ <?php esc_html_e( 'There are no notices to show.', 'health-check' ); ?>
989
+ </p>
990
+ </div>
991
+ <?php endif; ?>
992
 
993
+ <?php if ( 'plugins' === $screen->id ) : ?>
994
+ <div class="notice notice-warning inline">
995
+ <p>
996
+ <?php esc_html_e( 'Plugin actions, such as activating and deactivating, are not available while in Troubleshooting Mode.', 'health-check' ); ?>
997
  </p>
998
+ </div>
999
  <?php endif; ?>
 
1000
 
 
1001
  <?php
1002
+ foreach ( $notices as $notice ) {
1003
+ printf(
1004
+ '<div class="notice notice-%s inline"><p>%s</p></div>',
1005
+ esc_attr( $notice['severity'] ),
1006
+ esc_html( $notice['message'] )
1007
+ );
1008
+ }
1009
  ?>
1010
+
1011
+ <?php
1012
+ if ( ! empty( $notices ) ) {
1013
+ printf(
1014
+ '<div class="dismiss-notices"><a href="%s" class="">%s</a></div>',
1015
+ esc_url( add_query_arg( array(
1016
+ 'health-check-dismiss-notices' => true,
1017
+ ) ) ),
1018
+ esc_html__( 'Dismiss notices', 'health-check' )
1019
+ );
1020
+ }
1021
+ ?>
1022
+ </dd>
1023
+ </dl>
1024
  </div>
1025
  </div>
1026
  </div>
changelog.txt CHANGED
@@ -1,120 +1,158 @@
1
- = v 1.1.2 =
2
- * Fixed child themes not displaying properly in Troubleshooting Mode.
3
- * Improved styling for the backup warning, shown when activating the plugin, so it doesn't block mobile users.
4
- * Added explanations to the plugins screen if you enter Troubleshooting Mode there, so users know what is going on.
5
- * Fixed admin menu overflowing if too many plugins exist.
6
-
7
- = v 1.1.1 =
8
- * Fixed a fatal error that would occur if a user had an older version of Troubleshooting Mode on their system.
9
-
10
- = v 1.1.0 =
11
- * Check for theme, plugin and WordPress updates when visiting the debug tab.
12
- * Improved wording on some failure situations.
13
- * Made the Debug Information tab a bit easier to read with fixed table styles.
14
- * Redesigned tools page, with added accordion to avoid information overload, and different features mixing together.
15
- * Mail test tool now allows you to include an optional customized message.
16
- * Users can now change between any installed theme while in troubleshooting mode.
17
- * Renamed the Must-Use plugin, making it align with what features present in the file.
18
- * Improved the plugin cleanup process, when the plugin is deleted.
19
- * Show full plugin names, and not slugs, in the troubleshooting admin bar menu.
20
- * Check if the .htaccess file contains any rules not added by WordPress core in the debug section.
21
- * Allow the disabling of Troubleshooting Mode from the same page as you previously enabled it from.
22
- * Removed cURL checks from the automated test page, this was more confusion than help.
23
- * Add installation size to the debug information.
24
-
25
- = v 1.0.1 =
26
- * Fixed email tester having the wrong class reference, preventing it from running.
27
- * Add some missing text domains preventing full translations.
28
-
29
- = v 1.0.0 =
30
- * Added minimum PHP version checks with documentation links.
31
- * Added testing with a default theme to the loopback checker.
32
- * Added cURL version checker to the health check tab.
33
- * Added simple e-mail tester.
34
- * Added core file integrity checker.
35
- * Added capability checks, to avoid installing things that may modify the database while troubleshooting.
36
- * Added a prompt to install a default theme if none exist.
37
- * Added a warning encouraging users to maintain up to date backups when troubleshooting.
38
- * Fixed MU plugin not always updating (if available) when a user tries to troubleshoot.
39
- * Fixed fatal error when trying to troubleshoot "too early".
40
- * Updated troubleshooting drop down, it no longer shows theme switching if no default theme exists.
41
- * Removed the checkbox requirement from the Troubleshooting tab, it wasn't needed any more, and added pointless complexity now.
42
-
43
- = v 0.9.0 =
44
- * Various string changes, typo fixes and translation enhancements.
45
- * Added conditional hiding of the plugins list from the admin bar, if there's too many plugins it becomes a bad experience. (Hidden if there are more than 20 active plugins)
46
- * Added ability to enable/disable plugins in Troubleshooting Mode from the plugins list.
47
- * Added filter to remove actions from the plugin list in Troubleshooting Mode.
48
- * Fixed notices on the plugin screen when plugin data may be inconsistent.
49
- * Fixed jumping directly to troubleshooting mode for single file plugins placed directly in the plugin directory root.
50
- * Fixed issue where troubleshooting a plugin directly made it impossible to disable it while in Troubleshooting Mode.
51
- * Fixed so that the original language is returned when translating the debug data for copying.
52
- * Fixed issue where the Debug screen would turn to half-English when using a non-English language.
53
- * Fixed an issue where plugins could become truly disabled on a site when in Troubleshooting Mode.
54
- * Fixed so that enabled/disabled plugins don't carry over between troubleshooting sessions.
55
-
56
- = v 0.8.0 =
57
- * Updated recommended PHP version to mirror WordPress.org.
58
- * Updated texts for troubleshooting mode.
59
- * Re-labeled database terms to be more user friendly.
60
- * Added media information to the debug tab.
61
- * Added individual `Troubleshoot` links for the list of active plugins.
62
- * Added automatic copy to clipboard with supported browsers in the debug tab.
63
-
64
- = v 0.7.0 =
65
- * Troubleshooting mode now also switches to a default theme.
66
- * Introduced a method for toggling default or active theme use when in troubleshooting mode.
67
- * Introduced a method for enabling/disabling plugins while in troubleshooting mode.
68
- * Introduced a method for disabling troubleshooting mode without needing to log out and back in again.
69
-
70
- = v 0.6.0 =
71
- * Improved loopback tests
72
- * Check if loopbacks can be completed without plugins activated
73
- * Test individual plugins to identify loopback blockers
74
- * Add troubleshooting mode, test your website without any plugins for your session without disabling functionality for visitors.
75
-
76
- = v 0.5.1 =
77
- * Introduced loopback check to the health checker status.
78
-
79
- = v 0.5.0 =
80
- * Added clarity to many text strings.
81
- * Avoid listing MU directories if it's not being used.
82
- * Add a Table of Contents heading and make navigating the debug page from it smoother.
83
- * Only enqueue our CSS and JavaScript if we are on the health check pages.
84
- * Add some missing version numbers nor being included in text strings.
85
- * Avoid fatal errors if accessing files directly, caused by translation functions being used when they don't exist.
86
- * Avoid "empty" strings when author or version is missing from plugins or themes.
87
- * Make the health checker test background updates.
88
- * Make the health checker look for missed scheduled events.
89
- * If using a localized version of WordPress, also display the copy and paste field in English if using an international support resource.
90
- * Indicate if 64bit values are supported by PHP in the debug section.
91
- * Improved MariaDB version detection/comparison.
92
-
93
- = v 0.4.1 =
94
- * Better SQL version detection to account for MariaDB versions
95
- * Added translation support
96
- * Removed unintentional indentations in the debug copying field
97
-
98
- = v 0.4 =
99
- * Added debug section
100
- * Added PHP info section
101
- * Cleaned up the health check
102
- * Added WordPress.org connectivity check
103
- * Added HTTPS check
104
-
105
- = v 0.3.1 =
106
- * Fixed a few typos
107
-
108
- = v 0.3 =
109
- * Added recommended PHP and MySQL versions
110
- * Check for utf8mb4 support
111
- * Fixed a bunch of PHP warnings
112
-
113
- = v 0.2.1 =
114
- * Fixed version comparision bug - When the server had the exact required versions we reported it as out of date.
115
-
116
- = v 0.2 =
117
- * Updated with actual PHP and MySQL version requirements for WordPress 3.2
118
-
119
- = v 0.1 =
120
- * Initial release with checks for the PHP and MySQL versions we will likely target for WordPress 3.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ = v1.2.5 =
2
+ * Fix: Ensure the REST API status test runs as intended.
3
+ * Fix: Remove warning on plugin screens when premium plugins are used.
4
+ * Fix: Backup reminder would not remain dismissed in all scenarios after the recent update.
5
+
6
+ = v1.2.4 =
7
+ * Security: Prevent arbitrary file viewing through the integrity file actions. Independently reported by Julien Legras of [Synacktiv](https://synacktiv.com) and siliconforks.
8
+ * Security: Site status was available to any user with a subscriber role or higher on a site. Reported by Julien Legras of [Synacktiv](https://synacktiv.com).
9
+ * Security: Hardened the troubleshooting mode session so it is locked to the users location when active.
10
+ * New enhancement: Check that various PHP extensions exist, as recommended by the WordPress Hosting Community.
11
+ * New enhancement: Check if update APIs are being manipulated by plugins or themes.
12
+ * Fix: Copying debug information had the wrong indentation for easier readability.
13
+ * Fix: Toggling plugins and themes from the troubleshooting widget on in the dashboard now lets you expand/collapse them as intended.
14
+ * Fix: When debugging was enabled in WordPress, disabling a plugin in troubleshooting mode would cause a WSOD if the disabled plugin caused a fatal error.
15
+
16
+ = v1.2.3 =
17
+ * Added REST API availability test to the Site Status
18
+
19
+ = v 1.2.2 =
20
+ * Added Twenty Nineteen as a recognized core theme.
21
+
22
+ = v 1.2.1 =
23
+ * Make sure only those with access to the plugin see the backup encouragement notice.
24
+ * Make sure the `is_troubleshooting()` checks are available to the Site Status tester when the MU plugin may not have updated yet.
25
+ * Avoid a warning of an undefined variable if you have the latest WordPress version installed.
26
+
27
+ = v 1.2.0 =
28
+ * Changed plugin name, it now better describes the plugins two primary purposes.
29
+ * Changed the `Health Check` tab, it's now named `Site Status`, as we used the old name too many places and it was confusing.
30
+ * Site status tests now run asynchronously, making the page load much faster.
31
+ * The HTTPS tests now also check your Site URL settings to make sure they are following recommended best practices.
32
+ * Fixed a warning preventing plugin names from displaying on the front-end in some cases.
33
+ * Fixed an issue where you might get a 500 error if you tried using Troubleshooting Mode while using a child theme.
34
+ * Automatically disable/enable a plugin or theme in Troubleshooting Mode if they are detected to cause errors.
35
+ * Introduce a new dashboard widget during Troubleshooting Mode (and a simplified version on the plugins screen) to better explain what is going on, and make available actions more discoverable than the admin menu is.
36
+ * Some text improvements throughout the plugin.
37
+ * When loopback tests fail, we previously tested all plugins at once, for sites that have many plugins this may fail as the request times out. We now test one plugin at a time to avoid this, while also showing more information at the tests are running to the end user.
38
+
39
+ = v 1.1.2 =
40
+ * Fixed child themes not displaying properly in Troubleshooting Mode.
41
+ * Improved styling for the backup warning, shown when activating the plugin, so it doesn't block mobile users.
42
+ * Added explanations to the plugins screen if you enter Troubleshooting Mode there, so users know what is going on.
43
+ * Fixed admin menu overflowing if too many plugins exist.
44
+
45
+ = v 1.1.1 =
46
+ * Fixed a fatal error that would occur if a user had an older version of Troubleshooting Mode on their system.
47
+
48
+ = v 1.1.0 =
49
+ * Check for theme, plugin and WordPress updates when visiting the debug tab.
50
+ * Improved wording on some failure situations.
51
+ * Made the Debug Information tab a bit easier to read with fixed table styles.
52
+ * Redesigned tools page, with added accordion to avoid information overload, and different features mixing together.
53
+ * Mail test tool now allows you to include an optional customized message.
54
+ * Users can now change between any installed theme while in troubleshooting mode.
55
+ * Renamed the Must-Use plugin, making it align with what features present in the file.
56
+ * Improved the plugin cleanup process, when the plugin is deleted.
57
+ * Show full plugin names, and not slugs, in the troubleshooting admin bar menu.
58
+ * Check if the .htaccess file contains any rules not added by WordPress core in the debug section.
59
+ * Allow the disabling of Troubleshooting Mode from the same page as you previously enabled it from.
60
+ * Removed cURL checks from the automated test page, this was more confusion than help.
61
+ * Add installation size to the debug information.
62
+
63
+ = v 1.0.1 =
64
+ * Fixed email tester having the wrong class reference, preventing it from running.
65
+ * Add some missing text domains preventing full translations.
66
+
67
+ = v 1.0.0 =
68
+ * Added minimum PHP version checks with documentation links.
69
+ * Added testing with a default theme to the loopback checker.
70
+ * Added cURL version checker to the health check tab.
71
+ * Added simple e-mail tester.
72
+ * Added core file integrity checker.
73
+ * Added capability checks, to avoid installing things that may modify the database while troubleshooting.
74
+ * Added a prompt to install a default theme if none exist.
75
+ * Added a warning encouraging users to maintain up to date backups when troubleshooting.
76
+ * Fixed MU plugin not always updating (if available) when a user tries to troubleshoot.
77
+ * Fixed fatal error when trying to troubleshoot "too early".
78
+ * Updated troubleshooting drop down, it no longer shows theme switching if no default theme exists.
79
+ * Removed the checkbox requirement from the Troubleshooting tab, it wasn't needed any more, and added pointless complexity now.
80
+
81
+ = v 0.9.0 =
82
+ * Various string changes, typo fixes and translation enhancements.
83
+ * Added conditional hiding of the plugins list from the admin bar, if there's too many plugins it becomes a bad experience. (Hidden if there are more than 20 active plugins)
84
+ * Added ability to enable/disable plugins in Troubleshooting Mode from the plugins list.
85
+ * Added filter to remove actions from the plugin list in Troubleshooting Mode.
86
+ * Fixed notices on the plugin screen when plugin data may be inconsistent.
87
+ * Fixed jumping directly to troubleshooting mode for single file plugins placed directly in the plugin directory root.
88
+ * Fixed issue where troubleshooting a plugin directly made it impossible to disable it while in Troubleshooting Mode.
89
+ * Fixed so that the original language is returned when translating the debug data for copying.
90
+ * Fixed issue where the Debug screen would turn to half-English when using a non-English language.
91
+ * Fixed an issue where plugins could become truly disabled on a site when in Troubleshooting Mode.
92
+ * Fixed so that enabled/disabled plugins don't carry over between troubleshooting sessions.
93
+
94
+ = v 0.8.0 =
95
+ * Updated recommended PHP version to mirror WordPress.org.
96
+ * Updated texts for troubleshooting mode.
97
+ * Re-labeled database terms to be more user friendly.
98
+ * Added media information to the debug tab.
99
+ * Added individual `Troubleshoot` links for the list of active plugins.
100
+ * Added automatic copy to clipboard with supported browsers in the debug tab.
101
+
102
+ = v 0.7.0 =
103
+ * Troubleshooting mode now also switches to a default theme.
104
+ * Introduced a method for toggling default or active theme use when in troubleshooting mode.
105
+ * Introduced a method for enabling/disabling plugins while in troubleshooting mode.
106
+ * Introduced a method for disabling troubleshooting mode without needing to log out and back in again.
107
+
108
+ = v 0.6.0 =
109
+ * Improved loopback tests
110
+ * Check if loopbacks can be completed without plugins activated
111
+ * Test individual plugins to identify loopback blockers
112
+ * Add troubleshooting mode, test your website without any plugins for your session without disabling functionality for visitors.
113
+
114
+ = v 0.5.1 =
115
+ * Introduced loopback check to the health checker status.
116
+
117
+ = v 0.5.0 =
118
+ * Added clarity to many text strings.
119
+ * Avoid listing MU directories if it's not being used.
120
+ * Add a Table of Contents heading and make navigating the debug page from it smoother.
121
+ * Only enqueue our CSS and JavaScript if we are on the health check pages.
122
+ * Add some missing version numbers nor being included in text strings.
123
+ * Avoid fatal errors if accessing files directly, caused by translation functions being used when they don't exist.
124
+ * Avoid "empty" strings when author or version is missing from plugins or themes.
125
+ * Make the health checker test background updates.
126
+ * Make the health checker look for missed scheduled events.
127
+ * If using a localized version of WordPress, also display the copy and paste field in English if using an international support resource.
128
+ * Indicate if 64bit values are supported by PHP in the debug section.
129
+ * Improved MariaDB version detection/comparison.
130
+
131
+ = v 0.4.1 =
132
+ * Better SQL version detection to account for MariaDB versions
133
+ * Added translation support
134
+ * Removed unintentional indentations in the debug copying field
135
+
136
+ = v 0.4 =
137
+ * Added debug section
138
+ * Added PHP info section
139
+ * Cleaned up the health check
140
+ * Added WordPress.org connectivity check
141
+ * Added HTTPS check
142
+
143
+ = v 0.3.1 =
144
+ * Fixed a few typos
145
+
146
+ = v 0.3 =
147
+ * Added recommended PHP and MySQL versions
148
+ * Check for utf8mb4 support
149
+ * Fixed a bunch of PHP warnings
150
+
151
+ = v 0.2.1 =
152
+ * Fixed version comparision bug - When the server had the exact required versions we reported it as out of date.
153
+
154
+ = v 0.2 =
155
+ * Updated with actual PHP and MySQL version requirements for WordPress 3.2
156
+
157
+ = v 0.1 =
158
+ * Initial release with checks for the PHP and MySQL versions we will likely target for WordPress 3.2
health-check.php CHANGED
@@ -9,12 +9,12 @@
9
  * Plugin URI: https://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
- * Version: 1.2.6
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
16
 
17
- // Check that the file is nto accessed directly.
18
  if ( ! defined( 'ABSPATH' ) ) {
19
  die( 'We\'re sorry, but you can not directly access this file.' );
20
  }
@@ -35,7 +35,7 @@ define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' );
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
- define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.2.6' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
@@ -63,3 +63,7 @@ require_once( dirname( __FILE__ ) . '/includes/class-health-check-updates.php' )
63
 
64
  // Initialize our plugin.
65
  new Health_Check();
 
 
 
 
9
  * Plugin URI: https://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
+ * Version: 1.3.0
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
16
 
17
+ // Check that the file is not accessed directly.
18
  if ( ! defined( 'ABSPATH' ) ) {
19
  die( 'We\'re sorry, but you can not directly access this file.' );
20
  }
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
+ define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.3.0' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
63
 
64
  // Initialize our plugin.
65
  new Health_Check();
66
+
67
+ // Setup up scheduled events.
68
+ register_activation_hook( __FILE__, array( 'Health_Check', 'plugin_activation' ) );
69
+ register_deactivation_hook( __FILE__, array( 'Health_Check', 'plugin_deactivation' ) );
includes/class-health-check-auto-updates.php CHANGED
@@ -5,39 +5,23 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_Auto_Updates
10
  */
11
  class Health_Check_Auto_Updates {
12
  /**
13
- * Health_Check_Auto_Updates constructor.
14
- *
15
- * @uses Health_Check::init()
16
- *
17
- * @return void
18
  */
19
  public function __construct() {
20
- $this->init();
21
- }
22
-
23
- /**
24
- * Initiate the plugin class.
25
- *
26
- * @return void
27
- */
28
- public function init() {
29
  include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
30
  }
31
 
32
- /**
33
- * Run tests to determine if auto-updates can run.
34
- *
35
- * @uses get_class_methods()
36
- * @uses substr()
37
- * @uses call_user_func()
38
- *
39
- * @return array
40
- */
41
  public function run_tests() {
42
  $tests = array();
43
 
@@ -64,68 +48,36 @@ class Health_Check_Auto_Updates {
64
  return $tests;
65
  }
66
 
67
- /**
68
- * Test if file modifications are possible.
69
- *
70
- * @uses defined()
71
- * @uses sprintf()
72
- * @uses esc_html__()
73
- *
74
- * @return array
75
- */
76
- function test_constant_FILE_MODS() {
77
- if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
78
- return array(
79
- 'desc' => sprintf(
80
- /* translators: %s: Name of the constant used. */
81
- esc_html__( 'The %s constant is defined and enabled.', 'health-check' ),
82
- '<code>DISALLOW_FILE_MODS</code>'
83
- ),
84
- 'severity' => 'fail',
85
- );
86
- }
87
  }
88
 
89
- /**
90
- * Check if automatic updates are disabled with a constant.
91
- *
92
- * @uses defined()
93
- * @uses sprintf()
94
- * @uses esc_html__()
95
- *
96
- * @return array
97
- */
98
- function test_constant_AUTOMATIC_UPDATER_DISABLED() {
99
- if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED ) {
100
- return array(
101
- 'desc' => sprintf(
102
- /* translators: %s: Name of the constant used. */
103
- esc_html__( 'The %s constant is defined and enabled.', 'health-check' ),
104
- '<code>AUTOMATIC_UPDATER_DISABLED</code>'
105
- ),
106
- 'severity' => 'fail',
107
- );
108
- }
109
  }
110
 
111
  /**
112
- * Check if automatic core updates are disabled with a constant.
113
  *
114
- * @uses defined()
115
- * @uses sprintf()
116
- * @uses esc_html__()
117
  *
118
- * @return array
 
 
119
  */
120
- function test_constant_WP_AUTO_UPDATE_CORE() {
121
- if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
122
  return array(
123
- 'desc' => sprintf(
124
  /* translators: %s: Name of the constant used. */
125
- esc_html__( 'The %s constant is defined and enabled.', 'health-check' ),
126
- '<code>WP_AUTO_UPDATE_CORE</code>'
127
  ),
128
- 'severity' => 'fail',
129
  );
130
  }
131
  }
@@ -133,13 +85,15 @@ class Health_Check_Auto_Updates {
133
  /**
134
  * Check if updates are intercepted by a filter.
135
  *
136
- * @uses has_filter()
137
- * @uses sprintf()
138
- * @uses esc_html__()
139
  *
140
- * @return array
141
  */
142
- function test_wp_version_check_attached() {
 
 
 
 
143
  $cookies = wp_unslash( $_COOKIE );
144
  $timeout = 10;
145
  $headers = array(
@@ -151,22 +105,36 @@ class Health_Check_Auto_Updates {
151
  $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
152
  }
153
 
154
- $url = add_query_arg( array(
155
- 'health-check-test-wp_version_check' => true,
156
- ), admin_url() );
 
 
 
157
 
158
  $test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
159
 
 
 
 
 
 
 
 
 
 
 
 
160
  $response = wp_remote_retrieve_body( $test );
161
 
162
  if ( 'yes' !== $response ) {
163
  return array(
164
- 'desc' => sprintf(
165
  /* translators: %s: Name of the filter used. */
166
- esc_html__( 'A plugin has prevented updates by disabling %s.', 'health-check' ),
167
  '<code>wp_version_check()</code>'
168
  ),
169
- 'severity' => 'fail',
170
  );
171
  }
172
  }
@@ -174,21 +142,19 @@ class Health_Check_Auto_Updates {
174
  /**
175
  * Check if automatic updates are disabled by a filter.
176
  *
177
- * @uses apply_filters()
178
- * @uses sprintf()
179
- * @uses esc_html__()
180
  *
181
- * @return array
182
  */
183
- function test_filters_automatic_updater_disabled() {
184
  if ( apply_filters( 'automatic_updater_disabled', false ) ) {
185
  return array(
186
- 'desc' => sprintf(
187
  /* translators: %s: Name of the filter used. */
188
- esc_html__( 'The %s filter is enabled.', 'health-check' ),
189
  '<code>automatic_updater_disabled</code>'
190
  ),
191
- 'severity' => 'fail',
192
  );
193
  }
194
  }
@@ -196,11 +162,9 @@ class Health_Check_Auto_Updates {
196
  /**
197
  * Check if automatic updates have tried to run, but failed, previously.
198
  *
199
- * @uses get_site_option()
200
- * @uses esc_html__()
201
- * @uses sprintf()
202
  *
203
- * @return array|bool
204
  */
205
  function test_if_failed_update() {
206
  $failed = get_site_option( 'auto_core_update_failed' );
@@ -210,53 +174,45 @@ class Health_Check_Auto_Updates {
210
  }
211
 
212
  if ( ! empty( $failed['critical'] ) ) {
213
- $desc = esc_html__( 'A previous automatic background update ended with a critical failure, so updates are now disabled.', 'health-check' );
214
- $desc .= ' ' . esc_html__( 'You would have received an email because of this.', 'health-check' );
215
- $desc .= ' ' . esc_html__( "When you've been able to update using the \"Update Now\" button on Dashboard > Updates, we'll clear this error for future update attempts.", 'health-check' );
216
- $desc .= ' ' . sprintf(
217
  /* translators: %s: Code of error shown. */
218
- esc_html__( 'The error code was %s.', 'health-check' ),
219
  '<code>' . $failed['error_code'] . '</code>'
220
  );
221
  return array(
222
- 'desc' => $desc,
223
- 'severity' => 'warning',
224
  );
225
  }
226
 
227
- $desc = esc_html__( 'A previous automatic background update could not occur.', 'health-check' );
228
  if ( empty( $failed['retry'] ) ) {
229
- $desc .= ' ' . esc_html__( 'You would have received an email because of this.', 'health-check' );
230
  }
231
 
232
- $desc .= ' ' . esc_html__( "We'll try again with the next release.", 'health-check' );
233
- $desc .= ' ' . sprintf(
234
  /* translators: %s: Code of error shown. */
235
- esc_html__( 'The error code was %s.', 'health-check' ),
236
  '<code>' . $failed['error_code'] . '</code>'
237
  );
238
  return array(
239
- 'desc' => $desc,
240
- 'severity' => 'warning',
241
  );
242
  }
243
 
244
  /**
245
  * Check if WordPress is controlled by a VCS (Git, Subversion etc).
246
  *
247
- * @uses dirname()
248
- * @uses array_unique()
249
- * @uses is_dir()
250
- * @uses rtrim()
251
- * @uses apply_filters()
252
- * @uses sprintf()
253
- * @uses esc_html__()
254
- *
255
- * @param string $context The path to check from.
256
  *
257
- * @return array
258
  */
259
- function _test_is_vcs_checkout( $context ) {
260
  $context_dirs = array( ABSPATH );
261
  $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
262
  $check_dirs = array();
@@ -287,103 +243,76 @@ class Health_Check_Auto_Updates {
287
  }
288
  }
289
 
290
- if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, $context ) ) {
291
  return array(
292
- 'desc' => sprintf(
293
- // translators: %1$s: Folder name. %2$s: Version control directory. %3$s: Filter name.
294
- esc_html__( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.', 'health-check' ),
295
  '<code>' . $check_dir . '</code>',
296
  "<code>$vcs_dir</code>",
297
  '<code>automatic_updates_is_vcs_checkout</code>'
298
  ),
299
- 'severity' => 'info',
300
  );
301
  }
302
 
303
  if ( $checkout ) {
304
  return array(
305
- 'desc' => sprintf(
306
- // translators: %1$s: Folder name. %2$s: Version control directory.
307
- esc_html__( 'The folder %1$s was detected as being under version control (%2$s).', 'health-check' ),
308
  '<code>' . $check_dir . '</code>',
309
  "<code>$vcs_dir</code>"
310
  ),
311
- 'severity' => 'fail',
312
  );
313
  }
314
 
315
  return array(
316
- 'desc' => esc_html__( 'No version control systems were detected.', 'health-check' ),
317
- 'severity' => 'pass',
318
  );
319
  }
320
 
321
- /**
322
- * Check if the absolute path is under Version Control.
323
- *
324
- * @uses Health_Check_Auto_Updates::_test_is_vcs_checkout()
325
- *
326
- * @return array
327
- */
328
- function test_vcs_ABSPATH() {
329
- $result = $this->_test_is_vcs_checkout( ABSPATH );
330
- return $result;
331
- }
332
-
333
  /**
334
  * Check if we can access files without providing credentials.
335
  *
336
- * @uses Automatic_Upgrader_Skin
337
- * @uses Automatic_Upgrader_Skin::request_filesystem_credentials()
338
- * @uses esc_html__()
339
  *
340
- * @return array
341
  */
342
  function test_check_wp_filesystem_method() {
343
  $skin = new Automatic_Upgrader_Skin;
344
  $success = $skin->request_filesystem_credentials( false, ABSPATH );
345
 
346
  if ( ! $success ) {
347
- $desc = esc_html__( 'Your installation of WordPress prompts for FTP credentials to perform updates.', 'health-check' );
348
- $desc .= ' ' . esc_html__( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)', 'health-check' );
349
 
350
  return array(
351
- 'desc' => $desc,
352
- 'severity' => 'fail',
353
  );
354
  }
355
 
356
  return array(
357
- 'desc' => esc_html__( "Your installation of WordPress doesn't require FTP credentials to perform updates.", 'health-check' ),
358
- 'severity' => 'pass',
359
  );
360
  }
361
 
362
  /**
363
- * Check if core files are writeable by the web user/group.
364
  *
365
- * @global $wp_filesystem
366
  *
367
- * @uses Automatic_Upgrader_Skin
368
- * @uses Automatic_Upgrader_Skin::request_filesystem_credentials()
369
- * @uses WP_Filesystem
370
- * @uses WP_Filesystem::method
371
- * @uses get_core_checksums()
372
- * @uses strpos()
373
- * @uses sprintf()
374
- * @uses esc_html__()
375
- * @uses array_keys()
376
- * @uses substr()
377
- * @uses file_exists()
378
- * @uses is_writable()
379
- * @uses count()
380
- * @uses array_slice()
381
- * @uses implode()
382
  *
383
- * @return array|bool
384
  */
385
  function test_all_files_writable() {
386
  global $wp_filesystem;
 
387
  include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
388
 
389
  $skin = new Automatic_Upgrader_Skin;
@@ -412,15 +341,15 @@ class Health_Check_Auto_Updates {
412
  }
413
 
414
  if ( ! $checksums ) {
415
- $desc = sprintf(
416
  // translators: %s: WordPress version
417
- esc_html__( "Couldn't retrieve a list of the checksums for WordPress %s.", 'health-check' ),
418
  $wp_version
419
  );
420
- $desc .= ' ' . esc_html__( 'This could mean that connections are failing to WordPress.org.', 'health-check' );
421
  return array(
422
- 'desc' => $desc,
423
- 'severity' => 'warning',
424
  );
425
  }
426
 
@@ -429,10 +358,10 @@ class Health_Check_Auto_Updates {
429
  if ( 'wp-content' == substr( $file, 0, 10 ) ) {
430
  continue;
431
  }
432
- if ( ! file_exists( ABSPATH . '/' . $file ) ) {
433
  continue;
434
  }
435
- if ( ! is_writable( ABSPATH . '/' . $file ) ) {
436
  $unwritable_files[] = $file;
437
  }
438
  }
@@ -443,13 +372,13 @@ class Health_Check_Auto_Updates {
443
  $unwritable_files[] = '...';
444
  }
445
  return array(
446
- 'desc' => esc_html__( 'Some files are not writable by WordPress:', 'health-check' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>',
447
- 'severity' => 'fail',
448
  );
449
  } else {
450
  return array(
451
- 'desc' => esc_html__( 'All of your WordPress files are writable.', 'health-check' ),
452
- 'severity' => 'pass',
453
  );
454
  }
455
  }
@@ -457,13 +386,9 @@ class Health_Check_Auto_Updates {
457
  /**
458
  * Check if the install is using a development branch and can use nightly packages.
459
  *
460
- * @uses strpos()
461
- * @uses defined()
462
- * @uses sprintf()
463
- * @uses esc_html__()
464
- * @uses apply_filters()
465
  *
466
- * @return array|bool
467
  */
468
  function test_accepts_dev_updates() {
469
  include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
@@ -474,23 +399,23 @@ class Health_Check_Auto_Updates {
474
 
475
  if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) {
476
  return array(
477
- 'desc' => sprintf(
478
  /* translators: %s: Name of the constant used. */
479
- esc_html__( 'WordPress development updates are blocked by the %s constant.', 'health-check' ),
480
  '<code>WP_AUTO_UPDATE_CORE</code>'
481
  ),
482
- 'severity' => 'fail',
483
  );
484
  }
485
 
486
  if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) {
487
  return array(
488
- 'desc' => sprintf(
489
  /* translators: %s: Name of the filter used. */
490
- esc_html__( 'WordPress development updates are blocked by the %s filter.', 'health-check' ),
491
  '<code>allow_dev_auto_core_updates</code>'
492
  ),
493
- 'severity' => 'fail',
494
  );
495
  }
496
  }
@@ -498,33 +423,30 @@ class Health_Check_Auto_Updates {
498
  /**
499
  * Check if the site supports automatic minor updates.
500
  *
501
- * @uses defined()
502
- * @uses sprintf()
503
- * @uses esc_html__()
504
- * @uses apply_filters()
505
  *
506
- * @return array
507
  */
508
  function test_accepts_minor_updates() {
509
  if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
510
  return array(
511
- 'desc' => sprintf(
512
  /* translators: %s: Name of the constant used. */
513
- esc_html__( 'WordPress security and maintenance releases are blocked by %s.', 'health-check' ),
514
  "<code>define( 'WP_AUTO_UPDATE_CORE', false );</code>"
515
  ),
516
- 'severity' => 'fail',
517
  );
518
  }
519
 
520
  if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) {
521
  return array(
522
- 'desc' => sprintf(
523
  /* translators: %s: Name of the filter used. */
524
- esc_html__( 'WordPress security and maintenance releases are blocked by the %s filter.', 'health-check' ),
525
  '<code>allow_minor_auto_core_updates</code>'
526
  ),
527
- 'severity' => 'fail',
528
  );
529
  }
530
  }
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_Auto_Updates
15
  */
16
  class Health_Check_Auto_Updates {
17
  /**
18
+ * WP_Site_Health_Auto_Updates constructor.
19
+ * @since 5.2.0
 
 
 
20
  */
21
  public function __construct() {
 
 
 
 
 
 
 
 
 
22
  include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  public function run_tests() {
26
  $tests = array();
27
 
48
  return $tests;
49
  }
50
 
51
+ public function test_contant_DISALLOW_FILE_MODS() {
52
+ return $this->check_constants( 'DISALLOW_FILE_MODS', false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
+ public function test_contant_AUTOMATIC_UPDATER_DISABLED() {
56
+ return $this->check_constants( 'AUTOMATIC_UPDATER_DISABLED', false );
57
+ }
58
+
59
+ public function test_contant_WP_AUTO_UPDATE_CORE() {
60
+ return $this->check_constants( 'WP_AUTO_UPDATE_CORE', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  /**
64
+ * Test if auto-updates related constants are set correctly.
65
  *
66
+ * @since 5.2.0
 
 
67
  *
68
+ * @param string $constant The name of the constant to check.
69
+ * @param bool $value The value that the constant should be, if set.
70
+ * @return array The test results.
71
  */
72
+ public function check_constants( $constant, $value ) {
73
+ if ( defined( $constant ) && constant( $constant ) != $value ) {
74
  return array(
75
+ 'description' => sprintf(
76
  /* translators: %s: Name of the constant used. */
77
+ __( 'The %s constant is defined and enabled.', 'health-check' ),
78
+ "<code>$constant</code>"
79
  ),
80
+ 'severity' => 'fail',
81
  );
82
  }
83
  }
85
  /**
86
  * Check if updates are intercepted by a filter.
87
  *
88
+ * @since 5.2.0
 
 
89
  *
90
+ * @return array The test results.
91
  */
92
+ public function test_wp_version_check_attached() {
93
+ if ( ! is_main_site() ) {
94
+ return;
95
+ }
96
+
97
  $cookies = wp_unslash( $_COOKIE );
98
  $timeout = 10;
99
  $headers = array(
105
  $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
106
  }
107
 
108
+ $url = add_query_arg(
109
+ array(
110
+ 'health-check-test-wp_version_check' => true,
111
+ ),
112
+ admin_url( '' )
113
+ );
114
 
115
  $test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
116
 
117
+ if ( is_wp_error( $test ) ) {
118
+ return array(
119
+ 'description' => sprintf(
120
+ /* translators: %s: Name of the filter used. */
121
+ __( 'Could not confirm that the %s filter is available.', 'health-check' ),
122
+ '<code>wp_version_check()</code>'
123
+ ),
124
+ 'severity' => 'warning',
125
+ );
126
+ }
127
+
128
  $response = wp_remote_retrieve_body( $test );
129
 
130
  if ( 'yes' !== $response ) {
131
  return array(
132
+ 'description' => sprintf(
133
  /* translators: %s: Name of the filter used. */
134
+ __( 'A plugin has prevented updates by disabling %s.', 'health-check' ),
135
  '<code>wp_version_check()</code>'
136
  ),
137
+ 'severity' => 'fail',
138
  );
139
  }
140
  }
142
  /**
143
  * Check if automatic updates are disabled by a filter.
144
  *
145
+ * @since 5.2.0
 
 
146
  *
147
+ * @return array The test results.
148
  */
149
+ public function test_filters_automatic_updater_disabled() {
150
  if ( apply_filters( 'automatic_updater_disabled', false ) ) {
151
  return array(
152
+ 'description' => sprintf(
153
  /* translators: %s: Name of the filter used. */
154
+ __( 'The %s filter is enabled.', 'health-check' ),
155
  '<code>automatic_updater_disabled</code>'
156
  ),
157
+ 'severity' => 'fail',
158
  );
159
  }
160
  }
162
  /**
163
  * Check if automatic updates have tried to run, but failed, previously.
164
  *
165
+ * @since 5.2.0
 
 
166
  *
167
+ * @return array|bool The test results. false if the auto updates failed.
168
  */
169
  function test_if_failed_update() {
170
  $failed = get_site_option( 'auto_core_update_failed' );
174
  }
175
 
176
  if ( ! empty( $failed['critical'] ) ) {
177
+ $description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.', 'health-check' );
178
+ $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
179
+ $description .= ' ' . __( "When you've been able to update using the \"Update Now\" button on Dashboard > Updates, we'll clear this error for future update attempts.", 'health-check' );
180
+ $description .= ' ' . sprintf(
181
  /* translators: %s: Code of error shown. */
182
+ __( 'The error code was %s.', 'health-check' ),
183
  '<code>' . $failed['error_code'] . '</code>'
184
  );
185
  return array(
186
+ 'description' => $description,
187
+ 'severity' => 'warning',
188
  );
189
  }
190
 
191
+ $description = __( 'A previous automatic background update could not occur.', 'health-check' );
192
  if ( empty( $failed['retry'] ) ) {
193
+ $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
194
  }
195
 
196
+ $description .= ' ' . __( "We'll try again with the next release.", 'health-check' );
197
+ $description .= ' ' . sprintf(
198
  /* translators: %s: Code of error shown. */
199
+ __( 'The error code was %s.', 'health-check' ),
200
  '<code>' . $failed['error_code'] . '</code>'
201
  );
202
  return array(
203
+ 'description' => $description,
204
+ 'severity' => 'warning',
205
  );
206
  }
207
 
208
  /**
209
  * Check if WordPress is controlled by a VCS (Git, Subversion etc).
210
  *
211
+ * @since 5.2.0
 
 
 
 
 
 
 
 
212
  *
213
+ * @return array The test results.
214
  */
215
+ public function test_vcs_abspath() {
216
  $context_dirs = array( ABSPATH );
217
  $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
218
  $check_dirs = array();
243
  }
244
  }
245
 
246
+ if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) {
247
  return array(
248
+ 'description' => sprintf(
249
+ // translators: 1: Folder name. 2: Version control directory. 3: Filter name.
250
+ __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.', 'health-check' ),
251
  '<code>' . $check_dir . '</code>',
252
  "<code>$vcs_dir</code>",
253
  '<code>automatic_updates_is_vcs_checkout</code>'
254
  ),
255
+ 'severity' => 'info',
256
  );
257
  }
258
 
259
  if ( $checkout ) {
260
  return array(
261
+ 'description' => sprintf(
262
+ // translators: 1: Folder name. 2: Version control directory.
263
+ __( 'The folder %1$s was detected as being under version control (%2$s).', 'health-check' ),
264
  '<code>' . $check_dir . '</code>',
265
  "<code>$vcs_dir</code>"
266
  ),
267
+ 'severity' => 'fail',
268
  );
269
  }
270
 
271
  return array(
272
+ 'description' => __( 'No version control systems were detected.', 'health-check' ),
273
+ 'severity' => 'pass',
274
  );
275
  }
276
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  /**
278
  * Check if we can access files without providing credentials.
279
  *
280
+ * @since 5.2.0
 
 
281
  *
282
+ * @return array The test results.
283
  */
284
  function test_check_wp_filesystem_method() {
285
  $skin = new Automatic_Upgrader_Skin;
286
  $success = $skin->request_filesystem_credentials( false, ABSPATH );
287
 
288
  if ( ! $success ) {
289
+ $description = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.', 'health-check' );
290
+ $description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)', 'health-check' );
291
 
292
  return array(
293
+ 'description' => $description,
294
+ 'severity' => 'fail',
295
  );
296
  }
297
 
298
  return array(
299
+ 'description' => __( "Your installation of WordPress doesn't require FTP credentials to perform updates.", 'health-check' ),
300
+ 'severity' => 'pass',
301
  );
302
  }
303
 
304
  /**
305
+ * Check if core files are writable by the web user/group.
306
  *
307
+ * @since 5.2.0
308
  *
309
+ * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  *
311
+ * @return array|bool The test results. false if they're not writeable.
312
  */
313
  function test_all_files_writable() {
314
  global $wp_filesystem;
315
+
316
  include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
317
 
318
  $skin = new Automatic_Upgrader_Skin;
341
  }
342
 
343
  if ( ! $checksums ) {
344
+ $description = sprintf(
345
  // translators: %s: WordPress version
346
+ __( "Couldn't retrieve a list of the checksums for WordPress %s.", 'health-check' ),
347
  $wp_version
348
  );
349
+ $description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.', 'health-check' );
350
  return array(
351
+ 'description' => $description,
352
+ 'severity' => 'warning',
353
  );
354
  }
355
 
358
  if ( 'wp-content' == substr( $file, 0, 10 ) ) {
359
  continue;
360
  }
361
+ if ( ! file_exists( ABSPATH . $file ) ) {
362
  continue;
363
  }
364
+ if ( ! is_writable( ABSPATH . $file ) ) {
365
  $unwritable_files[] = $file;
366
  }
367
  }
372
  $unwritable_files[] = '...';
373
  }
374
  return array(
375
+ 'description' => __( 'Some files are not writable by WordPress:', 'health-check' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>',
376
+ 'severity' => 'fail',
377
  );
378
  } else {
379
  return array(
380
+ 'description' => __( 'All of your WordPress files are writable.', 'health-check' ),
381
+ 'severity' => 'pass',
382
  );
383
  }
384
  }
386
  /**
387
  * Check if the install is using a development branch and can use nightly packages.
388
  *
389
+ * @since 5.2.0
 
 
 
 
390
  *
391
+ * @return array|bool The test results. false if it isn't a development version.
392
  */
393
  function test_accepts_dev_updates() {
394
  include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
399
 
400
  if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) {
401
  return array(
402
+ 'description' => sprintf(
403
  /* translators: %s: Name of the constant used. */
404
+ __( 'WordPress development updates are blocked by the %s constant.', 'health-check' ),
405
  '<code>WP_AUTO_UPDATE_CORE</code>'
406
  ),
407
+ 'severity' => 'fail',
408
  );
409
  }
410
 
411
  if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) {
412
  return array(
413
+ 'description' => sprintf(
414
  /* translators: %s: Name of the filter used. */
415
+ __( 'WordPress development updates are blocked by the %s filter.', 'health-check' ),
416
  '<code>allow_dev_auto_core_updates</code>'
417
  ),
418
+ 'severity' => 'fail',
419
  );
420
  }
421
  }
423
  /**
424
  * Check if the site supports automatic minor updates.
425
  *
426
+ * @since 5.2.0
 
 
 
427
  *
428
+ * @return array The test results.
429
  */
430
  function test_accepts_minor_updates() {
431
  if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
432
  return array(
433
+ 'description' => sprintf(
434
  /* translators: %s: Name of the constant used. */
435
+ __( 'WordPress security and maintenance releases are blocked by %s.', 'health-check' ),
436
  "<code>define( 'WP_AUTO_UPDATE_CORE', false );</code>"
437
  ),
438
+ 'severity' => 'fail',
439
  );
440
  }
441
 
442
  if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) {
443
  return array(
444
+ 'description' => sprintf(
445
  /* translators: %s: Name of the filter used. */
446
+ __( 'WordPress security and maintenance releases are blocked by the %s filter.', 'health-check' ),
447
  '<code>allow_minor_auto_core_updates</code>'
448
  ),
449
+ 'severity' => 'fail',
450
  );
451
  }
452
  }
includes/class-health-check-debug-data.php CHANGED
@@ -5,13 +5,18 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_Debug_Data
10
  */
11
  class Health_Check_Debug_Data {
12
 
13
  /**
14
- * Calls all core funtions to check for updates
15
  *
16
  * @uses wp_version_check()
17
  * @uses wp_update_plugins()
@@ -27,288 +32,451 @@ class Health_Check_Debug_Data {
27
 
28
  }
29
 
30
- static function debug_data( $locale = null ) {
31
- if ( ! empty( $locale ) ) {
32
- // Change the language used for translations
33
- if ( function_exists( 'switch_to_locale' ) ) {
34
- $original_locale = get_locale();
35
- $switched_locale = switch_to_locale( $locale );
36
- }
37
- }
 
 
 
38
  global $wpdb;
39
 
40
- $upload_dir = wp_upload_dir();
41
- if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
42
- $wp_config_path = ABSPATH . 'wp-config.php';
43
- // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
44
- } elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
45
- $wp_config_path = dirname( ABSPATH ) . '/wp-config.php';
46
- }
47
-
48
- $core_current_version = get_bloginfo( 'version' );
49
- $core_updates = get_core_updates();
50
- $core_update_needed = '';
51
 
52
  foreach ( $core_updates as $core => $update ) {
53
  if ( 'upgrade' === $update->response ) {
54
  // translators: %s: Latest WordPress version number.
55
- $core_update_needed = ' ' . sprintf( __( '( Latest version: %s )', 'health-check' ), $update->version );
56
  } else {
57
  $core_update_needed = '';
58
  }
59
  }
60
 
61
- $info = array(
62
- 'wp-core' => array(
63
- 'label' => __( 'WordPress', 'health-check' ),
64
- 'fields' => array(
65
- array(
66
- 'label' => __( 'Version', 'health-check' ),
67
- 'value' => $core_current_version . $core_update_needed,
68
- ),
69
- array(
70
- 'label' => __( 'Language', 'health-check' ),
71
- 'value' => ( ! empty( $locale ) ? $original_locale : get_locale() ),
72
- ),
73
- array(
74
- 'label' => __( 'Home URL', 'health-check' ),
75
- 'value' => get_bloginfo( 'url' ),
76
- 'private' => true,
77
- ),
78
- array(
79
- 'label' => __( 'Site URL', 'health-check' ),
80
- 'value' => get_bloginfo( 'wpurl' ),
81
- 'private' => true,
82
- ),
83
- array(
84
- 'label' => __( 'Permalink structure', 'health-check' ),
85
- 'value' => get_option( 'permalink_structure' ),
86
- ),
87
- array(
88
- 'label' => __( 'Is this site using HTTPS?', 'health-check' ),
89
- 'value' => ( is_ssl() ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
90
- ),
91
- array(
92
- 'label' => __( 'Can anyone register on this site?', 'health-check' ),
93
- 'value' => ( get_option( 'users_can_register' ) ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
94
- ),
95
- array(
96
- 'label' => __( 'Default comment status', 'health-check' ),
97
- 'value' => get_option( 'default_comment_status' ),
98
- ),
99
- array(
100
- 'label' => __( 'Is this a multisite?', 'health-check' ),
101
- 'value' => ( is_multisite() ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
102
- ),
 
 
 
 
 
 
 
 
 
 
 
103
  ),
104
  ),
105
- 'wp-install-size' => array(
106
- 'label' => __( 'Installation size', 'health-check' ),
107
- 'fields' => array(),
108
- ),
109
- 'wp-dropins' => array(
110
- 'label' => __( 'Drop-ins', 'health-check' ),
111
- 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins', 'health-check' ),
112
- 'fields' => array(),
113
- ),
114
- 'wp-active-theme' => array(
115
- 'label' => __( 'Active Theme', 'health-check' ),
116
- 'fields' => array(),
117
- ),
118
- 'wp-themes' => array(
119
- 'label' => __( 'Other themes', 'health-check' ),
120
- 'show_count' => true,
121
- 'fields' => array(),
122
- ),
123
- 'wp-mu-plugins' => array(
124
- 'label' => __( 'Must Use Plugins', 'health-check' ),
125
- 'show_count' => true,
126
- 'fields' => array(),
127
- ),
128
- 'wp-plugins-active' => array(
129
- 'label' => __( 'Active Plugins', 'health-check' ),
130
- 'show_count' => true,
131
- 'fields' => array(),
132
- ),
133
- 'wp-plugins-inactive' => array(
134
- 'label' => __( 'Inactive Plugins', 'health-check' ),
135
- 'show_count' => true,
136
- 'fields' => array(),
137
- ),
138
- 'wp-media' => array(
139
- 'label' => __( 'Media handling', 'health-check' ),
140
- 'fields' => array(),
141
- ),
142
- 'wp-server' => array(
143
- 'label' => __( 'Server', 'health-check' ),
144
- 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host\'s assistance.', 'health-check' ),
145
- 'fields' => array(),
146
- ),
147
- 'wp-database' => array(
148
- 'label' => __( 'Database', 'health-check' ),
149
  'fields' => array(),
150
- ),
151
- 'wp-constants' => array(
152
- 'label' => __( 'WordPress Constants', 'health-check' ),
153
- 'description' => __( 'These values represent values set in your websites code which affect WordPress in various ways that may be of importance when seeking help with your site.', 'health-check' ),
154
- 'fields' => array(
155
- array(
156
- 'label' => 'ABSPATH',
157
- 'value' => ( ! defined( 'ABSPATH' ) ? __( 'Undefined', 'health-check' ) : ABSPATH ),
158
- ),
159
- array(
160
- 'label' => 'WP_HOME',
161
- 'value' => ( ! defined( 'WP_HOME' ) ? __( 'Undefined', 'health-check' ) : WP_HOME ),
162
- ),
163
- array(
164
- 'label' => 'WP_SITEURL',
165
- 'value' => ( ! defined( 'WP_SITEURL' ) ? __( 'Undefined', 'health-check' ) : WP_SITEURL ),
166
- ),
167
- array(
168
- 'label' => 'WP_DEBUG',
169
- 'value' => ( ! defined( 'WP_DEBUG' ) ? __( 'Undefined', 'health-check' ) : ( WP_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
170
- ),
171
- array(
172
- 'label' => 'WP_MAX_MEMORY_LIMIT',
173
- 'value' => ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ? __( 'Undefined', 'health-check' ) : WP_MAX_MEMORY_LIMIT ),
174
- ),
175
- array(
176
- 'label' => 'WP_DEBUG_DISPLAY',
177
- 'value' => ( ! defined( 'WP_DEBUG_DISPLAY' ) ? __( 'Undefined', 'health-check' ) : ( WP_DEBUG_DISPLAY ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
178
- ),
179
- array(
180
- 'label' => 'WP_DEBUG_LOG',
181
- 'value' => ( ! defined( 'WP_DEBUG_LOG' ) ? __( 'Undefined', 'health-check' ) : ( WP_DEBUG_LOG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
182
- ),
183
- array(
184
- 'label' => 'SCRIPT_DEBUG',
185
- 'value' => ( ! defined( 'SCRIPT_DEBUG' ) ? __( 'Undefined', 'health-check' ) : ( SCRIPT_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
186
- ),
187
- array(
188
- 'label' => 'WP_CACHE',
189
- 'value' => ( ! defined( 'WP_CACHE' ) ? __( 'Undefined', 'health-check' ) : ( WP_CACHE ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
190
- ),
191
- array(
192
- 'label' => 'CONCATENATE_SCRIPTS',
193
- 'value' => ( ! defined( 'CONCATENATE_SCRIPTS' ) ? __( 'Undefined', 'health-check' ) : ( CONCATENATE_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
194
- ),
195
- array(
196
- 'label' => 'COMPRESS_SCRIPTS',
197
- 'value' => ( ! defined( 'COMPRESS_SCRIPTS' ) ? __( 'Undefined', 'health-check' ) : ( COMPRESS_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
198
- ),
199
- array(
200
- 'label' => 'COMPRESS_CSS',
201
- 'value' => ( ! defined( 'COMPRESS_CSS' ) ? __( 'Undefined', 'health-check' ) : ( COMPRESS_CSS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
202
- ),
203
- array(
204
- 'label' => 'WP_LOCAL_DEV',
205
- 'value' => ( ! defined( 'WP_LOCAL_DEV' ) ? __( 'Undefined', 'health-check' ) : ( WP_LOCAL_DEV ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ) ) ),
206
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  ),
208
  ),
209
- 'wp-filesystem' => array(
210
- 'label' => __( 'Filesystem Permissions', 'health-check' ),
211
- 'description' => __( 'The status of various locations WordPress needs to write files in various scenarios.', 'health-check' ),
212
- 'fields' => array(
213
- array(
214
- 'label' => __( 'The main WordPress directory', 'health-check' ),
215
- 'value' => ( wp_is_writable( ABSPATH ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
216
- ),
217
- array(
218
- 'label' => __( 'The wp-content directory', 'health-check' ),
219
- 'value' => ( wp_is_writable( WP_CONTENT_DIR ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
220
- ),
221
- array(
222
- 'label' => __( 'The uploads directory', 'health-check' ),
223
- 'value' => ( wp_is_writable( $upload_dir['basedir'] ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
224
- ),
225
- array(
226
- 'label' => __( 'The plugins directory', 'health-check' ),
227
- 'value' => ( wp_is_writable( WP_PLUGIN_DIR ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
228
- ),
229
- array(
230
- 'label' => __( 'The themes directory', 'health-check' ),
231
- 'value' => ( wp_is_writable( get_template_directory() . '/..' ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
232
- ),
 
 
 
 
 
 
 
 
 
 
 
 
233
  ),
234
  ),
235
  );
236
 
 
237
  if ( is_multisite() ) {
238
  $network_query = new WP_Network_Query();
239
- $network_ids = $network_query->query( array(
240
- 'fields' => 'ids',
241
- 'number' => 100,
242
- 'no_found_rows' => false,
243
- ) );
 
 
244
 
245
  $site_count = 0;
246
  foreach ( $network_ids as $network_id ) {
247
  $site_count += get_blog_count( $network_id );
248
  }
249
 
250
- $info['wp-core']['fields'][] = array(
251
- 'label' => __( 'User Count', 'health-check' ),
252
  'value' => get_user_count(),
253
  );
254
- $info['wp-core']['fields'][] = array(
255
- 'label' => __( 'Site Count', 'health-check' ),
 
256
  'value' => $site_count,
257
  );
258
- $info['wp-core']['fields'][] = array(
259
- 'label' => __( 'Network Count', 'health-check' ),
 
260
  'value' => $network_query->found_networks,
261
  );
262
  } else {
263
  $user_count = count_users();
264
 
265
- $info['wp-core']['fields'][] = array(
266
- 'label' => __( 'User Count', 'health-check' ),
267
  'value' => $user_count['total_users'],
268
  );
269
  }
270
 
271
  // WordPress features requiring processing.
272
- $wp_dotorg = wp_remote_get( 'https://wordpress.org', array(
273
- 'timeout' => 10,
274
- ) );
275
  if ( ! is_wp_error( $wp_dotorg ) ) {
276
- $info['wp-core']['fields'][] = array(
277
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
278
- 'value' => sprintf(
279
- __( 'WordPress.org is reachable', 'health-check' )
280
- ),
281
  );
282
  } else {
283
- $info['wp-core']['fields'][] = array(
284
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
285
  'value' => sprintf(
286
- // translators: %1$s: The IP address WordPress.org resolves to. %2$s: The error returned by the lookup.
287
  __( 'Unable to reach WordPress.org at %1$s: %2$s', 'health-check' ),
288
- gethostbyname( 'wordpress.org' ),
289
  $wp_dotorg->get_error_message()
290
  ),
 
291
  );
292
  }
293
 
294
- $loopback = Health_Check_Loopback::can_perform_loopback();
295
- $info['wp-core']['fields'][] = array(
296
- 'label' => __( 'Create loopback requests', 'health-check' ),
297
- 'value' => $loopback->message,
298
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
- // Get drop-ins.
301
- $dropins = get_dropins();
302
- $dropin_description = _get_dropins();
303
  foreach ( $dropins as $dropin_key => $dropin ) {
304
- $info['wp-dropins']['fields'][] = array(
305
  'label' => $dropin_key,
306
- 'value' => $dropin_description[ $dropin_key ][0],
 
307
  );
308
  }
309
 
310
  // Populate the media fields.
311
- $info['wp-media']['fields'][] = array(
312
  'label' => __( 'Active editor', 'health-check' ),
313
  'value' => _wp_image_editor_choose(),
314
  );
@@ -319,31 +487,43 @@ class Health_Check_Debug_Data {
319
  $imagick = new Imagick();
320
  $imagick_version = $imagick->getVersion();
321
  } else {
322
- $imagick_version = 'Imagick not available';
323
  }
324
- $info['wp-media']['fields'][] = array(
325
- 'label' => __( 'Imagick Module Version', 'health-check' ),
 
326
  'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
327
  );
328
- $info['wp-media']['fields'][] = array(
329
- 'label' => __( 'ImageMagick Version', 'health-check' ),
 
330
  'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
331
  );
332
 
333
  // If Imagick is used as our editor, provide some more information about its limitations.
334
  if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
335
  $limits = array(
336
- 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'Not Available' ),
337
- 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'Not Available' ),
338
- 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'Not Available' ),
339
- 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'Not Available' ),
340
- 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'Not Available' ),
341
- 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'Not Available' ),
 
 
 
 
 
 
 
 
 
342
  );
343
 
344
- $info['wp-media']['fields'][] = array(
345
  'label' => __( 'Imagick Resource Limits', 'health-check' ),
346
  'value' => $limits,
 
347
  );
348
  }
349
 
@@ -353,112 +533,167 @@ class Health_Check_Debug_Data {
353
  } else {
354
  $gd = false;
355
  }
356
- $info['wp-media']['fields'][] = array(
357
- 'label' => __( 'GD Version', 'health-check' ),
358
- 'value' => ( is_array( $gd ) ? $gd['GD Version'] : __( 'GD not available', 'health-check' ) ),
 
 
359
  );
360
 
361
  // Get Ghostscript information, if available.
362
  if ( function_exists( 'exec' ) ) {
363
  $gs = exec( 'gs --version' );
364
- $gs = ( ! empty( $gs ) ? $gs : __( 'Not available', 'health-check' ) );
 
 
 
 
 
 
365
  } else {
366
- $gs = __( 'Unable to determine if Ghostscript is installed', 'health-check' );
 
367
  }
368
- $info['wp-media']['fields'][] = array(
369
- 'label' => __( 'Ghostscript Version', 'health-check' ),
 
370
  'value' => $gs,
 
371
  );
372
 
373
  // Populate the server debug fields.
374
- $info['wp-server']['fields'][] = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  'label' => __( 'Server architecture', 'health-check' ),
376
- 'value' => ( ! function_exists( 'php_uname' ) ? __( 'Unable to determine server architecture', 'health-check' ) : sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ) ),
 
377
  );
378
- $info['wp-server']['fields'][] = array(
379
- 'label' => __( 'Web Server Software', 'health-check' ),
380
  'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used', 'health-check' ) ),
 
381
  );
382
- $info['wp-server']['fields'][] = array(
383
- 'label' => __( 'PHP Version', 'health-check' ),
384
- 'value' => ( ! function_exists( 'phpversion' ) ? __( 'Unable to determine PHP version', 'health-check' ) : sprintf(
385
- '%s %s',
386
- phpversion(),
387
- ( 64 === PHP_INT_SIZE * 8 ? __( '(Supports 64bit values)', 'health-check' ) : __( '(Does not support 64bit values)', 'health-check' ) )
388
- )
389
- ),
390
  );
391
- $info['wp-server']['fields'][] = array(
392
  'label' => __( 'PHP SAPI', 'health-check' ),
393
- 'value' => ( ! function_exists( 'php_sapi_name' ) ? __( 'Unable to determine PHP SAPI', 'health-check' ) : php_sapi_name() ),
 
394
  );
395
 
 
396
  if ( ! function_exists( 'ini_get' ) ) {
397
- $info['wp-server']['fields'][] = array(
398
  'label' => __( 'Server settings', 'health-check' ),
399
- 'value' => __( 'Unable to determine some settings as the ini_get() function has been disabled', 'health-check' ),
 
400
  );
401
  } else {
402
- $info['wp-server']['fields'][] = array(
403
  'label' => __( 'PHP max input variables', 'health-check' ),
404
  'value' => ini_get( 'max_input_vars' ),
405
  );
406
- $info['wp-server']['fields'][] = array(
407
  'label' => __( 'PHP time limit', 'health-check' ),
408
  'value' => ini_get( 'max_execution_time' ),
409
  );
410
- $info['wp-server']['fields'][] = array(
411
  'label' => __( 'PHP memory limit', 'health-check' ),
412
  'value' => ini_get( 'memory_limit' ),
413
  );
414
- $info['wp-server']['fields'][] = array(
415
  'label' => __( 'Max input time', 'health-check' ),
416
  'value' => ini_get( 'max_input_time' ),
417
  );
418
- $info['wp-server']['fields'][] = array(
419
  'label' => __( 'Upload max filesize', 'health-check' ),
420
  'value' => ini_get( 'upload_max_filesize' ),
421
  );
422
- $info['wp-server']['fields'][] = array(
423
  'label' => __( 'PHP post max size', 'health-check' ),
424
  'value' => ini_get( 'post_max_size' ),
425
  );
426
  }
427
 
428
  if ( function_exists( 'curl_version' ) ) {
429
- $curl = curl_version();
430
- $info['wp-server']['fields'][] = array(
431
- 'label' => __( 'cURL Version', 'health-check' ),
 
432
  'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
433
  );
434
  } else {
435
- $info['wp-server']['fields'][] = array(
436
- 'label' => __( 'cURL Version', 'health-check' ),
437
- 'value' => __( 'Your server does not support cURL', 'health-check' ),
 
438
  );
439
  }
440
 
441
- $info['wp-server']['fields'][] = array(
442
- 'label' => __( 'SUHOSIN installed', 'health-check' ),
443
- 'value' => ( ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ) ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
 
 
 
 
444
  );
445
 
446
- $info['wp-server']['fields'][] = array(
447
- 'label' => __( 'Is the Imagick library available', 'health-check' ),
448
- 'value' => ( extension_loaded( 'imagick' ) ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
 
 
 
 
449
  );
450
 
451
  // Check if a .htaccess file exists.
452
- if ( is_file( ABSPATH . '/.htaccess' ) ) {
453
  // If the file exists, grab the content of it.
454
- $htaccess_content = file_get_contents( ABSPATH . '/.htaccess' );
455
 
456
  // Filter away the core WordPress rules.
457
  $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
 
458
 
459
- $info['wp-server']['fields'][] = array(
460
- 'label' => __( 'htaccess rules', 'health-check' ),
461
- 'value' => ( ! empty( $filtered_htaccess_content ) ? __( 'Custom rules have been added to your htaccess file', 'health-check' ) : __( 'Your htaccess file only contains core WordPress features', 'health-check' ) ),
 
462
  );
463
  }
464
 
@@ -474,6 +709,11 @@ class Health_Check_Debug_Data {
474
  $extension = null;
475
  }
476
 
 
 
 
 
 
477
  if ( method_exists( $wpdb, 'db_version' ) ) {
478
  if ( $wpdb->use_mysqli ) {
479
  // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info
@@ -497,36 +737,43 @@ class Health_Check_Debug_Data {
497
  }
498
  }
499
 
500
- $info['wp-database']['fields'][] = array(
501
  'label' => __( 'Extension', 'health-check' ),
502
  'value' => $extension,
503
  );
504
- $info['wp-database']['fields'][] = array(
 
505
  'label' => __( 'Server version', 'health-check' ),
506
  'value' => $server,
507
  );
508
- $info['wp-database']['fields'][] = array(
 
509
  'label' => __( 'Client version', 'health-check' ),
510
  'value' => $client_version,
511
  );
512
- $info['wp-database']['fields'][] = array(
 
513
  'label' => __( 'Database user', 'health-check' ),
514
  'value' => $wpdb->dbuser,
515
  'private' => true,
516
  );
517
- $info['wp-database']['fields'][] = array(
 
518
  'label' => __( 'Database host', 'health-check' ),
519
  'value' => $wpdb->dbhost,
520
  'private' => true,
521
  );
522
- $info['wp-database']['fields'][] = array(
 
523
  'label' => __( 'Database name', 'health-check' ),
524
  'value' => $wpdb->dbname,
525
  'private' => true,
526
  );
527
- $info['wp-database']['fields'][] = array(
528
- 'label' => __( 'Database prefix', 'health-check' ),
529
- 'value' => $wpdb->prefix,
 
 
530
  );
531
 
532
  // List must use plugins if there are any.
@@ -536,24 +783,31 @@ class Health_Check_Debug_Data {
536
  $plugin_version = $plugin['Version'];
537
  $plugin_author = $plugin['Author'];
538
 
539
- $plugin_version_string = __( 'No version or author information available', 'health-check' );
 
540
 
541
  if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
542
- // translators: %1$s: Plugin version number. %2$s: Plugin author name.
543
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
544
- }
545
- if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) {
546
- // translators: %s: Plugin author name.
547
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
548
- }
549
- if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) {
550
- // translators: %s: Plugin version number.
551
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
 
 
 
 
 
552
  }
553
 
554
- $info['wp-mu-plugins']['fields'][] = array(
555
  'label' => $plugin['Name'],
556
  'value' => $plugin_version_string,
 
557
  );
558
  }
559
 
@@ -567,37 +821,44 @@ class Health_Check_Debug_Data {
567
  $plugin_version = $plugin['Version'];
568
  $plugin_author = $plugin['Author'];
569
 
570
- $plugin_version_string = __( 'No version or author information available', 'health-check' );
 
571
 
572
  if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
573
- // translators: %1$s: Plugin version number. %2$s: Plugin author name.
574
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
575
- }
576
- if ( empty( $plugin_version ) && ! empty( $plugin_author ) ) {
577
- // translators: %s: Plugin author name.
578
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
579
- }
580
- if ( ! empty( $plugin_version ) && empty( $plugin_author ) ) {
581
- // translators: %s: Plugin version number.
582
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
 
 
 
 
 
583
  }
584
 
585
  if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
586
  // translators: %s: Latest plugin version number.
587
- $plugin_update_needed = ' ' . sprintf( __( '( Latest version: %s )', 'health-check' ), $plugin_updates[ $plugin_path ]->update->new_version );
588
- } else {
589
- $plugin_update_needed = '';
590
  }
591
 
592
- $info[ $plugin_part ]['fields'][] = array(
593
  'label' => $plugin['Name'],
594
- 'value' => $plugin_version_string . $plugin_update_needed,
 
595
  );
596
  }
597
 
598
  // Populate the section for the currently active theme.
599
  global $_wp_theme_features;
600
  $theme_features = array();
 
601
  if ( ! empty( $_wp_theme_features ) ) {
602
  foreach ( $_wp_theme_features as $feature => $options ) {
603
  $theme_features[] = $feature;
@@ -607,41 +868,54 @@ class Health_Check_Debug_Data {
607
  $active_theme = wp_get_theme();
608
  $theme_updates = get_theme_updates();
609
 
 
 
 
 
610
  if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
 
 
611
  // translators: %s: Latest theme version number.
612
- $theme_update_needed_active = ' ' . sprintf( __( '( Latest version: %s )', 'health-check' ), $theme_updates[ $active_theme->stylesheet ]->update['new_version'] );
613
- } else {
614
- $theme_update_needed_active = '';
615
  }
616
 
 
 
617
  $info['wp-active-theme']['fields'] = array(
618
- array(
619
  'label' => __( 'Name', 'health-check' ),
620
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
621
  'value' => $active_theme->Name,
622
  ),
623
- array(
624
  'label' => __( 'Version', 'health-check' ),
625
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
626
- 'value' => $active_theme->Version . $theme_update_needed_active,
627
  ),
628
- array(
629
  'label' => __( 'Author', 'health-check' ),
630
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
631
  'value' => wp_kses( $active_theme->Author, array() ),
632
  ),
633
- array(
634
  'label' => __( 'Author website', 'health-check' ),
635
- 'value' => ( $active_theme->offsetGet( 'Author URI' ) ? $active_theme->offsetGet( 'Author URI' ) : __( 'Undefined', 'health-check' ) ),
 
636
  ),
637
- array(
638
  'label' => __( 'Parent theme', 'health-check' ),
639
- 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme : __( 'Not a child theme', 'health-check' ) ),
 
640
  ),
641
- array(
642
- 'label' => __( 'Supported theme features', 'health-check' ),
643
  'value' => implode( ', ', $theme_features ),
644
  ),
 
 
 
 
645
  );
646
 
647
  // Populate a list of all themes available in the install.
@@ -649,7 +923,7 @@ class Health_Check_Debug_Data {
649
 
650
  foreach ( $all_themes as $theme_slug => $theme ) {
651
  // Ignore the currently active theme from the list of all themes.
652
- if ( $active_theme->stylesheet == $theme_slug ) {
653
  continue;
654
  }
655
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
@@ -657,110 +931,119 @@ class Health_Check_Debug_Data {
657
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
658
  $theme_author = $theme->Author;
659
 
660
- $theme_version_string = __( 'No version or author information available', 'health-check' );
 
 
 
 
661
 
662
  if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
663
- // translators: %1$s: Theme version number. %2$s: Theme author name.
664
- $theme_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $theme_version, wp_kses( $theme_author, array() ) );
665
- }
666
- if ( empty( $theme_version ) && ! empty( $theme_author ) ) {
667
- // translators: %s: Theme author name.
668
- $theme_version_string = sprintf( __( 'By %s', 'health-check' ), wp_kses( $theme_author, array() ) );
669
- }
670
- if ( ! empty( $theme_version ) && empty( $theme_author ) ) {
671
- // translators: %s: Theme version number.
672
- $theme_version_string = sprintf( __( 'Version %s', 'health-check' ), $theme_version );
 
 
 
 
 
673
  }
674
 
675
  if ( array_key_exists( $theme_slug, $theme_updates ) ) {
676
  // translators: %s: Latest theme version number.
677
- $theme_update_needed = ' ' . sprintf( __( '( Latest version: %s )', 'health-check' ), $theme_updates[ $theme_slug ]->update['new_version'] );
678
- } else {
679
- $theme_update_needed = '';
680
  }
681
 
682
- $info['wp-themes']['fields'][] = array(
 
683
  'label' => sprintf(
684
- // translators: %1$s: Theme name. %2$s: Theme slug.
685
  __( '%1$s (%2$s)', 'health-check' ),
686
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
687
  $theme->Name,
688
  $theme_slug
689
  ),
690
- 'value' => $theme_version_string . $theme_update_needed,
 
691
  );
692
  }
693
 
694
  // Add more filesystem checks
695
  if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
696
- $info['wp-filesystem']['fields'][] = array(
697
- 'label' => __( 'The Must Use Plugins directory', 'health-check' ),
698
- 'value' => ( wp_is_writable( WPMU_PLUGIN_DIR ) ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
 
 
 
699
  );
700
  }
701
 
702
- $info['wp-install-size']['fields'] = Health_Check_Debug_Data::get_installation_size();
703
-
704
  /**
705
- * Add or modify new debug sections.
706
  *
707
- * Plugin or themes may wish to introduce their own debug information without creating additional admin pages for this
708
- * kind of information as it is rarely needed, they can then utilize this filter to introduce their own sections.
709
  *
710
- * This filter intentionally does not include the fields introduced by core as those should always be un-modified
711
- * and reliable for support related scenarios, take note that the core fields will take priority if a filtered value
712
- * is trying to use the same array keys.
713
  *
714
- * Array keys added by core are all prefixed with `wp-`, plugins and themes are encouraged to use their own slug as
715
- * a prefix, both for consistency as well as avoiding key collisions.
716
  *
717
- * @since 4.9.0
718
  *
719
  * @param array $args {
720
  * The debug information to be added to the core information page.
721
  *
 
 
 
 
722
  * @type string $label The title for this section of the debug output.
723
  * @type string $description Optional. A description for your information section which may contain basic HTML
724
- * markup: `em`, `strong` and `a` for linking to documentation or putting emphasis.
725
  * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
726
  * this section.
727
  * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
728
- * from the copy-paste text area.
729
  * @type array $fields {
730
  * An associative array containing the data to be displayed.
731
  *
732
  * @type string $label The label for this piece of information.
733
- * @type string $value The output that is of interest for this field.
734
- * @type boolean $private Optional. If set to `true` the field will not be included in the copy-paste text area
735
- * on top of the page, allowing you to show, for example, API keys here.
 
 
 
 
736
  * }
737
  * }
738
  */
739
- $external_info = apply_filters( 'debug_information', array() );
740
-
741
- // Merge the core and external debug fields.
742
- $info = array_replace_recursive( $info, array_replace_recursive( $external_info, $info ) );
743
-
744
- if ( ! empty( $locale ) ) {
745
- // Change the language used for translations
746
- if ( function_exists( 'restore_previous_locale' ) && $switched_locale ) {
747
- restore_previous_locale();
748
- }
749
- }
750
 
751
  return $info;
752
  }
753
 
754
  /**
755
- * Print the formatted variation of the information gathered for debugging, in a manner
756
- * suitable for a text area that can be instantly copied to a forum or support ticket.
757
  *
758
- * @param array $info_array
759
  *
760
- * @return void
 
 
761
  */
762
- public static function textarea_format( $info_array ) {
763
- echo "`\n";
764
 
765
  foreach ( $info_array as $section => $details ) {
766
  // Skip this section if there are no fields, or the section has been declared as private.
@@ -768,132 +1051,201 @@ class Health_Check_Debug_Data {
768
  continue;
769
  }
770
 
771
- printf(
 
 
772
  "### %s%s ###\n\n",
773
- $details['label'],
774
  ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
775
  );
776
 
777
- foreach ( $details['fields'] as $field ) {
778
  if ( isset( $field['private'] ) && true === $field['private'] ) {
779
  continue;
780
  }
781
 
782
- $values = $field['value'];
783
- if ( is_array( $field['value'] ) ) {
784
- $values = '';
 
 
 
 
 
 
785
 
786
- foreach ( $field['value'] as $name => $value ) {
787
- $values .= sprintf(
788
- "\n\t%s: %s",
789
- $name,
790
- $value
791
- );
792
  }
 
 
 
 
 
 
 
 
 
 
 
 
793
  }
794
 
795
- printf(
796
- "%s: %s\n",
797
- $field['label'],
798
- $values
799
- );
800
  }
801
- echo "\n";
 
802
  }
803
- echo '`';
804
- }
805
 
806
- public static function get_installation_size() {
807
- $uploads_dir = wp_upload_dir();
808
 
809
- $sizes = array(
810
- 'wp' => array(
811
- 'path' => ABSPATH,
812
- 'size' => 0,
813
- ),
814
- 'themes' => array(
815
- 'path' => trailingslashit( get_theme_root() ),
816
- 'size' => 0,
817
- ),
818
- 'plugins' => array(
819
- 'path' => WP_PLUGIN_DIR,
820
- 'size' => 0,
821
- ),
822
- 'uploads' => array(
823
- 'path' => $uploads_dir['basedir'],
824
- 'size' => 0,
825
- ),
826
- );
827
 
828
- $inaccurate = false;
 
 
 
 
 
 
 
 
 
 
829
 
830
- foreach ( $sizes as $size => $attributes ) {
831
- try {
832
- $sizes[ $size ]['size'] = Health_Check_Debug_Data::get_directory_size( $attributes['path'] );
833
- } catch ( Exception $e ) {
834
- $inaccurate = true;
835
  }
836
  }
837
 
838
- $size_db = Health_Check_Debug_Data::get_database_size();
 
839
 
840
- $size_total = $sizes['wp']['size'] + $size_db;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
 
842
- $result = array(
843
- array(
844
- 'label' => __( 'Uploads Directory', 'health-check' ),
845
- 'value' => size_format( $sizes['uploads']['size'], 2 ),
846
- ),
847
- array(
848
- 'label' => __( 'Themes Directory', 'health-check' ),
849
- 'value' => size_format( $sizes['themes']['size'], 2 ),
850
- ),
851
- array(
852
- 'label' => __( 'Plugins Directory', 'health-check' ),
853
- 'value' => size_format( $sizes['plugins']['size'], 2 ),
854
- ),
855
- array(
856
- 'label' => __( 'Database size', 'health-check' ),
857
- 'value' => size_format( $size_db, 2 ),
858
- ),
859
- array(
860
- 'label' => __( 'Whole WordPress Directory', 'health-check' ),
861
- 'value' => size_format( $sizes['wp']['size'], 2 ),
862
- ),
863
- array(
864
- 'label' => __( 'Total installation size', 'health-check' ),
865
- 'value' => sprintf(
866
- '%s%s',
867
- size_format( $size_total, 2 ),
868
- ( false === $inaccurate ? '' : __( '- Some errors, likely caused by invalid permissions, were encountered when determining the size of your installation. This means the values represented may be inaccurate.', 'health-check' ) )
869
- ),
870
- ),
871
  );
872
 
873
- return $result;
874
- }
 
875
 
876
- public static function get_directory_size( $path ) {
877
- $size = 0;
878
 
879
- foreach ( new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ) ) as $file ) {
880
- $size += $file->getSize();
881
- }
 
 
 
 
882
 
883
- return $size;
884
- }
 
 
 
 
 
885
 
886
- public static function get_database_size() {
887
- global $wpdb;
888
- $size = 0;
889
- $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
890
 
891
- if ( $wpdb->num_rows > 0 ) {
892
- foreach ( $rows as $row ) {
893
- $size += $row['Data_length'] + $row['Index_length'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
895
  }
896
 
897
- return $size;
898
  }
899
  }
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_Debug_Data
15
  */
16
  class Health_Check_Debug_Data {
17
 
18
  /**
19
+ * Calls all core functions to check for updates
20
  *
21
  * @uses wp_version_check()
22
  * @uses wp_update_plugins()
32
 
33
  }
34
 
35
+ /**
36
+ * Static function for generating site debug data when required.
37
+ *
38
+ * @since 5.2.0
39
+ *
40
+ * @throws ImagickException
41
+ * @global wpdb $wpdb WordPress database abstraction object.
42
+ *
43
+ * @return array The debug data for the site.
44
+ */
45
+ static function debug_data() {
46
  global $wpdb;
47
 
48
+ // Save few function calls.
49
+ $upload_dir = wp_get_upload_dir();
50
+ $permalink_structure = get_option( 'permalink_structure' );
51
+ $is_ssl = is_ssl();
52
+ $users_can_register = get_option( 'users_can_register' );
53
+ $default_comment_status = get_option( 'default_comment_status' );
54
+ $is_multisite = is_multisite();
55
+ $core_version = get_bloginfo( 'version' );
56
+ $core_updates = get_core_updates();
57
+ $core_update_needed = '';
 
58
 
59
  foreach ( $core_updates as $core => $update ) {
60
  if ( 'upgrade' === $update->response ) {
61
  // translators: %s: Latest WordPress version number.
62
+ $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $update->version );
63
  } else {
64
  $core_update_needed = '';
65
  }
66
  }
67
 
68
+ // Set up the array that holds all debug information.
69
+ $info = array();
70
+
71
+ $info['wp-core'] = array(
72
+ 'label' => __( 'WordPress', 'health-check' ),
73
+ 'fields' => array(
74
+ 'version' => array(
75
+ 'label' => __( 'Version', 'health-check' ),
76
+ 'value' => $core_version . $core_update_needed,
77
+ 'debug' => $core_version,
78
+ ),
79
+ 'site_language' => array(
80
+ 'label' => __( 'Site Language', 'health-check' ),
81
+ 'value' => get_locale(),
82
+ ),
83
+ 'user_language' => array(
84
+ 'label' => __( 'User Language', 'health-check' ),
85
+ 'value' => get_user_locale(),
86
+ ),
87
+ 'home_url' => array(
88
+ 'label' => __( 'Home URL', 'health-check' ),
89
+ 'value' => get_bloginfo( 'url' ),
90
+ 'private' => true,
91
+ ),
92
+ 'site_url' => array(
93
+ 'label' => __( 'Site URL', 'health-check' ),
94
+ 'value' => get_bloginfo( 'wpurl' ),
95
+ 'private' => true,
96
+ ),
97
+ 'permalink' => array(
98
+ 'label' => __( 'Permalink structure', 'health-check' ),
99
+ 'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set', 'health-check' ),
100
+ 'debug' => $permalink_structure,
101
+ ),
102
+ 'https_status' => array(
103
+ 'label' => __( 'Is this site using HTTPS?', 'health-check' ),
104
+ 'value' => $is_ssl ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
105
+ 'debug' => $is_ssl,
106
+ ),
107
+ 'user_registration' => array(
108
+ 'label' => __( 'Can anyone register on this site?', 'health-check' ),
109
+ 'value' => $users_can_register ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
110
+ 'debug' => $users_can_register,
111
+ ),
112
+ 'default_comment_status' => array(
113
+ 'label' => __( 'Default comment status', 'health-check' ),
114
+ 'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status', 'health-check' ) : _x( 'Closed', 'comment status', 'health-check' ),
115
+ 'debug' => $default_comment_status,
116
+ ),
117
+ 'multisite' => array(
118
+ 'label' => __( 'Is this a multisite?', 'health-check' ),
119
+ 'value' => $is_multisite ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
120
+ 'debug' => $is_multisite,
121
  ),
122
  ),
123
+ );
124
+
125
+ if ( ! $is_multisite ) {
126
+ $info['wp-paths-sizes'] = array(
127
+ 'label' => __( 'Directories and Sizes', 'health-check' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  'fields' => array(),
129
+ );
130
+ }
131
+
132
+ $info['wp-dropins'] = array(
133
+ 'label' => __( 'Drop-ins', 'health-check' ),
134
+ 'show_count' => true,
135
+ 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.', 'health-check' ),
136
+ 'fields' => array(),
137
+ );
138
+
139
+ $info['wp-active-theme'] = array(
140
+ 'label' => __( 'Active Theme', 'health-check' ),
141
+ 'fields' => array(),
142
+ );
143
+
144
+ $info['wp-themes'] = array(
145
+ 'label' => __( 'Other Themes', 'health-check' ),
146
+ 'show_count' => true,
147
+ 'fields' => array(),
148
+ );
149
+
150
+ $info['wp-mu-plugins'] = array(
151
+ 'label' => __( 'Must Use Plugins', 'health-check' ),
152
+ 'show_count' => true,
153
+ 'fields' => array(),
154
+ );
155
+
156
+ $info['wp-plugins-active'] = array(
157
+ 'label' => __( 'Active Plugins', 'health-check' ),
158
+ 'show_count' => true,
159
+ 'fields' => array(),
160
+ );
161
+
162
+ $info['wp-plugins-inactive'] = array(
163
+ 'label' => __( 'Inactive Plugins', 'health-check' ),
164
+ 'show_count' => true,
165
+ 'fields' => array(),
166
+ );
167
+
168
+ $info['wp-media'] = array(
169
+ 'label' => __( 'Media Handling', 'health-check' ),
170
+ 'fields' => array(),
171
+ );
172
+
173
+ $info['wp-server'] = array(
174
+ 'label' => __( 'Server', 'health-check' ),
175
+ 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host&#8217;s assistance.', 'health-check' ),
176
+ 'fields' => array(),
177
+ );
178
+
179
+ $info['wp-database'] = array(
180
+ 'label' => __( 'Database', 'health-check' ),
181
+ 'fields' => array(),
182
+ );
183
+
184
+ // Check if WP_DEBUG_LOG is set.
185
+ $wp_debug_log_value = __( 'Disabled', 'health-check' );
186
+
187
+ if ( is_string( WP_DEBUG_LOG ) ) {
188
+ $wp_debug_log_value = WP_DEBUG_LOG;
189
+ } elseif ( WP_DEBUG_LOG ) {
190
+ $wp_debug_log_value = __( 'Enabled', 'health-check' );
191
+ }
192
+
193
+ // Check CONCATENATE_SCRIPTS.
194
+ if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
195
+ $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
196
+ $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
197
+ } else {
198
+ $concatenate_scripts = __( 'Undefined', 'health-check' );
199
+ $concatenate_scripts_debug = 'undefined';
200
+ }
201
+
202
+ // Check COMPRESS_SCRIPTS.
203
+ if ( defined( 'COMPRESS_SCRIPTS' ) ) {
204
+ $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
205
+ $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
206
+ } else {
207
+ $compress_scripts = __( 'Undefined', 'health-check' );
208
+ $compress_scripts_debug = 'undefined';
209
+ }
210
+
211
+ // Check COMPRESS_CSS.
212
+ if ( defined( 'COMPRESS_CSS' ) ) {
213
+ $compress_css = COMPRESS_CSS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
214
+ $compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
215
+ } else {
216
+ $compress_css = __( 'Undefined', 'health-check' );
217
+ $compress_css_debug = 'undefined';
218
+ }
219
+
220
+ // Check WP_LOCAL_DEV.
221
+ if ( defined( 'WP_LOCAL_DEV' ) ) {
222
+ $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
223
+ $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false';
224
+ } else {
225
+ $wp_local_dev = __( 'Undefined', 'health-check' );
226
+ $wp_local_dev_debug = 'undefined';
227
+ }
228
+
229
+ $info['wp-constants'] = array(
230
+ 'label' => __( 'WordPress Constants', 'health-check' ),
231
+ 'description' => __( 'These settings alter where and how parts of WordPress are loaded.', 'health-check' ),
232
+ 'fields' => array(
233
+ 'ABSPATH' => array(
234
+ 'label' => 'ABSPATH',
235
+ 'value' => ABSPATH,
236
+ 'private' => true,
237
+ ),
238
+ 'WP_HOME' => array(
239
+ 'label' => 'WP_HOME',
240
+ 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined', 'health-check' ) ),
241
+ 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
242
+ ),
243
+ 'WP_SITEURL' => array(
244
+ 'label' => 'WP_SITEURL',
245
+ 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined', 'health-check' ) ),
246
+ 'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
247
+ ),
248
+ 'WP_CONTENT_DIR' => array(
249
+ 'label' => 'WP_CONTENT_DIR',
250
+ 'value' => WP_CONTENT_DIR,
251
+ ),
252
+ 'WP_PLUGIN_DIR' => array(
253
+ 'label' => 'WP_PLUGIN_DIR',
254
+ 'value' => WP_PLUGIN_DIR,
255
+ ),
256
+ 'WP_MAX_MEMORY_LIMIT' => array(
257
+ 'label' => 'WP_MAX_MEMORY_LIMIT',
258
+ 'value' => WP_MAX_MEMORY_LIMIT,
259
+ ),
260
+ 'WP_DEBUG' => array(
261
+ 'label' => 'WP_DEBUG',
262
+ 'value' => WP_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
263
+ 'debug' => WP_DEBUG,
264
+ ),
265
+ 'WP_DEBUG_DISPLAY' => array(
266
+ 'label' => 'WP_DEBUG_DISPLAY',
267
+ 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
268
+ 'debug' => WP_DEBUG_DISPLAY,
269
+ ),
270
+ 'WP_DEBUG_LOG' => array(
271
+ 'label' => 'WP_DEBUG_LOG',
272
+ 'value' => $wp_debug_log_value,
273
+ 'debug' => WP_DEBUG_LOG,
274
+ ),
275
+ 'SCRIPT_DEBUG' => array(
276
+ 'label' => 'SCRIPT_DEBUG',
277
+ 'value' => SCRIPT_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
278
+ 'debug' => SCRIPT_DEBUG,
279
+ ),
280
+ 'WP_CACHE' => array(
281
+ 'label' => 'WP_CACHE',
282
+ 'value' => WP_CACHE ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
283
+ 'debug' => WP_CACHE,
284
+ ),
285
+ 'CONCATENATE_SCRIPTS' => array(
286
+ 'label' => 'CONCATENATE_SCRIPTS',
287
+ 'value' => $concatenate_scripts,
288
+ 'debug' => $concatenate_scripts_debug,
289
+ ),
290
+ 'COMPRESS_SCRIPTS' => array(
291
+ 'label' => 'COMPRESS_SCRIPTS',
292
+ 'value' => $compress_scripts,
293
+ 'debug' => $compress_scripts_debug,
294
+ ),
295
+ 'COMPRESS_CSS' => array(
296
+ 'label' => 'COMPRESS_CSS',
297
+ 'value' => $compress_css,
298
+ 'debug' => $compress_css_debug,
299
+ ),
300
+ 'WP_LOCAL_DEV' => array(
301
+ 'label' => 'WP_LOCAL_DEV',
302
+ 'value' => $wp_local_dev,
303
+ 'debug' => $wp_local_dev_debug,
304
  ),
305
  ),
306
+ );
307
+
308
+ $is_writable_abspath = wp_is_writable( ABSPATH );
309
+ $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR );
310
+ $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] );
311
+ $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR );
312
+ $is_writable_template_directory = wp_is_writable( get_template_directory() . '/..' );
313
+
314
+ $info['wp-filesystem'] = array(
315
+ 'label' => __( 'Filesystem Permissions', 'health-check' ),
316
+ 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.', 'health-check' ),
317
+ 'fields' => array(
318
+ 'wordpress' => array(
319
+ 'label' => __( 'The main WordPress directory', 'health-check' ),
320
+ 'value' => ( $is_writable_abspath ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
321
+ 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
322
+ ),
323
+ 'wp-content' => array(
324
+ 'label' => __( 'The wp-content directory', 'health-check' ),
325
+ 'value' => ( $is_writable_wp_content_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
326
+ 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
327
+ ),
328
+ 'uploads' => array(
329
+ 'label' => __( 'The uploads directory', 'health-check' ),
330
+ 'value' => ( $is_writable_upload_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
331
+ 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
332
+ ),
333
+ 'plugins' => array(
334
+ 'label' => __( 'The plugins directory', 'health-check' ),
335
+ 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
336
+ 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
337
+ ),
338
+ 'themes' => array(
339
+ 'label' => __( 'The themes directory', 'health-check' ),
340
+ 'value' => ( $is_writable_template_directory ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
341
+ 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
342
  ),
343
  ),
344
  );
345
 
346
+ // Conditionally add debug information for multisite setups.
347
  if ( is_multisite() ) {
348
  $network_query = new WP_Network_Query();
349
+ $network_ids = $network_query->query(
350
+ array(
351
+ 'fields' => 'ids',
352
+ 'number' => 100,
353
+ 'no_found_rows' => false,
354
+ )
355
+ );
356
 
357
  $site_count = 0;
358
  foreach ( $network_ids as $network_id ) {
359
  $site_count += get_blog_count( $network_id );
360
  }
361
 
362
+ $info['wp-core']['fields']['user_count'] = array(
363
+ 'label' => __( 'User count', 'health-check' ),
364
  'value' => get_user_count(),
365
  );
366
+
367
+ $info['wp-core']['fields']['site_count'] = array(
368
+ 'label' => __( 'Site count', 'health-check' ),
369
  'value' => $site_count,
370
  );
371
+
372
+ $info['wp-core']['fields']['network_count'] = array(
373
+ 'label' => __( 'Network count', 'health-check' ),
374
  'value' => $network_query->found_networks,
375
  );
376
  } else {
377
  $user_count = count_users();
378
 
379
+ $info['wp-core']['fields']['user_count'] = array(
380
+ 'label' => __( 'User count', 'health-check' ),
381
  'value' => $user_count['total_users'],
382
  );
383
  }
384
 
385
  // WordPress features requiring processing.
386
+ $wp_dotorg = wp_remote_get( 'https://api.wordpress.org', array( 'timeout' => 10 ) );
387
+
 
388
  if ( ! is_wp_error( $wp_dotorg ) ) {
389
+ $info['wp-core']['fields']['dotorg_communication'] = array(
390
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
391
+ 'value' => __( 'WordPress.org is reachable', 'health-check' ),
392
+ 'debug' => 'true',
 
393
  );
394
  } else {
395
+ $info['wp-core']['fields']['dotorg_communication'] = array(
396
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
397
  'value' => sprintf(
398
+ // translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup.
399
  __( 'Unable to reach WordPress.org at %1$s: %2$s', 'health-check' ),
400
+ gethostbyname( 'api.wordpress.org' ),
401
  $wp_dotorg->get_error_message()
402
  ),
403
+ 'debug' => $wp_dotorg->get_error_message(),
404
  );
405
  }
406
 
407
+ // Remove accordion for Directories and Sizes if in Multisite.
408
+ if ( ! $is_multisite ) {
409
+ $loading = __( 'Loading&hellip;', 'health-check' );
410
+
411
+ $info['wp-paths-sizes']['fields'] = array(
412
+ 'wordpress_path' => array(
413
+ 'label' => __( 'WordPress directory location', 'health-check' ),
414
+ 'value' => untrailingslashit( ABSPATH ),
415
+ ),
416
+ 'wordpress_size' => array(
417
+ 'label' => __( 'WordPress directory size', 'health-check' ),
418
+ 'value' => $loading,
419
+ 'debug' => 'loading...',
420
+ ),
421
+ 'uploads_path' => array(
422
+ 'label' => __( 'Uploads directory location', 'health-check' ),
423
+ 'value' => $upload_dir['basedir'],
424
+ ),
425
+ 'uploads_size' => array(
426
+ 'label' => __( 'Uploads directory size', 'health-check' ),
427
+ 'value' => $loading,
428
+ 'debug' => 'loading...',
429
+ ),
430
+ 'themes_path' => array(
431
+ 'label' => __( 'Themes directory location', 'health-check' ),
432
+ 'value' => get_theme_root(),
433
+ ),
434
+ 'themes_size' => array(
435
+ 'label' => __( 'Themes directory size', 'health-check' ),
436
+ 'value' => $loading,
437
+ 'debug' => 'loading...',
438
+ ),
439
+ 'plugins_path' => array(
440
+ 'label' => __( 'Plugins directory location', 'health-check' ),
441
+ 'value' => WP_PLUGIN_DIR,
442
+ ),
443
+ 'plugins_size' => array(
444
+ 'label' => __( 'Plugins directory size', 'health-check' ),
445
+ 'value' => $loading,
446
+ 'debug' => 'loading...',
447
+ ),
448
+ 'database_size' => array(
449
+ 'label' => __( 'Database size', 'health-check' ),
450
+ 'value' => $loading,
451
+ 'debug' => 'loading...',
452
+ ),
453
+ 'total_size' => array(
454
+ 'label' => __( 'Total installation size', 'health-check' ),
455
+ 'value' => $loading,
456
+ 'debug' => 'loading...',
457
+ ),
458
+ );
459
+ }
460
+
461
+ // Get a list of all drop-in replacements.
462
+ $dropins = get_dropins();
463
+
464
+ // Get dropins descriptions.
465
+ $dropin_descriptions = _get_dropins();
466
+
467
+ // Spare few function calls.
468
+ $not_available = __( 'Not available', 'health-check' );
469
 
 
 
 
470
  foreach ( $dropins as $dropin_key => $dropin ) {
471
+ $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
472
  'label' => $dropin_key,
473
+ 'value' => $dropin_descriptions[ $dropin_key ][0],
474
+ 'debug' => 'true',
475
  );
476
  }
477
 
478
  // Populate the media fields.
479
+ $info['wp-media']['fields']['image_editor'] = array(
480
  'label' => __( 'Active editor', 'health-check' ),
481
  'value' => _wp_image_editor_choose(),
482
  );
487
  $imagick = new Imagick();
488
  $imagick_version = $imagick->getVersion();
489
  } else {
490
+ $imagick_version = __( 'Not available', 'health-check' );
491
  }
492
+
493
+ $info['wp-media']['fields']['imagick_module_version'] = array(
494
+ 'label' => __( 'ImageMagick version number', 'health-check' ),
495
  'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
496
  );
497
+
498
+ $info['wp-media']['fields']['imagemagick_version'] = array(
499
+ 'label' => __( 'ImageMagick version string', 'health-check' ),
500
  'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
501
  );
502
 
503
  // If Imagick is used as our editor, provide some more information about its limitations.
504
  if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
505
  $limits = array(
506
+ 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
507
+ 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
508
+ 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
509
+ 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
510
+ 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
511
+ 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
512
+ );
513
+
514
+ $limits_debug = array(
515
+ 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
516
+ 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
517
+ 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
518
+ 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
519
+ 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
520
+ 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
521
  );
522
 
523
+ $info['wp-media']['fields']['imagick_limits'] = array(
524
  'label' => __( 'Imagick Resource Limits', 'health-check' ),
525
  'value' => $limits,
526
+ 'debug' => $limits_debug,
527
  );
528
  }
529
 
533
  } else {
534
  $gd = false;
535
  }
536
+
537
+ $info['wp-media']['fields']['gd_version'] = array(
538
+ 'label' => __( 'GD version', 'health-check' ),
539
+ 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
540
+ 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
541
  );
542
 
543
  // Get Ghostscript information, if available.
544
  if ( function_exists( 'exec' ) ) {
545
  $gs = exec( 'gs --version' );
546
+
547
+ if ( empty( $gs ) ) {
548
+ $gs = $not_available;
549
+ $gs_debug = 'not available';
550
+ } else {
551
+ $gs_debug = $gs;
552
+ }
553
  } else {
554
+ $gs = __( 'Unable to determine if Ghostscript is installed', 'health-check' );
555
+ $gs_debug = 'unknown';
556
  }
557
+
558
+ $info['wp-media']['fields']['ghostscript_version'] = array(
559
+ 'label' => __( 'Ghostscript version', 'health-check' ),
560
  'value' => $gs,
561
+ 'debug' => $gs_debug,
562
  );
563
 
564
  // Populate the server debug fields.
565
+ if ( function_exists( 'php_uname' ) ) {
566
+ $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
567
+ } else {
568
+ $server_architecture = 'unknown';
569
+ }
570
+
571
+ if ( function_exists( 'phpversion' ) ) {
572
+ $php_version_debug = phpversion();
573
+ // Whether PHP supports 64bit
574
+ $php64bit = ( PHP_INT_SIZE * 8 === 64 );
575
+
576
+ $php_version = sprintf(
577
+ '%s %s',
578
+ $php_version_debug,
579
+ ( $php64bit ? __( '(Supports 64bit values)', 'health-check' ) : __( '(Does not support 64bit values)', 'health-check' ) )
580
+ );
581
+
582
+ if ( $php64bit ) {
583
+ $php_version_debug .= ' 64bit';
584
+ }
585
+ } else {
586
+ $php_version = __( 'Unable to determine PHP version', 'health-check' );
587
+ $php_version_debug = 'unknown';
588
+ }
589
+
590
+ if ( function_exists( 'php_sapi_name' ) ) {
591
+ $php_sapi = php_sapi_name();
592
+ } else {
593
+ $php_sapi = 'unknown';
594
+ }
595
+
596
+ $info['wp-server']['fields']['server_architecture'] = array(
597
  'label' => __( 'Server architecture', 'health-check' ),
598
+ 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture', 'health-check' ) ),
599
+ 'debug' => $server_architecture,
600
  );
601
+ $info['wp-server']['fields']['httpd_software'] = array(
602
+ 'label' => __( 'Web server', 'health-check' ),
603
  'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used', 'health-check' ) ),
604
+ 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
605
  );
606
+ $info['wp-server']['fields']['php_version'] = array(
607
+ 'label' => __( 'PHP version', 'health-check' ),
608
+ 'value' => $php_version,
609
+ 'debug' => $php_version_debug,
 
 
 
 
610
  );
611
+ $info['wp-server']['fields']['php_sapi'] = array(
612
  'label' => __( 'PHP SAPI', 'health-check' ),
613
+ 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI', 'health-check' ) ),
614
+ 'debug' => $php_sapi,
615
  );
616
 
617
+ // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
618
  if ( ! function_exists( 'ini_get' ) ) {
619
+ $info['wp-server']['fields']['ini_get'] = array(
620
  'label' => __( 'Server settings', 'health-check' ),
621
+ 'value' => __( 'Unable to determine some settings, as the ini_get() function has been disabled.', 'health-check' ),
622
+ 'debug' => 'ini_get() is disabled',
623
  );
624
  } else {
625
+ $info['wp-server']['fields']['max_input_variables'] = array(
626
  'label' => __( 'PHP max input variables', 'health-check' ),
627
  'value' => ini_get( 'max_input_vars' ),
628
  );
629
+ $info['wp-server']['fields']['time_limit'] = array(
630
  'label' => __( 'PHP time limit', 'health-check' ),
631
  'value' => ini_get( 'max_execution_time' ),
632
  );
633
+ $info['wp-server']['fields']['memory_limit'] = array(
634
  'label' => __( 'PHP memory limit', 'health-check' ),
635
  'value' => ini_get( 'memory_limit' ),
636
  );
637
+ $info['wp-server']['fields']['max_input_time'] = array(
638
  'label' => __( 'Max input time', 'health-check' ),
639
  'value' => ini_get( 'max_input_time' ),
640
  );
641
+ $info['wp-server']['fields']['upload_max_size'] = array(
642
  'label' => __( 'Upload max filesize', 'health-check' ),
643
  'value' => ini_get( 'upload_max_filesize' ),
644
  );
645
+ $info['wp-server']['fields']['php_post_max_size'] = array(
646
  'label' => __( 'PHP post max size', 'health-check' ),
647
  'value' => ini_get( 'post_max_size' ),
648
  );
649
  }
650
 
651
  if ( function_exists( 'curl_version' ) ) {
652
+ $curl = curl_version();
653
+
654
+ $info['wp-server']['fields']['curl_version'] = array(
655
+ 'label' => __( 'cURL version', 'health-check' ),
656
  'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
657
  );
658
  } else {
659
+ $info['wp-server']['fields']['curl_version'] = array(
660
+ 'label' => __( 'cURL version', 'health-check' ),
661
+ 'value' => $not_available,
662
+ 'debug' => 'not available',
663
  );
664
  }
665
 
666
+ // SUHOSIN
667
+ $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
668
+
669
+ $info['wp-server']['fields']['suhosin'] = array(
670
+ 'label' => __( 'Is SUHOSIN installed?', 'health-check' ),
671
+ 'value' => ( $suhosin_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
672
+ 'debug' => $suhosin_loaded,
673
  );
674
 
675
+ // Imagick
676
+ $imagick_loaded = extension_loaded( 'imagick' );
677
+
678
+ $info['wp-server']['fields']['imagick_availability'] = array(
679
+ 'label' => __( 'Is the Imagick library available?', 'health-check' ),
680
+ 'value' => ( $imagick_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
681
+ 'debug' => $imagick_loaded,
682
  );
683
 
684
  // Check if a .htaccess file exists.
685
+ if ( is_file( ABSPATH . '.htaccess' ) ) {
686
  // If the file exists, grab the content of it.
687
+ $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
688
 
689
  // Filter away the core WordPress rules.
690
  $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
691
+ $filtered_htaccess_content = ! empty( $filtered_htaccess_content );
692
 
693
+ $info['wp-server']['fields']['htaccess_extra_rules'] = array(
694
+ 'label' => __( '.htaccess rules', 'health-check' ),
695
+ 'value' => ( $filtered_htaccess_content ? __( 'Custom rules have been added to your .htaccess file.', 'health-check' ) : __( 'Your .htaccess file contains only core WordPress features.', 'health-check' ) ),
696
+ 'debug' => $filtered_htaccess_content,
697
  );
698
  }
699
 
709
  $extension = null;
710
  }
711
 
712
+ /*
713
+ * Check what database engine is used, this will throw compatibility
714
+ * warnings from PHP compatibility testers, but `mysql_*` is
715
+ * still valid in PHP 5.6, so we need to account for that.
716
+ */
717
  if ( method_exists( $wpdb, 'db_version' ) ) {
718
  if ( $wpdb->use_mysqli ) {
719
  // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info
737
  }
738
  }
739
 
740
+ $info['wp-database']['fields']['extension'] = array(
741
  'label' => __( 'Extension', 'health-check' ),
742
  'value' => $extension,
743
  );
744
+
745
+ $info['wp-database']['fields']['server_version'] = array(
746
  'label' => __( 'Server version', 'health-check' ),
747
  'value' => $server,
748
  );
749
+
750
+ $info['wp-database']['fields']['client_version'] = array(
751
  'label' => __( 'Client version', 'health-check' ),
752
  'value' => $client_version,
753
  );
754
+
755
+ $info['wp-database']['fields']['database_user'] = array(
756
  'label' => __( 'Database user', 'health-check' ),
757
  'value' => $wpdb->dbuser,
758
  'private' => true,
759
  );
760
+
761
+ $info['wp-database']['fields']['database_host'] = array(
762
  'label' => __( 'Database host', 'health-check' ),
763
  'value' => $wpdb->dbhost,
764
  'private' => true,
765
  );
766
+
767
+ $info['wp-database']['fields']['database_name'] = array(
768
  'label' => __( 'Database name', 'health-check' ),
769
  'value' => $wpdb->dbname,
770
  'private' => true,
771
  );
772
+
773
+ $info['wp-database']['fields']['database_prefix'] = array(
774
+ 'label' => __( 'Database prefix', 'health-check' ),
775
+ 'value' => $wpdb->prefix,
776
+ 'private' => true,
777
  );
778
 
779
  // List must use plugins if there are any.
783
  $plugin_version = $plugin['Version'];
784
  $plugin_author = $plugin['Author'];
785
 
786
+ $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
787
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
788
 
789
  if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
790
+ // translators: 1: Plugin version number. 2: Plugin author name.
791
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
792
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
793
+ } else {
794
+ if ( ! empty( $plugin_author ) ) {
795
+ // translators: %s: Plugin author name.
796
+ $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
797
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
798
+ }
799
+
800
+ if ( ! empty( $plugin_version ) ) {
801
+ // translators: %s: Plugin version number.
802
+ $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
803
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
804
+ }
805
  }
806
 
807
+ $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
808
  'label' => $plugin['Name'],
809
  'value' => $plugin_version_string,
810
+ 'debug' => $plugin_version_string_debug,
811
  );
812
  }
813
 
821
  $plugin_version = $plugin['Version'];
822
  $plugin_author = $plugin['Author'];
823
 
824
+ $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
825
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
826
 
827
  if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
828
+ // translators: 1: Plugin version number. 2: Plugin author name.
829
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
830
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
831
+ } else {
832
+ if ( ! empty( $plugin_author ) ) {
833
+ // translators: %s: Plugin author name.
834
+ $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
835
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
836
+ }
837
+
838
+ if ( ! empty( $plugin_version ) ) {
839
+ // translators: %s: Plugin version number.
840
+ $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
841
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
842
+ }
843
  }
844
 
845
  if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
846
  // translators: %s: Latest plugin version number.
847
+ $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $plugin_updates[ $plugin_path ]->update->new_version );
848
+ $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
 
849
  }
850
 
851
+ $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
852
  'label' => $plugin['Name'],
853
+ 'value' => $plugin_version_string,
854
+ 'debug' => $plugin_version_string_debug,
855
  );
856
  }
857
 
858
  // Populate the section for the currently active theme.
859
  global $_wp_theme_features;
860
  $theme_features = array();
861
+
862
  if ( ! empty( $_wp_theme_features ) ) {
863
  foreach ( $_wp_theme_features as $feature => $options ) {
864
  $theme_features[] = $feature;
868
  $active_theme = wp_get_theme();
869
  $theme_updates = get_theme_updates();
870
 
871
+ // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
872
+ $active_theme_version = $active_theme->Version;
873
+ $active_theme_version_debug = $active_theme_version;
874
+
875
  if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
876
+ $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
877
+
878
  // translators: %s: Latest theme version number.
879
+ $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_update_new_version );
880
+ $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
 
881
  }
882
 
883
+ $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' );
884
+
885
  $info['wp-active-theme']['fields'] = array(
886
+ 'name' => array(
887
  'label' => __( 'Name', 'health-check' ),
888
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
889
  'value' => $active_theme->Name,
890
  ),
891
+ 'version' => array(
892
  'label' => __( 'Version', 'health-check' ),
893
+ 'value' => $active_theme_version,
894
+ 'debug' => $active_theme_version_debug,
895
  ),
896
+ 'author' => array(
897
  'label' => __( 'Author', 'health-check' ),
898
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
899
  'value' => wp_kses( $active_theme->Author, array() ),
900
  ),
901
+ 'author_website' => array(
902
  'label' => __( 'Author website', 'health-check' ),
903
+ 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined', 'health-check' ) ),
904
+ 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
905
  ),
906
+ 'parent_theme' => array(
907
  'label' => __( 'Parent theme', 'health-check' ),
908
+ 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme : __( 'None', 'health-check' ) ),
909
+ 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme : 'none' ),
910
  ),
911
+ 'theme_features' => array(
912
+ 'label' => __( 'Theme features', 'health-check' ),
913
  'value' => implode( ', ', $theme_features ),
914
  ),
915
+ 'theme_path' => array(
916
+ 'label' => __( 'Theme directory location', 'health-check' ),
917
+ 'value' => get_template_directory(),
918
+ ),
919
  );
920
 
921
  // Populate a list of all themes available in the install.
923
 
924
  foreach ( $all_themes as $theme_slug => $theme ) {
925
  // Ignore the currently active theme from the list of all themes.
926
+ if ( $active_theme->stylesheet === $theme_slug ) {
927
  continue;
928
  }
929
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
931
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
932
  $theme_author = $theme->Author;
933
 
934
+ // Sanitize
935
+ $theme_author = wp_kses( $theme_author, array() );
936
+
937
+ $theme_version_string = __( 'No version or author information is available.', 'health-check' );
938
+ $theme_version_string_debug = 'undefined';
939
 
940
  if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
941
+ // translators: 1: Theme version number. 2: Theme author name.
942
+ $theme_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $theme_version, $theme_author );
943
+ $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
944
+ } else {
945
+ if ( ! empty( $theme_author ) ) {
946
+ // translators: %s: Theme author name.
947
+ $theme_version_string = sprintf( __( 'By %s', 'health-check' ), $theme_author );
948
+ $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
949
+ }
950
+
951
+ if ( ! empty( $theme_version ) ) {
952
+ // translators: %s: Theme version number.
953
+ $theme_version_string = sprintf( __( 'Version %s', 'health-check' ), $theme_version );
954
+ $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
955
+ }
956
  }
957
 
958
  if ( array_key_exists( $theme_slug, $theme_updates ) ) {
959
  // translators: %s: Latest theme version number.
960
+ $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_updates[ $theme_slug ]->update['new_version'] );
961
+ $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
 
962
  }
963
 
964
+ // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
965
+ $info['wp-themes']['fields'][ sanitize_text_field( $theme->Name ) ] = array(
966
  'label' => sprintf(
967
+ // translators: 1: Theme name. 2: Theme slug.
968
  __( '%1$s (%2$s)', 'health-check' ),
969
  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
970
  $theme->Name,
971
  $theme_slug
972
  ),
973
+ 'value' => $theme_version_string,
974
+ 'debug' => $theme_version_string_debug,
975
  );
976
  }
977
 
978
  // Add more filesystem checks
979
  if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
980
+ $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
981
+
982
+ $info['wp-filesystem']['fields']['mu-plugins'] = array(
983
+ 'label' => __( 'The must use plugins directory', 'health-check' ),
984
+ 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
985
+ 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
986
  );
987
  }
988
 
 
 
989
  /**
990
+ * Add or modify the debug information.
991
  *
992
+ * Plugin or themes may wish to introduce their own debug information without creating additional admin pages
993
+ * they can utilize this filter to introduce their own sections or add more data to existing sections.
994
  *
995
+ * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as
996
+ * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels
997
+ * for the copied data.
998
  *
999
+ * All strings are expected to be plain text except $description that can contain inline HTML tags (see below).
 
1000
  *
1001
+ * @since 5.2.0
1002
  *
1003
  * @param array $args {
1004
  * The debug information to be added to the core information page.
1005
  *
1006
+ * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections.
1007
+ * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be
1008
+ * another associative array of name/value pairs when there is more structured data to display.
1009
+ *
1010
  * @type string $label The title for this section of the debug output.
1011
  * @type string $description Optional. A description for your information section which may contain basic HTML
1012
+ * markup, inline tags only as it is outputted in a paragraph.
1013
  * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
1014
  * this section.
1015
  * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
1016
+ * from the copied data.
1017
  * @type array $fields {
1018
  * An associative array containing the data to be displayed.
1019
  *
1020
  * @type string $label The label for this piece of information.
1021
+ * @type string $value The output that is displayed for this field. Text should be translated. Can be
1022
+ * an associative array that is displayed as name/value pairs.
1023
+ * @type string $debug Optional. The output that is used for this field when the user copies the data.
1024
+ * It should be more concise and not translated. If not set, the content of `$value` is used.
1025
+ * Note that the array keys are used as labels for the copied data.
1026
+ * @type boolean $private Optional. If set to `true` the field will not be included in the copied data
1027
+ * allowing you to show, for example, API keys here.
1028
  * }
1029
  * }
1030
  */
1031
+ $info = apply_filters( 'debug_information', $info );
 
 
 
 
 
 
 
 
 
 
1032
 
1033
  return $info;
1034
  }
1035
 
1036
  /**
1037
+ * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
 
1038
  *
1039
+ * @since 5.2.0
1040
  *
1041
+ * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
1042
+ * @param string $type The data type to return, either 'info' or 'debug'.
1043
+ * @return string The formatted data.
1044
  */
1045
+ public static function format( $info_array, $type ) {
1046
+ $return = "`\n";
1047
 
1048
  foreach ( $info_array as $section => $details ) {
1049
  // Skip this section if there are no fields, or the section has been declared as private.
1051
  continue;
1052
  }
1053
 
1054
+ $section_label = 'debug' === $type ? $section : $details['label'];
1055
+
1056
+ $return .= sprintf(
1057
  "### %s%s ###\n\n",
1058
+ $section_label,
1059
  ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
1060
  );
1061
 
1062
+ foreach ( $details['fields'] as $field_name => $field ) {
1063
  if ( isset( $field['private'] ) && true === $field['private'] ) {
1064
  continue;
1065
  }
1066
 
1067
+ if ( 'debug' === $type && isset( $field['debug'] ) ) {
1068
+ $debug_data = $field['debug'];
1069
+ } else {
1070
+ $debug_data = $field['value'];
1071
+ }
1072
+
1073
+ // Can be array, one level deep only.
1074
+ if ( is_array( $debug_data ) ) {
1075
+ $value = '';
1076
 
1077
+ foreach ( $debug_data as $sub_field_name => $sub_field_value ) {
1078
+ $value .= sprintf( "\n\t%s: %s", $sub_field_name, $sub_field_value );
 
 
 
 
1079
  }
1080
+ } elseif ( is_bool( $debug_data ) ) {
1081
+ $value = $debug_data ? 'true' : 'false';
1082
+ } elseif ( empty( $debug_data ) && '0' !== $debug_data ) {
1083
+ $value = 'undefined';
1084
+ } else {
1085
+ $value = $debug_data;
1086
+ }
1087
+
1088
+ if ( 'debug' === $type ) {
1089
+ $label = $field_name;
1090
+ } else {
1091
+ $label = $field['label'];
1092
  }
1093
 
1094
+ $return .= sprintf( "%s: %s\n", $label, $value );
 
 
 
 
1095
  }
1096
+
1097
+ $return .= "\n";
1098
  }
 
 
1099
 
1100
+ $return .= '`';
 
1101
 
1102
+ return $return;
1103
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1104
 
1105
+ /**
1106
+ * Fetch the total size of all the database tables for the active database user.
1107
+ *
1108
+ * @since 5.2.0
1109
+ *
1110
+ * @return int The size of the database, in bytes.
1111
+ */
1112
+ public static function get_database_size() {
1113
+ global $wpdb;
1114
+ $size = 0;
1115
+ $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
1116
 
1117
+ if ( $wpdb->num_rows > 0 ) {
1118
+ foreach ( $rows as $row ) {
1119
+ $size += $row['Data_length'] + $row['Index_length'];
 
 
1120
  }
1121
  }
1122
 
1123
+ return (int) $size;
1124
+ }
1125
 
1126
+ /**
1127
+ * Fetch the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.
1128
+ * Intended to supplement the array returned by `WP_Debug_Data::debug_data()`.
1129
+ *
1130
+ * @since 5.2.0
1131
+ *
1132
+ * @return array The sizes of the directories, also the database size and total installation size.
1133
+ */
1134
+ public static function get_sizes() {
1135
+ $size_db = self::get_database_size();
1136
+ $upload_dir = wp_get_upload_dir();
1137
+
1138
+ /*
1139
+ * We will be using the PHP max execution time to prevent the size calculations
1140
+ * from causing a timeout. The default value is 30 seconds, and some
1141
+ * hosts do not allow you to read configuration values.
1142
+ */
1143
+ if ( function_exists( 'ini_get' ) ) {
1144
+ $max_execution_time = ini_get( 'max_execution_time' );
1145
+ }
1146
 
1147
+ // The max_execution_time defaults to 0 when PHP runs from cli.
1148
+ // We still want to limit it below.
1149
+ if ( empty( $max_execution_time ) ) {
1150
+ $max_execution_time = 30;
1151
+ }
1152
+
1153
+ if ( $max_execution_time > 20 ) {
1154
+ // If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent
1155
+ // edge-case timeouts that may happen after the size loop has finished running.
1156
+ $max_execution_time -= 2;
1157
+ }
1158
+
1159
+ // Go through the various installation directories and calculate their sizes.
1160
+ // No trailing slashes.
1161
+ $paths = array(
1162
+ 'wordpress_size' => untrailingslashit( ABSPATH ),
1163
+ 'themes_size' => get_theme_root(),
1164
+ 'plugins_size' => WP_PLUGIN_DIR,
1165
+ 'uploads_size' => $upload_dir['basedir'],
 
 
 
 
 
 
 
 
 
 
1166
  );
1167
 
1168
+ $exclude = $paths;
1169
+ unset( $exclude['wordpress_size'] );
1170
+ $exclude = array_values( $exclude );
1171
 
1172
+ $size_total = 0;
1173
+ $all_sizes = array();
1174
 
1175
+ // Loop over all the directories we want to gather the sizes for.
1176
+ foreach ( $paths as $name => $path ) {
1177
+ $dir_size = null; // Default to timeout.
1178
+ $results = array(
1179
+ 'path' => $path,
1180
+ 'raw' => 0,
1181
+ );
1182
 
1183
+ if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
1184
+ if ( 'wordpress_size' === $name ) {
1185
+ $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
1186
+ } else {
1187
+ $dir_size = recurse_dirsize( $path, null, $max_execution_time );
1188
+ }
1189
+ }
1190
 
1191
+ if ( false === $dir_size ) {
1192
+ // Error reading.
1193
+ $results['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.', 'health-check' );
1194
+ $results['debug'] = 'not accessible';
1195
 
1196
+ // Stop total size calculation.
1197
+ $size_total = null;
1198
+ } elseif ( null === $dir_size ) {
1199
+ // Timeout.
1200
+ $results['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.', 'health-check' );
1201
+ $results['debug'] = 'timeout while calculating size';
1202
+
1203
+ // Stop total size calculation.
1204
+ $size_total = null;
1205
+ } else {
1206
+ if ( null !== $size_total ) {
1207
+ $size_total += $dir_size;
1208
+ }
1209
+
1210
+ $results['raw'] = $dir_size;
1211
+ $results['size'] = size_format( $dir_size, 2 );
1212
+ $results['debug'] = $results['size'] . " ({$dir_size} bytes)";
1213
  }
1214
+
1215
+ $all_sizes[ $name ] = $results;
1216
+ }
1217
+
1218
+ if ( $size_db > 0 ) {
1219
+ $database_size = size_format( $size_db, 2 );
1220
+
1221
+ $all_sizes['database_size'] = array(
1222
+ 'raw' => $size_db,
1223
+ 'size' => $database_size,
1224
+ 'debug' => $database_size . " ({$size_db} bytes)",
1225
+ );
1226
+ } else {
1227
+ $all_sizes['database_size'] = array(
1228
+ 'size' => __( 'Not available', 'health-check' ),
1229
+ 'debug' => 'not available',
1230
+ );
1231
+ }
1232
+
1233
+ if ( null !== $size_total && $size_db > 0 ) {
1234
+ $total_size = $size_total + $size_db;
1235
+ $total_size_mb = size_format( $total_size, 2 );
1236
+
1237
+ $all_sizes['total_size'] = array(
1238
+ 'raw' => $total_size,
1239
+ 'size' => $total_size_mb,
1240
+ 'debug' => $total_size_mb . " ({$total_size} bytes)",
1241
+ );
1242
+ } else {
1243
+ $all_sizes['total_size'] = array(
1244
+ 'size' => __( 'Total size is not available. Some errors were encountered when determining the size of your installation.', 'health-check' ),
1245
+ 'debug' => 'not available',
1246
+ );
1247
  }
1248
 
1249
+ return $all_sizes;
1250
  }
1251
  }
includes/class-health-check-files-integrity.php CHANGED
@@ -6,6 +6,11 @@
6
  * @package Health Check
7
  */
8
 
 
 
 
 
 
9
  /**
10
  * Class Files_Integrity
11
  */
@@ -28,18 +33,18 @@ class Health_Check_Files_Integrity {
28
  }
29
 
30
  /**
31
- * Calls the WordPress API on the checksums endpoint
32
- *
33
- * @uses get_bloginfo()
34
- * @uses get_locale()
35
- * @uses ABSPATH
36
- * @uses wp_remote_get()
37
- * @uses get_bloginfo()
38
- * @uses strpos()
39
- * @uses unset()
40
- *
41
- * @return array
42
- */
43
  static function call_checksum_api() {
44
  // Setup variables.
45
  $wpversion = get_bloginfo( 'version' );
@@ -64,16 +69,16 @@ class Health_Check_Files_Integrity {
64
  }
65
 
66
  /**
67
- * Parses the results from the WordPress API call
68
- *
69
- * @uses file_exists()
70
- * @uses md5_file()
71
- * @uses ABSPATH
72
- *
73
- * @param array $checksums
74
- *
75
- * @return array
76
- */
77
  static function parse_checksum_results( $checksums ) {
78
  $filepath = ABSPATH;
79
  $files = array();
@@ -92,16 +97,16 @@ class Health_Check_Files_Integrity {
92
  }
93
 
94
  /**
95
- * Generates the response
96
- *
97
- * @uses wp_send_json_success()
98
- * @uses wp_die()
99
- * @uses ABSPATH
100
- *
101
- * @param null|array $files
102
- *
103
- * @return void
104
- */
105
  static function create_the_response( $files ) {
106
  $filepath = ABSPATH;
107
  $output = '';
@@ -129,7 +134,7 @@ class Health_Check_Files_Integrity {
129
  $output .= '</td></tr></tfoot><tbody>';
130
  foreach ( $files as $tampered ) {
131
  $output .= '<tr>';
132
- $output .= '<td><span class="error"></span></td>';
133
  $output .= '<td>' . $filepath . $tampered[0] . '</td>';
134
  $output .= '<td>' . $tampered[1] . '</td>';
135
  $output .= '</tr>';
@@ -148,24 +153,24 @@ class Health_Check_Files_Integrity {
148
  }
149
 
150
  /**
151
- * Generates Diff view
152
- *
153
- * @uses get_bloginfo()
154
- * @uses wp_remote_get()
155
- * @uses wp_remote_retrieve_body()
156
- * @uses wp_send_json_success()
157
- * @uses wp_die()
158
- * @uses ABSPATH
159
- * @uses FILE_USE_INCLUDE_PATH
160
- * @uses wp_text_diff()
161
- *
162
- *
163
- * @return void
164
- */
165
  static function view_file_diff() {
166
  check_ajax_referer( 'health-check-view-file-diff' );
167
 
168
- if ( ! current_user_can( 'manage_options' ) ) {
169
  wp_send_json_error();
170
  }
171
 
@@ -174,7 +179,7 @@ class Health_Check_Files_Integrity {
174
  $wpversion = get_bloginfo( 'version' );
175
 
176
  if ( 0 !== validate_file( $filepath . $file ) ) {
177
- wp_send_json_error( array( 'message' => esc_html__( 'You do not have access to this file.' , 'health-check' ) ) );
178
  }
179
 
180
  $allowed_files = get_transient( 'health-check-checksums' );
@@ -185,7 +190,7 @@ class Health_Check_Files_Integrity {
185
  }
186
 
187
  if ( ! isset( $allowed_files['checksums'][ $file ] ) ) {
188
- wp_send_json_error( array( 'message' => esc_html__( 'You do not have access to this file.' , 'health-check' ) ) );
189
  }
190
 
191
  $local_file_body = file_get_contents( $filepath . $file, FILE_USE_INCLUDE_PATH );
@@ -221,20 +226,20 @@ class Health_Check_Files_Integrity {
221
  ob_start();
222
  ?>
223
 
224
- <div>
225
- <p>
226
  <?php _e( 'The File Integrity checks all the core files with the <code>checksums</code> provided by the WordPress API to see if they are intact. If there are changes you will be able to make a Diff between the files hosted on WordPress.org and your installation to see what has been changed.', 'health-check' ); ?>
227
- </p>
228
- <form action="#" id="health-check-file-integrity" method="POST">
229
- <p>
230
- <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Check the Files Integrity', 'health-check' ); ?>">
231
- </p>
232
- </form>
233
-
234
- <div id="tools-file-integrity-response-holder">
235
- <span class="spinner"></span>
236
- </div>
237
- </div>
238
 
239
  <?php
240
  $tab_content = ob_get_clean();
6
  * @package Health Check
7
  */
8
 
9
+ // Make sure the file is not directly accessible.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die( 'We\'re sorry, but you can not directly access this file.' );
12
+ }
13
+
14
  /**
15
  * Class Files_Integrity
16
  */
33
  }
34
 
35
  /**
36
+ * Calls the WordPress API on the checksums endpoint
37
+ *
38
+ * @uses get_bloginfo()
39
+ * @uses get_locale()
40
+ * @uses ABSPATH
41
+ * @uses wp_remote_get()
42
+ * @uses get_bloginfo()
43
+ * @uses strpos()
44
+ * @uses unset()
45
+ *
46
+ * @return array
47
+ */
48
  static function call_checksum_api() {
49
  // Setup variables.
50
  $wpversion = get_bloginfo( 'version' );
69
  }
70
 
71
  /**
72
+ * Parses the results from the WordPress API call
73
+ *
74
+ * @uses file_exists()
75
+ * @uses md5_file()
76
+ * @uses ABSPATH
77
+ *
78
+ * @param array $checksums
79
+ *
80
+ * @return array
81
+ */
82
  static function parse_checksum_results( $checksums ) {
83
  $filepath = ABSPATH;
84
  $files = array();
97
  }
98
 
99
  /**
100
+ * Generates the response
101
+ *
102
+ * @uses wp_send_json_success()
103
+ * @uses wp_die()
104
+ * @uses ABSPATH
105
+ *
106
+ * @param null|array $files
107
+ *
108
+ * @return void
109
+ */
110
  static function create_the_response( $files ) {
111
  $filepath = ABSPATH;
112
  $output = '';
134
  $output .= '</td></tr></tfoot><tbody>';
135
  foreach ( $files as $tampered ) {
136
  $output .= '<tr>';
137
+ $output .= '<td><span class="error"><span class="screen-reader-text">' . esc_html__( 'Error', 'health-check' ) . '</span></span></td>';
138
  $output .= '<td>' . $filepath . $tampered[0] . '</td>';
139
  $output .= '<td>' . $tampered[1] . '</td>';
140
  $output .= '</tr>';
153
  }
154
 
155
  /**
156
+ * Generates Diff view
157
+ *
158
+ * @uses get_bloginfo()
159
+ * @uses wp_remote_get()
160
+ * @uses wp_remote_retrieve_body()
161
+ * @uses wp_send_json_success()
162
+ * @uses wp_die()
163
+ * @uses ABSPATH
164
+ * @uses FILE_USE_INCLUDE_PATH
165
+ * @uses wp_text_diff()
166
+ *
167
+ *
168
+ * @return void
169
+ */
170
  static function view_file_diff() {
171
  check_ajax_referer( 'health-check-view-file-diff' );
172
 
173
+ if ( ! current_user_can( 'install_plugins' ) ) {
174
  wp_send_json_error();
175
  }
176
 
179
  $wpversion = get_bloginfo( 'version' );
180
 
181
  if ( 0 !== validate_file( $filepath . $file ) ) {
182
+ wp_send_json_error( array( 'message' => esc_html__( 'You do not have access to this file.', 'health-check' ) ) );
183
  }
184
 
185
  $allowed_files = get_transient( 'health-check-checksums' );
190
  }
191
 
192
  if ( ! isset( $allowed_files['checksums'][ $file ] ) ) {
193
+ wp_send_json_error( array( 'message' => esc_html__( 'You do not have access to this file.', 'health-check' ) ) );
194
  }
195
 
196
  $local_file_body = file_get_contents( $filepath . $file, FILE_USE_INCLUDE_PATH );
226
  ob_start();
227
  ?>
228
 
229
+ <div>
230
+ <p>
231
  <?php _e( 'The File Integrity checks all the core files with the <code>checksums</code> provided by the WordPress API to see if they are intact. If there are changes you will be able to make a Diff between the files hosted on WordPress.org and your installation to see what has been changed.', 'health-check' ); ?>
232
+ </p>
233
+ <form action="#" id="health-check-file-integrity" method="POST">
234
+ <p>
235
+ <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Check the Files Integrity', 'health-check' ); ?>">
236
+ </p>
237
+ </form>
238
+
239
+ <div id="tools-file-integrity-response-holder">
240
+ <span class="spinner"></span>
241
+ </div>
242
+ </div>
243
 
244
  <?php
245
  $tab_content = ob_get_clean();
includes/class-health-check-loopback.php CHANGED
@@ -5,6 +5,11 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_Loopback
10
  */
@@ -65,10 +70,10 @@ class Health_Check_Loopback {
65
 
66
  if ( is_wp_error( $r ) ) {
67
  return (object) array(
68
- 'status' => 'error',
69
  'message' => sprintf(
70
  '%s<br>%s',
71
- esc_html__( 'The loopback request to your site failed, this may prevent WP_Cron from working, along with theme and plugin editors.', 'health-check' ),
72
  sprintf(
73
  /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */
74
  esc_html__( 'Error encountered: (%1$d) %2$s', 'health-check' ),
@@ -81,10 +86,10 @@ class Health_Check_Loopback {
81
 
82
  if ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
83
  return (object) array(
84
- 'status' => 'warning',
85
  'message' => sprintf(
86
  /* translators: %d: The HTTP response code returned. */
87
- esc_html__( 'The loopback request returned an unexpected status code, %d, this may affect tools such as WP_Cron, or theme and plugin editors.', 'health-check' ),
88
  wp_remote_retrieve_response_code( $r )
89
  ),
90
  );
@@ -121,7 +126,7 @@ class Health_Check_Loopback {
121
  static function loopback_no_plugins() {
122
  check_ajax_referer( 'health-check-loopback-no-plugins' );
123
 
124
- if ( ! current_user_can( 'manage_options' ) ) {
125
  wp_send_json_error();
126
  }
127
 
@@ -236,7 +241,7 @@ class Health_Check_Loopback {
236
  static function loopback_test_individual_plugins() {
237
  check_ajax_referer( 'health-check-loopback-individual-plugins' );
238
 
239
- if ( ! current_user_can( 'manage_options' ) ) {
240
  wp_send_json_error();
241
  }
242
 
@@ -287,7 +292,7 @@ class Health_Check_Loopback {
287
  static function loopback_test_default_theme() {
288
  check_ajax_referer( 'health-check-loopback-default-theme' );
289
 
290
- if ( ! current_user_can( 'manage_options' ) ) {
291
  wp_send_json_error();
292
  }
293
 
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_Loopback
15
  */
70
 
71
  if ( is_wp_error( $r ) ) {
72
  return (object) array(
73
+ 'status' => 'critical',
74
  'message' => sprintf(
75
  '%s<br>%s',
76
+ esc_html__( 'The loopback request to your site failed, this means features relying on them are not currently working as expected.', 'health-check' ),
77
  sprintf(
78
  /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */
79
  esc_html__( 'Error encountered: (%1$d) %2$s', 'health-check' ),
86
 
87
  if ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
88
  return (object) array(
89
+ 'status' => 'recommended',
90
  'message' => sprintf(
91
  /* translators: %d: The HTTP response code returned. */
92
+ esc_html__( 'The loopback request returned an unexpected http status code, %d, it was not possible to determine if this will prevent features from working as expected.', 'health-check' ),
93
  wp_remote_retrieve_response_code( $r )
94
  ),
95
  );
126
  static function loopback_no_plugins() {
127
  check_ajax_referer( 'health-check-loopback-no-plugins' );
128
 
129
+ if ( ! current_user_can( 'install_plugins' ) ) {
130
  wp_send_json_error();
131
  }
132
 
241
  static function loopback_test_individual_plugins() {
242
  check_ajax_referer( 'health-check-loopback-individual-plugins' );
243
 
244
+ if ( ! current_user_can( 'install_plugins' ) ) {
245
  wp_send_json_error();
246
  }
247
 
292
  static function loopback_test_default_theme() {
293
  check_ajax_referer( 'health-check-loopback-default-theme' );
294
 
295
+ if ( ! current_user_can( 'install_plugins' ) ) {
296
  wp_send_json_error();
297
  }
298
 
includes/class-health-check-mail-check.php CHANGED
@@ -6,6 +6,11 @@
6
  * @package Health Check
7
  */
8
 
 
 
 
 
 
9
  /**
10
  * Class Mail Check
11
  */
@@ -24,7 +29,7 @@ class Health_Check_Mail_Check {
24
  static function run_mail_check() {
25
  check_ajax_referer( 'health-check-mail-check' );
26
 
27
- if ( ! current_user_can( 'manage_options' ) ) {
28
  wp_send_json_error();
29
  }
30
 
@@ -34,8 +39,8 @@ class Health_Check_Mail_Check {
34
  $email_message = sanitize_text_field( $_POST['email_message'] );
35
  $wp_address = get_bloginfo( 'url' );
36
  $wp_name = get_bloginfo( 'name' );
37
- $date = date( 'F j, Y' );
38
- $time = date( 'g:i a' );
39
 
40
  // translators: %s: website url.
41
  $email_subject = sprintf( esc_html__( 'Health Check – Test Message from %s', 'health-check' ), $wp_address );
@@ -46,8 +51,7 @@ class Health_Check_Mail_Check {
46
  $wp_name,
47
  $wp_address,
48
  $date,
49
- $time,
50
- $email_message
51
  );
52
 
53
  if ( ! empty( $email_message ) ) {
@@ -85,7 +89,7 @@ class Health_Check_Mail_Check {
85
  *
86
  * @param array $tabs
87
  *
88
- * return array
89
  */
90
  public static function tools_tab( $tabs ) {
91
  ob_start();
6
  * @package Health Check
7
  */
8
 
9
+ // Make sure the file is not directly accessible.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die( 'We\'re sorry, but you can not directly access this file.' );
12
+ }
13
+
14
  /**
15
  * Class Mail Check
16
  */
29
  static function run_mail_check() {
30
  check_ajax_referer( 'health-check-mail-check' );
31
 
32
+ if ( ! current_user_can( 'install_plugins' ) ) {
33
  wp_send_json_error();
34
  }
35
 
39
  $email_message = sanitize_text_field( $_POST['email_message'] );
40
  $wp_address = get_bloginfo( 'url' );
41
  $wp_name = get_bloginfo( 'name' );
42
+ $date = date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) );
43
+ $time = date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) );
44
 
45
  // translators: %s: website url.
46
  $email_subject = sprintf( esc_html__( 'Health Check – Test Message from %s', 'health-check' ), $wp_address );
51
  $wp_name,
52
  $wp_address,
53
  $date,
54
+ $time
 
55
  );
56
 
57
  if ( ! empty( $email_message ) ) {
89
  *
90
  * @param array $tabs
91
  *
92
+ * @return array
93
  */
94
  public static function tools_tab( $tabs ) {
95
  ob_start();
includes/class-health-check-site-status.php CHANGED
@@ -1,33 +1,45 @@
1
  <?php
2
 
3
- class Health_Check_Site_Status {
4
- private $php_min_version_check;
5
- private $php_supported_version_check;
6
- private $php_rec_version_check;
7
 
 
8
  private $mysql_min_version_check;
9
  private $mysql_rec_version_check;
10
 
11
- public $mariadb = false;
12
- private $mysql_server_version = null;
13
- private $health_check_mysql_rec_version = null;
 
14
 
15
  public function __construct() {
16
  $this->init();
17
  }
18
 
19
  public function init() {
20
- $this->php_min_version_check = version_compare( HEALTH_CHECK_PHP_MIN_VERSION, PHP_VERSION, '<=' );
21
- $this->php_supported_version_check = version_compare( HEALTH_CHECK_PHP_SUPPORTED_VERSION, PHP_VERSION, '<=' );
22
- $this->php_rec_version_check = version_compare( HEALTH_CHECK_PHP_REC_VERSION, PHP_VERSION, '<=' );
23
-
24
  $this->prepare_sql_data();
25
 
26
  add_action( 'wp_ajax_health-check-site-status', array( $this, 'site_status' ) );
27
 
28
- add_action( 'wp_loaded', array( $this, 'check_wp_version_check_exists' ) );
 
 
 
 
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
31
  private function prepare_sql_data() {
32
  global $wpdb;
33
 
@@ -43,19 +55,30 @@ class Health_Check_Site_Status {
43
  $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );
44
  }
45
 
46
- $this->health_check_mysql_rec_version = HEALTH_CHECK_MYSQL_REC_VERSION;
47
 
48
  if ( stristr( $mysql_server_type, 'mariadb' ) ) {
49
- $this->mariadb = true;
50
  $this->health_check_mysql_rec_version = '10.0';
51
  }
52
 
53
- $this->mysql_min_version_check = version_compare( HEALTH_CHECK_MYSQL_MIN_VERSION, $this->mysql_server_version, '<=' );
54
  $this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' );
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
57
  public function check_wp_version_check_exists() {
58
- if ( ! is_admin() || ! is_user_logged_in() || ! current_user_can( 'manage_options' ) || ! isset( $_GET['health-check-test-wp_version_check'] ) ) {
59
  return;
60
  }
61
 
@@ -64,47 +87,80 @@ class Health_Check_Site_Status {
64
  die();
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
67
  public function site_status() {
68
  check_ajax_referer( 'health-check-site-status' );
69
 
70
- if ( ! current_user_can( 'manage_options' ) ) {
71
  wp_send_json_error();
72
  }
73
 
74
  $function = sprintf(
75
- 'test_%s',
76
  $_POST['feature']
77
  );
78
 
79
  if ( ! method_exists( $this, $function ) || ! is_callable( array( $this, $function ) ) ) {
80
- die();
81
  }
82
 
83
  $call = call_user_func( array( $this, $function ) );
84
-
85
- die();
86
  }
87
 
88
  /**
89
  * Tests for WordPress version and outputs it.
90
  *
91
- * @return void It is an AJAX call.
 
 
 
 
 
92
  */
93
- public function test_wordpress_version() {
 
 
 
 
 
 
 
 
 
 
 
 
94
  $core_current_version = get_bloginfo( 'version' );
95
  $core_updates = get_core_updates();
96
 
97
- // Prepare for a class and text for later use.
98
- $text = '';
99
- $class = '';
100
-
101
  if ( ! is_array( $core_updates ) ) {
102
- $class = 'warning';
103
- $text = sprintf(
 
104
  // translators: %s: Your current version of WordPress.
105
- __( '%s - We were unable to check if any new versions are available.', 'health-check' ),
106
  $core_current_version
107
  );
 
 
 
 
 
 
 
 
 
 
 
108
  } else {
109
  foreach ( $core_updates as $core => $update ) {
110
  if ( 'upgrade' === $update->response ) {
@@ -114,33 +170,61 @@ class Health_Check_Site_Status {
114
  $current_major = $current_version[0] . '.' . $current_version[1];
115
  $new_major = $new_version[0] . '.' . $new_version[1];
116
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  if ( $current_major !== $new_major ) {
118
  // This is a major version mismatch.
119
- $class = 'warning';
120
- $text = sprintf(
121
- // translators: %1$s: Your current version of WordPress. %2$s The latest version of WordPress available.
122
- __( '%1$s ( Latest version: %2$s )', 'health-check' ),
123
- $core_current_version,
124
- $update->version
125
  );
126
  } else {
127
  // This is a minor version, sometimes considered more critical.
128
- $class = 'error';
129
- $text = sprintf(
130
- // translators: %1$s: Your current version of WordPress. %2$s The latest version of WordPress available.
131
- __( '%1$s ( Latest version: %2$s ) - We strongly urge you to update, as minor updates are often security related.', 'health-check' ),
132
- $core_current_version,
133
- $update->version
134
  );
135
  }
136
  } else {
137
- $class = 'good';
138
- $text = $core_current_version;
 
 
 
 
 
 
 
 
 
139
  }
140
  }
141
  }
142
 
143
- printf( '<span class="%1$s"></span> %2$s', esc_attr( $class ), esc_html( $text ) );
 
 
 
 
 
 
 
 
 
 
144
  }
145
 
146
  /**
@@ -150,8 +234,8 @@ class Health_Check_Site_Status {
150
  */
151
  public function is_troubleshooting() {
152
  // Check if a session cookie to disable plugins has been set.
153
- if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
154
- $_GET['health-check-disable-plugin-hash'] = $_COOKIE['health-check-disable-plugins'];
155
  }
156
 
157
  // If the disable hash isn't set, no need to interact with things.
@@ -173,20 +257,44 @@ class Health_Check_Site_Status {
173
  return true;
174
  }
175
 
176
- public function test_plugin_version() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  $plugins = get_plugins();
178
  $plugin_updates = get_plugin_updates();
179
 
180
- $show_unused_plugins = true;
181
  $plugins_have_updates = false;
182
  $plugins_active = 0;
183
  $plugins_total = 0;
184
- $plugins_needs_update = 0;
185
-
186
- if ( $this->is_troubleshooting() ) {
187
- $show_unused_plugins = false;
188
- }
189
 
 
190
  foreach ( $plugins as $plugin_path => $plugin ) {
191
  $plugins_total++;
192
 
@@ -197,80 +305,135 @@ class Health_Check_Site_Status {
197
  $plugin_version = $plugin['Version'];
198
 
199
  if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
200
- $plugins_needs_update++;
201
  $plugins_have_updates = true;
202
  }
203
  }
204
 
205
- echo '<ul>';
 
 
206
 
207
- if ( $plugins_needs_update > 0 ) {
208
- printf(
209
- '<li><span class="error"></span> %s',
 
210
  sprintf(
211
- // translators: %d: The amount of outdated plugins.
212
- esc_html( _n(
213
  'Your site has %d plugin waiting to be updated.',
214
  'Your site has %d plugins waiting to be updated.',
215
- $plugins_needs_update,
216
  'health-check'
217
- ) ),
218
- $plugins_needs_update
219
  )
220
  );
221
- } else {
222
- printf(
223
- '<li><span class="good"></span> %s',
224
- sprintf(
225
- // translators: %d: The amount of plugins.
226
- esc_html( _n(
227
- 'Your site has %d active plugin, and it is up to date.',
228
- 'Your site has %d active plugins, and they are all up to date.',
229
- $plugins_active,
230
- 'health-check'
231
- ) ),
232
- $plugins_active
233
- )
234
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
 
237
- if ( ( $plugins_total > $plugins_active ) && $show_unused_plugins ) {
 
238
  $unused_plugins = $plugins_total - $plugins_active;
239
- printf(
240
- '<li><span class="warning"></span> %s',
 
 
 
 
 
241
  sprintf(
242
- // translators: %d: The amount of inactive plugins.
243
- esc_html( _n(
244
- 'Your site has %d inactive plugin, it is recommended to remove any unused plugins to enhance your site security.',
245
- 'Your site has %d inactive plugins, it is recommended to remove any unused plugins to enhance your site security.',
246
  $unused_plugins,
247
  'health-check'
248
- ) ),
249
  $unused_plugins
250
- )
 
 
 
 
 
 
 
251
  );
252
  }
253
 
254
- echo '</ul>';
255
  }
256
 
257
- public function test_theme_version() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  $theme_updates = get_theme_updates();
259
 
260
  $themes_total = 0;
261
  $themes_need_updates = 0;
262
  $themes_inactive = 0;
263
 
264
- // This value is changed dduring processing to determine how many themes are considered a reasonable amount.
265
  $allowed_theme_count = 1;
266
 
267
- $has_default_theme = false;
268
- $has_unused_themes = false;
269
- $show_unused_themes = true;
270
-
271
- if ( $this->is_troubleshooting() ) {
272
- $show_unused_themes = false;
273
- }
274
 
275
  // Populate a list of all themes available in the install.
276
  $all_themes = wp_get_themes();
@@ -281,6 +444,10 @@ class Health_Check_Site_Status {
281
 
282
  if ( WP_DEFAULT_THEME === $theme_slug ) {
283
  $has_default_theme = true;
 
 
 
 
284
  }
285
 
286
  if ( array_key_exists( $theme_slug, $theme_updates ) ) {
@@ -291,10 +458,14 @@ class Health_Check_Site_Status {
291
  // If this is a child theme, increase the allowed theme count by one, to account for the parent.
292
  if ( $active_theme->parent() ) {
293
  $allowed_theme_count++;
 
 
 
 
294
  }
295
 
296
- // If there's a default theme installed, we count that as allowed as well.
297
- if ( $has_default_theme ) {
298
  $allowed_theme_count++;
299
  }
300
 
@@ -303,184 +474,379 @@ class Health_Check_Site_Status {
303
  $themes_inactive = ( $themes_total - $allowed_theme_count );
304
  }
305
 
306
- echo '<ul>';
307
-
308
  if ( $themes_need_updates > 0 ) {
309
- printf(
310
- '<li><span class="error"></span> %s',
 
 
 
 
311
  sprintf(
312
- // translators: %d: The amount of outdated themes.
313
- esc_html( _n(
314
  'Your site has %d theme waiting to be updated.',
315
  'Your site has %d themes waiting to be updated.',
316
  $themes_need_updates,
317
  'health-check'
318
- ) ),
319
  $themes_need_updates
320
  )
321
  );
322
  } else {
323
- printf(
324
- '<li><span class="good"></span> %s',
325
- sprintf(
326
- // translators: %d: The amount of themes.
327
- esc_html( _n(
328
- 'Your site has %d installed theme, and it is up to date.',
329
- 'Your site has %d installed themes, and they are all up to date.',
330
- $themes_total,
331
- 'health-check'
332
- ) ),
333
- $themes_total
334
- )
335
- );
336
- }
337
-
338
- if ( $has_unused_themes && $show_unused_themes ) {
339
-
340
- // This is a child theme, so we want to be a bit more explicit in our messages.
341
- if ( $active_theme->parent() ) {
342
- printf(
343
- '<li><span class="warning"></span> %s',
344
- sprintf(
345
- // translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. %4$s: The active themes parent theme.
346
- esc_html( _n(
347
- 'Your site has %1$d inactive theme. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme.',
348
- 'Your site has %1$d inactive themes. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme.',
349
- $themes_inactive,
350
- 'health-check'
351
- ) ),
352
- $themes_inactive,
353
- WP_DEFAULT_THEME,
354
- $active_theme->name,
355
- $active_theme->parent()->name
356
- )
357
  );
358
-
359
  } else {
360
- printf(
361
- '<li><span class="warning"></span> %s',
362
  sprintf(
363
- // translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme.
364
- esc_html( _n(
365
- 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme. It is recommended to remove any unused themes to enhance your sites security.',
366
- 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme. It is recommended to remove any unused themes to enhance your sites security.',
367
- $themes_inactive,
368
  'health-check'
369
- ) ),
370
- $themes_inactive,
371
- WP_DEFAULT_THEME,
372
- $active_theme->name
373
  )
374
  );
 
 
 
 
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
  }
378
 
 
379
  if ( ! $has_default_theme ) {
380
- printf(
381
- '<li><span class="warning"></span> %s',
382
- esc_html__( 'Your site does not have a default theme, default themes are used by WordPress automatically if anything is wrong with your normal theme.', 'health-check' )
 
 
 
 
383
  );
384
  }
385
 
386
- echo '</ul>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  }
388
 
389
- public function test_php_version() {
390
- $status = 'good';
391
- $notice = array();
392
 
393
- if ( ! $this->php_min_version_check ) {
394
- $status = 'error';
395
- $notice[] = sprintf(
396
- '<a href="%s">%s</a>',
397
- esc_url(
398
- _x( 'https://wordpress.org/support/upgrade-php/', 'The link to the Update PHP page, which may be localized.', 'health-check' )
399
- ),
400
- sprintf(
401
- // translators: %1$s: Current PHP version. %2$s: Recommended PHP version. %3$s: Minimum PHP version.
402
- esc_html__( 'Your version of PHP, %1$s, is very outdated and no longer receiving security updates and is not supported by WordPress. You should contact your host for an upgrade, WordPress recommends using PHP version %2$s, but will work with version %3$s or newer.', 'health-check' ),
403
- PHP_VERSION,
404
- HEALTH_CHECK_PHP_REC_VERSION,
405
- HEALTH_CHECK_PHP_MIN_VERSION
406
- )
407
- );
408
- } elseif ( ! $this->php_supported_version_check ) {
409
- $status = 'warning';
410
- $notice[] = sprintf(
411
- '<a href="%s">%s</a>',
412
- esc_url(
413
- _x( 'https://wordpress.org/support/upgrade-php/', 'The link to the Update PHP page, which may be localized.', 'health-check' )
414
- ),
415
- sprintf(
416
- // translators: %1$s: Current PHP version. %2$s: Recommended PHP version.
417
- esc_html__( 'Your version of PHP, %1$s, is very outdated and no longer receiving security updates. You should contact your host for an upgrade, WordPress recommends using PHP version %2$s.', 'health-check' ),
418
- PHP_VERSION,
419
- HEALTH_CHECK_PHP_REC_VERSION
420
- )
421
- );
422
- } elseif ( ! $this->php_rec_version_check ) {
423
- $status = 'warning';
424
- $notice[] = sprintf(
425
- '<a href="%s">%s</a>',
426
- esc_url(
427
- _x( 'https://wordpress.org/support/upgrade-php/', 'The link to the Update PHP page, which may be localized.', 'health-check' )
428
- ),
429
- sprintf(
430
- // translators: %s: Recommended PHP version
431
- esc_html__( 'For best performance we recommend using PHP %s or higher.', 'health-check' ),
432
- HEALTH_CHECK_PHP_REC_VERSION
433
- )
434
- );
435
  }
436
 
437
- printf(
438
- '<span class="%s"></span> %s',
439
- esc_attr( $status ),
440
- sprintf(
441
- '%s%s',
442
- PHP_VERSION,
443
- ( ! empty( $notice ) ? ' - ' . implode( '<br>', $notice ) : '' )
444
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
 
448
- public function child_test_php_extension_availability( $extension = null, $function = null ) {
 
 
 
 
 
 
 
 
 
 
 
 
449
  // If no extension or function is passed, claim to fail testing, as we have nothing to test against.
450
- if ( null === $extension && null === $function ) {
451
  return false;
452
  }
453
 
454
- $available = true;
455
-
456
- if ( null !== $extension && ! extension_loaded( $extension ) ) {
457
- $available = false;
458
  }
459
- if ( null !== $function && ! function_exists( $function ) ) {
460
- $available = false;
461
  }
462
 
463
- return $available;
464
  }
465
 
466
- public function test_php_extensions() {
467
- /*
468
- * An array representing all the modules we wish to test for.
469
- *
470
- * array $modules {
471
- * An associated array of modules to test for.
472
- *
473
- * array $module {
474
- * An associated array of module properties used during testing.
475
- * One of either `$function` or `$extension` must be provided, or they will fail by default.
476
- *
477
- * string $function Optional. A function name to test for the existence of.
478
- * string $extension Optional. An extension to check if is loaded in PHP.
479
- * bool $required Is this a required feature or not.
480
- * string $fallback_for Optional. The module this module replaces as a fallback.
481
- * }
482
- * }
483
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  $modules = array(
485
  'bcmath' => array(
486
  'function' => 'bcadd',
@@ -511,8 +877,9 @@ class Health_Check_Site_Status {
511
  'required' => false,
512
  ),
513
  'libsodium' => array(
514
- 'function' => 'sodium_compare',
515
- 'required' => false,
 
516
  ),
517
  'openssl' => array(
518
  'function' => 'openssl_encrypt',
@@ -548,6 +915,27 @@ class Health_Check_Site_Status {
548
  ),
549
  );
550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  $failures = array();
552
 
553
  foreach ( $modules as $library => $module ) {
@@ -567,123 +955,213 @@ class Health_Check_Site_Status {
567
  }
568
  }
569
 
570
- if ( ! $this->child_test_php_extension_availability( $extension, $function ) ) {
571
- $failures[ $library ] = sprintf(
572
- '<span class="%s"></span> %s',
573
- ( $module['required'] ? 'error' : 'warning' ),
574
- sprintf(
575
- // translators: %1$2: If a module is required or recommended. %2$s: The module name.
576
- __( 'The %1$s module, %2$s, is not installer, or has been disabled.', 'health-check' ),
577
- ( $module['required'] ? __( 'required', 'health-check' ) : __( 'optional', 'health-check' ) ),
578
- $library
579
- )
580
- );
581
- }
582
- }
583
-
584
- if ( ! empty( $failures ) ) {
585
- echo '<ul>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
 
587
  foreach ( $failures as $failure ) {
588
- printf(
589
  '<li>%s</li>',
590
  $failure
591
  );
592
  }
593
 
594
- echo '</ul>';
595
- } else {
596
- printf(
597
- '<span class="good"></span> %s',
598
- __( 'All required and recommended modules are installed.', 'health-check' )
 
 
 
 
 
 
 
 
 
599
  );
600
  }
 
 
601
  }
602
 
603
- public function test_sql_server() {
604
- $status = 'good';
605
- $notice = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
 
607
  $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' );
608
 
609
  if ( ! $this->mysql_rec_version_check ) {
610
- $status = 'warning';
611
- $notice[] = sprintf(
612
- // translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server recommended version number.
613
- esc_html__( 'For performance and security reasons, we strongly recommend running %1$s version %2$s or higher.', 'health-check' ),
614
- ( $this->mariadb ? 'MariaDB' : 'MySQL' ),
615
- $this->health_check_mysql_rec_version
 
 
 
 
 
 
616
  );
617
  }
618
 
619
  if ( ! $this->mysql_min_version_check ) {
620
- $status = 'error';
621
- $notice[] = sprintf(
622
- // translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server minimum version number.
623
- esc_html__( 'WordPress 3.2+ requires %1$s version %2$s or higher.', 'health-check' ),
624
- ( $this->mariadb ? 'MariaDB' : 'MySQL' ),
625
- HEALTH_CHECK_MYSQL_MIN_VERSION
 
 
 
 
 
 
 
626
  );
627
  }
628
 
629
  if ( $db_dropin ) {
630
- // translators: %s: The database engine in use (MySQL or MariaDB).
631
- $notice[] = wp_kses(
632
- sprintf(
633
- // translators: %s: The name of the database engine being used.
634
- __( 'You are using a <code>wp-content/db.php</code> drop-in which might mean that a %s database is not being used.', 'health-check' ),
635
- ( $this->mariadb ? 'MariaDB' : 'MySQL' )
636
- ),
637
- array(
638
- 'code' => true,
 
 
 
639
  )
640
  );
641
  }
642
 
643
- printf(
644
- '<span class="%s"></span> %s',
645
- esc_attr( $status ),
646
- sprintf(
647
- '%s%s',
648
- esc_html( $this->mysql_server_version ),
649
- ( ! empty( $notice ) ? '<br> - ' . implode( '<br>', $notice ) : '' )
650
- )
651
- );
652
  }
653
 
654
- public function test_utf8mb4_support() {
 
 
 
 
 
 
 
655
  global $wpdb;
656
 
657
- if ( ! $this->mariadb ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) {
659
- printf(
660
- '<span class="warning"></span> %s',
 
 
 
 
661
  sprintf(
662
- /* translators: %s: Number of version. */
663
- esc_html__( 'WordPress\' utf8mb4 support requires MySQL version %s or greater', 'health-check' ),
664
  '5.5.3'
665
  )
666
  );
667
  } else {
668
- printf(
669
- '<span class="good"></span> %s',
670
- esc_html__( 'Your MySQL version supports utf8mb4', 'health-check' )
671
  );
672
  }
673
  } else { // MariaDB introduced utf8mb4 support in 5.5.0
674
  if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
675
- printf(
676
- '<span class="warning"></span> %s',
 
 
 
 
677
  sprintf(
678
- /* translators: %s: Number of version. */
679
- esc_html__( 'WordPress\' utf8mb4 support requires MariaDB version %s or greater', 'health-check' ),
680
  '5.5.0'
681
  )
682
  );
683
  } else {
684
- printf(
685
- '<span class="good"></span> %s',
686
- esc_html__( 'Your MariaDB version supports utf8mb4', 'health-check' )
687
  );
688
  }
689
  }
@@ -703,11 +1181,15 @@ class Health_Check_Site_Status {
703
  if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) {
704
  $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
705
  if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
706
- printf(
707
- '<br><span class="warning"></span> %s',
 
 
 
 
708
  sprintf(
709
- /* translators: %1$s: Name of the library, %2$s: Number of version. */
710
- __( 'WordPress\' utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.', 'health-check' ),
711
  'mysqlnd',
712
  '5.0.9'
713
  )
@@ -715,164 +1197,548 @@ class Health_Check_Site_Status {
715
  }
716
  } else {
717
  if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) {
718
- printf(
719
- '<br><span class="warning"></span> %s',
 
 
 
 
720
  sprintf(
721
- /* translators: %1$s: Name of the library, %2$s: Number of version. */
722
- __( 'WordPress\' utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.', 'health-check' ),
723
  'libmysql',
724
  '5.5.3'
725
  )
726
  );
727
  }
728
  }
 
 
729
  }
730
 
731
- public function test_dotorg_communication() {
732
- $wp_dotorg = wp_remote_get( 'https://wordpress.org', array(
733
- 'timeout' => 10,
734
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
  if ( ! is_wp_error( $wp_dotorg ) ) {
736
- printf(
737
- '<span class="good"></span> %s',
738
- esc_html__( 'WordPress.org is reachable from your server.', 'health-check' )
739
- );
740
  } else {
741
- printf(
742
- '<span class="error"></span> %s',
 
 
 
 
743
  sprintf(
744
- // translators: %1$s: The IP address WordPress.org resolves to. %2$s: The error returned by the lookup.
745
- __( 'Unable to reach WordPress.org at %1$s: %2$s', 'health-check' ),
746
- gethostbyname( 'wordpress.org' ),
747
- $wp_dotorg->get_error_message()
 
 
 
 
748
  )
749
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
750
  }
 
 
 
 
 
 
751
  }
752
 
753
- public function test_https_status() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  if ( is_ssl() ) {
755
  $wp_url = get_bloginfo( 'wpurl' );
756
  $site_url = get_bloginfo( 'url' );
757
 
758
  if ( 'https' !== substr( $wp_url, 0, 5 ) || 'https' !== substr( $site_url, 0, 5 ) ) {
759
- printf(
760
- '<span class="warning"></span> %s',
 
 
 
 
761
  sprintf(
762
- // translators: %s: URL to Settings > General to change options.
763
  __( 'You are accessing this website using HTTPS, but your <a href="%s">WordPress Address</a> is not set up to use HTTPS by default.', 'health-check' ),
764
  esc_url( admin_url( 'options-general.php' ) )
765
  )
766
  );
767
- } else {
768
- printf(
769
- '<span class="good"></span> %s',
770
- esc_html__( 'You are accessing this website using HTTPS.', 'health-check' )
 
771
  );
772
  }
773
  } else {
774
- printf(
775
- '<span class="warning"></span> %s',
776
- esc_html__( 'You are not using HTTPS to access this website.', 'health-check' )
777
- );
778
  }
 
 
779
  }
780
 
781
- public function test_ssl_support() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
782
  $supports_https = wp_http_supports( array( 'ssl' ) );
783
 
784
  if ( $supports_https ) {
785
- printf(
786
- '<span class="good"></span> %s',
787
- esc_html__( 'Your WordPress install can communicate securely with other services.', 'health-check' )
788
- );
789
  } else {
790
- printf(
791
- '<span class="error"></span> %s',
792
- esc_html__( 'Your WordPress install cannot communicate securely with other services. Talk to your web host about OpenSSL support for PHP.', 'health-check' )
 
 
 
 
793
  );
794
  }
 
 
795
  }
796
 
797
- public function test_scheduled_events() {
798
- $scheduled_events = new Health_Check_WP_Cron();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
 
800
- if ( is_wp_error( $scheduled_events->has_missed_cron() ) ) {
801
- printf(
802
- '<span class="error"></span> %s',
803
- esc_html( $scheduled_events->has_missed_cron()->get_error_message() )
 
 
 
804
  );
805
  } else {
806
- if ( $scheduled_events->has_missed_cron() ) {
807
- printf(
808
- '<span class="warning"></span> %s',
 
 
 
 
809
  sprintf(
810
- // translators: %s: The name of the failed cron event.
811
- esc_html__( 'A scheduled event (%s) has failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ),
812
- $scheduled_events->last_missed_cron
813
  )
814
  );
815
- } else {
816
- printf(
817
- '<span class="good"></span> %s',
818
- esc_html__( 'No scheduled events have been missed.', 'health-check' )
819
- );
820
  }
821
  }
 
 
822
  }
823
 
824
- public function test_background_updates() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
825
  $automatic_updates = new Health_Check_Auto_Updates();
826
  $tests = $automatic_updates->run_tests();
827
 
828
- echo '<ul>';
829
 
830
  foreach ( $tests as $test ) {
831
- printf(
832
- '<li><span class="%s"></span> %s</li>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
  esc_attr( $test->severity ),
834
- $test->desc
 
835
  );
836
  }
837
 
838
- echo '</ul>';
 
 
 
 
 
 
 
 
 
 
 
 
 
839
  }
840
 
841
- public function test_extension_updates() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842
  $updates = new Health_Check_Updates();
843
  $tests = $updates->run_tests();
844
 
845
- echo '<ul>';
846
 
847
  foreach ( $tests as $test ) {
848
- printf(
849
- '<li><span class="%s"></span> %s</li>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
850
  esc_attr( $test->severity ),
 
851
  $test->desc
852
  );
853
  }
854
 
855
- echo '</ul>';
856
- }
 
 
 
 
 
 
857
 
858
- public function test_loopback_requests() {
859
- $check_loopback = Health_Check_Loopback::can_perform_loopback();
860
 
861
- printf(
862
- '<span class="%s"></span> %s',
863
- esc_attr( $check_loopback->status ),
864
- $check_loopback->message
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
  );
866
 
867
- if ( 'error' === $check_loopback->status ) {
868
- printf(
869
- '<br><button type="button" id="loopback-no-plugins" class="button button-primary">%s</button>',
870
- esc_html__( 'Test without plugins', 'health-check' )
 
 
 
 
 
 
 
 
871
  );
872
  }
 
 
873
  }
874
 
875
- public function test_http_requests() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
876
  $blocked = false;
877
  $hosts = array();
878
 
@@ -885,35 +1751,65 @@ class Health_Check_Site_Status {
885
  }
886
 
887
  if ( $blocked && 0 === sizeof( $hosts ) ) {
888
- printf(
889
- '<span class="%s"></span> %s',
890
- esc_attr( 'fail' ),
891
- esc_html__( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with no allowed hosts.', 'health-check' )
 
 
 
 
 
 
 
892
  );
893
  }
894
 
895
  if ( $blocked && 0 < sizeof( $hosts ) ) {
896
- printf(
897
- '<span class="%s"></span> %s',
898
- esc_attr( 'warning' ),
 
 
 
899
  sprintf(
900
- /* translators: %s: List of hostnames whitelisted. */
901
- esc_html__( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with some hosts whitelisted: %s.', 'health-check' ),
 
902
  implode( ',', $hosts )
903
  )
904
  );
905
  }
906
 
907
- if ( ! $blocked ) {
908
- printf(
909
- '<span class="%s"></span> %s',
910
- esc_attr( 'good' ),
911
- esc_html__( 'HTTP requests should be working as expected.', 'health-check' )
912
- );
913
- }
914
  }
915
 
916
- public function test_rest_availability() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  $cookies = wp_unslash( $_COOKIE );
918
  $timeout = 10;
919
  $headers = array(
@@ -928,33 +1824,44 @@ class Health_Check_Site_Status {
928
 
929
  $url = rest_url( 'wp/v2/types/post' );
930
 
931
- // We only need the first post to ensure this works, to make it low impact.
932
- $url = add_query_arg( array(
933
- 'context' => 'edit',
934
- ), $url );
 
 
 
935
 
936
  $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
937
 
938
  if ( is_wp_error( $r ) ) {
939
- printf(
940
- '<span class="error"></span> %s',
 
 
 
 
941
  sprintf(
942
  '%s<br>%s',
943
- esc_html__( 'The REST API request failed due to an error.', 'health-check' ),
944
  sprintf(
945
- /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */
946
- esc_html__( 'Error encountered: (%1$d) %2$s', 'health-check' ),
947
  wp_remote_retrieve_response_code( $r ),
948
  $r->get_error_message()
949
  )
950
  )
951
  );
952
  } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
953
- printf(
954
- '<span class="warning"></span> %s',
 
 
 
 
955
  sprintf(
956
- /* translators: %1$d: The HTTP response code returned. %2$s: The error message returned. */
957
- esc_html__( 'The REST API call gave the following unexpected result: (%1$d) %2$s.', 'health-check' ),
958
  wp_remote_retrieve_response_code( $r ),
959
  wp_remote_retrieve_body( $r )
960
  )
@@ -963,90 +1870,99 @@ class Health_Check_Site_Status {
963
  $json = json_decode( wp_remote_retrieve_body( $r ), true );
964
 
965
  if ( false !== $json && ! isset( $json['capabilities'] ) ) {
966
- printf(
967
- '<span class="warning"></span> %s',
968
- esc_html__( 'The REST API did not process the \'context\' query parameter correctly.', 'health-check' )
969
- );
970
- } else {
971
- printf(
972
- '<span class="good"></span> %s',
973
- __( 'The REST API is available.', 'health-check' )
 
 
 
974
  );
975
  }
976
  }
 
 
977
  }
978
 
979
  /**
980
  * Return a set of tests that belong to the site status page.
981
  *
982
- * Each site status test is defined here, they may be `direct` tests, that run on page load,
983
- * or `async` tests which will run later down the line via JavaScript calls to improve page
984
- * performance and hopefully also user experiences.
985
  *
986
- * @return array
 
 
987
  */
988
  public static function get_tests() {
 
 
989
  $tests = array(
990
  'direct' => array(
991
- array(
992
  'label' => __( 'WordPress Version', 'health-check' ),
993
- 'test' => 'wordpress_version',
994
  ),
995
- array(
996
  'label' => __( 'Plugin Versions', 'health-check' ),
997
- 'test' => 'plugin_version',
998
  ),
999
- array(
1000
  'label' => __( 'Theme Versions', 'health-check' ),
1001
- 'test' => 'theme_version',
1002
  ),
1003
- array(
1004
  'label' => __( 'PHP Version', 'health-check' ),
1005
- 'test' => 'php_version',
1006
  ),
1007
- array(
1008
  'label' => __( 'Database Server version', 'health-check' ),
1009
- 'test' => 'sql_server',
1010
  ),
1011
- array(
1012
  'label' => __( 'PHP Extensions', 'health-check' ),
1013
- 'test' => 'php_extensions',
1014
  ),
1015
- array(
1016
  'label' => __( 'MySQL utf8mb4 support', 'health-check' ),
1017
- 'test' => 'utf8mb4_support',
1018
  ),
1019
- array(
1020
  'label' => __( 'HTTPS status', 'health-check' ),
1021
- 'test' => 'https_status',
1022
  ),
1023
- array(
1024
  'label' => __( 'Secure communication', 'health-check' ),
1025
- 'test' => 'ssl_support',
1026
  ),
1027
- array(
1028
  'label' => __( 'Scheduled events', 'health-check' ),
1029
- 'test' => 'scheduled_events',
1030
  ),
1031
- array(
1032
- 'label' => __( 'Plugin and Theme Updates', 'health-check' ),
1033
- 'test' => 'extension_updates',
1034
- ),
1035
- array(
1036
  'label' => __( 'HTTP Requests', 'health-check' ),
1037
- 'test' => 'http_requests',
 
 
 
 
1038
  ),
1039
  ),
1040
  'async' => array(
1041
- array(
1042
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
1043
  'test' => 'dotorg_communication',
1044
  ),
1045
- array(
1046
  'label' => __( 'Background updates', 'health-check' ),
1047
  'test' => 'background_updates',
1048
  ),
1049
- array(
1050
  'label' => __( 'Loopback request', 'health-check' ),
1051
  'test' => 'loopback_requests',
1052
  ),
@@ -1055,14 +1971,88 @@ class Health_Check_Site_Status {
1055
 
1056
  // Conditionally include REST rules if the function for it exists.
1057
  if ( function_exists( 'rest_url' ) ) {
1058
- $tests['direct'][] = array(
1059
  'label' => __( 'REST API availability', 'health-check' ),
1060
- 'test' => 'rest_availability',
1061
  );
1062
  }
1063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1064
  return $tests;
1065
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1066
  }
1067
 
1068
  global $health_check_site_status;
1
  <?php
2
 
3
+ // Make sure the file is not directly accessible.
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ die( 'We\'re sorry, but you can not directly access this file.' );
6
+ }
7
 
8
+ class Health_Check_Site_Status {
9
  private $mysql_min_version_check;
10
  private $mysql_rec_version_check;
11
 
12
+ public $is_mariadb = false;
13
+ private $mysql_server_version = '';
14
+ private $health_check_mysql_required_version = '5.5';
15
+ private $health_check_mysql_rec_version = '';
16
 
17
  public function __construct() {
18
  $this->init();
19
  }
20
 
21
  public function init() {
 
 
 
 
22
  $this->prepare_sql_data();
23
 
24
  add_action( 'wp_ajax_health-check-site-status', array( $this, 'site_status' ) );
25
 
26
+ add_action( 'wp_ajax_health-check-site-status-result', array( $this, 'site_status_result' ) );
27
+
28
+ add_action( 'admin_init', array( $this, 'check_wp_version_check_exists' ) );
29
+
30
+ add_action( 'health-check-scheduled-site-status-check', array( $this, 'scheduled_check' ) );
31
  }
32
 
33
+ /**
34
+ * Run the SQL version checks.
35
+ *
36
+ * These values are used in later tests, but the part of preparing them is more easily managed early
37
+ * in the class for ease of access and discovery.
38
+ *
39
+ * @since 5.2.0
40
+ *
41
+ * @global wpdb $wpdb WordPress database abstraction object.
42
+ */
43
  private function prepare_sql_data() {
44
  global $wpdb;
45
 
55
  $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );
56
  }
57
 
58
+ $this->health_check_mysql_rec_version = '5.6';
59
 
60
  if ( stristr( $mysql_server_type, 'mariadb' ) ) {
61
+ $this->is_mariadb = true;
62
  $this->health_check_mysql_rec_version = '10.0';
63
  }
64
 
65
+ $this->mysql_min_version_check = version_compare( '5.5', $this->mysql_server_version, '<=' );
66
  $this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' );
67
  }
68
 
69
+ /**
70
+ * Test if `wp_version_check` is blocked.
71
+ *
72
+ * It's possible to block updates with the `wp_version_check` filter, but this can't be checked during an
73
+ * AJAX call, as the filter is never introduced then.
74
+ *
75
+ * This filter overrides a normal page request if it's made by an admin through the AJAX call with the
76
+ * right query argument to check for this.
77
+ *
78
+ * @since 5.2.0
79
+ */
80
  public function check_wp_version_check_exists() {
81
+ if ( ! is_admin() || ! is_user_logged_in() || ! current_user_can( 'update_core' ) || ! isset( $_GET['health-check-test-wp_version_check'] ) ) {
82
  return;
83
  }
84
 
87
  die();
88
  }
89
 
90
+ public function site_status_result() {
91
+ check_ajax_referer( 'health-check-site-status-result' );
92
+
93
+ if ( ! current_user_can( 'install_plugins' ) ) {
94
+ wp_send_json_error();
95
+ }
96
+
97
+ set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
98
+ }
99
+
100
  public function site_status() {
101
  check_ajax_referer( 'health-check-site-status' );
102
 
103
+ if ( ! current_user_can( 'install_plugins' ) ) {
104
  wp_send_json_error();
105
  }
106
 
107
  $function = sprintf(
108
+ 'json_test_%s',
109
  $_POST['feature']
110
  );
111
 
112
  if ( ! method_exists( $this, $function ) || ! is_callable( array( $this, $function ) ) ) {
113
+ return;
114
  }
115
 
116
  $call = call_user_func( array( $this, $function ) );
 
 
117
  }
118
 
119
  /**
120
  * Tests for WordPress version and outputs it.
121
  *
122
+ * Gives various results depending on what kind of updates are available, if any, to encourage the
123
+ * user to install security updates as a priority.
124
+ *
125
+ * @since 5.2.0
126
+ *
127
+ * @return array The test result.
128
  */
129
+ public function get_test_wordpress_version() {
130
+ $result = array(
131
+ 'label' => '',
132
+ 'status' => '',
133
+ 'badge' => array(
134
+ 'label' => __( 'Performance', 'health-check' ),
135
+ 'color' => 'blue',
136
+ ),
137
+ 'description' => '',
138
+ 'actions' => '',
139
+ 'test' => 'wordpress_version',
140
+ );
141
+
142
  $core_current_version = get_bloginfo( 'version' );
143
  $core_updates = get_core_updates();
144
 
 
 
 
 
145
  if ( ! is_array( $core_updates ) ) {
146
+ $result['status'] = 'recommended';
147
+
148
+ $result['label'] = sprintf(
149
  // translators: %s: Your current version of WordPress.
150
+ __( 'WordPress version %s', 'health-check' ),
151
  $core_current_version
152
  );
153
+
154
+ $result['description'] = sprintf(
155
+ '<p>%s</p>',
156
+ __( 'We were unable to check if any new versions of WordPress are available.', 'health-check' )
157
+ );
158
+
159
+ $result['actions'] = sprintf(
160
+ '<a href="%s">%s</a>',
161
+ esc_url( admin_url( 'update-core.php?force-check=1' ) ),
162
+ __( 'Check for updates manually', 'health-check' )
163
+ );
164
  } else {
165
  foreach ( $core_updates as $core => $update ) {
166
  if ( 'upgrade' === $update->response ) {
170
  $current_major = $current_version[0] . '.' . $current_version[1];
171
  $new_major = $new_version[0] . '.' . $new_version[1];
172
 
173
+ $result['label'] = sprintf(
174
+ // translators: %s: The latest version of WordPress available.
175
+ __( 'WordPress update available (%s)', 'health-check' ),
176
+ $update->version
177
+ );
178
+
179
+ $result['actions'] = sprintf(
180
+ '<a href="%s">%s</a>',
181
+ esc_url( admin_url( 'update-core.php' ) ),
182
+ __( 'Install the latest version of WordPress', 'health-check' )
183
+ );
184
+
185
  if ( $current_major !== $new_major ) {
186
  // This is a major version mismatch.
187
+ $result['status'] = 'recommended';
188
+ $result['description'] = sprintf(
189
+ '<p>%s</p>',
190
+ __( 'A new version of WordPress is available.', 'health-check' )
 
 
191
  );
192
  } else {
193
  // This is a minor version, sometimes considered more critical.
194
+ $result['status'] = 'critical';
195
+ $result['badge']['label'] = __( 'Security', 'health-check' );
196
+ $result['description'] = sprintf(
197
+ '<p>%s</p>',
198
+ __( 'A new minor update is available for your site. Because minor updates often address security, it&#8217;s important to install them.', 'health-check' )
 
199
  );
200
  }
201
  } else {
202
+ $result['status'] = 'good';
203
+ $result['label'] = sprintf(
204
+ // translators: %s: The current version of WordPress installed on this site.
205
+ __( 'Your WordPress version is up to date (%s)', 'health-check' ),
206
+ $core_current_version
207
+ );
208
+
209
+ $result['description'] = sprintf(
210
+ '<p>%s</p>',
211
+ __( 'You are currently running the latest version of WordPress available, keep it up!', 'health-check' )
212
+ );
213
  }
214
  }
215
  }
216
 
217
+ return $result;
218
+ }
219
+
220
+ public function test_wordpress_version() {
221
+ $check = $this->get_test_wordpress_version();
222
+
223
+ printf( '<span class="%s"></span> %s', esc_attr( $check['status'] ), esc_html( $check['label'] ) );
224
+ }
225
+
226
+ public function json_wordpress_version() {
227
+ wp_send_json_success( $this->get_test_wordpress_version() );
228
  }
229
 
230
  /**
234
  */
235
  public function is_troubleshooting() {
236
  // Check if a session cookie to disable plugins has been set.
237
+ if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
238
+ $_GET['health-check-disable-plugin-hash'] = $_COOKIE['wp-health-check-disable-plugins'];
239
  }
240
 
241
  // If the disable hash isn't set, no need to interact with things.
257
  return true;
258
  }
259
 
260
+ /**
261
+ * Test if plugins are outdated, or unnecessary.
262
+ *
263
+ * The tests checks if your plugins are up to date, and encourages you to remove any that are not in use.
264
+ *
265
+ * @since 5.2.0
266
+ *
267
+ * @return array The test result.
268
+ */
269
+ public function get_test_plugin_version() {
270
+ $result = array(
271
+ 'label' => __( 'Your plugins are up to date', 'health-check' ),
272
+ 'status' => 'good',
273
+ 'badge' => array(
274
+ 'label' => __( 'Security', 'health-check' ),
275
+ 'color' => 'blue',
276
+ ),
277
+ 'description' => sprintf(
278
+ '<p>%s</p>',
279
+ __( 'Plugins extend your site&#8217;s functionality with things like contact forms, ecommerce and much more. That means they have deep access to your site, so it&#8217;s vital to keep them up to date.', 'health-check' )
280
+ ),
281
+ 'actions' => sprintf(
282
+ '<p><a href="%s">%s</a></p>',
283
+ esc_url( admin_url( 'plugins.php' ) ),
284
+ __( 'Manage your plugins', 'health-check' )
285
+ ),
286
+ 'test' => 'plugin_version',
287
+ );
288
+
289
  $plugins = get_plugins();
290
  $plugin_updates = get_plugin_updates();
291
 
 
292
  $plugins_have_updates = false;
293
  $plugins_active = 0;
294
  $plugins_total = 0;
295
+ $plugins_need_update = 0;
 
 
 
 
296
 
297
+ // Loop over the available plugins and check their versions and active state.
298
  foreach ( $plugins as $plugin_path => $plugin ) {
299
  $plugins_total++;
300
 
305
  $plugin_version = $plugin['Version'];
306
 
307
  if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
308
+ $plugins_need_update++;
309
  $plugins_have_updates = true;
310
  }
311
  }
312
 
313
+ // Add a notice if there are outdated plugins.
314
+ if ( $plugins_need_update > 0 ) {
315
+ $result['status'] = 'critical';
316
 
317
+ $result['label'] = __( 'You have plugins waiting to be updated', 'health-check' );
318
+
319
+ $result['description'] .= sprintf(
320
+ '<p>%s</p>',
321
  sprintf(
322
+ /* translators: %d: The number of outdated plugins. */
323
+ _n(
324
  'Your site has %d plugin waiting to be updated.',
325
  'Your site has %d plugins waiting to be updated.',
326
+ $plugins_need_update,
327
  'health-check'
328
+ ),
329
+ $plugins_need_update
330
  )
331
  );
332
+
333
+ $result['actions'] .= sprintf(
334
+ '<p><a href="%s">%s</a></p>',
335
+ esc_url( admin_url( 'plugins.php?plugin_status=upgrade' ) ),
336
+ __( 'Update your plugins', 'health-check' )
 
 
 
 
 
 
 
 
337
  );
338
+ } else {
339
+ if ( 1 === $plugins_active ) {
340
+ $result['description'] .= sprintf(
341
+ '<p>%s</p>',
342
+ __( 'Your site has 1 active plugin, and it is up to date.', 'health-check' )
343
+ );
344
+ } else {
345
+ $result['description'] .= sprintf(
346
+ '<p>%s</p>',
347
+ sprintf(
348
+ /* translators: %d: The number of active plugins. */
349
+ _n(
350
+ 'Your site has %d active plugin, and they are all up to date.',
351
+ 'Your site has %d active plugins, and they are all up to date.',
352
+ $plugins_active,
353
+ 'health-check'
354
+ ),
355
+ $plugins_active
356
+ )
357
+ );
358
+ }
359
  }
360
 
361
+ // Check if there are inactive plugins.
362
+ if ( $plugins_total > $plugins_active && ! is_multisite() ) {
363
  $unused_plugins = $plugins_total - $plugins_active;
364
+
365
+ $result['status'] = 'recommended';
366
+
367
+ $result['label'] = __( 'You should remove inactive plugins', 'health-check' );
368
+
369
+ $result['description'] .= sprintf(
370
+ '<p>%s %s</p>',
371
  sprintf(
372
+ /* translators: %d: The number of inactive plugins. */
373
+ _n(
374
+ 'Your site has %d inactive plugin.',
375
+ 'Your site has %d inactive plugins.',
376
  $unused_plugins,
377
  'health-check'
378
+ ),
379
  $unused_plugins
380
+ ),
381
+ __( 'Inactive plugins are tempting targets for attackers. If you&#8217;re not going to use a plugin, we recommend you remove it.', 'health-check' )
382
+ );
383
+
384
+ $result['actions'] .= sprintf(
385
+ '<p><a href="%s">%s</a></p>',
386
+ esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
387
+ __( 'Manage inactive plugins', 'health-check' )
388
  );
389
  }
390
 
391
+ return $result;
392
  }
393
 
394
+ /**
395
+ * Test if themes are outdated, or unnecessary.
396
+ *
397
+ * The tests checks if your site has a default theme (to fall back on if there is a need), if your themes
398
+ * are up to date and, finally, encourages you to remove any themes that are not needed.
399
+ *
400
+ * @since 5.2.0
401
+ *
402
+ * @return array The test results.
403
+ */
404
+ public function get_test_theme_version() {
405
+ $result = array(
406
+ 'label' => __( 'Your themes are up to date', 'health-check' ),
407
+ 'status' => 'good',
408
+ 'badge' => array(
409
+ 'label' => __( 'Security', 'health-check' ),
410
+ 'color' => 'blue',
411
+ ),
412
+ 'description' => sprintf(
413
+ '<p>%s</p>',
414
+ __( 'Themes add your site&#8217;s look and feel. It&#8217;s important to keep them up to date, to stay consistent with your brand and keep your site secure.', 'health-check' )
415
+ ),
416
+ 'actions' => sprintf(
417
+ '<p><a href="%s">%s</a></p>',
418
+ esc_url( admin_url( 'themes.php' ) ),
419
+ __( 'Manage your themes', 'health-check' )
420
+ ),
421
+ 'test' => 'theme_version',
422
+ );
423
+
424
  $theme_updates = get_theme_updates();
425
 
426
  $themes_total = 0;
427
  $themes_need_updates = 0;
428
  $themes_inactive = 0;
429
 
430
+ // This value is changed during processing to determine how many themes are considered a reasonable amount.
431
  $allowed_theme_count = 1;
432
 
433
+ $has_default_theme = false;
434
+ $has_unused_themes = false;
435
+ $show_unused_themes = true;
436
+ $using_default_theme = false;
 
 
 
437
 
438
  // Populate a list of all themes available in the install.
439
  $all_themes = wp_get_themes();
444
 
445
  if ( WP_DEFAULT_THEME === $theme_slug ) {
446
  $has_default_theme = true;
447
+
448
+ if ( get_stylesheet() === $theme_slug ) {
449
+ $using_default_theme = true;
450
+ }
451
  }
452
 
453
  if ( array_key_exists( $theme_slug, $theme_updates ) ) {
458
  // If this is a child theme, increase the allowed theme count by one, to account for the parent.
459
  if ( $active_theme->parent() ) {
460
  $allowed_theme_count++;
461
+
462
+ if ( $active_theme->get_template() === WP_DEFAULT_THEME ) {
463
+ $using_default_theme = true;
464
+ }
465
  }
466
 
467
+ // If there's a default theme installed and not in use, we count that as allowed as well.
468
+ if ( $has_default_theme && ! $using_default_theme ) {
469
  $allowed_theme_count++;
470
  }
471
 
474
  $themes_inactive = ( $themes_total - $allowed_theme_count );
475
  }
476
 
477
+ // Check if any themes need to be updated.
 
478
  if ( $themes_need_updates > 0 ) {
479
+ $result['status'] = 'critical';
480
+
481
+ $result['label'] = __( 'You have themes waiting to be updated', 'health-check' );
482
+
483
+ $result['description'] .= sprintf(
484
+ '<p>%s</p>',
485
  sprintf(
486
+ /* translators: %d: The number of outdated themes. */
487
+ _n(
488
  'Your site has %d theme waiting to be updated.',
489
  'Your site has %d themes waiting to be updated.',
490
  $themes_need_updates,
491
  'health-check'
492
+ ),
493
  $themes_need_updates
494
  )
495
  );
496
  } else {
497
+ // Give positive feedback about the site being good about keeping things up to date.
498
+ if ( 1 === $themes_total ) {
499
+ $result['description'] .= sprintf(
500
+ '<p>%s</p>',
501
+ __( 'Your site has 1 installed theme, and it is up to date.', 'health-check' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  );
 
503
  } else {
504
+ $result['description'] .= sprintf(
505
+ '<p>%s</p>',
506
  sprintf(
507
+ /* translators: %d: The number of themes. */
508
+ _n(
509
+ 'Your site has %d installed theme, and they are all up to date.',
510
+ 'Your site has %d installed themes, and they are all up to date.',
511
+ $themes_total,
512
  'health-check'
513
+ ),
514
+ $themes_total
 
 
515
  )
516
  );
517
+ }
518
+ }
519
+
520
+ if ( $has_unused_themes && $show_unused_themes && ! is_multisite() ) {
521
 
522
+ // This is a child theme, so we want to be a bit more explicit in our messages.
523
+ if ( $active_theme->parent() ) {
524
+ // Recommend removing inactive themes, except a default theme, your current one, and the parent theme.
525
+ $result['status'] = 'recommended';
526
+
527
+ $result['label'] = __( 'You should remove inactive themes', 'health-check' );
528
+
529
+ if ( $using_default_theme ) {
530
+ $result['description'] .= sprintf(
531
+ '<p>%s %s</p>',
532
+ sprintf(
533
+ /* translators: %d: The number of inactive themes. */
534
+ _n(
535
+ 'Your site has %d inactive theme.',
536
+ 'Your site has %d inactive themes.',
537
+ $themes_inactive,
538
+ 'health-check'
539
+ ),
540
+ $themes_inactive
541
+ ),
542
+ sprintf(
543
+ /* translators: 1: The currently active theme. 2: The active theme's parent theme. */
544
+ __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep your current theme, %1$s, and %2$s, its parent theme.', 'health-check' ),
545
+ $active_theme->name,
546
+ $active_theme->parent()->name
547
+ )
548
+ );
549
+ } else {
550
+ $result['description'] .= sprintf(
551
+ '<p>%s %s</p>',
552
+ sprintf(
553
+ /* translators: %d: The number of inactive themes. */
554
+ _n(
555
+ 'Your site has %d inactive theme.',
556
+ 'Your site has %d inactive themes.',
557
+ $themes_inactive,
558
+ 'health-check'
559
+ ),
560
+ $themes_inactive
561
+ ),
562
+ sprintf(
563
+ /* translators: 1: The default theme for WordPress. 2: The currently active theme. 3: The active theme's parent theme. */
564
+ __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep %1$s, the default WordPress theme, %2$s, your current theme, and %3$s, its parent theme.', 'health-check' ),
565
+ WP_DEFAULT_THEME,
566
+ $active_theme->name,
567
+ $active_theme->parent()->name
568
+ )
569
+ );
570
+ }
571
+ } else {
572
+ // Recommend removing all inactive themes.
573
+ $result['status'] = 'recommended';
574
+
575
+ $result['label'] = __( 'You should remove inactive themes', 'health-check' );
576
+
577
+ if ( $using_default_theme ) {
578
+ $result['description'] .= sprintf(
579
+ '<p>%s %s</p>',
580
+ sprintf(
581
+ /* translators: 1: The amount of inactive themes. 2: The currently active theme. */
582
+ _n(
583
+ 'Your site has %1$d inactive theme, other than %2$s, your active theme.',
584
+ 'Your site has %1$d inactive themes, other than %2$s, your active theme.',
585
+ $themes_inactive,
586
+ 'health-check'
587
+ ),
588
+ $themes_inactive,
589
+ $active_theme->name
590
+ ),
591
+ __( 'We recommend removing any unused themes to enhance your site&#8217;s security.', 'health-check' )
592
+ );
593
+ } else {
594
+ $result['description'] .= sprintf(
595
+ '<p>%s %s</p>',
596
+ sprintf(
597
+ /* translators: 1: The amount of inactive themes. 2: The default theme for WordPress. 3: The currently active theme. */
598
+ _n(
599
+ 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
600
+ 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
601
+ $themes_inactive,
602
+ 'health-check'
603
+ ),
604
+ $themes_inactive,
605
+ WP_DEFAULT_THEME,
606
+ $active_theme->name
607
+ ),
608
+ __( 'We recommend removing any unused themes to enhance your site&#8217;s security.', 'health-check' )
609
+ );
610
+ }
611
  }
612
  }
613
 
614
+ // If not default Twenty* theme exists.
615
  if ( ! $has_default_theme ) {
616
+ $result['status'] = 'recommended';
617
+
618
+ $result['label'] = __( 'Have a default theme available', 'health-check' );
619
+
620
+ $result['description'] .= sprintf(
621
+ '<p>%s</p>',
622
+ __( 'Your site does not have any default theme. Default themes are used by WordPress automatically if anything is wrong with your normal theme.', 'health-check' )
623
  );
624
  }
625
 
626
+ return $result;
627
+ }
628
+
629
+ /**
630
+ * Fallback function replicating core behavior from WordPress 5.1 to check PHP versions.
631
+ *
632
+ * @return array|bool|mixed|object|WP_Error
633
+ */
634
+ private function wp_check_php_version() {
635
+ $version = phpversion();
636
+ $key = md5( $version );
637
+
638
+ $response = get_site_transient( 'php_check_' . $key );
639
+ if ( false === $response ) {
640
+ $url = 'http://api.wordpress.org/core/serve-happy/1.0/';
641
+ if ( wp_http_supports( array( 'ssl' ) ) ) {
642
+ $url = set_url_scheme( $url, 'https' );
643
+ }
644
+
645
+ $url = add_query_arg( 'php_version', $version, $url );
646
+
647
+ $response = wp_remote_get( $url );
648
+
649
+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
650
+ return false;
651
+ }
652
+
653
+ /**
654
+ * Response should be an array with:
655
+ * 'recommended_version' - string - The PHP version recommended by WordPress.
656
+ * 'is_supported' - boolean - Whether the PHP version is actively supported.
657
+ * 'is_secure' - boolean - Whether the PHP version receives security updates.
658
+ * 'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
659
+ */
660
+ $response = json_decode( wp_remote_retrieve_body( $response ), true );
661
+
662
+ if ( ! is_array( $response ) ) {
663
+ return false;
664
+ }
665
+
666
+ set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS );
667
+ }
668
+
669
+ if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
670
+ /**
671
+ * Filters whether the active PHP version is considered acceptable by WordPress.
672
+ *
673
+ * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
674
+ *
675
+ * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring
676
+ * that this filter can only make this check stricter, but not loosen it.
677
+ *
678
+ * @since 5.1.1
679
+ *
680
+ * @param bool $is_acceptable Whether the PHP version is considered acceptable. Default true.
681
+ * @param string $version PHP version checked.
682
+ */
683
+ $response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
684
+ }
685
+
686
+ return $response;
687
  }
688
 
689
+ private function wp_get_update_php_url() {
690
+ $default_url = _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page', 'health-check' );
 
691
 
692
+ $update_url = $default_url;
693
+ if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) {
694
+ $update_url = getenv( 'WP_UPDATE_PHP_URL' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
695
  }
696
 
697
+ /**
698
+ * Filters the URL to learn more about updating the PHP version the site is running on.
699
+ *
700
+ * Providing an empty string is not allowed and will result in the default URL being used. Furthermore
701
+ * the page the URL links to should preferably be localized in the site language.
702
+ *
703
+ * @since 5.1.0
704
+ *
705
+ * @param string $update_url URL to learn more about updating PHP.
706
+ */
707
+ $update_url = apply_filters( 'wp_update_php_url', $update_url );
708
+
709
+ if ( empty( $update_url ) ) {
710
+ $update_url = $default_url;
711
+ }
712
+
713
+ return $update_url;
714
+ }
715
+
716
+ /**
717
+ * Test if the supplied PHP version is supported.
718
+ *
719
+ * @since 5.2.0
720
+ *
721
+ * @return array The test results.
722
+ */
723
+ public function get_test_php_version() {
724
+ if ( ! function_exists( 'wp_check_php_version' ) ) {
725
+ $response = $this->wp_check_php_version();
726
+ } else {
727
+ $response = wp_check_php_version();
728
+ }
729
+
730
+ $result = array(
731
+ 'label' => sprintf(
732
+ // translators: %s: The current PHP version.
733
+ __( 'PHP is up to date (%s)', 'health-check' ),
734
+ PHP_VERSION
735
+ ),
736
+ 'status' => 'good',
737
+ 'badge' => array(
738
+ 'label' => __( 'Performance', 'health-check' ),
739
+ 'color' => 'blue',
740
+ ),
741
+ 'description' => sprintf(
742
+ '<p>%s</p>',
743
+ __( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site&#8217;s performance.', 'health-check' )
744
+ ),
745
+ 'actions' => sprintf(
746
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
747
+ esc_url( ( function_exists( 'wp_get_update_php_url' ) ? wp_get_update_php_url() : $this->wp_get_update_php_url() ) ),
748
+ __( 'Learn more about updating PHP', 'health-check' ),
749
+ /* translators: accessibility text */
750
+ __( '(opens in a new tab)', 'health-check' )
751
+ ),
752
+ 'test' => 'php_version',
753
  );
754
+
755
+ // PHP is up to date.
756
+ if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) {
757
+ return $result;
758
+ }
759
+
760
+ // The PHP version is older than the recommended version, but still acceptable.
761
+ if ( $response['is_supported'] ) {
762
+ $result['label'] = __( 'We recommend that you update PHP', 'health-check' );
763
+ $result['status'] = 'recommended';
764
+
765
+ return $result;
766
+ }
767
+
768
+ // The PHP version is only receiving security fixes.
769
+ if ( $response['is_secure'] ) {
770
+ $result['label'] = __( 'Your PHP version should be updated', 'health-check' );
771
+ $result['status'] = 'recommended';
772
+
773
+ return $result;
774
+ }
775
+
776
+ // Anything no longer secure must be updated.
777
+ $result['label'] = __( 'Your PHP version requires an update', 'health-check' );
778
+ $result['status'] = 'critical';
779
+ $result['badge']['label'] = __( 'Security', 'health-check' );
780
+
781
+ return $result;
782
  }
783
 
784
+ /**
785
+ * Check if the passed extension or function are available.
786
+ *
787
+ * Make the check for available PHP modules into a simple boolean operator for a cleaner test runner.
788
+ *
789
+ * @since 5.2.0
790
+ *
791
+ * @param string $extension Optional. The extension name to test. Default null.
792
+ * @param string $function Optional. The function name to test. Default null.
793
+ *
794
+ * @return bool Whether or not the extension and function are available.
795
+ */
796
+ private function test_php_extension_availability( $extension = null, $function = null ) {
797
  // If no extension or function is passed, claim to fail testing, as we have nothing to test against.
798
+ if ( ! $extension && ! $function ) {
799
  return false;
800
  }
801
 
802
+ if ( $extension && ! extension_loaded( $extension ) ) {
803
+ return false;
 
 
804
  }
805
+ if ( $function && ! function_exists( $function ) ) {
806
+ return false;
807
  }
808
 
809
+ return true;
810
  }
811
 
812
+ /**
813
+ * Test if required PHP modules are installed on the host.
814
+ *
815
+ * This test builds on the recommendations made by the WordPress Hosting Team
816
+ * as seen at https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
817
+ *
818
+ * @since 5.2.0
819
+ *
820
+ * @return array
821
+ */
822
+ public function get_test_php_extensions() {
823
+ $result = array(
824
+ 'label' => __( 'Required and recommended modules are installed', 'health-check' ),
825
+ 'status' => 'good',
826
+ 'badge' => array(
827
+ 'label' => __( 'Performance', 'health-check' ),
828
+ 'color' => 'blue',
829
+ ),
830
+ 'description' => sprintf(
831
+ '<p>%s</p><p>%s</p>',
832
+ __( 'PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator.', 'health-check' ),
833
+ sprintf(
834
+ /* translators: %s: Link to the hosting group page about recommended PHP modules. */
835
+ __( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in %s.', 'health-check' ),
836
+ sprintf(
837
+ '<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
838
+ /* translators: Localized team handbook, if one exists. */
839
+ esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions', 'health-check' ) ),
840
+ __( 'the team handbook', 'health-check' ),
841
+ /* translators: accessibility text */
842
+ __( '(opens in a new tab)', 'health-check' )
843
+ )
844
+ )
845
+ ),
846
+ 'actions' => '',
847
+ 'test' => 'php_extensions',
848
+ );
849
+
850
  $modules = array(
851
  'bcmath' => array(
852
  'function' => 'bcadd',
877
  'required' => false,
878
  ),
879
  'libsodium' => array(
880
+ 'function' => 'sodium_compare',
881
+ 'required' => false,
882
+ 'php_bundled_version' => '7.2.0',
883
  ),
884
  'openssl' => array(
885
  'function' => 'openssl_encrypt',
915
  ),
916
  );
917
 
918
+ /**
919
+ * An array representing all the modules we wish to test for.
920
+ *
921
+ * @since 5.2.0
922
+ *
923
+ * @param array $modules {
924
+ * An associated array of modules to test for.
925
+ *
926
+ * array $module {
927
+ * An associated array of module properties used during testing.
928
+ * One of either `$function` or `$extension` must be provided, or they will fail by default.
929
+ *
930
+ * string $function Optional. A function name to test for the existence of.
931
+ * string $extension Optional. An extension to check if is loaded in PHP.
932
+ * bool $required Is this a required feature or not.
933
+ * string $fallback_for Optional. The module this module replaces as a fallback.
934
+ * }
935
+ * }
936
+ */
937
+ $modules = apply_filters( 'site_status_test_php_modules', $modules );
938
+
939
  $failures = array();
940
 
941
  foreach ( $modules as $library => $module ) {
955
  }
956
  }
957
 
958
+ if ( ! $this->test_php_extension_availability( $extension, $function ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {
959
+ if ( $module['required'] ) {
960
+ $result['status'] = 'critical';
961
+
962
+ $class = 'error';
963
+ $screen_reader = __( 'Error', 'health-check' );
964
+ $message = sprintf(
965
+ /* translators: %s: The module name. */
966
+ __( 'The required module, %s, is not installed, or has been disabled.', 'health-check' ),
967
+ $library
968
+ );
969
+ } else {
970
+ $class = 'warning';
971
+ $screen_reader = __( 'Warning', 'health-check' );
972
+ $message = sprintf(
973
+ /* translators: %s: The module name. */
974
+ __( 'The optional module, %s, is not installed, or has been disabled.', 'health-check' ),
975
+ $library
976
+ );
977
+ }
978
+
979
+ if ( ! $module['required'] && 'good' === $result['status'] ) {
980
+ $result['status'] = 'recommended';
981
+ }
982
+
983
+ $failures[ $library ] = "<span class='$class'><span class='screen-reader-text'>$screen_reader</span></span> $message";
984
+ }
985
+ }
986
+
987
+ if ( ! empty( $failures ) ) {
988
+ $output = '<ul>';
989
 
990
  foreach ( $failures as $failure ) {
991
+ $output .= sprintf(
992
  '<li>%s</li>',
993
  $failure
994
  );
995
  }
996
 
997
+ $output .= '</ul>';
998
+ }
999
+
1000
+ if ( 'good' !== $result['status'] ) {
1001
+ if ( 'recommended' === $result['status'] ) {
1002
+ $result['label'] = __( 'One or more recommended modules are missing', 'health-check' );
1003
+ }
1004
+ if ( 'critical' === $result['status'] ) {
1005
+ $result['label'] = __( 'One or more required modules are missing', 'health-check' );
1006
+ }
1007
+
1008
+ $result['description'] .= sprintf(
1009
+ '<p>%s</p>',
1010
+ $output
1011
  );
1012
  }
1013
+
1014
+ return $result;
1015
  }
1016
 
1017
+ /**
1018
+ * Test if the SQL server is up to date.
1019
+ *
1020
+ * @since 5.2.0
1021
+ *
1022
+ * @return array The test results.
1023
+ */
1024
+ public function get_test_sql_server() {
1025
+ $result = array(
1026
+ 'label' => __( 'SQL server is up to date', 'health-check' ),
1027
+ 'status' => 'good',
1028
+ 'badge' => array(
1029
+ 'label' => __( 'Performance', 'health-check' ),
1030
+ 'color' => 'blue',
1031
+ ),
1032
+ 'description' => sprintf(
1033
+ '<p>%s</p>',
1034
+ __( 'The SQL server is a required piece of software for the database WordPress uses to store all your site&#8217;s content and settings.', 'health-check' )
1035
+ ),
1036
+ 'actions' => sprintf(
1037
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1038
+ /* translators: Localized version of WordPress requirements if one exists. */
1039
+ esc_url( __( 'https://wordpress.org/about/requirements/', 'health-check' ) ),
1040
+ __( 'Read more about what WordPress requires to run.', 'health-check' ),
1041
+ /* translators: accessibility text */
1042
+ __( '(opens in a new tab)', 'health-check' )
1043
+ ),
1044
+ 'test' => 'sql_server',
1045
+ );
1046
 
1047
  $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' );
1048
 
1049
  if ( ! $this->mysql_rec_version_check ) {
1050
+ $result['status'] = 'recommended';
1051
+
1052
+ $result['label'] = __( 'Outdated SQL server', 'health-check' );
1053
+
1054
+ $result['description'] .= sprintf(
1055
+ '<p>%s</p>',
1056
+ sprintf(
1057
+ /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */
1058
+ __( 'For optimal performance and security reasons, we recommend running %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ),
1059
+ ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
1060
+ $this->health_check_mysql_rec_version
1061
+ )
1062
  );
1063
  }
1064
 
1065
  if ( ! $this->mysql_min_version_check ) {
1066
+ $result['status'] = 'critical';
1067
+
1068
+ $result['label'] = __( 'Severely outdated SQL server', 'health-check' );
1069
+ $result['badge']['label'] = __( 'Security', 'health-check' );
1070
+
1071
+ $result['description'] .= sprintf(
1072
+ '<p>%s</p>',
1073
+ sprintf(
1074
+ /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */
1075
+ __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ),
1076
+ ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
1077
+ $this->health_check_mysql_required_version
1078
+ )
1079
  );
1080
  }
1081
 
1082
  if ( $db_dropin ) {
1083
+ $result['description'] .= sprintf(
1084
+ '<p>%s</p>',
1085
+ wp_kses(
1086
+ sprintf(
1087
+ /* translators: 1: The name of the drop-in. 2: The name of the database engine. */
1088
+ __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.', 'health-check' ),
1089
+ '<code>wp-content/db.php</code>',
1090
+ ( $this->is_mariadb ? 'MariaDB' : 'MySQL' )
1091
+ ),
1092
+ array(
1093
+ 'code' => true,
1094
+ )
1095
  )
1096
  );
1097
  }
1098
 
1099
+ return $result;
 
 
 
 
 
 
 
 
1100
  }
1101
 
1102
+ /**
1103
+ * Test if the database server is capable of using utf8mb4.
1104
+ *
1105
+ * @since 5.2.0
1106
+ *
1107
+ * @return array The test results.
1108
+ */
1109
+ public function get_test_utf8mb4_support() {
1110
  global $wpdb;
1111
 
1112
+ $result = array(
1113
+ 'label' => __( 'UTF8MB4 is supported', 'health-check' ),
1114
+ 'status' => 'good',
1115
+ 'badge' => array(
1116
+ 'label' => __( 'Performance', 'health-check' ),
1117
+ 'color' => 'blue',
1118
+ ),
1119
+ 'description' => sprintf(
1120
+ '<p>%s</p>',
1121
+ __( 'UTF8MB4 is a database storage attribute that makes sure your site can store non-English text and other strings (for instance emoticons) without unexpected problems.', 'health-check' )
1122
+ ),
1123
+ 'actions' => '',
1124
+ 'test' => 'utf8mb4_support',
1125
+ );
1126
+
1127
+ if ( ! $this->is_mariadb ) {
1128
  if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) {
1129
+ $result['status'] = 'recommended';
1130
+
1131
+ $result['label'] = __( 'utf8mb4 requires a MySQL update', 'health-check' );
1132
+
1133
+ $result['description'] .= sprintf(
1134
+ '<p>%s</p>',
1135
  sprintf(
1136
+ /* translators: %s: Version number. */
1137
+ __( 'WordPress&#8217; utf8mb4 support requires MySQL version %s or greater. Please contact your server administrator.', 'health-check' ),
1138
  '5.5.3'
1139
  )
1140
  );
1141
  } else {
1142
+ $result['description'] .= sprintf(
1143
+ '<p>%s</p>',
1144
+ __( 'Your MySQL version supports utf8mb4.', 'health-check' )
1145
  );
1146
  }
1147
  } else { // MariaDB introduced utf8mb4 support in 5.5.0
1148
  if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
1149
+ $result['status'] = 'recommended';
1150
+
1151
+ $result['label'] = __( 'utf8mb4 requires a MariaDB update', 'health-check' );
1152
+
1153
+ $result['description'] .= sprintf(
1154
+ '<p>%s</p>',
1155
  sprintf(
1156
+ /* translators: %s: Version number. */
1157
+ __( 'WordPress&#8217; utf8mb4 support requires MariaDB version %s or greater. Please contact your server administrator.', 'health-check' ),
1158
  '5.5.0'
1159
  )
1160
  );
1161
  } else {
1162
+ $result['description'] .= sprintf(
1163
+ '<p>%s</p>',
1164
+ __( 'Your MariaDB version supports utf8mb4.', 'health-check' )
1165
  );
1166
  }
1167
  }
1181
  if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) {
1182
  $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
1183
  if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
1184
+ $result['status'] = 'recommended';
1185
+
1186
+ $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' );
1187
+
1188
+ $result['description'] .= sprintf(
1189
+ '<p>%s</p>',
1190
  sprintf(
1191
+ /* translators: 1: Name of the library, 2: Number of version. */
1192
+ __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ),
1193
  'mysqlnd',
1194
  '5.0.9'
1195
  )
1197
  }
1198
  } else {
1199
  if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) {
1200
+ $result['status'] = 'recommended';
1201
+
1202
+ $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' );
1203
+
1204
+ $result['description'] .= sprintf(
1205
+ '<p>%s</p>',
1206
  sprintf(
1207
+ /* translators: 1: Name of the library, 2: Number of version. */
1208
+ __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ),
1209
  'libmysql',
1210
  '5.5.3'
1211
  )
1212
  );
1213
  }
1214
  }
1215
+
1216
+ return $result;
1217
  }
1218
 
1219
+ /**
1220
+ * Test if the site can communicate with WordPress.org.
1221
+ *
1222
+ * @since 5.2.0
1223
+ *
1224
+ * @return array The test results.
1225
+ */
1226
+ public function get_test_dotorg_communication() {
1227
+ $result = array(
1228
+ 'label' => __( 'Can communicate with WordPress.org', 'health-check' ),
1229
+ 'status' => '',
1230
+ 'badge' => array(
1231
+ 'label' => __( 'Security', 'health-check' ),
1232
+ 'color' => 'blue',
1233
+ ),
1234
+ 'description' => sprintf(
1235
+ '<p>%s</p>',
1236
+ __( 'Communicating with the WordPress servers is used to check for new versions, and to both install and update WordPress core, themes or plugins.', 'health-check' )
1237
+ ),
1238
+ 'actions' => '',
1239
+ 'test' => 'dotorg_communication',
1240
+ );
1241
+
1242
+ $wp_dotorg = wp_remote_get(
1243
+ 'https://api.wordpress.org',
1244
+ array(
1245
+ 'timeout' => 10,
1246
+ )
1247
+ );
1248
  if ( ! is_wp_error( $wp_dotorg ) ) {
1249
+ $result['status'] = 'good';
 
 
 
1250
  } else {
1251
+ $result['status'] = 'critical';
1252
+
1253
+ $result['label'] = __( 'Could not reach WordPress.org', 'health-check' );
1254
+
1255
+ $result['description'] .= sprintf(
1256
+ '<p>%s</p>',
1257
  sprintf(
1258
+ '<span class="error"><span class="screen-reader-text">%s</span></span> %s',
1259
+ __( 'Error', 'health-check' ),
1260
+ sprintf(
1261
+ /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
1262
+ __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s', 'health-check' ),
1263
+ gethostbyname( 'api.wordpress.org' ),
1264
+ $wp_dotorg->get_error_message()
1265
+ )
1266
  )
1267
  );
1268
+
1269
+ $result['actions'] = sprintf(
1270
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1271
+ /* translators: Localized Support reference. */
1272
+ esc_url( __( 'https://wordpress.org/support', 'health-check' ) ),
1273
+ __( 'Get help resolving this issue.', 'health-check' ),
1274
+ /* translators: accessibility text */
1275
+ __( '(opens in a new tab)', 'health-check' )
1276
+ );
1277
+ }
1278
+
1279
+ return $result;
1280
+ }
1281
+
1282
+ public function json_test_dotorg_communication() {
1283
+ wp_send_json_success( $this->get_test_dotorg_communication() );
1284
+ }
1285
+
1286
+ /**
1287
+ * Test if debug information is enabled.
1288
+ *
1289
+ * When WP_DEBUG is enabled, errors and information may be disclosed to site visitors, or it may be
1290
+ * logged to a publicly accessible file.
1291
+ *
1292
+ * Debugging is also frequently left enabled after looking for errors on a site, as site owners do
1293
+ * not understand the implications of this.
1294
+ *
1295
+ * @since 5.2.0
1296
+ *
1297
+ * @return array The test results.
1298
+ */
1299
+ public function get_test_is_in_debug_mode() {
1300
+ $result = array(
1301
+ 'label' => __( 'Your site is not set to output debug information', 'health-check' ),
1302
+ 'status' => 'good',
1303
+ 'badge' => array(
1304
+ 'label' => __( 'Security', 'health-check' ),
1305
+ 'color' => 'blue',
1306
+ ),
1307
+ 'description' => sprintf(
1308
+ '<p>%s</p>',
1309
+ __( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.', 'health-check' )
1310
+ ),
1311
+ 'actions' => sprintf(
1312
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1313
+ /* translators: Documentation explaining debugging in WordPress. */
1314
+ esc_url( __( 'https://wordpress.org/support/article/debugging-in-wordpress/', 'health-check' ) ),
1315
+ __( 'Read about debugging in WordPress.', 'health-check' ),
1316
+ /* translators: accessibility text */
1317
+ __( '(opens in a new tab)', 'health-check' )
1318
+ ),
1319
+ 'test' => 'is_in_debug_mode',
1320
+ );
1321
+
1322
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1323
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
1324
+ $result['label'] = __( 'Your site is set to log errors to a potentially public file.', 'health-check' );
1325
+
1326
+ $result['status'] = 'critical';
1327
+
1328
+ $result['description'] .= sprintf(
1329
+ '<p>%s</p>',
1330
+ sprintf(
1331
+ /* translators: %s: WP_DEBUG_LOG */
1332
+ __( 'The value, %s, has been added to this website&#8217;s configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.', 'health-check' ),
1333
+ '<code>WP_DEBUG_LOG</code>'
1334
+ )
1335
+ );
1336
+ }
1337
+
1338
+ if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) {
1339
+ $result['label'] = __( 'Your site is set to display errors to site visitors', 'health-check' );
1340
+
1341
+ $result['status'] = 'critical';
1342
+
1343
+ $result['description'] .= sprintf(
1344
+ '<p>%s</p>',
1345
+ sprintf(
1346
+ /* translators: 1: WP_DEBUG_DISPLAY, 2: WP_DEBUG */
1347
+ __( 'The value, %1$s, has either been enabled by %2$s or added to your configuration file. This will make errors display on the front end of your site.', 'health-check' ),
1348
+ '<code>WP_DEBUG_DISPLAY</code>',
1349
+ '<code>WP_DEBUG</code>'
1350
+ )
1351
+ );
1352
+ }
1353
  }
1354
+
1355
+ return $result;
1356
+ }
1357
+
1358
+ public function json_test_is_in_debug_mode() {
1359
+ wp_send_json_success( $this->get_test_is_in_debug_mode() );
1360
  }
1361
 
1362
+ /**
1363
+ * Test if your site is serving content over HTTPS.
1364
+ *
1365
+ * Many sites have varying degrees of HTTPS support, the most common of which is sites that have it
1366
+ * enabled, but only if you visit the right site address.
1367
+ *
1368
+ * @since 5.2.0
1369
+ *
1370
+ * @return array The test results.
1371
+ */
1372
+ public function get_test_https_status() {
1373
+ $result = array(
1374
+ 'label' => __( 'Your website is using an active HTTPS connection.', 'health-check' ),
1375
+ 'status' => 'good',
1376
+ 'badge' => array(
1377
+ 'label' => __( 'Security', 'health-check' ),
1378
+ 'color' => 'blue',
1379
+ ),
1380
+ 'description' => sprintf(
1381
+ '<p>%s</p>',
1382
+ __( 'An HTTPS connection is needed for many features on the web today, it also gains the trust of your visitors by helping to protecting their online privacy.', 'health-check' )
1383
+ ),
1384
+ 'actions' => sprintf(
1385
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1386
+ /* translators: Documentation explaining HTTPS and why it should be used. */
1387
+ esc_url( __( 'https://wordpress.org/support/article/why-should-i-use-https/', 'health-check' ) ),
1388
+ __( 'Read more about why you should use HTTPS', 'health-check' ),
1389
+ /* translators: accessibility text */
1390
+ __( '(opens in a new tab)', 'health-check' )
1391
+ ),
1392
+ 'test' => 'https_status',
1393
+ );
1394
+
1395
  if ( is_ssl() ) {
1396
  $wp_url = get_bloginfo( 'wpurl' );
1397
  $site_url = get_bloginfo( 'url' );
1398
 
1399
  if ( 'https' !== substr( $wp_url, 0, 5 ) || 'https' !== substr( $site_url, 0, 5 ) ) {
1400
+ $result['status'] = 'recommended';
1401
+
1402
+ $result['label'] = __( 'Only parts of your site are using HTTPS', 'health-check' );
1403
+
1404
+ $result['description'] = sprintf(
1405
+ '<p>%s</p>',
1406
  sprintf(
1407
+ /* translators: %s: URL to Settings > General to change options. */
1408
  __( 'You are accessing this website using HTTPS, but your <a href="%s">WordPress Address</a> is not set up to use HTTPS by default.', 'health-check' ),
1409
  esc_url( admin_url( 'options-general.php' ) )
1410
  )
1411
  );
1412
+
1413
+ $result['actions'] .= sprintf(
1414
+ '<p><a href="%s">%s</a></p>',
1415
+ esc_url( admin_url( 'options-general.php' ) ),
1416
+ __( 'Update your site addresses', 'health-check' )
1417
  );
1418
  }
1419
  } else {
1420
+ $result['status'] = 'recommended';
1421
+
1422
+ $result['label'] = __( 'Your site does not use HTTPS', 'health-check' );
 
1423
  }
1424
+
1425
+ return $result;
1426
  }
1427
 
1428
+ /**
1429
+ * Check if the HTTP API can handle SSL/TLS requests.
1430
+ *
1431
+ * @since 5.2.0
1432
+ *
1433
+ * @return array The test results.
1434
+ */
1435
+ public function get_test_ssl_support() {
1436
+ $result = array(
1437
+ 'label' => '',
1438
+ 'status' => '',
1439
+ 'badge' => array(
1440
+ 'label' => __( 'Security', 'health-check' ),
1441
+ 'color' => 'blue',
1442
+ ),
1443
+ 'description' => sprintf(
1444
+ '<p>%s</p>',
1445
+ __( 'Securely communicating between servers are needed for transactions such as fetching files, conducting sales on store sites, and much more.', 'health-check' )
1446
+ ),
1447
+ 'actions' => '',
1448
+ 'test' => 'ssl_support',
1449
+ );
1450
+
1451
  $supports_https = wp_http_supports( array( 'ssl' ) );
1452
 
1453
  if ( $supports_https ) {
1454
+ $result['status'] = 'good';
1455
+
1456
+ $result['label'] = __( 'Your site can communicate securely with other services', 'health-check' );
 
1457
  } else {
1458
+ $result['status'] = 'critical';
1459
+
1460
+ $result['label'] = __( 'Your site is unable to communicate securely with other services', 'health-check' );
1461
+
1462
+ $result['description'] .= sprintf(
1463
+ '<p>%s</p>',
1464
+ __( 'Talk to your web host about OpenSSL support for PHP.', 'health-check' )
1465
  );
1466
  }
1467
+
1468
+ return $result;
1469
  }
1470
 
1471
+ /**
1472
+ * Test if scheduled events run as intended.
1473
+ *
1474
+ * If scheduled events are not running, this may indicate something with WP_Cron is not working as intended,
1475
+ * or that there are orphaned events hanging around from older code.
1476
+ *
1477
+ * @since 5.2.0
1478
+ *
1479
+ * @return array The test results.
1480
+ */
1481
+ public function get_test_scheduled_events() {
1482
+ $result = array(
1483
+ 'label' => __( 'Scheduled events are running', 'health-check' ),
1484
+ 'status' => 'good',
1485
+ 'badge' => array(
1486
+ 'label' => __( 'Performance', 'health-check' ),
1487
+ 'color' => 'blue',
1488
+ ),
1489
+ 'description' => sprintf(
1490
+ '<p>%s</p>',
1491
+ __( 'Scheduled events are what periodically looks for updates to plugins, themes and WordPress itself. It is also what makes sure scheduled posts are published on time. It may also be used by various plugins to make sure that planned actions are executed.', 'health-check' )
1492
+ ),
1493
+ 'actions' => '',
1494
+ 'test' => 'scheduled_events',
1495
+ );
1496
+
1497
+ $schedule = new Health_Check_WP_Cron();
1498
+
1499
+ if ( is_wp_error( $schedule->has_missed_cron() ) ) {
1500
+ $result['status'] = 'critical';
1501
+
1502
+ $result['label'] = __( 'It was not possible to check your scheduled events', 'health-check' );
1503
 
1504
+ $result['description'] = sprintf(
1505
+ '<p>%s</p>',
1506
+ sprintf(
1507
+ /* translators: %s: The error message returned while from the cron scheduler. */
1508
+ __( 'While trying to test your site&#8217;s scheduled events, the following error was returned: %s', 'health-check' ),
1509
+ $schedule->has_missed_cron()->get_error_message()
1510
+ )
1511
  );
1512
  } else {
1513
+ if ( $schedule->has_missed_cron() ) {
1514
+ $result['status'] = 'recommended';
1515
+
1516
+ $result['label'] = __( 'A scheduled event has failed', 'health-check' );
1517
+
1518
+ $result['description'] = sprintf(
1519
+ '<p>%s</p>',
1520
  sprintf(
1521
+ /* translators: %s: The name of the failed cron event. */
1522
+ __( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ),
1523
+ $schedule->last_missed_cron
1524
  )
1525
  );
 
 
 
 
 
1526
  }
1527
  }
1528
+
1529
+ return $result;
1530
  }
1531
 
1532
+ /**
1533
+ * Test if WordPress can run automated background updates.
1534
+ *
1535
+ * Background updates in WordPress are primarily used for minor releases and security updates. It's important
1536
+ * to either have these working, or be aware that they are intentionally disabled for whatever reason.
1537
+ *
1538
+ * @since 5.2.0
1539
+ *
1540
+ * @return array The test results.
1541
+ */
1542
+ public function get_test_background_updates() {
1543
+ $result = array(
1544
+ 'label' => __( 'Background updates are working', 'health-check' ),
1545
+ 'status' => 'good',
1546
+ 'badge' => array(
1547
+ 'label' => __( 'Security', 'health-check' ),
1548
+ 'color' => 'blue',
1549
+ ),
1550
+ 'description' => sprintf(
1551
+ '<p>%s</p>',
1552
+ __( 'Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.', 'health-check' )
1553
+ ),
1554
+ 'actions' => '',
1555
+ 'test' => 'background_updates',
1556
+ );
1557
+
1558
+ // Run the auto-update tests in a separate class,
1559
+ // as there are many considerations to be made.
1560
  $automatic_updates = new Health_Check_Auto_Updates();
1561
  $tests = $automatic_updates->run_tests();
1562
 
1563
+ $output = '<ul>';
1564
 
1565
  foreach ( $tests as $test ) {
1566
+ $severity_string = __( 'Passed', 'health-check' );
1567
+
1568
+ if ( 'fail' === $test->severity ) {
1569
+ $result['label'] = __( 'Background updates are not working as expected', 'health-check' );
1570
+
1571
+ $result['status'] = 'critical';
1572
+
1573
+ $severity_string = __( 'Error', 'health-check' );
1574
+ }
1575
+
1576
+ if ( 'warning' === $test->severity && 'good' === $result['status'] ) {
1577
+ $result['label'] = __( 'Background updates may not be working properly', 'health-check' );
1578
+
1579
+ $result['status'] = 'recommended';
1580
+
1581
+ $severity_string = __( 'Warning', 'health-check' );
1582
+ }
1583
+
1584
+ $output .= sprintf(
1585
+ '<li><span class="%s"><span class="screen-reader-text">%s</span></span> %s</li>',
1586
  esc_attr( $test->severity ),
1587
+ $severity_string,
1588
+ $test->description
1589
  );
1590
  }
1591
 
1592
+ $output .= '</ul>';
1593
+
1594
+ if ( 'good' !== $result['status'] ) {
1595
+ $result['description'] .= sprintf(
1596
+ '<p>%s</p>',
1597
+ $output
1598
+ );
1599
+ }
1600
+
1601
+ return $result;
1602
+ }
1603
+
1604
+ public function json_test_background_updates() {
1605
+ wp_send_json_success( $this->get_test_background_updates() );
1606
  }
1607
 
1608
+ public function get_test_extension_updates() {
1609
+ $result = array(
1610
+ 'label' => esc_html__( 'Plugin and theme updates are working', 'health-check' ),
1611
+ 'status' => 'good',
1612
+ 'badge' => array(
1613
+ 'label' => esc_html__( 'Security', 'health-check' ),
1614
+ 'color' => 'red',
1615
+ ),
1616
+ 'description' => sprintf(
1617
+ '<p>%s</p>',
1618
+ esc_html__( 'Plugins or themes may have their own way of handling updates, which could break or negatively impact normal updates in WordPress.', 'health-check' )
1619
+ ),
1620
+ 'actions' => '',
1621
+ 'test' => 'extension_updates',
1622
+ );
1623
+
1624
  $updates = new Health_Check_Updates();
1625
  $tests = $updates->run_tests();
1626
 
1627
+ $output = '<ul>';
1628
 
1629
  foreach ( $tests as $test ) {
1630
+ $severity_string = esc_html__( 'Passed', 'health-check' );
1631
+
1632
+ if ( 'fail' === $test->severity ) {
1633
+ $result['label'] = esc_html__( 'Plugin or theme updates are not working', 'health-check' );
1634
+
1635
+ $result['status'] = 'critical';
1636
+
1637
+ $severity_string = esc_html__( 'Error', 'health-check' );
1638
+ }
1639
+
1640
+ if ( 'warning' === $test->severity && 'good' === $result['status'] ) {
1641
+ $result['label'] = esc_html__( 'Some plugin or theme updates may not work as expected', 'health-check' );
1642
+
1643
+ $result['status'] = 'recommended';
1644
+
1645
+ $severity_string = esc_html__( 'Warning', 'health-check' );
1646
+ }
1647
+
1648
+ $output .= sprintf(
1649
+ '<li><span class="%s"><span class="screen-reader-text">%s</span></span> %s</li>',
1650
  esc_attr( $test->severity ),
1651
+ $severity_string,
1652
  $test->desc
1653
  );
1654
  }
1655
 
1656
+ $output .= '</ul>';
1657
+
1658
+ if ( 'critical' === $result['status'] ) {
1659
+ $result['description'] .= sprintf(
1660
+ '<p>%s</p>',
1661
+ $output
1662
+ );
1663
+ }
1664
 
1665
+ return $result;
1666
+ }
1667
 
1668
+ /**
1669
+ * Test if loopbacks work as expected.
1670
+ *
1671
+ * A loopback is when WordPress queries itself, for example to start a new WP_Cron instance, or when editing a
1672
+ * plugin or theme. This has shown itself to be a recurring issue as code can very easily break this interaction.
1673
+ *
1674
+ * @since 5.2.0
1675
+ *
1676
+ * @return array The test results.
1677
+ */
1678
+ public function get_test_loopback_requests() {
1679
+ $result = array(
1680
+ 'label' => __( 'Your site can perform loopback requests', 'health-check' ),
1681
+ 'status' => 'good',
1682
+ 'badge' => array(
1683
+ 'label' => __( 'Performance', 'health-check' ),
1684
+ 'color' => 'blue',
1685
+ ),
1686
+ 'description' => sprintf(
1687
+ '<p>%s</p>',
1688
+ __( 'Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.', 'health-check' )
1689
+ ),
1690
+ 'actions' => '',
1691
+ 'test' => 'loopback_requests',
1692
  );
1693
 
1694
+ $loopback = new Health_Check_Loopback();
1695
+
1696
+ $check_loopback = $loopback->can_perform_loopback();
1697
+
1698
+ $result['status'] = $check_loopback->status;
1699
+
1700
+ if ( 'good' !== $check_loopback->status ) {
1701
+ $result['label'] = __( 'Your site could not complete a loopback request', 'health-check' );
1702
+
1703
+ $result['description'] .= sprintf(
1704
+ '<p>%s</p>',
1705
+ $check_loopback->message
1706
  );
1707
  }
1708
+
1709
+ return $result;
1710
  }
1711
 
1712
+ public function json_test_loopback_requests() {
1713
+ wp_send_json_success( $this->get_test_loopback_requests() );
1714
+ }
1715
+
1716
+ /**
1717
+ * Test if HTTP requests are blocked.
1718
+ *
1719
+ * It's possible to block all outgoing communication (with the possibility of whitelisting hosts) via the
1720
+ * HTTP API. This may create problems for users as many features are running as services these days.
1721
+ *
1722
+ * @since 5.2.0
1723
+ *
1724
+ * @return array The test results.
1725
+ */
1726
+ public function get_test_http_requests() {
1727
+ $result = array(
1728
+ 'label' => __( 'HTTP requests seem to be working as expected', 'health-check' ),
1729
+ 'status' => 'good',
1730
+ 'badge' => array(
1731
+ 'label' => __( 'Performance', 'health-check' ),
1732
+ 'color' => 'blue',
1733
+ ),
1734
+ 'description' => sprintf(
1735
+ '<p>%s</p>',
1736
+ __( 'It is possible for site maintainers to block all, or some, communication to other sites and services. If set up incorrectly, this may prevent plugins and themes from working as intended.', 'health-check' )
1737
+ ),
1738
+ 'actions' => '',
1739
+ 'test' => 'http_requests',
1740
+ );
1741
+
1742
  $blocked = false;
1743
  $hosts = array();
1744
 
1751
  }
1752
 
1753
  if ( $blocked && 0 === sizeof( $hosts ) ) {
1754
+ $result['status'] = 'critical';
1755
+
1756
+ $result['label'] = __( 'HTTP requests are blocked', 'health-check' );
1757
+
1758
+ $result['description'] .= sprintf(
1759
+ '<p>%s</p>',
1760
+ sprintf(
1761
+ /* translators: %s: Name of the constant used. */
1762
+ __( 'HTTP requests have been blocked by the %s constant, with no allowed hosts.', 'health-check' ),
1763
+ '<code>WP_HTTP_BLOCK_EXTERNAL</code>'
1764
+ )
1765
  );
1766
  }
1767
 
1768
  if ( $blocked && 0 < sizeof( $hosts ) ) {
1769
+ $result['status'] = 'recommended';
1770
+
1771
+ $result['label'] = __( 'HTTP requests are partially blocked', 'health-check' );
1772
+
1773
+ $result['description'] .= sprintf(
1774
+ '<p>%s</p>',
1775
  sprintf(
1776
+ /* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */
1777
+ __( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.', 'health-check' ),
1778
+ '<code>WP_HTTP_BLOCK_EXTERNAL</code>',
1779
  implode( ',', $hosts )
1780
  )
1781
  );
1782
  }
1783
 
1784
+ return $result;
 
 
 
 
 
 
1785
  }
1786
 
1787
+ /**
1788
+ * Test if the REST API is accessible.
1789
+ *
1790
+ * Various security measures may block the REST API from working, or it may have been disabled in general.
1791
+ * This is required for the new block editor to work, so we explicitly test for this.
1792
+ *
1793
+ * @since 5.2.0
1794
+ *
1795
+ * @return array The test results.
1796
+ */
1797
+ public function get_test_rest_availability() {
1798
+ $result = array(
1799
+ 'label' => __( 'The REST API is available', 'health-check' ),
1800
+ 'status' => 'good',
1801
+ 'badge' => array(
1802
+ 'label' => __( 'Performance', 'health-check' ),
1803
+ 'color' => 'blue',
1804
+ ),
1805
+ 'description' => sprintf(
1806
+ '<p>%s</p>',
1807
+ __( 'The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.', 'health-check' )
1808
+ ),
1809
+ 'actions' => '',
1810
+ 'test' => 'rest_availability',
1811
+ );
1812
+
1813
  $cookies = wp_unslash( $_COOKIE );
1814
  $timeout = 10;
1815
  $headers = array(
1824
 
1825
  $url = rest_url( 'wp/v2/types/post' );
1826
 
1827
+ // The context for this is editing with the new block editor.
1828
+ $url = add_query_arg(
1829
+ array(
1830
+ 'context' => 'edit',
1831
+ ),
1832
+ $url
1833
+ );
1834
 
1835
  $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
1836
 
1837
  if ( is_wp_error( $r ) ) {
1838
+ $result['status'] = 'critical';
1839
+
1840
+ $result['label'] = __( 'The REST API encountered an error', 'health-check' );
1841
+
1842
+ $result['description'] .= sprintf(
1843
+ '<p>%s</p>',
1844
  sprintf(
1845
  '%s<br>%s',
1846
+ __( 'The REST API request failed due to an error.', 'health-check' ),
1847
  sprintf(
1848
+ /* translators: 1: The HTTP response code. 2: The error message returned. */
1849
+ __( 'Error: [%1$s] %2$s', 'health-check' ),
1850
  wp_remote_retrieve_response_code( $r ),
1851
  $r->get_error_message()
1852
  )
1853
  )
1854
  );
1855
  } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
1856
+ $result['status'] = 'recommended';
1857
+
1858
+ $result['label'] = __( 'The REST API encountered an unexpected result', 'health-check' );
1859
+
1860
+ $result['description'] .= sprintf(
1861
+ '<p>%s</p>',
1862
  sprintf(
1863
+ /* translators: 1: The HTTP response code returned. 2: The error message returned. */
1864
+ __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.', 'health-check' ),
1865
  wp_remote_retrieve_response_code( $r ),
1866
  wp_remote_retrieve_body( $r )
1867
  )
1870
  $json = json_decode( wp_remote_retrieve_body( $r ), true );
1871
 
1872
  if ( false !== $json && ! isset( $json['capabilities'] ) ) {
1873
+ $result['status'] = 'recommended';
1874
+
1875
+ $result['label'] = __( 'The REST API did not behave correctly', 'health-check' );
1876
+
1877
+ $result['description'] .= sprintf(
1878
+ '<p>%s</p>',
1879
+ sprintf(
1880
+ /* translators: %s: the name of the query parameter being tested. */
1881
+ __( 'The REST API did not process the %s query parameter correctly.', 'health-check' ),
1882
+ '<code>context</code>'
1883
+ )
1884
  );
1885
  }
1886
  }
1887
+
1888
+ return $result;
1889
  }
1890
 
1891
  /**
1892
  * Return a set of tests that belong to the site status page.
1893
  *
1894
+ * Each site status test is defined here, they may be `direct` tests, that run on page load, or `async` tests
1895
+ * which will run later down the line via JavaScript calls to improve page performance and hopefully also user
1896
+ * experiences.
1897
  *
1898
+ * @since 5.2.0
1899
+ *
1900
+ * @return array The list of tests to run.
1901
  */
1902
  public static function get_tests() {
1903
+ global $health_check_site_status;
1904
+
1905
  $tests = array(
1906
  'direct' => array(
1907
+ 'wordpress_version' => array(
1908
  'label' => __( 'WordPress Version', 'health-check' ),
1909
+ 'test' => array( $health_check_site_status, 'get_test_wordpress_version' ),
1910
  ),
1911
+ 'plugin_version' => array(
1912
  'label' => __( 'Plugin Versions', 'health-check' ),
1913
+ 'test' => array( $health_check_site_status, 'get_test_plugin_version' ),
1914
  ),
1915
+ 'theme_version' => array(
1916
  'label' => __( 'Theme Versions', 'health-check' ),
1917
+ 'test' => array( $health_check_site_status, 'get_test_theme_version' ),
1918
  ),
1919
+ 'php_version' => array(
1920
  'label' => __( 'PHP Version', 'health-check' ),
1921
+ 'test' => array( $health_check_site_status, 'get_test_php_version' ),
1922
  ),
1923
+ 'sql_server' => array(
1924
  'label' => __( 'Database Server version', 'health-check' ),
1925
+ 'test' => array( $health_check_site_status, 'get_test_sql_server' ),
1926
  ),
1927
+ 'php_extensions' => array(
1928
  'label' => __( 'PHP Extensions', 'health-check' ),
1929
+ 'test' => array( $health_check_site_status, 'get_test_php_extensions' ),
1930
  ),
1931
+ 'utf8mb4_support' => array(
1932
  'label' => __( 'MySQL utf8mb4 support', 'health-check' ),
1933
+ 'test' => array( $health_check_site_status, 'get_test_utf8mb4_support' ),
1934
  ),
1935
+ 'https_status' => array(
1936
  'label' => __( 'HTTPS status', 'health-check' ),
1937
+ 'test' => array( $health_check_site_status, 'get_test_https_status' ),
1938
  ),
1939
+ 'ssl_support' => array(
1940
  'label' => __( 'Secure communication', 'health-check' ),
1941
+ 'test' => array( $health_check_site_status, 'get_test_ssl_support' ),
1942
  ),
1943
+ 'scheduled_events' => array(
1944
  'label' => __( 'Scheduled events', 'health-check' ),
1945
+ 'test' => array( $health_check_site_status, 'get_test_scheduled_events' ),
1946
  ),
1947
+ 'http_requests' => array(
 
 
 
 
1948
  'label' => __( 'HTTP Requests', 'health-check' ),
1949
+ 'test' => array( $health_check_site_status, 'get_test_http_requests' ),
1950
+ ),
1951
+ 'debug_enabled' => array(
1952
+ 'label' => __( 'Debugging enabled', 'health-check' ),
1953
+ 'test' => array( $health_check_site_status, 'get_test_is_in_debug_mode' ),
1954
  ),
1955
  ),
1956
  'async' => array(
1957
+ 'dotorg_communication' => array(
1958
  'label' => __( 'Communication with WordPress.org', 'health-check' ),
1959
  'test' => 'dotorg_communication',
1960
  ),
1961
+ 'background_updates' => array(
1962
  'label' => __( 'Background updates', 'health-check' ),
1963
  'test' => 'background_updates',
1964
  ),
1965
+ 'loopback_requests' => array(
1966
  'label' => __( 'Loopback request', 'health-check' ),
1967
  'test' => 'loopback_requests',
1968
  ),
1971
 
1972
  // Conditionally include REST rules if the function for it exists.
1973
  if ( function_exists( 'rest_url' ) ) {
1974
+ $tests['direct']['rest_availability'] = array(
1975
  'label' => __( 'REST API availability', 'health-check' ),
1976
+ 'test' => array( $health_check_site_status, 'get_test_rest_availability' ),
1977
  );
1978
  }
1979
 
1980
+ /**
1981
+ * Add or modify which site status tests are run on a site.
1982
+ *
1983
+ * The site health is determined by a set of tests based on best practices from
1984
+ * both the WordPress Hosting Team, but also web standards in general.
1985
+ *
1986
+ * Some sites may not have the same requirements, for example the automatic update
1987
+ * checks may be handled by a host, and are therefore disabled in core.
1988
+ * Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example.
1989
+ *
1990
+ * Tests may be added either as direct, or asynchronous ones. Any test that may require some time
1991
+ * to complete should run asynchronously, to avoid extended loading periods within wp-admin.
1992
+ *
1993
+ * @since 5.2.0
1994
+ *
1995
+ * @param array $test_type {
1996
+ * An associative array, where the `$test_type` is either `direct` or
1997
+ * `async`, to declare if the test should run via AJAX calls after page load.
1998
+ *
1999
+ * @type array $identifier {
2000
+ * `$identifier` should be a unique identifier for the test that should run.
2001
+ * Plugins and themes are encouraged to prefix test identifiers with their slug
2002
+ * to avoid any collisions between tests.
2003
+ *
2004
+ * @type string $label A friendly label for your test to identify it by.
2005
+ * @type mixed $test A callable to perform a direct test, or a string AJAX action to be called
2006
+ * to perform an async test.
2007
+ * }
2008
+ * }
2009
+ */
2010
+ $tests = apply_filters( 'site_status_tests', $tests );
2011
+
2012
  return $tests;
2013
  }
2014
+
2015
+ public function scheduled_check() {
2016
+ // Bootstrap wp-admin, as WP_Cron doesn't do this for us.
2017
+ require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php' );
2018
+
2019
+ $bulk_tests = Health_Check_Site_Status::get_tests();
2020
+
2021
+ $results = array();
2022
+
2023
+ $site_status = array(
2024
+ 'good' => 0,
2025
+ 'recommended' => 0,
2026
+ 'critical' => 0,
2027
+ );
2028
+
2029
+ $tests = array_merge( $bulk_tests['direct'], $bulk_tests['async'] );
2030
+
2031
+ foreach ( $tests as $test ) {
2032
+ $function = sprintf(
2033
+ 'get_test_%s',
2034
+ $test['test']
2035
+ );
2036
+
2037
+ if ( method_exists( $this, $function ) && is_callable( array( $this, $function ) ) ) {
2038
+ $results[] = call_user_func( array( $this, $function ) );
2039
+ } else {
2040
+ $results[] = call_user_func( $test['test'] );
2041
+ }
2042
+ }
2043
+
2044
+ foreach ( $results as $result ) {
2045
+ if ( 'critical' === $result['status'] ) {
2046
+ $site_status['critical']++;
2047
+ } elseif ( 'recommended' === $result['status'] ) {
2048
+ $site_status['recommended']++;
2049
+ } else {
2050
+ $site_status['good']++;
2051
+ }
2052
+ }
2053
+
2054
+ set_transient( 'health-check-site-status-result', json_encode( $site_status ) );
2055
+ }
2056
  }
2057
 
2058
  global $health_check_site_status;
includes/class-health-check-troubleshoot.php CHANGED
@@ -5,6 +5,11 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_Troubleshoot
10
  */
@@ -34,7 +39,7 @@ class Health_Check_Troubleshoot {
34
 
35
  update_option( 'health-check-disable-plugin-hash', $loopback_hash . md5( $_SERVER['REMOTE_ADDR'] ) );
36
 
37
- setcookie( 'health-check-disable-plugins', $loopback_hash, 0, COOKIEPATH, COOKIE_DOMAIN );
38
  }
39
 
40
  /**
@@ -59,72 +64,6 @@ class Health_Check_Troubleshoot {
59
  return file_exists( WPMU_PLUGIN_DIR . '/health-check-disable-plugins.php' );
60
  }
61
 
62
- /**
63
- * Check if the user has been shown the backup warning.
64
- *
65
- * @uses get_user_meta()
66
- * @uses get_current_user_id()
67
- *
68
- * @return bool
69
- */
70
- static function has_seen_warning() {
71
- /**
72
- * Filter who may see the backup warning from the plugin.
73
- *
74
- * The plugin displays a warning reminding users to keep backups when active.
75
- * This filter allows anyone to declare what capability is needed to view the warning, it is set to
76
- * the `manage_options` capability by default. This means the feature is available to any site admin,
77
- * even in a multisite environment.
78
- *
79
- * @param string $capability Default manage_options. The capability required to see the warning.
80
- */
81
- $capability_to_see = apply_filters( 'health_check_backup_warning_required_capability', 'manage_options' );
82
-
83
- // If the current user lacks the capabilities to use the plugin, pretend they've seen the warning so it isn't displayed.
84
- if ( ! current_user_can( $capability_to_see ) ) {
85
- return true;
86
- }
87
-
88
- $meta = get_user_meta( get_current_user_id(), 'health-check', true );
89
- if ( empty( $meta ) ) {
90
- return false;
91
- }
92
-
93
- if ( 'seen' === $meta['warning']['backup'] ) {
94
- return true;
95
- }
96
-
97
- return false;
98
- }
99
-
100
- /**
101
- * Save the confirmation of having seen a warning.
102
- *
103
- * @uses get_user_meta()
104
- * @uses get_current_user_id()
105
- * @uses update_user_meta()
106
- *
107
- * @return void
108
- */
109
- static function confirm_warning() {
110
- check_ajax_referer( 'health-check-confirm-warning' );
111
-
112
- if ( ! current_user_can( 'manage_options' ) ) {
113
- wp_send_json_error();
114
- }
115
-
116
- $user_meta = get_user_meta( get_current_user_id(), 'health-check', true );
117
- if ( empty( $user_meta ) ) {
118
- $user_meta = array(
119
- 'warning',
120
- );
121
- }
122
-
123
- $user_meta['warning'][ $_POST['warning'] ] = 'seen';
124
-
125
- update_user_meta( get_current_user_id(), 'health-check', $user_meta );
126
- }
127
-
128
  /**
129
  * Introduce our Must-Use plugin.
130
  *
@@ -289,7 +228,7 @@ class Health_Check_Troubleshoot {
289
  }
290
 
291
  ?>
292
- <div class="notice inline">
293
 
294
  <?php
295
  $troubleshooting = null;
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_Troubleshoot
15
  */
39
 
40
  update_option( 'health-check-disable-plugin-hash', $loopback_hash . md5( $_SERVER['REMOTE_ADDR'] ) );
41
 
42
+ setcookie( 'wp-health-check-disable-plugins', $loopback_hash, 0, COOKIEPATH, COOKIE_DOMAIN );
43
  }
44
 
45
  /**
64
  return file_exists( WPMU_PLUGIN_DIR . '/health-check-disable-plugins.php' );
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  /**
68
  * Introduce our Must-Use plugin.
69
  *
228
  }
229
 
230
  ?>
231
+ <div>
232
 
233
  <?php
234
  $troubleshooting = null;
includes/class-health-check-updates.php CHANGED
@@ -5,6 +5,11 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_Updates
10
  */
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_Updates
15
  */
includes/class-health-check-wp-cli.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP-CLI Commands for the Health Check plugin
4
+ *
5
+ * @package Health Check
6
+ */
7
+
8
+ use WP_CLI\Utils;
9
+
10
+ // Make sure the file is not directly accessible.
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ die( 'We\'re sorry, but you can not directly access this file.' );
13
+ }
14
+
15
+ /**
16
+ * Class Health_Check_WP_CLI
17
+ */
18
+ class Health_Check_WP_CLI extends WP_CLI_Command {
19
+ /**
20
+ * See the sites status based on best practices and WordPress recommendations.
21
+ *
22
+ * ## EXAMPLES
23
+ *
24
+ * wp health-check status
25
+ *
26
+ * ## OPTIONS
27
+ *
28
+ * [--format=<format>]
29
+ * : Render the output in a particular format.
30
+ * ---
31
+ * default: table
32
+ * options:
33
+ * - table
34
+ * - csv
35
+ * - json
36
+ * - yaml
37
+ * ---
38
+ */
39
+ public function status( $args, $assoc_args ) {
40
+ global $health_check_site_status;
41
+
42
+ $all_tests = $health_check_site_status::get_tests();
43
+ $all_tests = array_merge( $all_tests['direct'], $all_tests['async'] );
44
+
45
+ $test_result = array();
46
+
47
+ foreach ( $all_tests as $test ) {
48
+ ob_start();
49
+ call_user_func( array( $health_check_site_status, 'test_' . $test['test'] ) );
50
+ $test_output = ob_get_clean();
51
+
52
+ $test_result[] = array(
53
+ 'test' => $test['label'],
54
+ 'result' => wp_kses( $test_output, array() ),
55
+ );
56
+ }
57
+
58
+ if ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
59
+ WP_CLI\Utils\format_items( 'json', $test_result, array( 'test', 'result' ) );
60
+ } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'csv' ) {
61
+ WP_CLI\Utils\format_items( 'csv', $test_result, array( 'test', 'result' ) );
62
+ } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) {
63
+ WP_CLI\Utils\format_items( 'yaml', $test_result, array( 'test', 'result' ) );
64
+ } else {
65
+ WP_CLI\Utils\format_items( 'table', $test_result, array( 'test', 'result' ) );
66
+ }
67
+ }
68
+ }
69
+
70
+ WP_CLI::add_command( 'health-check', 'Health_Check_WP_CLI' );
includes/class-health-check-wp-cron.php CHANGED
@@ -5,6 +5,11 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class Health_Check_WP_Cron
10
  */
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class Health_Check_WP_Cron
15
  */
includes/class-health-check.php CHANGED
@@ -5,6 +5,11 @@
5
  * @package Health Check
6
  */
7
 
 
 
 
 
 
8
  /**
9
  * Class HealthCheck
10
  */
@@ -47,9 +52,7 @@ class Health_Check {
47
 
48
  add_filter( 'plugin_row_meta', array( $this, 'settings_link' ), 10, 2 );
49
 
50
- add_filter( 'plugin_action_links', array( $this, 'troubeshoot_plugin_action' ), 20, 4 );
51
-
52
- add_action( 'admin_footer', array( $this, 'show_backup_warning' ) );
53
 
54
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
55
 
@@ -64,25 +67,11 @@ class Health_Check {
64
  add_action( 'wp_ajax_health-check-files-integrity-check', array( 'Health_Check_Files_Integrity', 'run_files_integrity_check' ) );
65
  add_action( 'wp_ajax_health-check-view-file-diff', array( 'Health_Check_Files_Integrity', 'view_file_diff' ) );
66
  add_action( 'wp_ajax_health-check-mail-check', array( 'Health_Check_Mail_Check', 'run_mail_check' ) );
67
- add_action( 'wp_ajax_health-check-confirm-warning', array( 'Health_Check_Troubleshoot', 'confirm_warning' ) );
68
 
69
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Files_Integrity', 'tools_tab' ) );
70
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Mail_Check', 'tools_tab' ) );
71
- }
72
 
73
- /**
74
- * Show a warning modal about keeping backups.
75
- *
76
- * @uses Health_Check_Troubleshoot::has_seen_warning()
77
- *
78
- * @return void
79
- */
80
- public function show_backup_warning() {
81
- if ( Health_Check_Troubleshoot::has_seen_warning() ) {
82
- return;
83
- }
84
-
85
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/backup-warning.php' );
86
  }
87
 
88
  /**
@@ -96,7 +85,7 @@ class Health_Check {
96
  * @return void
97
  */
98
  public function start_troubleshoot_mode() {
99
- if ( ! isset( $_POST['health-check-troubleshoot-mode'] ) || ! current_user_can( 'manage_options' ) ) {
100
  return;
101
  }
102
 
@@ -128,7 +117,7 @@ class Health_Check {
128
  * @return void
129
  */
130
  public function start_troubleshoot_single_plugin_mode() {
131
- if ( ! isset( $_GET['health-check-troubleshoot-plugin'] ) || ! current_user_can( 'manage_options' ) ) {
132
  return;
133
  }
134
 
@@ -202,40 +191,105 @@ class Health_Check {
202
  * @return void
203
  */
204
  public function enqueues() {
205
- /*
206
- * Don't enqueue anything unless we're on the health check page
207
- *
208
- * Special consideration, if warnings are not dismissed we need to display
209
- * our modal, and thus require our styles, in other locations, before bailing.
210
- */
211
- if ( ( ! isset( $_GET['page'] ) || 'health-check' !== $_GET['page'] ) && Health_Check_Troubleshoot::has_seen_warning() ) {
212
  return;
213
  }
214
 
215
- wp_enqueue_style( 'health-check', HEALTH_CHECK_PLUGIN_URL . '/assets/css/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
216
-
217
- wp_enqueue_script( 'health-check', HEALTH_CHECK_PLUGIN_URL . '/assets/javascript/health-check.js', array( 'jquery' ), HEALTH_CHECK_PLUGIN_VERSION, true );
218
-
219
- wp_localize_script( 'health-check', 'HealthCheck', array(
220
- 'string' => array(
221
- 'please_wait' => esc_html__( 'Please wait...', 'health-check' ),
222
- 'copied' => esc_html__( 'Copied', 'health-check' ),
223
- 'running_tests' => esc_html__( 'Currently being tested...', 'health-check' ),
224
- ),
225
- 'warning' => array(
226
- 'seen_backup' => Health_Check_Troubleshoot::has_seen_warning(),
 
 
 
 
 
 
 
 
 
 
 
227
  ),
228
- 'nonce' => array(
229
  'loopback_no_plugins' => wp_create_nonce( 'health-check-loopback-no-plugins' ),
230
  'loopback_individual_plugins' => wp_create_nonce( 'health-check-loopback-individual-plugins' ),
231
  'loopback_default_theme' => wp_create_nonce( 'health-check-loopback-default-theme' ),
232
  'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ),
233
  'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ),
234
  'mail_check' => wp_create_nonce( 'health-check-mail-check' ),
235
- 'confirm_warning' => wp_create_nonce( 'health-check-confirm-warning' ),
236
  'site_status' => wp_create_nonce( 'health-check-site-status' ),
 
237
  ),
238
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  /**
@@ -247,7 +301,42 @@ class Health_Check {
247
  * @return void
248
  */
249
  public function action_admin_menu() {
250
- add_dashboard_page( _x( 'Health Check', 'Menu, Section and Page Title', 'health-check' ), _x( 'Health Check', 'Menu, Section and Page Title', 'health-check' ), 'manage_options', 'health-check', array( $this, 'dashboard_page' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
 
253
  /**
@@ -280,7 +369,7 @@ class Health_Check {
280
  *
281
  * @return array
282
  */
283
- public function troubeshoot_plugin_action( $actions, $plugin_file, $plugin_data, $context ) {
284
  // Don't add anything if this is a Must-Use plugin, we can't touch those.
285
  if ( 'mustuse' === $context ) {
286
  return $actions;
@@ -324,62 +413,41 @@ class Health_Check {
324
  * @return void
325
  */
326
  public function dashboard_page() {
327
- ?>
328
- <div class="wrap">
329
- <h1>
330
- <?php _ex( 'Health Check', 'Menu, Section and Page Title', 'health-check' ); ?>
331
- </h1>
332
-
333
- <?php
334
- $tabs = array(
335
- 'site-status' => esc_html__( 'Site Status', 'health-check' ),
336
- 'debug' => esc_html__( 'Debug Information', 'health-check' ),
337
- 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ),
338
- 'phpinfo' => esc_html__( 'PHP Information', 'health-check' ),
339
- 'tools' => esc_html__( 'Tools', 'health-check' ),
340
- );
 
 
 
 
 
341
 
342
- $current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'site-status' );
343
- ?>
344
-
345
- <h2 class="nav-tab-wrapper wp-clearfix">
346
- <?php
347
- foreach ( $tabs as $tab => $label ) {
348
- printf(
349
- '<a href="%s" class="nav-tab %s">%s</a>',
350
- sprintf(
351
- '%s&tab=%s',
352
- menu_page_url( 'health-check', false ),
353
- $tab
354
- ),
355
- ( $current_tab === $tab ? 'nav-tab-active' : '' ),
356
- $label
357
- );
358
- }
359
- ?>
360
- </h2>
361
-
362
- <?php
363
- switch ( $current_tab ) {
364
- case 'debug':
365
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' );
366
- break;
367
- case 'phpinfo':
368
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' );
369
- break;
370
- case 'troubleshoot':
371
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
372
- break;
373
- case 'tools':
374
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
375
- break;
376
- case 'site-status':
377
- default:
378
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' );
379
- }
380
- ?>
381
- </div>
382
- <?php
383
  }
384
 
385
  /**
@@ -394,16 +462,10 @@ class Health_Check {
394
  */
395
  static function display_notice( $message, $status = 'success' ) {
396
  printf(
397
- '<div class="notice notice-%s inline">',
398
- $status
399
- );
400
-
401
- printf(
402
- '<p>%s</p>',
403
  $message
404
  );
405
-
406
- echo '</div>';
407
  }
408
 
409
  /**
@@ -421,6 +483,17 @@ class Health_Check {
421
  }
422
  }
423
 
 
 
 
 
 
 
 
 
 
 
 
424
 
425
  /**
426
  * Conditionally show a form for providing filesystem credentials when introducing our troubleshooting mode plugin.
@@ -457,4 +530,14 @@ class Health_Check {
457
 
458
  return true;
459
  }
 
 
 
 
 
 
 
 
 
 
460
  }
5
  * @package Health Check
6
  */
7
 
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
  /**
14
  * Class HealthCheck
15
  */
52
 
53
  add_filter( 'plugin_row_meta', array( $this, 'settings_link' ), 10, 2 );
54
 
55
+ add_filter( 'plugin_action_links', array( $this, 'troubleshoot_plugin_action' ), 20, 4 );
 
 
56
 
57
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
58
 
67
  add_action( 'wp_ajax_health-check-files-integrity-check', array( 'Health_Check_Files_Integrity', 'run_files_integrity_check' ) );
68
  add_action( 'wp_ajax_health-check-view-file-diff', array( 'Health_Check_Files_Integrity', 'view_file_diff' ) );
69
  add_action( 'wp_ajax_health-check-mail-check', array( 'Health_Check_Mail_Check', 'run_mail_check' ) );
 
70
 
71
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Files_Integrity', 'tools_tab' ) );
72
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Mail_Check', 'tools_tab' ) );
 
73
 
74
+ add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  /**
85
  * @return void
86
  */
87
  public function start_troubleshoot_mode() {
88
+ if ( ! isset( $_POST['health-check-troubleshoot-mode'] ) || ! current_user_can( 'install_plugins' ) ) {
89
  return;
90
  }
91
 
117
  * @return void
118
  */
119
  public function start_troubleshoot_single_plugin_mode() {
120
+ if ( ! isset( $_GET['health-check-troubleshoot-plugin'] ) || ! current_user_can( 'install_plugins' ) ) {
121
  return;
122
  }
123
 
191
  * @return void
192
  */
193
  public function enqueues() {
194
+ // Don't enqueue anything unless we're on the health check page.
195
+ if ( ! isset( $_GET['page'] ) || 'health-check' !== $_GET['page'] ) {
 
 
 
 
 
196
  return;
197
  }
198
 
199
+ $health_check_js_variables = array(
200
+ 'string' => array(
201
+ 'please_wait' => esc_html__( 'Please wait...', 'health-check' ),
202
+ 'copied' => esc_html__( 'Copied', 'health-check' ),
203
+ 'running_tests' => esc_html__( 'Currently being tested...', 'health-check' ),
204
+ 'site_health_complete' => esc_html__( 'All site health tests have finished running.', 'health-check' ),
205
+ 'site_info_show_copy' => esc_html__( 'Show options for copying this information', 'health-check' ),
206
+ 'site_info_hide_copy' => esc_html__( 'Hide options for copying this information', 'health-check' ),
207
+ // translators: %s: The percentage pass rate for the tests.
208
+ 'site_health_complete_screen_reader' => esc_html__( 'All site health tests have finished running. Your site passed %s, and the results are now available on the page.', 'health-check' ),
209
+ 'site_info_copied' => esc_html__( 'Site information has been added to your clipboard.', 'health-check' ),
210
+ // translators: %s: Amount of critical issues.
211
+ 'site_info_heading_critical_single' => esc_html__( '%s Critical issue', 'health-check' ),
212
+ // translators: %s: Amount of critical issues.
213
+ 'site_info_heading_critical_plural' => esc_html__( '%s Critical issues', 'health-check' ),
214
+ // translators: %s: Amount of recommended issues.
215
+ 'site_info_heading_recommended_single' => esc_html__( '%s Recommended improvement', 'health-check' ),
216
+ // translators: %s: Amount of recommended issues.
217
+ 'site_info_heading_recommended_plural' => esc_html__( '%s Recommended improvements', 'health-check' ),
218
+ // translators: %s: Amount of passed tests.
219
+ 'site_info_heading_good_single' => esc_html__( '%s Item with no issues detected', 'health-check' ),
220
+ // translators: %s: Amount of passed tests.
221
+ 'site_info_heading_good_plural' => esc_html__( '%s Items with no issues detected', 'health-check' ),
222
  ),
223
+ 'nonce' => array(
224
  'loopback_no_plugins' => wp_create_nonce( 'health-check-loopback-no-plugins' ),
225
  'loopback_individual_plugins' => wp_create_nonce( 'health-check-loopback-individual-plugins' ),
226
  'loopback_default_theme' => wp_create_nonce( 'health-check-loopback-default-theme' ),
227
  'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ),
228
  'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ),
229
  'mail_check' => wp_create_nonce( 'health-check-mail-check' ),
 
230
  'site_status' => wp_create_nonce( 'health-check-site-status' ),
231
+ 'site_status_result' => wp_create_nonce( 'health-check-site-status-result' ),
232
  ),
233
+ 'site_status' => array(
234
+ 'direct' => array(),
235
+ 'async' => array(),
236
+ 'issues' => array(
237
+ 'good' => 0,
238
+ 'recommended' => 0,
239
+ 'critical' => 0,
240
+ ),
241
+ ),
242
+ );
243
+
244
+ $issue_counts = get_transient( 'health-check-site-status-result' );
245
+
246
+ if ( false !== $issue_counts ) {
247
+ $issue_counts = json_decode( $issue_counts );
248
+
249
+ $health_check_js_variables['site_status']['issues'] = $issue_counts;
250
+ }
251
+
252
+ if ( ! isset( $_GET['tab'] ) || ( isset( $_GET['tab'] ) && 'site-status' === $_GET['tab'] ) ) {
253
+ $tests = Health_Check_Site_Status::get_tests();
254
+
255
+ // Don't run https test on localhost
256
+ if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
257
+ unset( $tests['direct']['https_status'] );
258
+ }
259
+
260
+ foreach ( $tests['direct'] as $test ) {
261
+ if ( is_string( $test['test'] ) ) {
262
+ $test_function = sprintf(
263
+ 'get_test_%s',
264
+ $test['test']
265
+ );
266
+
267
+ if ( method_exists( $this, $test_function ) && is_callable( array( $this, $test_function ) ) ) {
268
+ $health_check_js_variables['site_status']['direct'][] = call_user_func( array( $this, $test_function ) );
269
+ continue;
270
+ }
271
+ }
272
+
273
+ if ( is_callable( $test['test'] ) ) {
274
+ $health_check_js_variables['site_status']['direct'][] = call_user_func( $test['test'] );
275
+ }
276
+ }
277
+
278
+ foreach ( $tests['async'] as $test ) {
279
+ if ( is_string( $test['test'] ) ) {
280
+ $health_check_js_variables['site_status']['async'][] = array(
281
+ 'test' => $test['test'],
282
+ 'completed' => false,
283
+ );
284
+ }
285
+ }
286
+ }
287
+
288
+ wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/css/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
289
+
290
+ wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/health-check.js', array( 'jquery', 'wp-a11y', 'clipboard', 'wp-util' ), HEALTH_CHECK_PLUGIN_VERSION, true );
291
+
292
+ wp_localize_script( 'health-check', 'SiteHealth', $health_check_js_variables );
293
  }
294
 
295
  /**
301
  * @return void
302
  */
303
  public function action_admin_menu() {
304
+ $critical_issues = 0;
305
+ $issue_counts = get_transient( 'health-check-site-status-result' );
306
+
307
+ if ( false !== $issue_counts ) {
308
+ $issue_counts = json_decode( $issue_counts );
309
+
310
+ $critical_issues = absint( $issue_counts->critical );
311
+ }
312
+
313
+ $critical_count = sprintf(
314
+ '<span class="update-plugins count-%d"><span class="update-count">%s</span></span>',
315
+ esc_attr( $critical_issues ),
316
+ sprintf(
317
+ '%d<span class="screen-reader-text"> %s</span>',
318
+ esc_html( $critical_issues ),
319
+ esc_html_x( 'Critical issues', 'Issue counter label for the admin menu', 'health-check' )
320
+ )
321
+ );
322
+
323
+ $menu_title =
324
+ sprintf(
325
+ // translators: %s: Critical issue counter, if any.
326
+ _x( 'Site Health %s', 'Menu Title', 'health-check' ),
327
+ ( ! $issue_counts || $critical_issues < 1 ? '' : $critical_count )
328
+ );
329
+
330
+ remove_submenu_page( 'tools.php', 'site-health.php' );
331
+
332
+ add_submenu_page(
333
+ 'tools.php',
334
+ _x( 'Site Health', 'Page Title', 'health-check' ),
335
+ $menu_title,
336
+ 'install_plugins',
337
+ 'health-check',
338
+ array( $this, 'dashboard_page' )
339
+ );
340
  }
341
 
342
  /**
369
  *
370
  * @return array
371
  */
372
+ public function troubleshoot_plugin_action( $actions, $plugin_file, $plugin_data, $context ) {
373
  // Don't add anything if this is a Must-Use plugin, we can't touch those.
374
  if ( 'mustuse' === $context ) {
375
  return $actions;
413
  * @return void
414
  */
415
  public function dashboard_page() {
416
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php' );
417
+
418
+ switch ( Health_Check::current_tab() ) {
419
+ case 'debug':
420
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' );
421
+ break;
422
+ case 'phpinfo':
423
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' );
424
+ break;
425
+ case 'troubleshoot':
426
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
427
+ break;
428
+ case 'tools':
429
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
430
+ break;
431
+ case 'site-status':
432
+ default:
433
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' );
434
+ }
435
 
436
+ // Close out the div tag opened as a wrapper in the header.
437
+ echo '</div>';
438
+ }
439
+
440
+ static function tabs() {
441
+ return array(
442
+ 'site-status' => esc_html__( 'Status', 'health-check' ),
443
+ 'debug' => esc_html__( 'Info', 'health-check' ),
444
+ 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ),
445
+ 'tools' => esc_html__( 'Tools', 'health-check' ),
446
+ );
447
+ }
448
+
449
+ static function current_tab() {
450
+ return ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'site-status' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  }
452
 
453
  /**
462
  */
463
  static function display_notice( $message, $status = 'success' ) {
464
  printf(
465
+ '<div class="notice notice-%s inline"><p>%s</p></div>',
466
+ esc_attr( $status ),
 
 
 
 
467
  $message
468
  );
 
 
469
  }
470
 
471
  /**
483
  }
484
  }
485
 
486
+ public function cron_schedules( $schedules ) {
487
+ if ( ! isset( $schedules['weekly'] ) ) {
488
+ $schedules['weekly'] = array(
489
+ 'interval' => 7 * DAY_IN_SECONDS,
490
+ 'display' => __( 'Once weekly', 'health-check' ),
491
+ );
492
+ }
493
+
494
+ return $schedules;
495
+ }
496
+
497
 
498
  /**
499
  * Conditionally show a form for providing filesystem credentials when introducing our troubleshooting mode plugin.
530
 
531
  return true;
532
  }
533
+
534
+ public static function plugin_activation() {
535
+ if ( ! wp_next_scheduled( 'health-check-scheduled-site-status-check' ) ) {
536
+ wp_schedule_event( time(), 'weekly', 'health-check-scheduled-site-status-check' );
537
+ }
538
+ }
539
+
540
+ public static function plugin_deactivation() {
541
+ wp_clear_scheduled_hook( 'health-check-scheduled-site-status-check' );
542
+ }
543
  }
modals/backup-warning.php DELETED
@@ -1,46 +0,0 @@
1
- <div class="health-check-modal" id="health-check-backup-warning" data-modal-action="" data-parent-field="">
2
- <div class="modal-content">
3
- <h2>
4
- <?php esc_html_e( 'Remember to keep backups', 'health-check' ); ?>
5
- </h2>
6
-
7
- <p>
8
- <?php _e( 'Because of how Troubleshooting Mode functions, unforeseen conflicts with other plugins or themes may in rare cases occur, leading to unexpected behaviors.', 'health-check' ); ?>
9
- </p>
10
-
11
- <p>
12
- <?php _e( 'We therefore strongly recommend <a href="https://codex.wordpress.org/WordPress_Backups">making a backup of your site</a> before you enable troubleshooting mode.', 'health-check' ); ?>
13
- </p>
14
-
15
- <p>
16
- <?php _e( 'Additionally, since we really want to make this plugin as safe as possible, if you should have any problems with the troubleshooting mode, please create a new topic in the <a href="https://wordpress.org/support/plugin/health-check">plugins support forum</a> with details about what theme and what plugins you’re using and the steps needed to reproduce the problem. This will help us to analyze and fix such problems.', 'health-check' ); ?>
17
- </p>
18
-
19
- <p>
20
- <button class="button button-primary" id="health-check-accept-backup-warning"><?php esc_html_e( 'I understand', 'health-check' ); ?></button>
21
- </p>
22
- </div>
23
- </div>
24
-
25
- <script type="text/javascript">
26
- jQuery( document ).ready(function( $ ) {
27
- if ( 'undefined' === typeof( health_check ) || false === health_check.warning.seen_backup ) {
28
- $( "#health-check-backup-warning" ).show();
29
- }
30
-
31
- $( "#health-check-accept-backup-warning" ).click(function( e ) {
32
- $( "#health-check-backup-warning" ).hide();
33
-
34
- var data = {
35
- 'action': 'health-check-confirm-warning',
36
- 'warning': 'backup',
37
- '_wpnonce': HealthCheck.nonce.confirm_warning
38
- };
39
-
40
- $.post(
41
- ajaxurl,
42
- data
43
- );
44
- });
45
- });
46
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modals/diff.php CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  <div id="health-check-diff-modal">
2
  <div id="health-check-diff-modal-content">
3
  <a id="health-check-diff-modal-close-ref" href="#health-check-diff-modal-close"><span class="dashicons dashicons-no"></span></a>
1
+ <?php
2
+
3
+ // Make sure the file is not directly accessible.
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ die( 'We\'re sorry, but you can not directly access this file.' );
6
+ }
7
+
8
+ ?>
9
+
10
  <div id="health-check-diff-modal">
11
  <div id="health-check-diff-modal-content">
12
  <a id="health-check-diff-modal-close-ref" href="#health-check-diff-modal-close"><span class="dashicons dashicons-no"></span></a>
modals/js-result-warnings.php CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  <div class="health-check-modal" data-modal-action="" data-parent-field="">
2
  <div class="modal-content">
3
  <span class="modal-close">&times;</span>
1
+ <?php
2
+
3
+ // Make sure the file is not directly accessible.
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ die( 'We\'re sorry, but you can not directly access this file.' );
6
+ }
7
+
8
+ ?>
9
+
10
  <div class="health-check-modal" data-modal-action="" data-parent-field="">
11
  <div class="modal-content">
12
  <span class="modal-close">&times;</span>
pages/debug-data.php CHANGED
@@ -15,126 +15,106 @@ Health_Check_Debug_Data::check_for_updates();
15
  $info = Health_Check_Debug_Data::debug_data();
16
  ?>
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- <div class="notice notice-info inline">
20
- <p>
21
- <?php esc_html_e( 'The system information shown below can also be copied and pasted into support requests such as on the WordPress.org forums, or to your theme and plugin developers.', 'health-check' ); ?>
22
- </p>
23
- <p>
24
- <button type="button" class="button button-primary" onclick="document.getElementById('system-information-copy-wrapper').style.display = 'block'; this.style.display = 'none';"><?php esc_html_e( 'Show copy and paste field', 'health-check' ); ?></button>
25
- <?php if ( 'en_US' !== get_locale() && version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) : ?>
26
- <button type="button" class="button" onclick="document.getElementById('system-information-english-copy-wrapper').style.display = 'block'; this.style.display = 'none';"><?php esc_html_e( 'Show copy and paste field in English', 'health-check' ); ?></button>
27
- <?php endif; ?>
28
- </p>
29
 
30
- <?php
31
- if ( 'en_US' !== get_locale() && version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- $english_info = Health_Check_Debug_Data::debug_data( 'en_US' );
 
 
34
 
35
- // Workaround for locales not being properly loaded back, see issue #30 on GitHub.
36
- if ( ! is_textdomain_loaded( 'health-check' ) && _get_path_to_translation( 'health-check' ) ) {
37
- load_textdomain( 'health-check', _get_path_to_translation( 'health-check' ) );
 
38
  }
 
39
  ?>
40
- <div id="system-information-english-copy-wrapper" style="display: none;">
41
- <textarea id="system-information-english-copy-field" class="widefat" rows="10"><?php Health_Check_Debug_Data::textarea_format( $english_info ); ?></textarea>
42
- <p>
43
- <?php esc_html_e( 'Some information may be filtered out from the list you are about to copy, this is information that may be considered private, and is not meant to be shared in a public forum.', 'health-check' ); ?>
44
- <br>
45
- <button type="button" class="button button-primary health-check-copy-field"><?php esc_html_e( 'Mark field for copying', 'health-check' ); ?></button>
46
- </p>
47
- </div>
48
-
49
- <?php endif; ?>
50
-
51
- <div id="system-information-copy-wrapper" style="display: none;">
52
- <textarea id="system-information-copy-field" class="widefat" rows="10"><?php Health_Check_Debug_Data::textarea_format( $info ); ?></textarea>
53
- <p>
54
- <?php esc_html_e( 'Some information may be filtered out from the list you are about to copy, this is information that may be considered private, and is not meant to be shared in a public forum.', 'health-check' ); ?>
55
- <br>
56
- <button type="button" class="button button-primary health-check-copy-field"><?php esc_html_e( 'Mark field for copying', 'health-check' ); ?></button>
57
- </p>
58
- </div>
59
- </div>
60
 
61
- <h2 id="system-information-table-of-contents">
62
- <?php esc_html_e( 'Table Of Contents', 'health-check' ); ?>
63
- </h2>
64
- <div>
65
  <?php
66
- $toc = array();
67
-
68
- foreach ( $info as $section => $details ) {
69
- if ( empty( $details['fields'] ) ) {
70
- continue;
71
- }
72
 
73
- $toc[] = sprintf(
74
- '<a href="#%s" class="health-check-toc">%s</a>',
75
- esc_attr( $section ),
76
- esc_html( $details['label'] )
77
- );
78
  }
79
 
80
- echo implode( ' | ', $toc );
81
  ?>
82
- </div>
 
 
83
 
84
- <?php
85
- foreach ( $info as $section => $details ) {
86
- if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
87
- continue;
88
- }
89
 
90
- printf(
91
- '<h2 id="%s">%s%s</h2>',
92
- esc_attr( $section ),
93
- esc_html( $details['label'] ),
94
- ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
95
- );
96
 
97
- if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
98
- printf(
99
- '<p>%s</p>',
100
- wp_kses( $details['description'], array(
101
- 'a' => array(
102
- 'href' => true,
103
- ),
104
- 'strong' => true,
105
- 'em' => true,
106
- ) )
107
- );
108
- }
109
- ?>
110
- <table class="widefat striped health-check-table">
111
- <tbody>
112
- <?php
113
- foreach ( $details['fields'] as $field ) {
114
- if ( is_array( $field['value'] ) ) {
115
- $values = '';
116
- foreach ( $field['value'] as $name => $value ) {
117
- $values .= sprintf(
118
- '<li>%s: %s</li>',
119
- esc_html( $name ),
120
- esc_html( $value )
121
- );
122
  }
123
- } else {
124
- $values = esc_html( $field['value'] );
125
  }
126
 
127
- printf(
128
- '<tr><td>%s</td><td>%s</td></tr>',
129
- esc_html( $field['label'] ),
130
- $values
131
- );
132
- }
133
- ?>
134
- </tbody>
135
- </table>
136
- <span style="display: block; width: 100%; text-align: <?php echo ( is_rtl() ? 'left' : 'right' ); ?>">
137
- <a href="#system-information-table-of-contents" class="health-check-toc"><?php esc_html_e( 'Return to table of contents', 'health-check' ); ?></a>
138
- </span>
139
  <?php
140
- }
 
 
 
 
 
 
15
  $info = Health_Check_Debug_Data::debug_data();
16
  ?>
17
 
18
+ <h2>
19
+ <?php esc_html_e( 'Site Health Info', 'health-check' ); ?>
20
+ </h2>
21
+
22
+ <p>
23
+ <?php _e( 'This page can show you every detail about the configuration of your WordPress website. If we see anything here that could be improved, we will let you know on the Site Health Status page.', 'health-check' ); ?>
24
+ </p>
25
+ <p>
26
+ <?php _e( 'If you want to export a handy list of all the information on this page, you can use the button below to copy it to the clipboard. You can then paste it in a text file and save it to your harddrive, or paste it in an email exchange with a support engineer or theme/plugin developer for example.', 'health-check' ); ?>
27
+ </p>
28
+
29
+ <div class="site-health-copy-buttons">
30
+ <div class="copy-button-wrapper">
31
+ <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( Health_Check_Debug_Data::format( $info, 'debug' ) ); ?>">
32
+ <?php _e( 'Copy site info to clipboard', 'health-check' ); ?>
33
+ </button>
34
+ <span class="success" aria-hidden="true"><?php _e( 'Copied!', 'health-check' ); ?></span>
35
+ </div>
36
+ </div>
37
 
38
+ <div id="health-check-debug" class="health-check-accordion">
 
 
 
 
 
 
 
 
 
39
 
40
+ <?php
41
+ $sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
42
+
43
+ foreach ( $info as $section => $details ) {
44
+ if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
45
+ continue;
46
+ }
47
+ ?>
48
+ <h3 class="health-check-accordion-heading">
49
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
50
+ <span class="title">
51
+ <?php echo esc_html( $details['label'] ); ?>
52
+ <?php
53
+
54
+ if ( isset( $details['show_count'] ) && $details['show_count'] ) {
55
+ printf( '(%d)', count( $details['fields'] ) );
56
+ }
57
 
58
+ ?>
59
+ </span>
60
+ <?php
61
 
62
+ if ( 'wp-paths-sizes' === $section ) {
63
+ ?>
64
+ <span class="health-check-wp-paths-sizes spinner"></span>
65
+ <?php
66
  }
67
+
68
  ?>
69
+ <span class="icon"></span>
70
+ </button>
71
+ </h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
+ <div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
 
 
 
74
  <?php
 
 
 
 
 
 
75
 
76
+ if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
77
+ printf( '<p>%s</p>', $details['description'] );
 
 
 
78
  }
79
 
 
80
  ?>
81
+ <table class="widefat striped health-check-table" role="presentation">
82
+ <tbody>
83
+ <?php
84
 
85
+ foreach ( $details['fields'] as $field_name => $field ) {
86
+ if ( is_array( $field['value'] ) ) {
87
+ $values = '<ul>';
 
 
88
 
89
+ foreach ( $field['value'] as $name => $value ) {
90
+ $values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
91
+ }
 
 
 
92
 
93
+ $values .= '</ul>';
94
+ } else {
95
+ $values = esc_html( $field['value'] );
96
+ }
97
+
98
+ if ( in_array( $field_name, $sizes_fields, true ) ) {
99
+ printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
100
+ } else {
101
+ printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
 
 
103
  }
104
 
105
+ ?>
106
+ </tbody>
107
+ </table>
108
+ </div>
109
+ <?php } ?>
110
+ </div>
111
+
112
+ <div class="site-health-view-more">
 
 
 
 
113
  <?php
114
+ printf(
115
+ '<a href="%s" class="button button-primary">%s</a>',
116
+ esc_url( admin_url( '?page=health-check&tab=phpinfo' ) ),
117
+ esc_html__( 'View extended PHP information', 'health-check' )
118
+ );
119
+ ?>
120
+ </div>
pages/phpinfo.php CHANGED
@@ -9,7 +9,13 @@
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
 
12
 
 
 
 
 
 
13
  if ( ! function_exists( 'phpinfo' ) ) {
14
  ?>
15
 
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
12
+ ?>
13
 
14
+ <h2>
15
+ <?php esc_html_e( 'Extended PHP Information', 'health-check' ); ?>
16
+ </h2>
17
+
18
+ <?php
19
  if ( ! function_exists( 'phpinfo' ) ) {
20
  ?>
21
 
pages/site-health-header.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The header template, printed on every Health Check related page.
4
+ *
5
+ * @package Health Check
6
+ */
7
+
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+ ?>
13
+
14
+ <div class="health-check-header">
15
+ <div class="health-check-title-section">
16
+ <h1>
17
+ <?php esc_html_e( 'Site Health', 'health-check' ); ?>
18
+ </h1>
19
+
20
+ <div class="site-health-progress hide-if-no-js loading">
21
+ <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
22
+ <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
23
+ <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
24
+ </svg>
25
+ <span class="screen-reader-text"><?php _e( 'Current completion rate:', 'health-check' ); ?></span>
26
+ <span class="site-health-progress-count"></span>
27
+ </div>
28
+ </div>
29
+
30
+ <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu', 'health-check' ); ?>">
31
+ <?php
32
+ $tabs = Health_Check::tabs();
33
+ $current_tab = Health_Check::current_tab();
34
+
35
+ foreach ( $tabs as $tab => $label ) {
36
+ printf(
37
+ '<a href="%s" class="health-check-tab health-check-%s-tab %s"%s>%s</a>',
38
+ sprintf(
39
+ '%s&tab=%s',
40
+ menu_page_url( 'health-check', false ),
41
+ $tab
42
+ ),
43
+ esc_attr( $tab ),
44
+ ( $current_tab === $tab ? 'active' : '' ),
45
+ ( $current_tab === $tab ? ' aria-current="true"' : '' ),
46
+ $label
47
+ );
48
+ }
49
+ ?>
50
+ </nav>
51
+ <div class="wp-clearfix"></div>
52
+ </div>
53
+
54
+ <hr class="wp-header-end">
55
+
56
+ <div class="notice notice-error hide-if-js">
57
+ <p><?php _e( 'The Site Health check requires JavaScript.', 'health-check' ); ?></p>
58
+ </div>
59
+
60
+ <div class="health-check-body hide-if-no-js">
pages/site-status.php CHANGED
@@ -13,45 +13,83 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  global $health_check_site_status;
14
  ?>
15
 
16
- <div class="notice notice-info inline">
17
- <p>
18
- <?php esc_html_e( 'The health check shows critical information about your WordPress configuration and items that require your attention.', 'health-check' ); ?>
19
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  </div>
21
 
22
- <table class="widefat striped health-check-table">
23
- <tbody>
24
- <?php
25
- $tests = Health_Check_Site_Status::get_tests();
26
- foreach ( $tests['direct'] as $test ) :
27
  ?>
28
- <tr>
29
- <td><?php echo esc_html( $test['label'] ); ?></td>
30
- <td class="" data-site-status="<?php echo esc_attr( $test['test'] ); ?>">
31
- <?php
32
- $test_function = sprintf(
33
- 'test_%s',
34
- $test['test']
35
- );
36
-
37
- if ( method_exists( $health_check_site_status, $test_function ) && is_callable( array( $health_check_site_status, $test_function ) ) ) {
38
- call_user_func( array( $health_check_site_status, $test_function ) );
39
- }
40
- ?>
41
- </td>
42
- </tr>
43
- <?php endforeach; ?>
44
-
45
- <?php foreach ( $tests['async'] as $test ) : ?>
46
- <tr>
47
- <td><?php echo esc_html( $test['label'] ); ?></td>
48
- <td class="health-check-site-status-test" data-site-status="<?php echo esc_attr( $test['test'] ); ?>">
49
- <span class="spinner is-active"></span>
50
- </td>
51
- </tr>
52
- <?php endforeach; ?>
53
- </tbody>
54
- </table>
55
-
56
- <?php
57
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/js-result-warnings.php' );
 
 
 
 
 
 
 
 
 
 
 
 
13
  global $health_check_site_status;
14
  ?>
15
 
16
+ <div class="site-status-all-clear hide">
17
+ <p class="icon">
18
+ <span class="dashicons dashicons-yes"></span>
19
+ </p>
20
+
21
+ <p class="encouragement">
22
+ <?php _e( 'Great job!', 'health-check' ); ?>
23
+ </p>
24
+
25
+ <p>
26
+ <?php _e( 'Everything is running smoothly here.', 'health-check' ); ?>
27
+ </p>
28
+ </div>
29
+
30
+ <div class="site-status-has-issues">
31
+ <h2>
32
+ <?php _e( 'Site Health Status', 'health-check' ); ?>
33
+ </h2>
34
+
35
+ <p><?php _e( 'The site health check shows critical information about your WordPress configuration and items that require your attention.', 'health-check' ); ?></p>
36
+
37
+ <div class="site-health-issues-wrapper" id="health-check-issues-critical">
38
+ <h3 class="site-health-issue-count-title">
39
+ <?php
40
+ /* translators: %s: number of critical issues found */
41
+ printf( _n( '%s Critical issue', '%s Critical issues', 0, 'health-check' ), '<span class="issue-count">0</span>' );
42
+ ?>
43
+ </h3>
44
+
45
+ <div id="health-check-site-status-critical" class="health-check-accordion issues"></div>
46
  </div>
47
 
48
+ <div class="site-health-issues-wrapper" id="health-check-issues-recommended">
49
+ <h3 class="site-health-issue-count-title">
50
+ <?php
51
+ /* translators: %s: number of recommended improvements */
52
+ printf( _n( '%s Recommended improvement', '%s Recommended improvements', 0, 'health-check' ), '<span class="issue-count">0</span>' );
53
  ?>
54
+ </h3>
55
+
56
+ <div id="health-check-site-status-recommended" class="health-check-accordion issues"></div>
57
+ </div>
58
+ </div>
59
+
60
+ <div class="site-health-view-more">
61
+ <button type="button" class="button site-health-view-passed" aria-expanded="false" aria-controls="health-check-issues-good">
62
+ <?php _e( 'Passed tests', 'health-check' ); ?>
63
+ <span class="icon"></span>
64
+ </button>
65
+ </div>
66
+
67
+ <div class="site-health-issues-wrapper hidden" id="health-check-issues-good">
68
+ <h3 class="site-health-issue-count-title">
69
+ <?php
70
+ /* translators: %s: number of items with no issues */
71
+ printf( _n( '%s Item with no issues detected', '%s Items with no issues detected', 0, 'health-check' ), '<span class="issue-count">0</span>' );
72
+ ?>
73
+ </h3>
74
+
75
+ <div id="health-check-site-status-good" class="health-check-accordion issues"></div>
76
+ </div>
77
+
78
+ <script id="tmpl-health-check-issue" type="text/template">
79
+ <h4 class="health-check-accordion-heading">
80
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button">
81
+ <span class="title">{{ data.label }}</span>
82
+ <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span>
83
+ <span class="icon"></span>
84
+ </button>
85
+ </h4>
86
+ <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden">
87
+ {{{ data.description }}}
88
+ <div class="actions">
89
+ <p class="button-container">{{{ data.actions }}}</p>
90
+ </div>
91
+ </div>
92
+ </script>
93
+
94
+ <?php
95
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/js-result-warnings.php' );
pages/tools.php CHANGED
@@ -12,7 +12,11 @@ if ( ! defined( 'ABSPATH' ) ) {
12
 
13
  ?>
14
 
15
- <dl id="health-check-tools" role="presentation" class="health-check-accordion">
 
 
 
 
16
  <?php
17
  /**
18
  * Filter the features available under the Tools tab.
@@ -39,20 +43,20 @@ if ( ! defined( 'ABSPATH' ) ) {
39
  foreach ( $tabs as $count => $tab ) :
40
  ?>
41
 
42
- <dt role="heading" aria-level="2">
43
- <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" id="health-check-accordion-heading-<?php echo esc_attr( $count ); ?>" type="button">
44
  <span class="title">
45
  <?php echo $tab['label']; ?>
46
  </span>
47
  <span class="icon"></span>
48
  </button>
49
- </dt>
50
- <dd id="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" role="region" aria-labelledby="health-check-accordion-heading-<?php echo esc_attr( $count ); ?>" class="health-check-accordion-panel" hidden="hidden">
51
  <?php echo $tab['content']; ?>
52
- </dd>
53
 
54
  <?php endforeach; ?>
55
- </dl>
56
 
57
  <?php
58
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/diff.php' );
12
 
13
  ?>
14
 
15
+ <h2>
16
+ <?php esc_html_e( 'Tools', 'health-check' ); ?>
17
+ </h2>
18
+
19
+ <div id="health-check-tools" role="presentation" class="health-check-accordion">
20
  <?php
21
  /**
22
  * Filter the features available under the Tools tab.
43
  foreach ( $tabs as $count => $tab ) :
44
  ?>
45
 
46
+ <h3 class="health-check-accordion-heading">
47
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" type="button">
48
  <span class="title">
49
  <?php echo $tab['label']; ?>
50
  </span>
51
  <span class="icon"></span>
52
  </button>
53
+ </h3>
54
+ <div id="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" class="health-check-accordion-panel" hidden="hidden">
55
  <?php echo $tab['content']; ?>
56
+ </div>
57
 
58
  <?php endforeach; ?>
59
+ </div>
60
 
61
  <?php
62
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/diff.php' );
pages/troubleshoot.php CHANGED
@@ -11,28 +11,27 @@ if ( ! defined( 'ABSPATH' ) ) {
11
  }
12
 
13
  ?>
14
- <div class="notice notice-warning inline">
15
- <p>
16
- <?php esc_html_e( 'When troubleshooting issues on your site, you are likely to be told to disable all plugins and switch to the default theme.', 'health-check' ); ?>
17
- <?php esc_html_e( 'Understandably, you do not wish to do so as it may affect your site visitors, leaving them with lost functionality.', 'health-check' ); ?>
18
- </p>
19
 
20
- <p>
21
- <?php esc_html_e( 'By enabling the Troubleshooting Mode, all plugins will appear inactive and your site will switch to the default theme only for you. All other users will see your site as usual.', 'health-check' ); ?>
22
- </p>
23
 
24
- <p>
25
- <?php esc_html_e( 'A Troubleshooting Mode menu is added to your admin bar, which will allow you to enable plugins individually, switch back to your current theme, and disable Troubleshooting Mode.', 'health-check' ); ?>
26
- </p>
 
27
 
28
- <p>
29
- <?php esc_html_e( 'Please note, that due to how Must Use plugins work, any such plugin will not be disabled for the troubleshooting session.', 'health-check' ); ?>
30
- </p>
31
- </div>
 
 
 
 
 
 
 
32
 
33
  <?php
34
  Health_Check_Troubleshoot::show_enable_troubleshoot_form();
35
-
36
- if ( ! Health_Check_Troubleshoot::has_seen_warning() ) {
37
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/backup-warning.php' );
38
- }
11
  }
12
 
13
  ?>
 
 
 
 
 
14
 
15
+ <h2>
16
+ <?php esc_html_e( 'Troubleshooting mode', 'health-check' ); ?>
17
+ </h2>
18
 
19
+ <p>
20
+ <?php esc_html_e( 'When troubleshooting issues on your site, you are likely to be told to disable all plugins and switch to the default theme.', 'health-check' ); ?>
21
+ <?php esc_html_e( 'Understandably, you do not wish to do so as it may affect your site visitors, leaving them with lost functionality.', 'health-check' ); ?>
22
+ </p>
23
 
24
+ <p>
25
+ <?php esc_html_e( 'By enabling the Troubleshooting Mode, all plugins will appear inactive and your site will switch to the default theme only for you. All other users will see your site as usual.', 'health-check' ); ?>
26
+ </p>
27
+
28
+ <p>
29
+ <?php esc_html_e( 'A Troubleshooting Mode menu is added to your admin bar, which will allow you to enable plugins individually, switch back to your current theme, and disable Troubleshooting Mode.', 'health-check' ); ?>
30
+ </p>
31
+
32
+ <p>
33
+ <?php esc_html_e( 'Please note, that due to how Must Use plugins work, any such plugin will not be disabled for the troubleshooting session.', 'health-check' ); ?>
34
+ </p>
35
 
36
  <?php
37
  Health_Check_Troubleshoot::show_enable_troubleshoot_form();
 
 
 
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
- Tested up to: 5.1
6
- Stable tag: 1.2.6
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -39,43 +39,13 @@ Are you unfamiliar with how to clear your cookies? No worries, you may also clos
39
 
40
  == Changelog ==
41
 
42
- = v1.2.6 =
43
- * Security: Harden the consistency checker, further limiting what files can be looked up to only include core files. Independently reported by Julien Legras of [Synacktiv](https://synacktiv.com) and Tim Coen of [Tim Coen IT Security & Development](https://security-consulting.icu/).
44
-
45
- = v1.2.5 =
46
- * Fix: Ensure the REST API status test runs as intended.
47
- * Fix: Remove warning on plugin screens when premium plugins are used.
48
- * Fix: Backup reminder would not remain dismissed in all scenarios after the recent update.
49
-
50
- = v1.2.4 =
51
- * Security: Prevent arbitrary file viewing through the integrity file actions. Independently reported by Julien Legras of [Synacktiv](https://synacktiv.com) and siliconforks.
52
- * Security: Site status was available to any user with a subscriber role or higher on a site. Reported by Julien Legras of [Synacktiv](https://synacktiv.com).
53
- * Security: Hardened the troubleshooting mode session so it is locked to the users location when active.
54
- * New enhancement: Check that various PHP extensions exist, as recommended by the WordPress Hosting Community.
55
- * New enhancement: Check if update APIs are being manipulated by plugins or themes.
56
- * Fix: Copying debug information had the wrong indentation for easier readability.
57
- * Fix: Toggling plugins and themes from the troubleshooting widget on in the dashboard now lets you expand/collapse them as intended.
58
- * Fix: When debugging was enabled in WordPress, disabling a plugin in troubleshooting mode would cause a WSOD if the disabled plugin caused a fatal error.
59
-
60
- = v1.2.3 =
61
- * Added REST API availability test to the Site Status
62
-
63
- = v 1.2.2 =
64
- * Added Twenty Nineteen as a recognized core theme.
65
-
66
- = v 1.2.1 =
67
- * Make sure only those with access to the plugin see the backup encouragement notice.
68
- * Make sure the `is_troubleshooting()` checks are available to the Site Status tester when the MU plugin may not have updated yet.
69
- * Avoid a warning of an undefined variable if you have the latest WordPress version installed.
70
-
71
- = v 1.2.0 =
72
- * Changed plugin name, it now better describes the plugins two primary purposes.
73
- * Changed the `Health Check` tab, it's now named `Site Status`, as we used the old name too many places and it was confusing.
74
- * Site status tests now run asynchronously, making the page load much faster.
75
- * The HTTPS tests now also check your Site URL settings to make sure they are following recommended best practices.
76
- * Fixed a warning preventing plugin names from displaying on the front-end in some cases.
77
- * Fixed an issue where you might get a 500 error if you tried using Troubleshooting Mode while using a child theme.
78
- * Automatically disable/enable a plugin or theme in Troubleshooting Mode if they are detected to cause errors.
79
- * Introduce a new dashboard widget during Troubleshooting Mode (and a simplified version on the plugins screen) to better explain what is going on, and make available actions more discoverable than the admin menu is.
80
- * Some text improvements throughout the plugin.
81
- * When loopback tests fail, we previously tested all plugins at once, for sites that have many plugins this may fail as the request times out. We now test one plugin at a time to avoid this, while also showing more information at the tests are running to the end user.
2
  Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
+ Tested up to: 5.2
6
+ Stable tag: 1.3.0
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
39
 
40
  == Changelog ==
41
 
42
+ = v1.3.0 =
43
+ * Plugin moved to the Tools section in the admin menu
44
+ * New UI/UX for the plugin pages
45
+ * New troubleshooting mode UI/UX
46
+ * Removed the backup reminder nag
47
+ * Improved security hardening
48
+ * Changed cookie names for improved hosting compatibility
49
+ * Improved accessibility
50
+ * Automatically check for critical issues once a week (adds a counter next to the menu item)
51
+ * Dates in the email tester now follow your site settings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uninstall.php CHANGED
@@ -34,7 +34,7 @@ if ( file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-disable-plu
34
  wp_delete_file( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-disable-plugins.php' );
35
  }
36
 
37
- // Remove the renamed Must-Use plugin if it exists
38
  if ( file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) {
39
  wp_delete_file( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' );
40
  }
34
  wp_delete_file( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-disable-plugins.php' );
35
  }
36
 
37
+ // Remove the renamed Must-Use plugin if it exists.
38
  if ( file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) {
39
  wp_delete_file( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' );
40
  }