author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
9 | 1 |
<?php |
2 |
/** |
|
3 |
* Class for testing automatic updates in the WordPress code. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Site_Health |
|
7 |
* @since 5.2.0 |
|
8 |
*/ |
|
9 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
#[AllowDynamicProperties] |
9 | 11 |
class WP_Site_Health_Auto_Updates { |
12 |
/** |
|
13 |
* WP_Site_Health_Auto_Updates constructor. |
|
16 | 14 |
* |
9 | 15 |
* @since 5.2.0 |
16 |
*/ |
|
17 |
public function __construct() { |
|
16 | 18 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
9 | 19 |
} |
20 |
||
21 |
||
22 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
23 |
* Runs tests to determine if auto-updates can run. |
9 | 24 |
* |
25 |
* @since 5.2.0 |
|
26 |
* |
|
27 |
* @return array The test results. |
|
28 |
*/ |
|
29 |
public function run_tests() { |
|
30 |
$tests = array( |
|
18 | 31 |
$this->test_constants( 'WP_AUTO_UPDATE_CORE', array( true, 'beta', 'rc', 'development', 'branch-development', 'minor' ) ), |
9 | 32 |
$this->test_wp_version_check_attached(), |
33 |
$this->test_filters_automatic_updater_disabled(), |
|
16 | 34 |
$this->test_wp_automatic_updates_disabled(), |
9 | 35 |
$this->test_if_failed_update(), |
36 |
$this->test_vcs_abspath(), |
|
37 |
$this->test_check_wp_filesystem_method(), |
|
38 |
$this->test_all_files_writable(), |
|
39 |
$this->test_accepts_dev_updates(), |
|
40 |
$this->test_accepts_minor_updates(), |
|
41 |
); |
|
42 |
||
43 |
$tests = array_filter( $tests ); |
|
44 |
$tests = array_map( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
static function ( $test ) { |
9 | 46 |
$test = (object) $test; |
47 |
||
48 |
if ( empty( $test->severity ) ) { |
|
49 |
$test->severity = 'warning'; |
|
50 |
} |
|
51 |
||
52 |
return $test; |
|
53 |
}, |
|
54 |
$tests |
|
55 |
); |
|
56 |
||
57 |
return $tests; |
|
58 |
} |
|
59 |
||
60 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
* Tests if auto-updates related constants are set correctly. |
9 | 62 |
* |
63 |
* @since 5.2.0 |
|
16 | 64 |
* @since 5.5.1 The `$value` parameter can accept an array. |
9 | 65 |
* |
16 | 66 |
* @param string $constant The name of the constant to check. |
67 |
* @param bool|string|array $value The value that the constant should be, if set, |
|
68 |
* or an array of acceptable values. |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
69 |
* @return array|null The test results if there are any constants set incorrectly, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
70 |
* or null if the test passed. |
9 | 71 |
*/ |
72 |
public function test_constants( $constant, $value ) { |
|
16 | 73 |
$acceptable_values = (array) $value; |
74 |
||
75 |
if ( defined( $constant ) && ! in_array( constant( $constant ), $acceptable_values, true ) ) { |
|
9 | 76 |
return array( |
77 |
'description' => sprintf( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
/* translators: 1: Name of the constant used. 2: Value of the constant used. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
79 |
__( 'The %1$s constant is defined as %2$s' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
80 |
"<code>$constant</code>", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
81 |
'<code>' . esc_html( var_export( constant( $constant ), true ) ) . '</code>' |
9 | 82 |
), |
83 |
'severity' => 'fail', |
|
84 |
); |
|
85 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
86 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
87 |
return null; |
9 | 88 |
} |
89 |
||
90 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
91 |
* Checks if updates are intercepted by a filter. |
9 | 92 |
* |
93 |
* @since 5.2.0 |
|
94 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
95 |
* @return array|null The test results if wp_version_check() is disabled, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
96 |
* or null if the test passed. |
9 | 97 |
*/ |
98 |
public function test_wp_version_check_attached() { |
|
18 | 99 |
if ( ( ! is_multisite() || is_main_site() && is_network_admin() ) |
100 |
&& ! has_filter( 'wp_version_check', 'wp_version_check' ) |
|
101 |
) { |
|
9 | 102 |
return array( |
103 |
'description' => sprintf( |
|
104 |
/* translators: %s: Name of the filter used. */ |
|
105 |
__( 'A plugin has prevented updates by disabling %s.' ), |
|
106 |
'<code>wp_version_check()</code>' |
|
107 |
), |
|
108 |
'severity' => 'fail', |
|
109 |
); |
|
110 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
111 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
112 |
return null; |
9 | 113 |
} |
114 |
||
115 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
* Checks if automatic updates are disabled by a filter. |
9 | 117 |
* |
118 |
* @since 5.2.0 |
|
119 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
120 |
* @return array|null The test results if the {@see 'automatic_updater_disabled'} filter is set, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
121 |
* or null if the test passed. |
9 | 122 |
*/ |
123 |
public function test_filters_automatic_updater_disabled() { |
|
16 | 124 |
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ |
9 | 125 |
if ( apply_filters( 'automatic_updater_disabled', false ) ) { |
126 |
return array( |
|
127 |
'description' => sprintf( |
|
128 |
/* translators: %s: Name of the filter used. */ |
|
129 |
__( 'The %s filter is enabled.' ), |
|
130 |
'<code>automatic_updater_disabled</code>' |
|
131 |
), |
|
132 |
'severity' => 'fail', |
|
133 |
); |
|
134 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
135 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
136 |
return null; |
9 | 137 |
} |
138 |
||
139 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
140 |
* Checks if automatic updates are disabled. |
16 | 141 |
* |
142 |
* @since 5.3.0 |
|
143 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
144 |
* @return array|false The test results if auto-updates are disabled, false otherwise. |
16 | 145 |
*/ |
146 |
public function test_wp_automatic_updates_disabled() { |
|
147 |
if ( ! class_exists( 'WP_Automatic_Updater' ) ) { |
|
148 |
require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; |
|
149 |
} |
|
150 |
||
151 |
$auto_updates = new WP_Automatic_Updater(); |
|
152 |
||
153 |
if ( ! $auto_updates->is_disabled() ) { |
|
154 |
return false; |
|
155 |
} |
|
156 |
||
157 |
return array( |
|
158 |
'description' => __( 'All automatic updates are disabled.' ), |
|
159 |
'severity' => 'fail', |
|
160 |
); |
|
161 |
} |
|
162 |
||
163 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
164 |
* Checks if automatic updates have tried to run, but failed, previously. |
9 | 165 |
* |
166 |
* @since 5.2.0 |
|
167 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
168 |
* @return array|false The test results if auto-updates previously failed, false otherwise. |
9 | 169 |
*/ |
19 | 170 |
public function test_if_failed_update() { |
9 | 171 |
$failed = get_site_option( 'auto_core_update_failed' ); |
172 |
||
173 |
if ( ! $failed ) { |
|
174 |
return false; |
|
175 |
} |
|
176 |
||
177 |
if ( ! empty( $failed['critical'] ) ) { |
|
178 |
$description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.' ); |
|
179 |
$description .= ' ' . __( 'You would have received an email because of this.' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
180 |
$description .= ' ' . __( "When you've been able to update using the \"Update now\" button on Dashboard > Updates, this error will be cleared for future update attempts." ); |
9 | 181 |
$description .= ' ' . sprintf( |
182 |
/* translators: %s: Code of error shown. */ |
|
183 |
__( 'The error code was %s.' ), |
|
184 |
'<code>' . $failed['error_code'] . '</code>' |
|
185 |
); |
|
186 |
return array( |
|
187 |
'description' => $description, |
|
188 |
'severity' => 'warning', |
|
189 |
); |
|
190 |
} |
|
191 |
||
192 |
$description = __( 'A previous automatic background update could not occur.' ); |
|
193 |
if ( empty( $failed['retry'] ) ) { |
|
194 |
$description .= ' ' . __( 'You would have received an email because of this.' ); |
|
195 |
} |
|
196 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
197 |
$description .= ' ' . __( 'Another attempt will be made with the next release.' ); |
9 | 198 |
$description .= ' ' . sprintf( |
199 |
/* translators: %s: Code of error shown. */ |
|
200 |
__( 'The error code was %s.' ), |
|
201 |
'<code>' . $failed['error_code'] . '</code>' |
|
202 |
); |
|
203 |
return array( |
|
204 |
'description' => $description, |
|
205 |
'severity' => 'warning', |
|
206 |
); |
|
207 |
} |
|
208 |
||
209 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
210 |
* Checks if WordPress is controlled by a VCS (Git, Subversion etc). |
9 | 211 |
* |
212 |
* @since 5.2.0 |
|
213 |
* |
|
214 |
* @return array The test results. |
|
215 |
*/ |
|
216 |
public function test_vcs_abspath() { |
|
217 |
$context_dirs = array( ABSPATH ); |
|
218 |
$vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' ); |
|
219 |
$check_dirs = array(); |
|
220 |
||
221 |
foreach ( $context_dirs as $context_dir ) { |
|
222 |
// Walk up from $context_dir to the root. |
|
223 |
do { |
|
224 |
$check_dirs[] = $context_dir; |
|
225 |
||
226 |
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here. |
|
16 | 227 |
if ( dirname( $context_dir ) === $context_dir ) { |
9 | 228 |
break; |
229 |
} |
|
230 |
||
231 |
// Continue one level at a time. |
|
232 |
} while ( $context_dir = dirname( $context_dir ) ); |
|
233 |
} |
|
234 |
||
235 |
$check_dirs = array_unique( $check_dirs ); |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
236 |
$updater = new WP_Automatic_Updater(); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
237 |
$checkout = false; |
9 | 238 |
|
239 |
// Search all directories we've found for evidence of version control. |
|
240 |
foreach ( $vcs_dirs as $vcs_dir ) { |
|
241 |
foreach ( $check_dirs as $check_dir ) { |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
242 |
if ( ! $updater->is_allowed_dir( $check_dir ) ) { |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
243 |
continue; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
244 |
} |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
245 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
246 |
$checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ); |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
247 |
if ( $checkout ) { |
9 | 248 |
break 2; |
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
||
16 | 253 |
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ |
9 | 254 |
if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) { |
255 |
return array( |
|
256 |
'description' => sprintf( |
|
16 | 257 |
/* translators: 1: Folder name. 2: Version control directory. 3: Filter name. */ |
9 | 258 |
__( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.' ), |
259 |
'<code>' . $check_dir . '</code>', |
|
260 |
"<code>$vcs_dir</code>", |
|
261 |
'<code>automatic_updates_is_vcs_checkout</code>' |
|
262 |
), |
|
263 |
'severity' => 'info', |
|
264 |
); |
|
265 |
} |
|
266 |
||
267 |
if ( $checkout ) { |
|
268 |
return array( |
|
269 |
'description' => sprintf( |
|
16 | 270 |
/* translators: 1: Folder name. 2: Version control directory. */ |
9 | 271 |
__( 'The folder %1$s was detected as being under version control (%2$s).' ), |
272 |
'<code>' . $check_dir . '</code>', |
|
273 |
"<code>$vcs_dir</code>" |
|
274 |
), |
|
16 | 275 |
'severity' => 'warning', |
9 | 276 |
); |
277 |
} |
|
278 |
||
279 |
return array( |
|
280 |
'description' => __( 'No version control systems were detected.' ), |
|
281 |
'severity' => 'pass', |
|
282 |
); |
|
283 |
} |
|
284 |
||
285 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
* Checks if we can access files without providing credentials. |
9 | 287 |
* |
288 |
* @since 5.2.0 |
|
289 |
* |
|
290 |
* @return array The test results. |
|
291 |
*/ |
|
19 | 292 |
public function test_check_wp_filesystem_method() { |
18 | 293 |
// Make sure the `request_filesystem_credentials()` function is available during our REST API call. |
294 |
if ( ! function_exists( 'request_filesystem_credentials' ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
18 | 296 |
} |
297 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
298 |
$skin = new Automatic_Upgrader_Skin(); |
9 | 299 |
$success = $skin->request_filesystem_credentials( false, ABSPATH ); |
300 |
||
301 |
if ( ! $success ) { |
|
302 |
$description = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.' ); |
|
303 |
$description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)' ); |
|
304 |
||
305 |
return array( |
|
306 |
'description' => $description, |
|
307 |
'severity' => 'fail', |
|
308 |
); |
|
309 |
} |
|
310 |
||
311 |
return array( |
|
19 | 312 |
'description' => __( 'Your installation of WordPress does not require FTP credentials to perform updates.' ), |
9 | 313 |
'severity' => 'pass', |
314 |
); |
|
315 |
} |
|
316 |
||
317 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
318 |
* Checks if core files are writable by the web user/group. |
9 | 319 |
* |
320 |
* @since 5.2.0 |
|
321 |
* |
|
322 |
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. |
|
323 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
324 |
* @return array|false The test results if at least some of WordPress core files are writeable, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
325 |
* or if a list of the checksums could not be retrieved from WordPress.org. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
326 |
* False if the core files are not writeable. |
9 | 327 |
*/ |
19 | 328 |
public function test_all_files_writable() { |
9 | 329 |
global $wp_filesystem; |
330 |
||
16 | 331 |
require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z |
9 | 332 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
$skin = new Automatic_Upgrader_Skin(); |
9 | 334 |
$success = $skin->request_filesystem_credentials( false, ABSPATH ); |
335 |
||
336 |
if ( ! $success ) { |
|
337 |
return false; |
|
338 |
} |
|
339 |
||
340 |
WP_Filesystem(); |
|
341 |
||
16 | 342 |
if ( 'direct' !== $wp_filesystem->method ) { |
9 | 343 |
return false; |
344 |
} |
|
345 |
||
18 | 346 |
// Make sure the `get_core_checksums()` function is available during our REST API call. |
347 |
if ( ! function_exists( 'get_core_checksums' ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
348 |
require_once ABSPATH . 'wp-admin/includes/update.php'; |
18 | 349 |
} |
350 |
||
9 | 351 |
$checksums = get_core_checksums( $wp_version, 'en_US' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
352 |
$dev = ( str_contains( $wp_version, '-' ) ); |
16 | 353 |
// Get the last stable version's files and test against that. |
9 | 354 |
if ( ! $checksums && $dev ) { |
355 |
$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' ); |
|
356 |
} |
|
357 |
||
16 | 358 |
// There aren't always checksums for development releases, so just skip the test if we still can't find any. |
9 | 359 |
if ( ! $checksums && $dev ) { |
360 |
return false; |
|
361 |
} |
|
362 |
||
363 |
if ( ! $checksums ) { |
|
364 |
$description = sprintf( |
|
16 | 365 |
/* translators: %s: WordPress version. */ |
9 | 366 |
__( "Couldn't retrieve a list of the checksums for WordPress %s." ), |
367 |
$wp_version |
|
368 |
); |
|
369 |
$description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.' ); |
|
370 |
return array( |
|
371 |
'description' => $description, |
|
372 |
'severity' => 'warning', |
|
373 |
); |
|
374 |
} |
|
375 |
||
376 |
$unwritable_files = array(); |
|
377 |
foreach ( array_keys( $checksums ) as $file ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
378 |
if ( str_starts_with( $file, 'wp-content' ) ) { |
9 | 379 |
continue; |
380 |
} |
|
381 |
if ( ! file_exists( ABSPATH . $file ) ) { |
|
382 |
continue; |
|
383 |
} |
|
384 |
if ( ! is_writable( ABSPATH . $file ) ) { |
|
385 |
$unwritable_files[] = $file; |
|
386 |
} |
|
387 |
} |
|
388 |
||
389 |
if ( $unwritable_files ) { |
|
390 |
if ( count( $unwritable_files ) > 20 ) { |
|
391 |
$unwritable_files = array_slice( $unwritable_files, 0, 20 ); |
|
392 |
$unwritable_files[] = '...'; |
|
393 |
} |
|
394 |
return array( |
|
395 |
'description' => __( 'Some files are not writable by WordPress:' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>', |
|
396 |
'severity' => 'fail', |
|
397 |
); |
|
398 |
} else { |
|
399 |
return array( |
|
400 |
'description' => __( 'All of your WordPress files are writable.' ), |
|
401 |
'severity' => 'pass', |
|
402 |
); |
|
403 |
} |
|
404 |
} |
|
405 |
||
406 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
407 |
* Checks if the install is using a development branch and can use nightly packages. |
9 | 408 |
* |
409 |
* @since 5.2.0 |
|
410 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
411 |
* @return array|false|null The test results if development updates are blocked. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
412 |
* False if it isn't a development version. Null if the test passed. |
9 | 413 |
*/ |
19 | 414 |
public function test_accepts_dev_updates() { |
16 | 415 |
require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z |
416 |
// Only for dev versions. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
417 |
if ( ! str_contains( $wp_version, '-' ) ) { |
9 | 418 |
return false; |
419 |
} |
|
420 |
||
421 |
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) { |
|
422 |
return array( |
|
423 |
'description' => sprintf( |
|
424 |
/* translators: %s: Name of the constant used. */ |
|
425 |
__( 'WordPress development updates are blocked by the %s constant.' ), |
|
426 |
'<code>WP_AUTO_UPDATE_CORE</code>' |
|
427 |
), |
|
428 |
'severity' => 'fail', |
|
429 |
); |
|
430 |
} |
|
431 |
||
16 | 432 |
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
9 | 433 |
if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) { |
434 |
return array( |
|
435 |
'description' => sprintf( |
|
436 |
/* translators: %s: Name of the filter used. */ |
|
437 |
__( 'WordPress development updates are blocked by the %s filter.' ), |
|
438 |
'<code>allow_dev_auto_core_updates</code>' |
|
439 |
), |
|
440 |
'severity' => 'fail', |
|
441 |
); |
|
442 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
443 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
444 |
return null; |
9 | 445 |
} |
446 |
||
447 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
448 |
* Checks if the site supports automatic minor updates. |
9 | 449 |
* |
450 |
* @since 5.2.0 |
|
451 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
452 |
* @return array|null The test results if minor updates are blocked, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
453 |
* or null if the test passed. |
9 | 454 |
*/ |
19 | 455 |
public function test_accepts_minor_updates() { |
9 | 456 |
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) { |
457 |
return array( |
|
458 |
'description' => sprintf( |
|
459 |
/* translators: %s: Name of the constant used. */ |
|
460 |
__( 'WordPress security and maintenance releases are blocked by %s.' ), |
|
461 |
"<code>define( 'WP_AUTO_UPDATE_CORE', false );</code>" |
|
462 |
), |
|
463 |
'severity' => 'fail', |
|
464 |
); |
|
465 |
} |
|
466 |
||
16 | 467 |
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
9 | 468 |
if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) { |
469 |
return array( |
|
470 |
'description' => sprintf( |
|
471 |
/* translators: %s: Name of the filter used. */ |
|
472 |
__( 'WordPress security and maintenance releases are blocked by the %s filter.' ), |
|
473 |
'<code>allow_minor_auto_core_updates</code>' |
|
474 |
), |
|
475 |
'severity' => 'fail', |
|
476 |
); |
|
477 |
} |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
478 |
|
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
479 |
return null; |
9 | 480 |
} |
481 |
} |