author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Administration Update API |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
5 | 10 |
* Selects the first update version from the update_core option. |
0 | 11 |
* |
16 | 12 |
* @since 2.7.0 |
13 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* @return object|array|false The response from the API on success, false on failure. |
0 | 15 |
*/ |
16 |
function get_preferred_from_update_core() { |
|
17 |
$updates = get_core_updates(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
18 |
|
9 | 19 |
if ( ! is_array( $updates ) ) { |
0 | 20 |
return false; |
9 | 21 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
|
9 | 23 |
if ( empty( $updates ) ) { |
0 | 24 |
return (object) array( 'response' => 'latest' ); |
9 | 25 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
26 |
|
0 | 27 |
return $updates[0]; |
28 |
} |
|
29 |
||
30 |
/** |
|
16 | 31 |
* Gets available core updates. |
32 |
* |
|
33 |
* @since 2.7.0 |
|
0 | 34 |
* |
35 |
* @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, |
|
9 | 36 |
* set $options['available'] to false to skip not-dismissed updates. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* @return array|false Array of the update objects on success, false on failure. |
0 | 38 |
*/ |
39 |
function get_core_updates( $options = array() ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
40 |
$options = array_merge( |
9 | 41 |
array( |
42 |
'available' => true, |
|
43 |
'dismissed' => false, |
|
44 |
), |
|
45 |
$options |
|
46 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
|
0 | 48 |
$dismissed = get_site_option( 'dismissed_update_core' ); |
49 |
||
9 | 50 |
if ( ! is_array( $dismissed ) ) { |
0 | 51 |
$dismissed = array(); |
9 | 52 |
} |
0 | 53 |
|
54 |
$from_api = get_site_transient( 'update_core' ); |
|
55 |
||
9 | 56 |
if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
0 | 57 |
return false; |
9 | 58 |
} |
0 | 59 |
|
60 |
$updates = $from_api->updates; |
|
9 | 61 |
$result = array(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
|
0 | 63 |
foreach ( $updates as $update ) { |
16 | 64 |
if ( 'autoupdate' === $update->response ) { |
0 | 65 |
continue; |
9 | 66 |
} |
0 | 67 |
|
68 |
if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
|
69 |
if ( $options['dismissed'] ) { |
|
70 |
$update->dismissed = true; |
|
9 | 71 |
$result[] = $update; |
0 | 72 |
} |
73 |
} else { |
|
74 |
if ( $options['available'] ) { |
|
75 |
$update->dismissed = false; |
|
9 | 76 |
$result[] = $update; |
0 | 77 |
} |
78 |
} |
|
79 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
80 |
|
0 | 81 |
return $result; |
82 |
} |
|
83 |
||
84 |
/** |
|
16 | 85 |
* Gets the best available (and enabled) Auto-Update for WordPress core. |
0 | 86 |
* |
16 | 87 |
* If there's 1.2.3 and 1.3 on offer, it'll choose 1.3 if the installation allows it, else, 1.2.3. |
0 | 88 |
* |
89 |
* @since 3.7.0 |
|
90 |
* |
|
16 | 91 |
* @return object|false The core update offering on success, false on failure. |
0 | 92 |
*/ |
93 |
function find_core_auto_update() { |
|
94 |
$updates = get_site_transient( 'update_core' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
|
9 | 96 |
if ( ! $updates || empty( $updates->updates ) ) { |
0 | 97 |
return false; |
9 | 98 |
} |
0 | 99 |
|
16 | 100 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
0 | 101 |
|
102 |
$auto_update = false; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
103 |
$upgrader = new WP_Automatic_Updater(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
104 |
|
0 | 105 |
foreach ( $updates->updates as $update ) { |
16 | 106 |
if ( 'autoupdate' !== $update->response ) { |
0 | 107 |
continue; |
9 | 108 |
} |
0 | 109 |
|
9 | 110 |
if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) { |
0 | 111 |
continue; |
9 | 112 |
} |
0 | 113 |
|
9 | 114 |
if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) { |
0 | 115 |
$auto_update = $update; |
9 | 116 |
} |
0 | 117 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
|
0 | 119 |
return $auto_update; |
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* Gets and caches the checksums for the given version of WordPress. |
|
124 |
* |
|
125 |
* @since 3.7.0 |
|
126 |
* |
|
127 |
* @param string $version Version string to query. |
|
128 |
* @param string $locale Locale to query. |
|
16 | 129 |
* @return array|false An array of checksums on success, false on failure. |
0 | 130 |
*/ |
131 |
function get_core_checksums( $version, $locale ) { |
|
19 | 132 |
$http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), '', '&' ); |
16 | 133 |
$url = $http_url; |
0 | 134 |
|
16 | 135 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
136 |
|
16 | 137 |
if ( $ssl ) { |
0 | 138 |
$url = set_url_scheme( $url, 'https' ); |
9 | 139 |
} |
0 | 140 |
|
141 |
$options = array( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
'timeout' => wp_doing_cron() ? 30 : 3, |
0 | 143 |
); |
144 |
||
145 |
$response = wp_remote_get( $url, $options ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
146 |
|
0 | 147 |
if ( $ssl && is_wp_error( $response ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
148 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
149 |
__FUNCTION__, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
sprintf( |
16 | 151 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), |
16 | 153 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
157 |
|
0 | 158 |
$response = wp_remote_get( $http_url, $options ); |
159 |
} |
|
160 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
161 |
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { |
0 | 162 |
return false; |
9 | 163 |
} |
0 | 164 |
|
165 |
$body = trim( wp_remote_retrieve_body( $response ) ); |
|
166 |
$body = json_decode( $body, true ); |
|
167 |
||
9 | 168 |
if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { |
0 | 169 |
return false; |
9 | 170 |
} |
0 | 171 |
|
172 |
return $body['checksums']; |
|
173 |
} |
|
174 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
/** |
16 | 176 |
* Dismisses core update. |
177 |
* |
|
178 |
* @since 2.7.0 |
|
179 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
* @param object $update |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
*/ |
0 | 183 |
function dismiss_core_update( $update ) { |
184 |
$dismissed = get_site_option( 'dismissed_update_core' ); |
|
185 |
$dismissed[ $update->current . '|' . $update->locale ] = true; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
186 |
|
0 | 187 |
return update_site_option( 'dismissed_update_core', $dismissed ); |
188 |
} |
|
189 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
/** |
16 | 191 |
* Undismisses core update. |
192 |
* |
|
193 |
* @since 2.7.0 |
|
194 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
* @param string $version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
* @param string $locale |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
*/ |
0 | 199 |
function undismiss_core_update( $version, $locale ) { |
200 |
$dismissed = get_site_option( 'dismissed_update_core' ); |
|
9 | 201 |
$key = $version . '|' . $locale; |
0 | 202 |
|
9 | 203 |
if ( ! isset( $dismissed[ $key ] ) ) { |
0 | 204 |
return false; |
9 | 205 |
} |
0 | 206 |
|
9 | 207 |
unset( $dismissed[ $key ] ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
208 |
|
0 | 209 |
return update_site_option( 'dismissed_update_core', $dismissed ); |
210 |
} |
|
211 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
/** |
16 | 213 |
* Finds the available update for WordPress core. |
214 |
* |
|
215 |
* @since 2.7.0 |
|
216 |
* |
|
217 |
* @param string $version Version string to find the update for. |
|
218 |
* @param string $locale Locale to find the update for. |
|
219 |
* @return object|false The core update offering on success, false on failure. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
*/ |
0 | 221 |
function find_core_update( $version, $locale ) { |
222 |
$from_api = get_site_transient( 'update_core' ); |
|
223 |
||
9 | 224 |
if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
0 | 225 |
return false; |
9 | 226 |
} |
0 | 227 |
|
228 |
$updates = $from_api->updates; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
229 |
|
0 | 230 |
foreach ( $updates as $update ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
231 |
if ( $update->current === $version && $update->locale === $locale ) { |
0 | 232 |
return $update; |
9 | 233 |
} |
0 | 234 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
235 |
|
0 | 236 |
return false; |
237 |
} |
|
238 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
240 |
* Returns core update footer message. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
241 |
* |
16 | 242 |
* @since 2.3.0 |
243 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
* @param string $msg |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
*/ |
0 | 247 |
function core_update_footer( $msg = '' ) { |
9 | 248 |
if ( ! current_user_can( 'update_core' ) ) { |
16 | 249 |
/* translators: %s: WordPress version. */ |
0 | 250 |
return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
9 | 251 |
} |
0 | 252 |
|
253 |
$cur = get_preferred_from_update_core(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
254 |
|
9 | 255 |
if ( ! is_object( $cur ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
256 |
$cur = new stdClass(); |
9 | 257 |
} |
0 | 258 |
|
9 | 259 |
if ( ! isset( $cur->current ) ) { |
0 | 260 |
$cur->current = ''; |
9 | 261 |
} |
0 | 262 |
|
9 | 263 |
if ( ! isset( $cur->response ) ) { |
0 | 264 |
$cur->response = ''; |
9 | 265 |
} |
0 | 266 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
267 |
$is_development_version = preg_match( '/alpha|beta|RC/', wp_get_wp_version() ); |
18 | 268 |
|
269 |
if ( $is_development_version ) { |
|
270 |
return sprintf( |
|
271 |
/* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */ |
|
272 |
__( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), |
|
273 |
get_bloginfo( 'version', 'display' ), |
|
274 |
network_admin_url( 'update-core.php' ) |
|
275 |
); |
|
276 |
} |
|
277 |
||
0 | 278 |
switch ( $cur->response ) { |
9 | 279 |
case 'upgrade': |
16 | 280 |
return sprintf( |
281 |
'<strong><a href="%s">%s</a></strong>', |
|
282 |
network_admin_url( 'update-core.php' ), |
|
283 |
/* translators: %s: WordPress version. */ |
|
284 |
sprintf( __( 'Get Version %s' ), $cur->current ) |
|
285 |
); |
|
0 | 286 |
|
9 | 287 |
case 'latest': |
288 |
default: |
|
16 | 289 |
/* translators: %s: WordPress version. */ |
9 | 290 |
return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
0 | 291 |
} |
292 |
} |
|
293 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
* Returns core update notification message. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
296 |
* |
16 | 297 |
* @since 2.3.0 |
298 |
* |
|
19 | 299 |
* @global string $pagenow The filename of the current screen. |
16 | 300 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
*/ |
0 | 302 |
function update_nag() { |
19 | 303 |
global $pagenow; |
304 |
||
9 | 305 |
if ( is_multisite() && ! current_user_can( 'update_core' ) ) { |
0 | 306 |
return false; |
9 | 307 |
} |
0 | 308 |
|
16 | 309 |
if ( 'update-core.php' === $pagenow ) { |
0 | 310 |
return; |
9 | 311 |
} |
0 | 312 |
|
313 |
$cur = get_preferred_from_update_core(); |
|
314 |
||
16 | 315 |
if ( ! isset( $cur->response ) || 'upgrade' !== $cur->response ) { |
0 | 316 |
return false; |
9 | 317 |
} |
318 |
||
319 |
$version_url = sprintf( |
|
16 | 320 |
/* translators: %s: WordPress version. */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
321 |
esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ), |
9 | 322 |
sanitize_title( $cur->current ) |
323 |
); |
|
0 | 324 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
if ( current_user_can( 'update_core' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
$msg = sprintf( |
16 | 327 |
/* translators: 1: URL to WordPress release notes, 2: New WordPress version, 3: URL to network admin, 4: Accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
__( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
9 | 329 |
$version_url, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
$cur->current, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
network_admin_url( 'update-core.php' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
esc_attr__( 'Please update WordPress now' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
); |
0 | 334 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
$msg = sprintf( |
16 | 336 |
/* translators: 1: URL to WordPress release notes, 2: New WordPress version. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
__( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
9 | 338 |
$version_url, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
$cur->current |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
); |
0 | 341 |
} |
16 | 342 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
343 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
344 |
$msg, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
345 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
346 |
'type' => 'warning', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
347 |
'additional_classes' => array( 'update-nag', 'inline' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
348 |
'paragraph_wrap' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
349 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
350 |
); |
0 | 351 |
} |
352 |
||
16 | 353 |
/** |
354 |
* Displays WordPress version and active theme in the 'At a Glance' dashboard widget. |
|
355 |
* |
|
356 |
* @since 2.5.0 |
|
357 |
*/ |
|
0 | 358 |
function update_right_now_message() { |
5 | 359 |
$theme_name = wp_get_theme(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
360 |
|
5 | 361 |
if ( current_user_can( 'switch_themes' ) ) { |
362 |
$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
363 |
} |
|
364 |
||
365 |
$msg = ''; |
|
0 | 366 |
|
9 | 367 |
if ( current_user_can( 'update_core' ) ) { |
0 | 368 |
$cur = get_preferred_from_update_core(); |
369 |
||
16 | 370 |
if ( isset( $cur->response ) && 'upgrade' === $cur->response ) { |
371 |
$msg .= sprintf( |
|
372 |
'<a href="%s" class="button" aria-describedby="wp-version">%s</a> ', |
|
373 |
network_admin_url( 'update-core.php' ), |
|
374 |
/* translators: %s: WordPress version number, or 'Latest' string. */ |
|
375 |
sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) |
|
376 |
); |
|
9 | 377 |
} |
0 | 378 |
} |
379 |
||
16 | 380 |
/* translators: 1: Version number, 2: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
$content = __( 'WordPress %1$s running %2$s theme.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* Filters the text displayed in the 'At a Glance' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
* @param string $content Default text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
$content = apply_filters( 'update_right_now_text', $content ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
$msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
5 | 395 |
|
396 |
echo "<p id='wp-version-message'>$msg</p>"; |
|
0 | 397 |
} |
398 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
400 |
* Retrieves plugins with updates available. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
401 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
* |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
404 |
* @return object[] |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
*/ |
0 | 406 |
function get_plugin_updates() { |
9 | 407 |
$all_plugins = get_plugins(); |
0 | 408 |
$upgrade_plugins = array(); |
9 | 409 |
$current = get_site_transient( 'update_plugins' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
410 |
|
9 | 411 |
foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) { |
0 | 412 |
if ( isset( $current->response[ $plugin_file ] ) ) { |
9 | 413 |
$upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
0 | 414 |
$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
415 |
} |
|
416 |
} |
|
417 |
||
418 |
return $upgrade_plugins; |
|
419 |
} |
|
420 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
422 |
* Adds a callback to display update information for plugins with updates available. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
423 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
*/ |
0 | 426 |
function wp_plugin_update_rows() { |
9 | 427 |
if ( ! current_user_can( 'update_plugins' ) ) { |
0 | 428 |
return; |
9 | 429 |
} |
0 | 430 |
|
431 |
$plugins = get_site_transient( 'update_plugins' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
432 |
|
9 | 433 |
if ( isset( $plugins->response ) && is_array( $plugins->response ) ) { |
0 | 434 |
$plugins = array_keys( $plugins->response ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
435 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
foreach ( $plugins as $plugin_file ) { |
16 | 437 |
add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 ); |
0 | 438 |
} |
439 |
} |
|
440 |
} |
|
441 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
* Displays update information for a plugin. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
* |
16 | 445 |
* @since 2.3.0 |
446 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
* @param string $file Plugin basename. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
* @param array $plugin_data Plugin information. |
16 | 449 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
*/ |
0 | 451 |
function wp_plugin_update_row( $file, $plugin_data ) { |
452 |
$current = get_site_transient( 'update_plugins' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
453 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
if ( ! isset( $current->response[ $file ] ) ) { |
0 | 455 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
$response = $current->response[ $file ]; |
0 | 459 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
$plugins_allowedtags = array( |
9 | 461 |
'a' => array( |
462 |
'href' => array(), |
|
463 |
'title' => array(), |
|
464 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
'abbr' => array( 'title' => array() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
'acronym' => array( 'title' => array() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
'code' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
'em' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
'strong' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
); |
0 | 471 |
|
9 | 472 |
$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); |
18 | 473 |
$plugin_slug = isset( $response->slug ) ? $response->slug : $response->id; |
474 |
||
475 |
if ( isset( $response->slug ) ) { |
|
476 |
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '§ion=changelog' ); |
|
477 |
} elseif ( isset( $response->url ) ) { |
|
478 |
$details_url = $response->url; |
|
479 |
} else { |
|
480 |
$details_url = $plugin_data['PluginURI']; |
|
481 |
} |
|
482 |
||
483 |
$details_url = add_query_arg( |
|
484 |
array( |
|
485 |
'TB_iframe' => 'true', |
|
486 |
'width' => 600, |
|
487 |
'height' => 800, |
|
488 |
), |
|
489 |
$details_url |
|
490 |
); |
|
0 | 491 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
/** @var WP_Plugins_List_Table $wp_list_table */ |
16 | 493 |
$wp_list_table = _get_list_table( |
494 |
'WP_Plugins_List_Table', |
|
495 |
array( |
|
496 |
'screen' => get_current_screen(), |
|
497 |
) |
|
498 |
); |
|
0 | 499 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
if ( is_network_admin() || ! is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
501 |
if ( is_network_admin() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
$active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
503 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
$active_class = is_plugin_active( $file ) ? ' active' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
|
9 | 507 |
$requires_php = isset( $response->requires_php ) ? $response->requires_php : null; |
508 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
509 |
$notice_type = $compatible_php ? 'notice-warning' : 'notice-error'; |
|
510 |
||
16 | 511 |
printf( |
512 |
'<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' . |
|
513 |
'<td colspan="%s" class="plugin-update colspanchange">' . |
|
514 |
'<div class="update-message notice inline %s notice-alt"><p>', |
|
515 |
$active_class, |
|
18 | 516 |
esc_attr( $plugin_slug . '-update' ), |
517 |
esc_attr( $plugin_slug ), |
|
16 | 518 |
esc_attr( $file ), |
519 |
esc_attr( $wp_list_table->get_column_count() ), |
|
520 |
$notice_type |
|
521 |
); |
|
0 | 522 |
|
5 | 523 |
if ( ! current_user_can( 'update_plugins' ) ) { |
9 | 524 |
printf( |
16 | 525 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
9 | 526 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
$plugin_name, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
esc_url( $details_url ), |
9 | 529 |
sprintf( |
530 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 531 |
/* translators: 1: Plugin name, 2: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
), |
9 | 534 |
esc_attr( $response->new_version ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
} elseif ( empty( $response->package ) ) { |
9 | 537 |
printf( |
16 | 538 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
9 | 539 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
$plugin_name, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
esc_url( $details_url ), |
9 | 542 |
sprintf( |
543 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 544 |
/* translators: 1: Plugin name, 2: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
), |
9 | 547 |
esc_attr( $response->new_version ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
); |
5 | 549 |
} else { |
9 | 550 |
if ( $compatible_php ) { |
551 |
printf( |
|
16 | 552 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ |
9 | 553 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
554 |
$plugin_name, |
|
555 |
esc_url( $details_url ), |
|
556 |
sprintf( |
|
557 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 558 |
/* translators: 1: Plugin name, 2: Version number. */ |
9 | 559 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
560 |
), |
|
561 |
esc_attr( $response->new_version ), |
|
562 |
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
|
563 |
sprintf( |
|
564 |
'class="update-link" aria-label="%s"', |
|
16 | 565 |
/* translators: %s: Plugin name. */ |
566 |
esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $plugin_name ) ) |
|
9 | 567 |
) |
568 |
); |
|
569 |
} else { |
|
570 |
printf( |
|
16 | 571 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number 5: URL to Update PHP page. */ |
19 | 572 |
__( 'There is a new version of %1$s available, but it does not work with your version of PHP. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s">learn more about updating PHP</a>.' ), |
9 | 573 |
$plugin_name, |
574 |
esc_url( $details_url ), |
|
575 |
sprintf( |
|
576 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 577 |
/* translators: 1: Plugin name, 2: Version number. */ |
9 | 578 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
579 |
), |
|
580 |
esc_attr( $response->new_version ), |
|
581 |
esc_url( wp_get_update_php_url() ) |
|
582 |
); |
|
583 |
wp_update_php_annotation( '<br><em>', '</em>' ); |
|
584 |
} |
|
5 | 585 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
|
5 | 587 |
/** |
588 |
* Fires at the end of the update message container in each |
|
589 |
* row of the plugins list table. |
|
590 |
* |
|
591 |
* The dynamic portion of the hook name, `$file`, refers to the path |
|
592 |
* of the plugin's primary file relative to the plugins directory. |
|
593 |
* |
|
594 |
* @since 2.8.0 |
|
595 |
* |
|
19 | 596 |
* @param array $plugin_data An array of plugin metadata. See get_plugin_data() |
597 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
598 |
* of possible values. |
|
599 |
* @param object $response { |
|
600 |
* An object of metadata about the available plugin update. |
|
5 | 601 |
* |
19 | 602 |
* @type string $id Plugin ID, e.g. `w.org/plugins/[plugin-name]`. |
603 |
* @type string $slug Plugin slug. |
|
604 |
* @type string $plugin Plugin basename. |
|
605 |
* @type string $new_version New plugin version. |
|
606 |
* @type string $url Plugin URL. |
|
607 |
* @type string $package Plugin update package URL. |
|
608 |
* @type string[] $icons An array of plugin icon URLs. |
|
609 |
* @type string[] $banners An array of plugin banner URLs. |
|
610 |
* @type string[] $banners_rtl An array of plugin RTL banner URLs. |
|
611 |
* @type string $requires The version of WordPress which the plugin requires. |
|
612 |
* @type string $tested The version of WordPress the plugin is tested against. |
|
613 |
* @type string $requires_php The version of PHP which the plugin requires. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* } |
5 | 615 |
*/ |
16 | 616 |
do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 617 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
echo '</p></div></td></tr>'; |
0 | 619 |
} |
620 |
} |
|
621 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
623 |
* Retrieves themes with updates available. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
624 |
* |
16 | 625 |
* @since 2.9.0 |
626 |
* |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
627 |
* @return WP_Theme[] |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
*/ |
0 | 629 |
function get_theme_updates() { |
9 | 630 |
$current = get_site_transient( 'update_themes' ); |
0 | 631 |
|
9 | 632 |
if ( ! isset( $current->response ) ) { |
0 | 633 |
return array(); |
9 | 634 |
} |
0 | 635 |
|
636 |
$update_themes = array(); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
637 |
|
0 | 638 |
foreach ( $current->response as $stylesheet => $data ) { |
9 | 639 |
$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
0 | 640 |
$update_themes[ $stylesheet ]->update = $data; |
641 |
} |
|
642 |
||
643 |
return $update_themes; |
|
644 |
} |
|
645 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
647 |
* Adds a callback to display update information for themes with updates available. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
648 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
*/ |
0 | 651 |
function wp_theme_update_rows() { |
9 | 652 |
if ( ! current_user_can( 'update_themes' ) ) { |
0 | 653 |
return; |
9 | 654 |
} |
0 | 655 |
|
656 |
$themes = get_site_transient( 'update_themes' ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
657 |
|
9 | 658 |
if ( isset( $themes->response ) && is_array( $themes->response ) ) { |
0 | 659 |
$themes = array_keys( $themes->response ); |
660 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
foreach ( $themes as $theme ) { |
16 | 662 |
add_action( "after_theme_row_{$theme}", 'wp_theme_update_row', 10, 2 ); |
0 | 663 |
} |
664 |
} |
|
665 |
} |
|
666 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
* Displays update information for a theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
* |
16 | 670 |
* @since 3.1.0 |
671 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
* @param string $theme_key Theme stylesheet. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
* @param WP_Theme $theme Theme object. |
16 | 674 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
*/ |
0 | 676 |
function wp_theme_update_row( $theme_key, $theme ) { |
677 |
$current = get_site_transient( 'update_themes' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
if ( ! isset( $current->response[ $theme_key ] ) ) { |
0 | 680 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
$response = $current->response[ $theme_key ]; |
0 | 684 |
|
9 | 685 |
$details_url = add_query_arg( |
686 |
array( |
|
687 |
'TB_iframe' => 'true', |
|
688 |
'width' => 1024, |
|
689 |
'height' => 800, |
|
690 |
), |
|
691 |
$current->response[ $theme_key ]['url'] |
|
692 |
); |
|
0 | 693 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
/** @var WP_MS_Themes_List_Table $wp_list_table */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
$active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
0 | 698 |
|
16 | 699 |
$requires_wp = isset( $response['requires'] ) ? $response['requires'] : null; |
700 |
$requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null; |
|
701 |
||
702 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
703 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
704 |
||
705 |
printf( |
|
706 |
'<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' . |
|
707 |
'<td colspan="%s" class="plugin-update colspanchange">' . |
|
708 |
'<div class="update-message notice inline notice-warning notice-alt"><p>', |
|
709 |
$active, |
|
710 |
esc_attr( $theme->get_stylesheet() . '-update' ), |
|
711 |
esc_attr( $theme->get_stylesheet() ), |
|
712 |
$wp_list_table->get_column_count() |
|
713 |
); |
|
714 |
||
715 |
if ( $compatible_wp && $compatible_php ) { |
|
716 |
if ( ! current_user_can( 'update_themes' ) ) { |
|
717 |
printf( |
|
718 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
|
719 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
|
720 |
$theme['Name'], |
|
721 |
esc_url( $details_url ), |
|
722 |
sprintf( |
|
723 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
724 |
/* translators: 1: Theme name, 2: Version number. */ |
|
725 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
726 |
), |
|
727 |
$response['new_version'] |
|
728 |
); |
|
729 |
} elseif ( empty( $response['package'] ) ) { |
|
730 |
printf( |
|
731 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
|
732 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ), |
|
733 |
$theme['Name'], |
|
734 |
esc_url( $details_url ), |
|
735 |
sprintf( |
|
736 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
737 |
/* translators: 1: Theme name, 2: Version number. */ |
|
738 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
739 |
), |
|
740 |
$response['new_version'] |
|
741 |
); |
|
742 |
} else { |
|
743 |
printf( |
|
744 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ |
|
745 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
|
746 |
$theme['Name'], |
|
747 |
esc_url( $details_url ), |
|
748 |
sprintf( |
|
749 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
750 |
/* translators: 1: Theme name, 2: Version number. */ |
|
751 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
752 |
), |
|
753 |
$response['new_version'], |
|
754 |
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
|
755 |
sprintf( |
|
756 |
'class="update-link" aria-label="%s"', |
|
757 |
/* translators: %s: Theme name. */ |
|
758 |
esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) ) |
|
759 |
) |
|
760 |
); |
|
761 |
} |
|
5 | 762 |
} else { |
16 | 763 |
if ( ! $compatible_wp && ! $compatible_php ) { |
764 |
printf( |
|
765 |
/* translators: %s: Theme name. */ |
|
19 | 766 |
__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ), |
16 | 767 |
$theme['Name'] |
768 |
); |
|
769 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
|
770 |
printf( |
|
771 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
|
772 |
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
|
773 |
self_admin_url( 'update-core.php' ), |
|
774 |
esc_url( wp_get_update_php_url() ) |
|
775 |
); |
|
776 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
777 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
778 |
printf( |
|
779 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
780 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
781 |
self_admin_url( 'update-core.php' ) |
|
782 |
); |
|
783 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
784 |
printf( |
|
785 |
/* translators: %s: URL to Update PHP page. */ |
|
786 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
787 |
esc_url( wp_get_update_php_url() ) |
|
788 |
); |
|
789 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
790 |
} |
|
791 |
} elseif ( ! $compatible_wp ) { |
|
792 |
printf( |
|
793 |
/* translators: %s: Theme name. */ |
|
19 | 794 |
__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ), |
16 | 795 |
$theme['Name'] |
796 |
); |
|
797 |
if ( current_user_can( 'update_core' ) ) { |
|
798 |
printf( |
|
799 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
800 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
801 |
self_admin_url( 'update-core.php' ) |
|
802 |
); |
|
803 |
} |
|
804 |
} elseif ( ! $compatible_php ) { |
|
805 |
printf( |
|
806 |
/* translators: %s: Theme name. */ |
|
19 | 807 |
__( 'There is a new version of %s available, but it does not work with your version of PHP.' ), |
16 | 808 |
$theme['Name'] |
809 |
); |
|
810 |
if ( current_user_can( 'update_php' ) ) { |
|
811 |
printf( |
|
812 |
/* translators: %s: URL to Update PHP page. */ |
|
813 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
814 |
esc_url( wp_get_update_php_url() ) |
|
815 |
); |
|
816 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
817 |
} |
|
818 |
} |
|
5 | 819 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
820 |
|
5 | 821 |
/** |
822 |
* Fires at the end of the update message container in each |
|
823 |
* row of the themes list table. |
|
824 |
* |
|
825 |
* The dynamic portion of the hook name, `$theme_key`, refers to |
|
826 |
* the theme slug as found in the WordPress.org themes repository. |
|
827 |
* |
|
828 |
* @since 3.1.0 |
|
829 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
* @param WP_Theme $theme The WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
831 |
* @param array $response { |
5 | 832 |
* An array of metadata about the available theme update. |
833 |
* |
|
834 |
* @type string $new_version New theme version. |
|
835 |
* @type string $url Theme URL. |
|
836 |
* @type string $package Theme update package URL. |
|
837 |
* } |
|
838 |
*/ |
|
16 | 839 |
do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 840 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
841 |
echo '</p></div></td></tr>'; |
0 | 842 |
} |
843 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
844 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
845 |
* Displays maintenance nag HTML message. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
846 |
* |
16 | 847 |
* @since 2.7.0 |
848 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
* @global int $upgrading |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
850 |
* |
16 | 851 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
852 |
*/ |
0 | 853 |
function maintenance_nag() { |
854 |
global $upgrading; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
855 |
|
0 | 856 |
$nag = isset( $upgrading ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
857 |
|
0 | 858 |
if ( ! $nag ) { |
859 |
$failed = get_site_option( 'auto_core_update_failed' ); |
|
860 |
/* |
|
861 |
* If an update failed critically, we may have copied over version.php but not other files. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
* In that case, if the installation claims we're running the version we attempted, nag. |
0 | 863 |
* This is serious enough to err on the side of nagging. |
864 |
* |
|
865 |
* If we simply failed to update before we tried to copy any files, then assume things are |
|
866 |
* OK if they are now running the latest. |
|
867 |
* |
|
868 |
* This flag is cleared whenever a successful update occurs using Core_Upgrader. |
|
869 |
*/ |
|
870 |
$comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
871 |
if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], wp_get_wp_version(), $comparison ) ) { |
0 | 872 |
$nag = true; |
9 | 873 |
} |
0 | 874 |
} |
875 |
||
9 | 876 |
if ( ! $nag ) { |
0 | 877 |
return false; |
9 | 878 |
} |
0 | 879 |
|
9 | 880 |
if ( current_user_can( 'update_core' ) ) { |
16 | 881 |
$msg = sprintf( |
882 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
883 |
__( 'An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.' ), |
|
884 |
'update-core.php' |
|
885 |
); |
|
9 | 886 |
} else { |
887 |
$msg = __( 'An automated WordPress update has failed to complete! Please notify the site administrator.' ); |
|
888 |
} |
|
0 | 889 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
890 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
891 |
$msg, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
892 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
893 |
'type' => 'warning', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
894 |
'additional_classes' => array( 'update-nag', 'inline' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
895 |
'paragraph_wrap' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
896 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
897 |
); |
0 | 898 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
899 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
* Prints the JavaScript templates for update admin notices. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
903 |
* @since 4.6.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
904 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
* Template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
* Arguments for admin notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
* @type string id ID of the notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
* @type string className Class names for the notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
* @type string message The notice's message. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
* @type string type The type of update the notice is for. Either 'plugin' or 'theme'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
function wp_print_admin_notice_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
918 |
<script id="tmpl-wp-updates-admin-notice" type="text/html"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
<div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
<script id="tmpl-wp-bulk-updates-admin-notice" type="text/html"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
922 |
<div id="{{ data.id }}" class="{{ data.className }} notice <# if ( data.errorMessage ) { #>notice-error<# } else { #>notice-success<# } #>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
<p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
924 |
<# if ( data.successMessage ) { #> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
925 |
{{{ data.successMessage }}} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
926 |
<# } #> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
927 |
<# if ( data.errorMessage ) { #> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
928 |
<button class="button-link bulk-action-errors-collapsed" aria-expanded="false"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
929 |
{{{ data.errorMessage }}} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
930 |
<span class="screen-reader-text"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
932 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
933 |
_e( 'Show more details' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
935 |
</span> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
<span class="toggle-indicator" aria-hidden="true"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
</button> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
</p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
940 |
<# if ( data.errorMessages ) { #> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
<ul class="bulk-action-errors hidden"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
<# _.each( data.errorMessages, function( errorMessage ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
<li>{{ errorMessage }}</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
944 |
<# } ); #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
* Prints the JavaScript templates for update and deletion rows in list tables. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
955 |
* @since 4.6.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
956 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
* The update template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
959 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
* Arguments for the update row |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
* @type string slug Plugin slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
* @type string plugin Plugin base name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
* @type string colspan The number of table columns this row spans. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
* @type string content The row content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
966 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
* The delete template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
970 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
* Arguments for the update row |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
* @type string slug Plugin slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
* @type string plugin Plugin base name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
* @type string name Plugin name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
* @type string colspan The number of table columns this row spans. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
function wp_print_update_row_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
981 |
<script id="tmpl-item-update-row" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
<tr class="plugin-update-tr update" id="{{ data.slug }}-update" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
<td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
{{{ data.content }}} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
<script id="tmpl-item-deleted-row" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
<tr class="plugin-deleted-tr inactive deleted" id="{{ data.slug }}-deleted" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
<td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
991 |
<# if ( data.plugin ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
printf( |
16 | 994 |
/* translators: %s: Plugin name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
_x( '%s was successfully deleted.', 'plugin' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
'<strong>{{{ data.name }}}</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
printf( |
16 | 1002 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
_x( '%s was successfully deleted.', 'theme' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
'<strong>{{{ data.name }}}</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
} |
9 | 1013 |
|
1014 |
/** |
|
1015 |
* Displays a notice when the user is in recovery mode. |
|
1016 |
* |
|
1017 |
* @since 5.2.0 |
|
1018 |
*/ |
|
1019 |
function wp_recovery_mode_nag() { |
|
1020 |
if ( ! wp_is_recovery_mode() ) { |
|
1021 |
return; |
|
1022 |
} |
|
1023 |
||
1024 |
$url = wp_login_url(); |
|
1025 |
$url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url ); |
|
1026 |
$url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION ); |
|
1027 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1028 |
$message = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1029 |
/* translators: %s: Recovery Mode exit link. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1030 |
__( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1031 |
esc_url( $url ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1032 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1033 |
wp_admin_notice( $message, array( 'type' => 'info' ) ); |
9 | 1034 |
} |
16 | 1035 |
|
1036 |
/** |
|
1037 |
* Checks whether auto-updates are enabled. |
|
1038 |
* |
|
1039 |
* @since 5.5.0 |
|
1040 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1041 |
* @param string $type The type of update being checked: Either 'theme' or 'plugin'. |
16 | 1042 |
* @return bool True if auto-updates are enabled for `$type`, false otherwise. |
1043 |
*/ |
|
1044 |
function wp_is_auto_update_enabled_for_type( $type ) { |
|
1045 |
if ( ! class_exists( 'WP_Automatic_Updater' ) ) { |
|
1046 |
require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; |
|
1047 |
} |
|
1048 |
||
1049 |
$updater = new WP_Automatic_Updater(); |
|
1050 |
$enabled = ! $updater->is_disabled(); |
|
1051 |
||
1052 |
switch ( $type ) { |
|
1053 |
case 'plugin': |
|
1054 |
/** |
|
1055 |
* Filters whether plugins auto-update is enabled. |
|
1056 |
* |
|
1057 |
* @since 5.5.0 |
|
1058 |
* |
|
1059 |
* @param bool $enabled True if plugins auto-update is enabled, false otherwise. |
|
1060 |
*/ |
|
1061 |
return apply_filters( 'plugins_auto_update_enabled', $enabled ); |
|
1062 |
case 'theme': |
|
1063 |
/** |
|
1064 |
* Filters whether themes auto-update is enabled. |
|
1065 |
* |
|
1066 |
* @since 5.5.0 |
|
1067 |
* |
|
1068 |
* @param bool $enabled True if themes auto-update is enabled, false otherwise. |
|
1069 |
*/ |
|
1070 |
return apply_filters( 'themes_auto_update_enabled', $enabled ); |
|
1071 |
} |
|
1072 |
||
1073 |
return false; |
|
1074 |
} |
|
1075 |
||
1076 |
/** |
|
18 | 1077 |
* Checks whether auto-updates are forced for an item. |
1078 |
* |
|
1079 |
* @since 5.6.0 |
|
1080 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1081 |
* @param string $type The type of update being checked: Either 'theme' or 'plugin'. |
18 | 1082 |
* @param bool|null $update Whether to update. The value of null is internally used |
1083 |
* to detect whether nothing has hooked into this filter. |
|
1084 |
* @param object $item The update offer. |
|
1085 |
* @return bool True if auto-updates are forced for `$item`, false otherwise. |
|
1086 |
*/ |
|
1087 |
function wp_is_auto_update_forced_for_item( $type, $update, $item ) { |
|
1088 |
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ |
|
1089 |
return apply_filters( "auto_update_{$type}", $update, $item ); |
|
1090 |
} |
|
1091 |
||
1092 |
/** |
|
16 | 1093 |
* Determines the appropriate auto-update message to be displayed. |
1094 |
* |
|
1095 |
* @since 5.5.0 |
|
1096 |
* |
|
1097 |
* @return string The update message to be shown. |
|
1098 |
*/ |
|
1099 |
function wp_get_auto_update_message() { |
|
1100 |
$next_update_time = wp_next_scheduled( 'wp_version_check' ); |
|
1101 |
||
1102 |
// Check if the event exists. |
|
1103 |
if ( false === $next_update_time ) { |
|
1104 |
$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' ); |
|
1105 |
} else { |
|
18 | 1106 |
$time_to_next_update = human_time_diff( (int) $next_update_time ); |
16 | 1107 |
|
1108 |
// See if cron is overdue. |
|
1109 |
$overdue = ( time() - $next_update_time ) > 0; |
|
1110 |
||
1111 |
if ( $overdue ) { |
|
1112 |
$message = sprintf( |
|
1113 |
/* translators: %s: Duration that WP-Cron has been overdue. */ |
|
1114 |
__( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ), |
|
1115 |
$time_to_next_update |
|
1116 |
); |
|
1117 |
} else { |
|
1118 |
$message = sprintf( |
|
1119 |
/* translators: %s: Time until the next update. */ |
|
1120 |
__( 'Automatic update scheduled in %s.' ), |
|
1121 |
$time_to_next_update |
|
1122 |
); |
|
1123 |
} |
|
1124 |
} |
|
1125 |
||
1126 |
return $message; |
|
1127 |
} |