11 * |
11 * |
12 * @return object|array|false The response from the API on success, false on failure. |
12 * @return object|array|false The response from the API on success, false on failure. |
13 */ |
13 */ |
14 function get_preferred_from_update_core() { |
14 function get_preferred_from_update_core() { |
15 $updates = get_core_updates(); |
15 $updates = get_core_updates(); |
16 if ( ! is_array( $updates ) ) |
16 if ( ! is_array( $updates ) ) { |
17 return false; |
17 return false; |
18 if ( empty( $updates ) ) |
18 } |
|
19 if ( empty( $updates ) ) { |
19 return (object) array( 'response' => 'latest' ); |
20 return (object) array( 'response' => 'latest' ); |
|
21 } |
20 return $updates[0]; |
22 return $updates[0]; |
21 } |
23 } |
22 |
24 |
23 /** |
25 /** |
24 * Get available core updates. |
26 * Get available core updates. |
25 * |
27 * |
26 * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, |
28 * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, |
27 * set $options['available'] to false to skip not-dismissed updates. |
29 * set $options['available'] to false to skip not-dismissed updates. |
28 * @return array|false Array of the update objects on success, false on failure. |
30 * @return array|false Array of the update objects on success, false on failure. |
29 */ |
31 */ |
30 function get_core_updates( $options = array() ) { |
32 function get_core_updates( $options = array() ) { |
31 $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
33 $options = array_merge( |
|
34 array( |
|
35 'available' => true, |
|
36 'dismissed' => false, |
|
37 ), |
|
38 $options |
|
39 ); |
32 $dismissed = get_site_option( 'dismissed_update_core' ); |
40 $dismissed = get_site_option( 'dismissed_update_core' ); |
33 |
41 |
34 if ( ! is_array( $dismissed ) ) |
42 if ( ! is_array( $dismissed ) ) { |
35 $dismissed = array(); |
43 $dismissed = array(); |
|
44 } |
36 |
45 |
37 $from_api = get_site_transient( 'update_core' ); |
46 $from_api = get_site_transient( 'update_core' ); |
38 |
47 |
39 if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
48 if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
40 return false; |
49 return false; |
|
50 } |
41 |
51 |
42 $updates = $from_api->updates; |
52 $updates = $from_api->updates; |
43 $result = array(); |
53 $result = array(); |
44 foreach ( $updates as $update ) { |
54 foreach ( $updates as $update ) { |
45 if ( $update->response == 'autoupdate' ) |
55 if ( $update->response == 'autoupdate' ) { |
46 continue; |
56 continue; |
|
57 } |
47 |
58 |
48 if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
59 if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
49 if ( $options['dismissed'] ) { |
60 if ( $options['dismissed'] ) { |
50 $update->dismissed = true; |
61 $update->dismissed = true; |
51 $result[] = $update; |
62 $result[] = $update; |
52 } |
63 } |
53 } else { |
64 } else { |
54 if ( $options['available'] ) { |
65 if ( $options['available'] ) { |
55 $update->dismissed = false; |
66 $update->dismissed = false; |
56 $result[] = $update; |
67 $result[] = $update; |
57 } |
68 } |
58 } |
69 } |
59 } |
70 } |
60 return $result; |
71 return $result; |
61 } |
72 } |
121 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
137 headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
122 ); |
138 ); |
123 $response = wp_remote_get( $http_url, $options ); |
139 $response = wp_remote_get( $http_url, $options ); |
124 } |
140 } |
125 |
141 |
126 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
142 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
127 return false; |
143 return false; |
|
144 } |
128 |
145 |
129 $body = trim( wp_remote_retrieve_body( $response ) ); |
146 $body = trim( wp_remote_retrieve_body( $response ) ); |
130 $body = json_decode( $body, true ); |
147 $body = json_decode( $body, true ); |
131 |
148 |
132 if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
149 if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) { |
133 return false; |
150 return false; |
|
151 } |
134 |
152 |
135 return $body['checksums']; |
153 return $body['checksums']; |
136 } |
154 } |
137 |
155 |
138 /** |
156 /** |
139 * |
|
140 * @param object $update |
157 * @param object $update |
141 * @return bool |
158 * @return bool |
142 */ |
159 */ |
143 function dismiss_core_update( $update ) { |
160 function dismiss_core_update( $update ) { |
144 $dismissed = get_site_option( 'dismissed_update_core' ); |
161 $dismissed = get_site_option( 'dismissed_update_core' ); |
145 $dismissed[ $update->current . '|' . $update->locale ] = true; |
162 $dismissed[ $update->current . '|' . $update->locale ] = true; |
146 return update_site_option( 'dismissed_update_core', $dismissed ); |
163 return update_site_option( 'dismissed_update_core', $dismissed ); |
147 } |
164 } |
148 |
165 |
149 /** |
166 /** |
150 * |
|
151 * @param string $version |
167 * @param string $version |
152 * @param string $locale |
168 * @param string $locale |
153 * @return bool |
169 * @return bool |
154 */ |
170 */ |
155 function undismiss_core_update( $version, $locale ) { |
171 function undismiss_core_update( $version, $locale ) { |
156 $dismissed = get_site_option( 'dismissed_update_core' ); |
172 $dismissed = get_site_option( 'dismissed_update_core' ); |
157 $key = $version . '|' . $locale; |
173 $key = $version . '|' . $locale; |
158 |
174 |
159 if ( ! isset( $dismissed[$key] ) ) |
175 if ( ! isset( $dismissed[ $key ] ) ) { |
160 return false; |
176 return false; |
161 |
177 } |
162 unset( $dismissed[$key] ); |
178 |
|
179 unset( $dismissed[ $key ] ); |
163 return update_site_option( 'dismissed_update_core', $dismissed ); |
180 return update_site_option( 'dismissed_update_core', $dismissed ); |
164 } |
181 } |
165 |
182 |
166 /** |
183 /** |
167 * |
|
168 * @param string $version |
184 * @param string $version |
169 * @param string $locale |
185 * @param string $locale |
170 * @return object|false |
186 * @return object|false |
171 */ |
187 */ |
172 function find_core_update( $version, $locale ) { |
188 function find_core_update( $version, $locale ) { |
173 $from_api = get_site_transient( 'update_core' ); |
189 $from_api = get_site_transient( 'update_core' ); |
174 |
190 |
175 if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
191 if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) { |
176 return false; |
192 return false; |
|
193 } |
177 |
194 |
178 $updates = $from_api->updates; |
195 $updates = $from_api->updates; |
179 foreach ( $updates as $update ) { |
196 foreach ( $updates as $update ) { |
180 if ( $update->current == $version && $update->locale == $locale ) |
197 if ( $update->current == $version && $update->locale == $locale ) { |
181 return $update; |
198 return $update; |
|
199 } |
182 } |
200 } |
183 return false; |
201 return false; |
184 } |
202 } |
185 |
203 |
186 /** |
204 /** |
187 * |
|
188 * @param string $msg |
205 * @param string $msg |
189 * @return string |
206 * @return string |
190 */ |
207 */ |
191 function core_update_footer( $msg = '' ) { |
208 function core_update_footer( $msg = '' ) { |
192 if ( !current_user_can('update_core') ) |
209 if ( ! current_user_can( 'update_core' ) ) { |
193 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
210 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
211 } |
194 |
212 |
195 $cur = get_preferred_from_update_core(); |
213 $cur = get_preferred_from_update_core(); |
196 if ( ! is_object( $cur ) ) |
214 if ( ! is_object( $cur ) ) { |
197 $cur = new stdClass; |
215 $cur = new stdClass; |
198 |
216 } |
199 if ( ! isset( $cur->current ) ) |
217 |
|
218 if ( ! isset( $cur->current ) ) { |
200 $cur->current = ''; |
219 $cur->current = ''; |
201 |
220 } |
202 if ( ! isset( $cur->url ) ) |
221 |
|
222 if ( ! isset( $cur->url ) ) { |
203 $cur->url = ''; |
223 $cur->url = ''; |
204 |
224 } |
205 if ( ! isset( $cur->response ) ) |
225 |
|
226 if ( ! isset( $cur->response ) ) { |
206 $cur->response = ''; |
227 $cur->response = ''; |
|
228 } |
207 |
229 |
208 switch ( $cur->response ) { |
230 switch ( $cur->response ) { |
209 case 'development' : |
231 case 'development': |
210 /* translators: 1: WordPress version number, 2: WordPress updates admin screen URL */ |
232 /* translators: 1: WordPress version number, 2: WordPress updates admin screen URL */ |
211 return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
233 return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
212 |
234 |
213 case 'upgrade' : |
235 case 'upgrade': |
214 return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
236 return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
215 |
237 |
216 case 'latest' : |
238 case 'latest': |
217 default : |
239 default: |
218 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
240 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
219 } |
241 } |
220 } |
242 } |
221 |
243 |
222 /** |
244 /** |
223 * |
|
224 * @global string $pagenow |
245 * @global string $pagenow |
225 * @return false|void |
246 * @return false|void |
226 */ |
247 */ |
227 function update_nag() { |
248 function update_nag() { |
228 if ( is_multisite() && !current_user_can('update_core') ) |
249 if ( is_multisite() && ! current_user_can( 'update_core' ) ) { |
229 return false; |
250 return false; |
|
251 } |
230 |
252 |
231 global $pagenow; |
253 global $pagenow; |
232 |
254 |
233 if ( 'update-core.php' == $pagenow ) |
255 if ( 'update-core.php' == $pagenow ) { |
234 return; |
256 return; |
|
257 } |
235 |
258 |
236 $cur = get_preferred_from_update_core(); |
259 $cur = get_preferred_from_update_core(); |
237 |
260 |
238 if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
261 if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) { |
239 return false; |
262 return false; |
|
263 } |
|
264 |
|
265 $version_url = sprintf( |
|
266 /* translators: %s: WordPress version */ |
|
267 esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), |
|
268 sanitize_title( $cur->current ) |
|
269 ); |
240 |
270 |
241 if ( current_user_can( 'update_core' ) ) { |
271 if ( current_user_can( 'update_core' ) ) { |
242 $msg = sprintf( |
272 $msg = sprintf( |
243 /* translators: 1: Codex URL to release notes, 2: new WordPress version, 3: URL to network admin, 4: accessibility text */ |
273 /* translators: 1: URL to WordPress release notes, 2: new WordPress version, 3: URL to network admin, 4: accessibility text */ |
244 __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
274 __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
245 sprintf( |
275 $version_url, |
246 /* translators: %s: WordPress version */ |
|
247 esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
248 $cur->current |
|
249 ), |
|
250 $cur->current, |
276 $cur->current, |
251 network_admin_url( 'update-core.php' ), |
277 network_admin_url( 'update-core.php' ), |
252 esc_attr__( 'Please update WordPress now' ) |
278 esc_attr__( 'Please update WordPress now' ) |
253 ); |
279 ); |
254 } else { |
280 } else { |
255 $msg = sprintf( |
281 $msg = sprintf( |
256 /* translators: 1: Codex URL to release notes, 2: new WordPress version */ |
282 /* translators: 1: URL to WordPress release notes, 2: new WordPress version */ |
257 __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
283 __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
258 sprintf( |
284 $version_url, |
259 /* translators: %s: WordPress version */ |
|
260 esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
261 $cur->current |
|
262 ), |
|
263 $cur->current |
285 $cur->current |
264 ); |
286 ); |
265 } |
287 } |
266 echo "<div class='update-nag'>$msg</div>"; |
288 echo "<div class='update-nag'>$msg</div>"; |
267 } |
289 } |
371 $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
398 $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
372 } else { |
399 } else { |
373 $active_class = is_plugin_active( $file ) ? ' active' : ''; |
400 $active_class = is_plugin_active( $file ) ? ' active' : ''; |
374 } |
401 } |
375 |
402 |
376 echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
403 $requires_php = isset( $response->requires_php ) ? $response->requires_php : null; |
|
404 $compatible_php = is_php_version_compatible( $requires_php ); |
|
405 $notice_type = $compatible_php ? 'notice-warning' : 'notice-error'; |
|
406 |
|
407 echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline ' . $notice_type . ' notice-alt"><p>'; |
377 |
408 |
378 if ( ! current_user_can( 'update_plugins' ) ) { |
409 if ( ! current_user_can( 'update_plugins' ) ) { |
379 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
410 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
380 printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
411 printf( |
|
412 __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
381 $plugin_name, |
413 $plugin_name, |
382 esc_url( $details_url ), |
414 esc_url( $details_url ), |
383 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
415 sprintf( |
|
416 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
384 /* translators: 1: plugin name, 2: version number */ |
417 /* translators: 1: plugin name, 2: version number */ |
385 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
418 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
386 ), |
419 ), |
387 $response->new_version |
420 esc_attr( $response->new_version ) |
388 ); |
421 ); |
389 } elseif ( empty( $response->package ) ) { |
422 } elseif ( empty( $response->package ) ) { |
390 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
423 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
391 printf( __( '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>' ), |
424 printf( |
|
425 __( '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>' ), |
392 $plugin_name, |
426 $plugin_name, |
393 esc_url( $details_url ), |
427 esc_url( $details_url ), |
394 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
428 sprintf( |
|
429 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
395 /* translators: 1: plugin name, 2: version number */ |
430 /* translators: 1: plugin name, 2: version number */ |
396 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
431 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
397 ), |
432 ), |
398 $response->new_version |
433 esc_attr( $response->new_version ) |
399 ); |
434 ); |
400 } else { |
435 } else { |
401 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
436 if ( $compatible_php ) { |
402 printf( __( '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>.' ), |
437 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
403 $plugin_name, |
438 printf( |
404 esc_url( $details_url ), |
439 __( '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>.' ), |
405 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
440 $plugin_name, |
406 /* translators: 1: plugin name, 2: version number */ |
441 esc_url( $details_url ), |
407 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
442 sprintf( |
408 ), |
443 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
409 $response->new_version, |
444 /* translators: 1: plugin name, 2: version number */ |
410 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
445 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
411 sprintf( 'class="update-link" aria-label="%s"', |
446 ), |
412 /* translators: %s: plugin name */ |
447 esc_attr( $response->new_version ), |
413 esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) |
448 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
414 ) |
449 sprintf( |
415 ); |
450 'class="update-link" aria-label="%s"', |
|
451 /* translators: %s: plugin name */ |
|
452 esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) |
|
453 ) |
|
454 ); |
|
455 } else { |
|
456 /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number 5: Update PHP page URL */ |
|
457 printf( |
|
458 __( '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>.' ), |
|
459 $plugin_name, |
|
460 esc_url( $details_url ), |
|
461 sprintf( |
|
462 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
463 /* translators: 1: plugin name, 2: version number */ |
|
464 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
465 ), |
|
466 esc_attr( $response->new_version ), |
|
467 esc_url( wp_get_update_php_url() ) |
|
468 ); |
|
469 wp_update_php_annotation( '<br><em>', '</em>' ); |
|
470 } |
416 } |
471 } |
417 |
472 |
418 /** |
473 /** |
419 * Fires at the end of the update message container in each |
474 * Fires at the end of the update message container in each |
420 * row of the plugins list table. |
475 * row of the plugins list table. |
455 echo '</p></div></td></tr>'; |
510 echo '</p></div></td></tr>'; |
456 } |
511 } |
457 } |
512 } |
458 |
513 |
459 /** |
514 /** |
460 * |
|
461 * @return array |
515 * @return array |
462 */ |
516 */ |
463 function get_theme_updates() { |
517 function get_theme_updates() { |
464 $current = get_site_transient('update_themes'); |
518 $current = get_site_transient( 'update_themes' ); |
465 |
519 |
466 if ( ! isset( $current->response ) ) |
520 if ( ! isset( $current->response ) ) { |
467 return array(); |
521 return array(); |
|
522 } |
468 |
523 |
469 $update_themes = array(); |
524 $update_themes = array(); |
470 foreach ( $current->response as $stylesheet => $data ) { |
525 foreach ( $current->response as $stylesheet => $data ) { |
471 $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
526 $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
472 $update_themes[ $stylesheet ]->update = $data; |
527 $update_themes[ $stylesheet ]->update = $data; |
473 } |
528 } |
474 |
529 |
475 return $update_themes; |
530 return $update_themes; |
476 } |
531 } |
477 |
532 |
478 /** |
533 /** |
479 * @since 3.1.0 |
534 * @since 3.1.0 |
480 */ |
535 */ |
481 function wp_theme_update_rows() { |
536 function wp_theme_update_rows() { |
482 if ( !current_user_can('update_themes' ) ) |
537 if ( ! current_user_can( 'update_themes' ) ) { |
483 return; |
538 return; |
|
539 } |
484 |
540 |
485 $themes = get_site_transient( 'update_themes' ); |
541 $themes = get_site_transient( 'update_themes' ); |
486 if ( isset($themes->response) && is_array($themes->response) ) { |
542 if ( isset( $themes->response ) && is_array( $themes->response ) ) { |
487 $themes = array_keys( $themes->response ); |
543 $themes = array_keys( $themes->response ); |
488 |
544 |
489 foreach ( $themes as $theme ) { |
545 foreach ( $themes as $theme ) { |
490 add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); |
546 add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); |
491 } |
547 } |
506 return false; |
562 return false; |
507 } |
563 } |
508 |
564 |
509 $response = $current->response[ $theme_key ]; |
565 $response = $current->response[ $theme_key ]; |
510 |
566 |
511 $details_url = add_query_arg( array( |
567 $details_url = add_query_arg( |
512 'TB_iframe' => 'true', |
568 array( |
513 'width' => 1024, |
569 'TB_iframe' => 'true', |
514 'height' => 800, |
570 'width' => 1024, |
515 ), $current->response[ $theme_key ]['url'] ); |
571 'height' => 800, |
|
572 ), |
|
573 $current->response[ $theme_key ]['url'] |
|
574 ); |
516 |
575 |
517 /** @var WP_MS_Themes_List_Table $wp_list_table */ |
576 /** @var WP_MS_Themes_List_Table $wp_list_table */ |
518 $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); |
577 $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); |
519 |
578 |
520 $active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
579 $active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
521 |
580 |
522 echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
581 echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
523 if ( ! current_user_can( 'update_themes' ) ) { |
582 if ( ! current_user_can( 'update_themes' ) ) { |
524 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
583 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
525 printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
584 printf( |
|
585 __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
526 $theme['Name'], |
586 $theme['Name'], |
527 esc_url( $details_url ), |
587 esc_url( $details_url ), |
528 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
588 sprintf( |
|
589 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
529 /* translators: 1: theme name, 2: version number */ |
590 /* translators: 1: theme name, 2: version number */ |
530 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
591 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
531 ), |
592 ), |
532 $response['new_version'] |
593 $response['new_version'] |
533 ); |
594 ); |
534 } elseif ( empty( $response['package'] ) ) { |
595 } elseif ( empty( $response['package'] ) ) { |
535 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
596 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
536 printf( __( '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>' ), |
597 printf( |
|
598 __( '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>' ), |
537 $theme['Name'], |
599 $theme['Name'], |
538 esc_url( $details_url ), |
600 esc_url( $details_url ), |
539 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
601 sprintf( |
|
602 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
540 /* translators: 1: theme name, 2: version number */ |
603 /* translators: 1: theme name, 2: version number */ |
541 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
604 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
542 ), |
605 ), |
543 $response['new_version'] |
606 $response['new_version'] |
544 ); |
607 ); |
545 } else { |
608 } else { |
546 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
609 /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
547 printf( __( '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>.' ), |
610 printf( |
|
611 __( '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>.' ), |
548 $theme['Name'], |
612 $theme['Name'], |
549 esc_url( $details_url ), |
613 esc_url( $details_url ), |
550 sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
614 sprintf( |
|
615 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
551 /* translators: 1: theme name, 2: version number */ |
616 /* translators: 1: theme name, 2: version number */ |
552 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
617 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
553 ), |
618 ), |
554 $response['new_version'], |
619 $response['new_version'], |
555 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
620 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
556 sprintf( 'class="update-link" aria-label="%s"', |
621 sprintf( |
|
622 'class="update-link" aria-label="%s"', |
557 /* translators: %s: theme name */ |
623 /* translators: %s: theme name */ |
558 esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) |
624 esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) |
559 ) |
625 ) |
560 ); |
626 ); |
561 } |
627 } |