153 $new_option->last_checked = time(); |
153 $new_option->last_checked = time(); |
154 |
154 |
155 // Check for update on a different schedule, depending on the page. |
155 // Check for update on a different schedule, depending on the page. |
156 switch ( current_filter() ) { |
156 switch ( current_filter() ) { |
157 case 'load-update-core.php' : |
157 case 'load-update-core.php' : |
158 $timeout = 60; // 1 min |
158 $timeout = MINUTE_IN_SECONDS; |
159 break; |
159 break; |
160 case 'load-plugins.php' : |
160 case 'load-plugins.php' : |
161 case 'load-update.php' : |
161 case 'load-update.php' : |
162 $timeout = 3600; // 1 hour |
162 $timeout = HOUR_IN_SECONDS; |
163 break; |
163 break; |
164 default : |
164 default : |
165 $timeout = 43200; // 12 hours |
165 $timeout = 12 * HOUR_IN_SECONDS; |
166 } |
166 } |
167 |
167 |
168 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
168 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
169 |
169 |
170 if ( $time_not_changed ) { |
170 if ( $time_not_changed ) { |
262 } |
262 } |
263 |
263 |
264 // Check for update on a different schedule, depending on the page. |
264 // Check for update on a different schedule, depending on the page. |
265 switch ( current_filter() ) { |
265 switch ( current_filter() ) { |
266 case 'load-update-core.php' : |
266 case 'load-update-core.php' : |
267 $timeout = 60; // 1 min |
267 $timeout = MINUTE_IN_SECONDS; |
268 break; |
268 break; |
269 case 'load-themes.php' : |
269 case 'load-themes.php' : |
270 case 'load-update.php' : |
270 case 'load-update.php' : |
271 $timeout = 3600; // 1 hour |
271 $timeout = HOUR_IN_SECONDS; |
272 break; |
272 break; |
273 default : |
273 default : |
274 $timeout = 43200; // 12 hours |
274 $timeout = 12 * HOUR_IN_SECONDS; |
275 } |
275 } |
276 |
276 |
277 $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked ); |
277 $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked ); |
278 |
278 |
279 if ( $time_not_changed ) { |
279 if ( $time_not_changed ) { |
280 $theme_changed = false; |
280 $theme_changed = false; |
281 foreach ( $checked as $slug => $v ) { |
281 foreach ( $checked as $slug => $v ) { |
282 $update_request->checked[ $slug ] = $v; |
|
283 |
|
284 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
282 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) |
285 $theme_changed = true; |
283 $theme_changed = true; |
286 } |
284 } |
287 |
285 |
288 if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) { |
286 if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) { |
352 if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) |
350 if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') ) |
353 $counts['wordpress'] = 1; |
351 $counts['wordpress'] = 1; |
354 } |
352 } |
355 |
353 |
356 $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress']; |
354 $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress']; |
357 $update_title = array(); |
355 $titles = array(); |
358 if ( $counts['wordpress'] ) |
356 if ( $counts['wordpress'] ) |
359 $update_title[] = sprintf(__('%d WordPress Update'), $counts['wordpress']); |
357 $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] ); |
360 if ( $counts['plugins'] ) |
358 if ( $counts['plugins'] ) |
361 $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $counts['plugins']), $counts['plugins']); |
359 $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); |
362 if ( $counts['themes'] ) |
360 if ( $counts['themes'] ) |
363 $update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $counts['themes']), $counts['themes']); |
361 $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); |
364 |
362 |
365 $update_title = ! empty( $update_title ) ? esc_attr( implode( ', ', $update_title ) ) : ''; |
363 $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : ''; |
366 |
364 |
367 return array( 'counts' => $counts, 'title' => $update_title ); |
365 return apply_filters( 'wp_get_update_data', array( 'counts' => $counts, 'title' => $update_title ), $titles ); |
368 } |
366 } |
369 |
367 |
370 function _maybe_update_core() { |
368 function _maybe_update_core() { |
371 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
369 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
372 |
370 |
373 $current = get_site_transient( 'update_core' ); |
371 $current = get_site_transient( 'update_core' ); |
374 |
372 |
375 if ( isset( $current->last_checked ) && |
373 if ( isset( $current->last_checked ) && |
376 43200 > ( time() - $current->last_checked ) && |
374 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && |
377 isset( $current->version_checked ) && |
375 isset( $current->version_checked ) && |
378 $current->version_checked == $wp_version ) |
376 $current->version_checked == $wp_version ) |
379 return; |
377 return; |
380 |
378 |
381 wp_version_check(); |
379 wp_version_check(); |