author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
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->url ) ) { |
0 | 244 |
$cur->url = ''; |
9 | 245 |
} |
0 | 246 |
|
9 | 247 |
if ( ! isset( $cur->response ) ) { |
0 | 248 |
$cur->response = ''; |
9 | 249 |
} |
0 | 250 |
|
251 |
switch ( $cur->response ) { |
|
9 | 252 |
case 'development': |
16 | 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 |
); |
|
0 | 259 |
|
9 | 260 |
case 'upgrade': |
16 | 261 |
return sprintf( |
262 |
'<strong><a href="%s">%s</a></strong>', |
|
263 |
network_admin_url( 'update-core.php' ), |
|
264 |
/* translators: %s: WordPress version. */ |
|
265 |
sprintf( __( 'Get Version %s' ), $cur->current ) |
|
266 |
); |
|
0 | 267 |
|
9 | 268 |
case 'latest': |
269 |
default: |
|
16 | 270 |
/* translators: %s: WordPress version. */ |
9 | 271 |
return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
0 | 272 |
} |
273 |
} |
|
274 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
/** |
16 | 276 |
* @since 2.3.0 |
277 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
* @global string $pagenow |
16 | 279 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
*/ |
0 | 281 |
function update_nag() { |
9 | 282 |
if ( is_multisite() && ! current_user_can( 'update_core' ) ) { |
0 | 283 |
return false; |
9 | 284 |
} |
0 | 285 |
|
286 |
global $pagenow; |
|
287 |
||
16 | 288 |
if ( 'update-core.php' === $pagenow ) { |
0 | 289 |
return; |
9 | 290 |
} |
0 | 291 |
|
292 |
$cur = get_preferred_from_update_core(); |
|
293 |
||
16 | 294 |
if ( ! isset( $cur->response ) || 'upgrade' !== $cur->response ) { |
0 | 295 |
return false; |
9 | 296 |
} |
297 |
||
298 |
$version_url = sprintf( |
|
16 | 299 |
/* translators: %s: WordPress version. */ |
9 | 300 |
esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), |
301 |
sanitize_title( $cur->current ) |
|
302 |
); |
|
0 | 303 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
if ( current_user_can( 'update_core' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
$msg = sprintf( |
16 | 306 |
/* 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
|
307 |
__( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
9 | 308 |
$version_url, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
$cur->current, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
network_admin_url( 'update-core.php' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
esc_attr__( 'Please update WordPress now' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
); |
0 | 313 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
$msg = sprintf( |
16 | 315 |
/* 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
|
316 |
__( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
9 | 317 |
$version_url, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
$cur->current |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
); |
0 | 320 |
} |
16 | 321 |
|
322 |
echo "<div class='update-nag notice notice-warning inline'>$msg</div>"; |
|
0 | 323 |
} |
324 |
||
16 | 325 |
/** |
326 |
* Displays WordPress version and active theme in the 'At a Glance' dashboard widget. |
|
327 |
* |
|
328 |
* @since 2.5.0 |
|
329 |
*/ |
|
0 | 330 |
function update_right_now_message() { |
5 | 331 |
$theme_name = wp_get_theme(); |
332 |
if ( current_user_can( 'switch_themes' ) ) { |
|
333 |
$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
334 |
} |
|
335 |
||
336 |
$msg = ''; |
|
0 | 337 |
|
9 | 338 |
if ( current_user_can( 'update_core' ) ) { |
0 | 339 |
$cur = get_preferred_from_update_core(); |
340 |
||
16 | 341 |
if ( isset( $cur->response ) && 'upgrade' === $cur->response ) { |
342 |
$msg .= sprintf( |
|
343 |
'<a href="%s" class="button" aria-describedby="wp-version">%s</a> ', |
|
344 |
network_admin_url( 'update-core.php' ), |
|
345 |
/* translators: %s: WordPress version number, or 'Latest' string. */ |
|
346 |
sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) |
|
347 |
); |
|
9 | 348 |
} |
0 | 349 |
} |
350 |
||
16 | 351 |
/* translators: 1: Version number, 2: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
$content = __( 'WordPress %1$s running %2$s theme.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
* 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
|
356 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
* 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
|
358 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* @since 4.4.0 |
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 |
* @param string $content Default text. |
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 |
$content = apply_filters( 'update_right_now_text', $content ); |
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 |
$msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
5 | 366 |
|
367 |
echo "<p id='wp-version-message'>$msg</p>"; |
|
0 | 368 |
} |
369 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
* @since 2.9.0 |
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 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
*/ |
0 | 375 |
function get_plugin_updates() { |
9 | 376 |
$all_plugins = get_plugins(); |
0 | 377 |
$upgrade_plugins = array(); |
9 | 378 |
$current = get_site_transient( 'update_plugins' ); |
379 |
foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) { |
|
0 | 380 |
if ( isset( $current->response[ $plugin_file ] ) ) { |
9 | 381 |
$upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
0 | 382 |
$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
383 |
} |
|
384 |
} |
|
385 |
||
386 |
return $upgrade_plugins; |
|
387 |
} |
|
388 |
||
7
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 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
*/ |
0 | 392 |
function wp_plugin_update_rows() { |
9 | 393 |
if ( ! current_user_can( 'update_plugins' ) ) { |
0 | 394 |
return; |
9 | 395 |
} |
0 | 396 |
|
397 |
$plugins = get_site_transient( 'update_plugins' ); |
|
9 | 398 |
if ( isset( $plugins->response ) && is_array( $plugins->response ) ) { |
0 | 399 |
$plugins = array_keys( $plugins->response ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
foreach ( $plugins as $plugin_file ) { |
16 | 401 |
add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 ); |
0 | 402 |
} |
403 |
} |
|
404 |
} |
|
405 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* Displays update information for a plugin. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
* |
16 | 409 |
* @since 2.3.0 |
410 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
* @param string $file Plugin basename. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
* @param array $plugin_data Plugin information. |
16 | 413 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
*/ |
0 | 415 |
function wp_plugin_update_row( $file, $plugin_data ) { |
416 |
$current = get_site_transient( 'update_plugins' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
if ( ! isset( $current->response[ $file ] ) ) { |
0 | 418 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
$response = $current->response[ $file ]; |
0 | 422 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
$plugins_allowedtags = array( |
9 | 424 |
'a' => array( |
425 |
'href' => array(), |
|
426 |
'title' => array(), |
|
427 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
'abbr' => array( 'title' => array() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
'acronym' => array( 'title' => array() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
'code' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
'em' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
'strong' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
); |
0 | 434 |
|
9 | 435 |
$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); |
436 |
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); |
|
0 | 437 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
/** @var WP_Plugins_List_Table $wp_list_table */ |
16 | 439 |
$wp_list_table = _get_list_table( |
440 |
'WP_Plugins_List_Table', |
|
441 |
array( |
|
442 |
'screen' => get_current_screen(), |
|
443 |
) |
|
444 |
); |
|
0 | 445 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
if ( is_network_admin() || ! is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
if ( is_network_admin() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
$active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
$active_class = is_plugin_active( $file ) ? ' active' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
|
9 | 453 |
$requires_php = isset( $response->requires_php ) ? $response->requires_php : null; |
454 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
455 |
$notice_type = $compatible_php ? 'notice-warning' : 'notice-error'; |
|
456 |
||
16 | 457 |
printf( |
458 |
'<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' . |
|
459 |
'<td colspan="%s" class="plugin-update colspanchange">' . |
|
460 |
'<div class="update-message notice inline %s notice-alt"><p>', |
|
461 |
$active_class, |
|
462 |
esc_attr( $response->slug . '-update' ), |
|
463 |
esc_attr( $response->slug ), |
|
464 |
esc_attr( $file ), |
|
465 |
esc_attr( $wp_list_table->get_column_count() ), |
|
466 |
$notice_type |
|
467 |
); |
|
0 | 468 |
|
5 | 469 |
if ( ! current_user_can( 'update_plugins' ) ) { |
9 | 470 |
printf( |
16 | 471 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
9 | 472 |
__( '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
|
473 |
$plugin_name, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
esc_url( $details_url ), |
9 | 475 |
sprintf( |
476 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 477 |
/* translators: 1: Plugin name, 2: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
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
|
479 |
), |
9 | 480 |
esc_attr( $response->new_version ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
} elseif ( empty( $response->package ) ) { |
9 | 483 |
printf( |
16 | 484 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
9 | 485 |
__( '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
|
486 |
$plugin_name, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
esc_url( $details_url ), |
9 | 488 |
sprintf( |
489 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 490 |
/* translators: 1: Plugin name, 2: Version number. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
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
|
492 |
), |
9 | 493 |
esc_attr( $response->new_version ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
); |
5 | 495 |
} else { |
9 | 496 |
if ( $compatible_php ) { |
497 |
printf( |
|
16 | 498 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ |
9 | 499 |
__( '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>.' ), |
500 |
$plugin_name, |
|
501 |
esc_url( $details_url ), |
|
502 |
sprintf( |
|
503 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
16 | 504 |
/* translators: 1: Plugin name, 2: Version number. */ |
9 | 505 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
506 |
), |
|
507 |
esc_attr( $response->new_version ), |
|
508 |
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
|
509 |
sprintf( |
|
510 |
'class="update-link" aria-label="%s"', |
|
16 | 511 |
/* translators: %s: Plugin name. */ |
512 |
esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $plugin_name ) ) |
|
9 | 513 |
) |
514 |
); |
|
515 |
} else { |
|
516 |
printf( |
|
16 | 517 |
/* translators: 1: Plugin name, 2: Details URL, 3: Additional link attributes, 4: Version number 5: URL to Update PHP page. */ |
9 | 518 |
__( '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>.' ), |
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 |
esc_url( wp_get_update_php_url() ) |
|
528 |
); |
|
529 |
wp_update_php_annotation( '<br><em>', '</em>' ); |
|
530 |
} |
|
5 | 531 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
|
5 | 533 |
/** |
534 |
* Fires at the end of the update message container in each |
|
535 |
* row of the plugins list table. |
|
536 |
* |
|
537 |
* The dynamic portion of the hook name, `$file`, refers to the path |
|
538 |
* of the plugin's primary file relative to the plugins directory. |
|
539 |
* |
|
540 |
* @since 2.8.0 |
|
541 |
* |
|
542 |
* @param array $plugin_data { |
|
543 |
* An array of plugin metadata. |
|
544 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
* @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
|
546 |
* @type string $plugin_uri Plugin URI. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
* @type string $version Plugin version. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
* @type string $description Plugin description. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
* @type string $author Plugin author. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
* @type string $author_uri Plugin author URI. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
* @type string $text_domain Plugin text domain. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
552 |
* @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
|
553 |
* @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
|
554 |
* @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
|
555 |
* @type string $author_name Plugin author's name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
* @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
|
557 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
* @param array $response { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
559 |
* An array of metadata about the available plugin update. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
* @type int $id Plugin ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
* @type string $slug Plugin slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
* @type string $new_version New plugin version. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
* @type string $url Plugin URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
* @type string $package Plugin update package URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
* } |
5 | 567 |
*/ |
16 | 568 |
do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 569 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
echo '</p></div></td></tr>'; |
0 | 571 |
} |
572 |
} |
|
573 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
/** |
16 | 575 |
* @since 2.9.0 |
576 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
*/ |
0 | 579 |
function get_theme_updates() { |
9 | 580 |
$current = get_site_transient( 'update_themes' ); |
0 | 581 |
|
9 | 582 |
if ( ! isset( $current->response ) ) { |
0 | 583 |
return array(); |
9 | 584 |
} |
0 | 585 |
|
586 |
$update_themes = array(); |
|
587 |
foreach ( $current->response as $stylesheet => $data ) { |
|
9 | 588 |
$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
0 | 589 |
$update_themes[ $stylesheet ]->update = $data; |
590 |
} |
|
591 |
||
592 |
return $update_themes; |
|
593 |
} |
|
594 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
*/ |
0 | 598 |
function wp_theme_update_rows() { |
9 | 599 |
if ( ! current_user_can( 'update_themes' ) ) { |
0 | 600 |
return; |
9 | 601 |
} |
0 | 602 |
|
603 |
$themes = get_site_transient( 'update_themes' ); |
|
9 | 604 |
if ( isset( $themes->response ) && is_array( $themes->response ) ) { |
0 | 605 |
$themes = array_keys( $themes->response ); |
606 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
foreach ( $themes as $theme ) { |
16 | 608 |
add_action( "after_theme_row_{$theme}", 'wp_theme_update_row', 10, 2 ); |
0 | 609 |
} |
610 |
} |
|
611 |
} |
|
612 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* Displays update information for a theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
* |
16 | 616 |
* @since 3.1.0 |
617 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
* @param string $theme_key Theme stylesheet. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
* @param WP_Theme $theme Theme object. |
16 | 620 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
*/ |
0 | 622 |
function wp_theme_update_row( $theme_key, $theme ) { |
623 |
$current = get_site_transient( 'update_themes' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
if ( ! isset( $current->response[ $theme_key ] ) ) { |
0 | 626 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
$response = $current->response[ $theme_key ]; |
0 | 630 |
|
9 | 631 |
$details_url = add_query_arg( |
632 |
array( |
|
633 |
'TB_iframe' => 'true', |
|
634 |
'width' => 1024, |
|
635 |
'height' => 800, |
|
636 |
), |
|
637 |
$current->response[ $theme_key ]['url'] |
|
638 |
); |
|
0 | 639 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
/** @var WP_MS_Themes_List_Table $wp_list_table */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
$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
|
642 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
$active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
0 | 644 |
|
16 | 645 |
$requires_wp = isset( $response['requires'] ) ? $response['requires'] : null; |
646 |
$requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null; |
|
647 |
||
648 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
649 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
650 |
||
651 |
printf( |
|
652 |
'<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' . |
|
653 |
'<td colspan="%s" class="plugin-update colspanchange">' . |
|
654 |
'<div class="update-message notice inline notice-warning notice-alt"><p>', |
|
655 |
$active, |
|
656 |
esc_attr( $theme->get_stylesheet() . '-update' ), |
|
657 |
esc_attr( $theme->get_stylesheet() ), |
|
658 |
$wp_list_table->get_column_count() |
|
659 |
); |
|
660 |
||
661 |
if ( $compatible_wp && $compatible_php ) { |
|
662 |
if ( ! current_user_can( 'update_themes' ) ) { |
|
663 |
printf( |
|
664 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
|
665 |
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
|
666 |
$theme['Name'], |
|
667 |
esc_url( $details_url ), |
|
668 |
sprintf( |
|
669 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
670 |
/* translators: 1: Theme name, 2: Version number. */ |
|
671 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
672 |
), |
|
673 |
$response['new_version'] |
|
674 |
); |
|
675 |
} elseif ( empty( $response['package'] ) ) { |
|
676 |
printf( |
|
677 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ |
|
678 |
__( '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>' ), |
|
679 |
$theme['Name'], |
|
680 |
esc_url( $details_url ), |
|
681 |
sprintf( |
|
682 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
683 |
/* translators: 1: Theme name, 2: Version number. */ |
|
684 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
685 |
), |
|
686 |
$response['new_version'] |
|
687 |
); |
|
688 |
} else { |
|
689 |
printf( |
|
690 |
/* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ |
|
691 |
__( '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>.' ), |
|
692 |
$theme['Name'], |
|
693 |
esc_url( $details_url ), |
|
694 |
sprintf( |
|
695 |
'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
696 |
/* translators: 1: Theme name, 2: Version number. */ |
|
697 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
698 |
), |
|
699 |
$response['new_version'], |
|
700 |
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
|
701 |
sprintf( |
|
702 |
'class="update-link" aria-label="%s"', |
|
703 |
/* translators: %s: Theme name. */ |
|
704 |
esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) ) |
|
705 |
) |
|
706 |
); |
|
707 |
} |
|
5 | 708 |
} else { |
16 | 709 |
if ( ! $compatible_wp && ! $compatible_php ) { |
710 |
printf( |
|
711 |
/* translators: %s: Theme name. */ |
|
712 |
__( 'There is a new version of %s available, but it doesn’t work with your versions of WordPress and PHP.' ), |
|
713 |
$theme['Name'] |
|
714 |
); |
|
715 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
|
716 |
printf( |
|
717 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
|
718 |
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
|
719 |
self_admin_url( 'update-core.php' ), |
|
720 |
esc_url( wp_get_update_php_url() ) |
|
721 |
); |
|
722 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
723 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
724 |
printf( |
|
725 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
726 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
727 |
self_admin_url( 'update-core.php' ) |
|
728 |
); |
|
729 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
730 |
printf( |
|
731 |
/* translators: %s: URL to Update PHP page. */ |
|
732 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
733 |
esc_url( wp_get_update_php_url() ) |
|
734 |
); |
|
735 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
736 |
} |
|
737 |
} elseif ( ! $compatible_wp ) { |
|
738 |
printf( |
|
739 |
/* translators: %s: Theme name. */ |
|
740 |
__( 'There is a new version of %s available, but it doesn’t work with your version of WordPress.' ), |
|
741 |
$theme['Name'] |
|
742 |
); |
|
743 |
if ( current_user_can( 'update_core' ) ) { |
|
744 |
printf( |
|
745 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
746 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
747 |
self_admin_url( 'update-core.php' ) |
|
748 |
); |
|
749 |
} |
|
750 |
} elseif ( ! $compatible_php ) { |
|
751 |
printf( |
|
752 |
/* translators: %s: Theme name. */ |
|
753 |
__( 'There is a new version of %s available, but it doesn’t work with your version of PHP.' ), |
|
754 |
$theme['Name'] |
|
755 |
); |
|
756 |
if ( current_user_can( 'update_php' ) ) { |
|
757 |
printf( |
|
758 |
/* translators: %s: URL to Update PHP page. */ |
|
759 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
760 |
esc_url( wp_get_update_php_url() ) |
|
761 |
); |
|
762 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
763 |
} |
|
764 |
} |
|
5 | 765 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
|
5 | 767 |
/** |
768 |
* Fires at the end of the update message container in each |
|
769 |
* row of the themes list table. |
|
770 |
* |
|
771 |
* The dynamic portion of the hook name, `$theme_key`, refers to |
|
772 |
* the theme slug as found in the WordPress.org themes repository. |
|
773 |
* |
|
774 |
* @since 3.1.0 |
|
775 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* @param WP_Theme $theme The WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
* @param array $response { |
5 | 778 |
* An array of metadata about the available theme update. |
779 |
* |
|
780 |
* @type string $new_version New theme version. |
|
781 |
* @type string $url Theme URL. |
|
782 |
* @type string $package Theme update package URL. |
|
783 |
* } |
|
784 |
*/ |
|
16 | 785 |
do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
0 | 786 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
787 |
echo '</p></div></td></tr>'; |
0 | 788 |
} |
789 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
/** |
16 | 791 |
* @since 2.7.0 |
792 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
* @global int $upgrading |
16 | 794 |
* @return void|false |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
*/ |
0 | 796 |
function maintenance_nag() { |
16 | 797 |
// Include an unmodified $wp_version. |
798 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 799 |
global $upgrading; |
800 |
$nag = isset( $upgrading ); |
|
801 |
if ( ! $nag ) { |
|
802 |
$failed = get_site_option( 'auto_core_update_failed' ); |
|
803 |
/* |
|
804 |
* 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
|
805 |
* In that case, if the installation claims we're running the version we attempted, nag. |
0 | 806 |
* This is serious enough to err on the side of nagging. |
807 |
* |
|
808 |
* If we simply failed to update before we tried to copy any files, then assume things are |
|
809 |
* OK if they are now running the latest. |
|
810 |
* |
|
811 |
* This flag is cleared whenever a successful update occurs using Core_Upgrader. |
|
812 |
*/ |
|
813 |
$comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
|
16 | 814 |
if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], $wp_version, $comparison ) ) { |
0 | 815 |
$nag = true; |
9 | 816 |
} |
0 | 817 |
} |
818 |
||
9 | 819 |
if ( ! $nag ) { |
0 | 820 |
return false; |
9 | 821 |
} |
0 | 822 |
|
9 | 823 |
if ( current_user_can( 'update_core' ) ) { |
16 | 824 |
$msg = sprintf( |
825 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
826 |
__( 'An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.' ), |
|
827 |
'update-core.php' |
|
828 |
); |
|
9 | 829 |
} else { |
830 |
$msg = __( 'An automated WordPress update has failed to complete! Please notify the site administrator.' ); |
|
831 |
} |
|
0 | 832 |
|
16 | 833 |
echo "<div class='update-nag notice notice-warning inline'>$msg</div>"; |
0 | 834 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
* Prints the JavaScript templates for update admin notices. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
* Template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
840 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
841 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
* Arguments for admin notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
843 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
844 |
* @type string id ID of the notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
845 |
* @type string className Class names for the notice. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
* @type string message The notice's message. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
* @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
|
848 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
852 |
function wp_print_admin_notice_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
<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
|
855 |
<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
|
856 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
857 |
<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
|
858 |
<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
|
859 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
<# if ( data.successes ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
<# if ( 1 === data.successes ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
<# if ( 'plugin' === data.type ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
<?php |
16 | 864 |
/* translators: %s: Number of plugins. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
866 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
868 |
<?php |
16 | 869 |
/* translators: %s: Number of themes. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
?> |
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 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
<# if ( 'plugin' === data.type ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
<?php |
16 | 876 |
/* translators: %s: Number of plugins. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
878 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
<?php |
16 | 881 |
/* translators: %s: Number of themes. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
<# } #> |
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 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
887 |
<# if ( data.errors ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
<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
|
889 |
<# if ( 1 === data.errors ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
<?php |
16 | 891 |
/* translators: %s: Number of failed updates. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
printf( __( '%s update failed.' ), '{{ data.errors }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
895 |
<?php |
16 | 896 |
/* translators: %s: Number of failed updates. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
printf( __( '%s updates failed.' ), '{{ data.errors }}' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
?> |
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 |
<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
|
901 |
<span class="toggle-indicator" aria-hidden="true"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
</button> |
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 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
<# if ( data.errors ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
<ul class="bulk-action-errors hidden"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
<# _.each( data.errorMessages, function( errorMessage ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
<li>{{ errorMessage }}</li> |
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 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
<?php |
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 |
|
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 |
* 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
|
919 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
* The update template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
* Arguments for the update row |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
* @type string slug Plugin slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
926 |
* @type string plugin Plugin base name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
* @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
|
928 |
* @type string content The row content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
* } |
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 |
* The delete template takes one argument with four values: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
933 |
* param {object} data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
* Arguments for the update row |
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 |
* @type string slug Plugin slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
* @type string plugin Plugin base name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
* @type string name Plugin name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
* @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
|
940 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
* @since 4.6.0 |
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 |
function wp_print_update_row_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
<script id="tmpl-item-update-row" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
<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
|
948 |
<td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
{{{ data.content }}} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
<script id="tmpl-item-deleted-row" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
<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
|
955 |
<td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
<# if ( data.plugin ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
printf( |
16 | 959 |
/* translators: %s: Plugin name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
_x( '%s was successfully deleted.', 'plugin' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
'<strong>{{{ data.name }}}</strong>' |
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 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
966 |
printf( |
16 | 967 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
_x( '%s was successfully deleted.', 'theme' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
'<strong>{{{ data.name }}}</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
970 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
?> |
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 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
</script> |
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 |
} |
9 | 978 |
|
979 |
/** |
|
980 |
* Displays a notice when the user is in recovery mode. |
|
981 |
* |
|
982 |
* @since 5.2.0 |
|
983 |
*/ |
|
984 |
function wp_recovery_mode_nag() { |
|
985 |
if ( ! wp_is_recovery_mode() ) { |
|
986 |
return; |
|
987 |
} |
|
988 |
||
989 |
$url = wp_login_url(); |
|
990 |
$url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url ); |
|
991 |
$url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION ); |
|
992 |
||
993 |
?> |
|
994 |
<div class="notice notice-info"> |
|
995 |
<p> |
|
996 |
<?php |
|
997 |
printf( |
|
16 | 998 |
/* translators: %s: Recovery Mode exit link. */ |
9 | 999 |
__( '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>' ), |
1000 |
esc_url( $url ) |
|
1001 |
); |
|
1002 |
?> |
|
1003 |
</p> |
|
1004 |
</div> |
|
1005 |
<?php |
|
1006 |
} |
|
16 | 1007 |
|
1008 |
/** |
|
1009 |
* Checks whether auto-updates are enabled. |
|
1010 |
* |
|
1011 |
* @since 5.5.0 |
|
1012 |
* |
|
1013 |
* @param string $type The type of update being checked: 'theme' or 'plugin'. |
|
1014 |
* @return bool True if auto-updates are enabled for `$type`, false otherwise. |
|
1015 |
*/ |
|
1016 |
function wp_is_auto_update_enabled_for_type( $type ) { |
|
1017 |
if ( ! class_exists( 'WP_Automatic_Updater' ) ) { |
|
1018 |
require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; |
|
1019 |
} |
|
1020 |
||
1021 |
$updater = new WP_Automatic_Updater(); |
|
1022 |
$enabled = ! $updater->is_disabled(); |
|
1023 |
||
1024 |
switch ( $type ) { |
|
1025 |
case 'plugin': |
|
1026 |
/** |
|
1027 |
* Filters whether plugins auto-update is enabled. |
|
1028 |
* |
|
1029 |
* @since 5.5.0 |
|
1030 |
* |
|
1031 |
* @param bool $enabled True if plugins auto-update is enabled, false otherwise. |
|
1032 |
*/ |
|
1033 |
return apply_filters( 'plugins_auto_update_enabled', $enabled ); |
|
1034 |
case 'theme': |
|
1035 |
/** |
|
1036 |
* Filters whether themes auto-update is enabled. |
|
1037 |
* |
|
1038 |
* @since 5.5.0 |
|
1039 |
* |
|
1040 |
* @param bool $enabled True if themes auto-update is enabled, false otherwise. |
|
1041 |
*/ |
|
1042 |
return apply_filters( 'themes_auto_update_enabled', $enabled ); |
|
1043 |
} |
|
1044 |
||
1045 |
return false; |
|
1046 |
} |
|
1047 |
||
1048 |
/** |
|
1049 |
* Determines the appropriate auto-update message to be displayed. |
|
1050 |
* |
|
1051 |
* @since 5.5.0 |
|
1052 |
* |
|
1053 |
* @return string The update message to be shown. |
|
1054 |
*/ |
|
1055 |
function wp_get_auto_update_message() { |
|
1056 |
$next_update_time = wp_next_scheduled( 'wp_version_check' ); |
|
1057 |
||
1058 |
// Check if the event exists. |
|
1059 |
if ( false === $next_update_time ) { |
|
1060 |
$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' ); |
|
1061 |
} else { |
|
1062 |
$time_to_next_update = human_time_diff( intval( $next_update_time ) ); |
|
1063 |
||
1064 |
// See if cron is overdue. |
|
1065 |
$overdue = ( time() - $next_update_time ) > 0; |
|
1066 |
||
1067 |
if ( $overdue ) { |
|
1068 |
$message = sprintf( |
|
1069 |
/* translators: %s: Duration that WP-Cron has been overdue. */ |
|
1070 |
__( 'Automatic update overdue by %s. There may be a problem with WP-Cron.' ), |
|
1071 |
$time_to_next_update |
|
1072 |
); |
|
1073 |
} else { |
|
1074 |
$message = sprintf( |
|
1075 |
/* translators: %s: Time until the next update. */ |
|
1076 |
__( 'Automatic update scheduled in %s.' ), |
|
1077 |
$time_to_next_update |
|
1078 |
); |
|
1079 |
} |
|
1080 |
} |
|
1081 |
||
1082 |
return $message; |
|
1083 |
} |