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