PageRenderTime 43ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/184.168.182.1/wp-includes/update.php

https://gitlab.com/endomorphosis/falkenstein
PHP | 634 lines | 393 code | 103 blank | 138 comment | 110 complexity | 42f802f2e6dcd1fcaf8c171ee84ad40d MD5 | raw file
  1. <?php
  2. /**
  3. * A simple set of functions to check our version 1.0 update service.
  4. *
  5. * @package WordPress
  6. * @since 2.3.0
  7. */
  8. /**
  9. * Check WordPress version against the newest version.
  10. *
  11. * The WordPress version, PHP version, and Locale is sent. Checks against the
  12. * WordPress server at api.wordpress.org server. Will only check if WordPress
  13. * isn't installing.
  14. *
  15. * @package WordPress
  16. * @since 2.3.0
  17. * @uses $wp_version Used to check against the newest WordPress version.
  18. *
  19. * @param array $extra_stats Extra statistics to report to the WordPress.org API.
  20. * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set.
  21. * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
  22. */
  23. function wp_version_check( $extra_stats = array(), $force_check = false ) {
  24. if ( defined('WP_INSTALLING') )
  25. return;
  26. global $wpdb, $wp_local_package;
  27. include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
  28. $php_version = phpversion();
  29. $current = get_site_transient( 'update_core' );
  30. $translations = wp_get_installed_translations( 'core' );
  31. // Invalidate the transient when $wp_version changes
  32. if ( is_object( $current ) && $wp_version != $current->version_checked )
  33. $current = false;
  34. if ( ! is_object($current) ) {
  35. $current = new stdClass;
  36. $current->updates = array();
  37. $current->version_checked = $wp_version;
  38. }
  39. if ( ! empty( $extra_stats ) )
  40. $force_check = true;
  41. // Wait 60 seconds between multiple version check requests
  42. $timeout = 60;
  43. $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
  44. if ( ! $force_check && $time_not_changed )
  45. return false;
  46. $locale = get_locale();
  47. /**
  48. * Filter the locale requested for WordPress core translations.
  49. *
  50. * @since 2.8.0
  51. *
  52. * @param string $locale Current locale.
  53. */
  54. $locale = apply_filters( 'core_version_check_locale', $locale );
  55. // Update last_checked for current to prevent multiple blocking requests if request hangs
  56. $current->last_checked = time();
  57. set_site_transient( 'update_core', $current );
  58. if ( method_exists( $wpdb, 'db_version' ) )
  59. $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
  60. else
  61. $mysql_version = 'N/A';
  62. if ( is_multisite() ) {
  63. $user_count = get_user_count();
  64. $num_blogs = get_blog_count();
  65. $wp_install = network_site_url();
  66. $multisite_enabled = 1;
  67. } else {
  68. $user_count = count_users();
  69. $user_count = $user_count['total_users'];
  70. $multisite_enabled = 0;
  71. $num_blogs = 1;
  72. $wp_install = home_url( '/' );
  73. }
  74. $query = array(
  75. 'version' => $wp_version,
  76. 'php' => $php_version,
  77. 'locale' => $locale,
  78. 'mysql' => $mysql_version,
  79. 'local_package' => isset( $wp_local_package ) ? $wp_local_package : '',
  80. 'blogs' => $num_blogs,
  81. 'users' => $user_count,
  82. 'multisite_enabled' => $multisite_enabled,
  83. );
  84. $post_body = array(
  85. 'translations' => json_encode( $translations ),
  86. );
  87. if ( is_array( $extra_stats ) )
  88. $post_body = array_merge( $post_body, $extra_stats );
  89. $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
  90. if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
  91. $url = set_url_scheme( $url, 'https' );
  92. $options = array(
  93. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
  94. 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
  95. 'headers' => array(
  96. 'wp_install' => $wp_install,
  97. 'wp_blog' => home_url( '/' )
  98. ),
  99. 'body' => $post_body,
  100. );
  101. $response = wp_remote_post( $url, $options );
  102. if ( $ssl && is_wp_error( $response ) ) {
  103. trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
  104. $response = wp_remote_post( $http_url, $options );
  105. }
  106. if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
  107. return false;
  108. $body = trim( wp_remote_retrieve_body( $response ) );
  109. $body = json_decode( $body, true );
  110. if ( ! is_array( $body ) || ! isset( $body['offers'] ) )
  111. return false;
  112. $offers = $body['offers'];
  113. foreach ( $offers as &$offer ) {
  114. foreach ( $offer as $offer_key => $value ) {
  115. if ( 'packages' == $offer_key )
  116. $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ),
  117. array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) );
  118. elseif ( 'download' == $offer_key )
  119. $offer['download'] = esc_url( $value );
  120. else
  121. $offer[ $offer_key ] = esc_html( $value );
  122. }
  123. $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale',
  124. 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) );
  125. }
  126. $updates = new stdClass();
  127. $updates->updates = $offers;
  128. $updates->last_checked = time();
  129. $updates->version_checked = $wp_version;
  130. if ( isset( $body['translations'] ) )
  131. $updates->translations = $body['translations'];
  132. set_site_transient( 'update_core', $updates);
  133. }
  134. /**
  135. * Check plugin versions against the latest versions hosted on WordPress.org.
  136. *
  137. * The WordPress version, PHP version, and Locale is sent along with a list of
  138. * all plugins installed. Checks against the WordPress server at
  139. * api.wordpress.org. Will only check if WordPress isn't installing.
  140. *
  141. * @package WordPress
  142. * @since 2.3.0
  143. * @uses $wp_version Used to notify the WordPress version.
  144. *
  145. * @param array $extra_stats Extra statistics to report to the WordPress.org API.
  146. * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
  147. */
  148. function wp_update_plugins( $extra_stats = array() ) {
  149. include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
  150. if ( defined('WP_INSTALLING') )
  151. return false;
  152. // If running blog-side, bail unless we've not checked in the last 12 hours
  153. if ( !function_exists( 'get_plugins' ) )
  154. require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  155. $plugins = get_plugins();
  156. $translations = wp_get_installed_translations( 'plugins' );
  157. $active = get_option( 'active_plugins', array() );
  158. $current = get_site_transient( 'update_plugins' );
  159. if ( ! is_object($current) )
  160. $current = new stdClass;
  161. $new_option = new stdClass;
  162. $new_option->last_checked = time();
  163. // Check for update on a different schedule, depending on the page.
  164. switch ( current_filter() ) {
  165. case 'upgrader_process_complete' :
  166. $timeout = 0;
  167. break;
  168. case 'load-update-core.php' :
  169. $timeout = MINUTE_IN_SECONDS;
  170. break;
  171. case 'load-plugins.php' :
  172. case 'load-update.php' :
  173. $timeout = HOUR_IN_SECONDS;
  174. break;
  175. default :
  176. $timeout = 12 * HOUR_IN_SECONDS;
  177. }
  178. $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
  179. if ( $time_not_changed && ! $extra_stats ) {
  180. $plugin_changed = false;
  181. foreach ( $plugins as $file => $p ) {
  182. $new_option->checked[ $file ] = $p['Version'];
  183. if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
  184. $plugin_changed = true;
  185. }
  186. if ( isset ( $current->response ) && is_array( $current->response ) ) {
  187. foreach ( $current->response as $plugin_file => $update_details ) {
  188. if ( ! isset($plugins[ $plugin_file ]) ) {
  189. $plugin_changed = true;
  190. break;
  191. }
  192. }
  193. }
  194. // Bail if we've checked recently and if nothing has changed
  195. if ( ! $plugin_changed )
  196. return false;
  197. }
  198. // Update last_checked for current to prevent multiple blocking requests if request hangs
  199. $current->last_checked = time();
  200. set_site_transient( 'update_plugins', $current );
  201. $to_send = compact( 'plugins', 'active' );
  202. $locales = array( get_locale() );
  203. /**
  204. * Filter the locales requested for plugin translations.
  205. *
  206. * @since 3.7.0
  207. *
  208. * @param array $locales Plugin locale. Default is current locale of the site.
  209. */
  210. $locales = apply_filters( 'plugins_update_check_locales', $locales );
  211. $options = array(
  212. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
  213. 'body' => array(
  214. 'plugins' => json_encode( $to_send ),
  215. 'translations' => json_encode( $translations ),
  216. 'locale' => json_encode( $locales ),
  217. ),
  218. 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
  219. );
  220. if ( $extra_stats ) {
  221. $options['body']['update_stats'] = json_encode( $extra_stats );
  222. }
  223. $url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
  224. if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
  225. $url = set_url_scheme( $url, 'https' );
  226. $raw_response = wp_remote_post( $url, $options );
  227. if ( $ssl && is_wp_error( $raw_response ) ) {
  228. trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
  229. $raw_response = wp_remote_post( $http_url, $options );
  230. }
  231. if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
  232. return false;
  233. $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
  234. foreach ( $response['plugins'] as &$plugin ) {
  235. $plugin = (object) $plugin;
  236. }
  237. unset( $plugin );
  238. if ( is_array( $response ) ) {
  239. $new_option->response = $response['plugins'];
  240. $new_option->translations = $response['translations'];
  241. } else {
  242. $new_option->response = array();
  243. $new_option->translations = array();
  244. }
  245. set_site_transient( 'update_plugins', $new_option );
  246. }
  247. /**
  248. * Check theme versions against the latest versions hosted on WordPress.org.
  249. *
  250. * A list of all themes installed in sent to WP. Checks against the
  251. * WordPress server at api.wordpress.org. Will only check if WordPress isn't
  252. * installing.
  253. *
  254. * @package WordPress
  255. * @since 2.7.0
  256. * @uses $wp_version Used to notify the WordPress version.
  257. *
  258. * @param array $extra_stats Extra statistics to report to the WordPress.org API.
  259. * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
  260. */
  261. function wp_update_themes( $extra_stats = array() ) {
  262. include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
  263. if ( defined( 'WP_INSTALLING' ) )
  264. return false;
  265. $installed_themes = wp_get_themes();
  266. $translations = wp_get_installed_translations( 'themes' );
  267. $last_update = get_site_transient( 'update_themes' );
  268. if ( ! is_object($last_update) )
  269. $last_update = new stdClass;
  270. $themes = $checked = $request = array();
  271. // Put slug of current theme into request.
  272. $request['active'] = get_option( 'stylesheet' );
  273. foreach ( $installed_themes as $theme ) {
  274. $checked[ $theme->get_stylesheet() ] = $theme->get('Version');
  275. $themes[ $theme->get_stylesheet() ] = array(
  276. 'Name' => $theme->get('Name'),
  277. 'Title' => $theme->get('Name'),
  278. 'Version' => $theme->get('Version'),
  279. 'Author' => $theme->get('Author'),
  280. 'Author URI' => $theme->get('AuthorURI'),
  281. 'Template' => $theme->get_template(),
  282. 'Stylesheet' => $theme->get_stylesheet(),
  283. );
  284. }
  285. // Check for update on a different schedule, depending on the page.
  286. switch ( current_filter() ) {
  287. case 'upgrader_process_complete' :
  288. $timeout = 0;
  289. break;
  290. case 'load-update-core.php' :
  291. $timeout = MINUTE_IN_SECONDS;
  292. break;
  293. case 'load-themes.php' :
  294. case 'load-update.php' :
  295. $timeout = HOUR_IN_SECONDS;
  296. break;
  297. default :
  298. $timeout = 12 * HOUR_IN_SECONDS;
  299. }
  300. $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
  301. if ( $time_not_changed && ! $extra_stats ) {
  302. $theme_changed = false;
  303. foreach ( $checked as $slug => $v ) {
  304. if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
  305. $theme_changed = true;
  306. }
  307. if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) {
  308. foreach ( $last_update->response as $slug => $update_details ) {
  309. if ( ! isset($checked[ $slug ]) ) {
  310. $theme_changed = true;
  311. break;
  312. }
  313. }
  314. }
  315. // Bail if we've checked recently and if nothing has changed
  316. if ( ! $theme_changed )
  317. return false;
  318. }
  319. // Update last_checked for current to prevent multiple blocking requests if request hangs
  320. $last_update->last_checked = time();
  321. set_site_transient( 'update_themes', $last_update );
  322. $request['themes'] = $themes;
  323. $locales = array( get_locale() );
  324. /**
  325. * Filter the locales requested for theme translations.
  326. *
  327. * @since 3.7.0
  328. *
  329. * @param array $locales Theme locale. Default is current locale of the site.
  330. */
  331. $locales = apply_filters( 'themes_update_check_locales', $locales );
  332. $options = array(
  333. 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
  334. 'body' => array(
  335. 'themes' => json_encode( $request ),
  336. 'translations' => json_encode( $translations ),
  337. 'locale' => json_encode( $locales ),
  338. ),
  339. 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
  340. );
  341. if ( $extra_stats ) {
  342. $options['body']['update_stats'] = json_encode( $extra_stats );
  343. }
  344. $url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
  345. if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
  346. $url = set_url_scheme( $url, 'https' );
  347. $raw_response = wp_remote_post( $url, $options );
  348. if ( $ssl && is_wp_error( $raw_response ) ) {
  349. trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
  350. $raw_response = wp_remote_post( $http_url, $options );
  351. }
  352. if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
  353. return false;
  354. $new_update = new stdClass;
  355. $new_update->last_checked = time();
  356. $new_update->checked = $checked;
  357. $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
  358. if ( is_array( $response ) ) {
  359. $new_update->response = $response['themes'];
  360. $new_update->translations = $response['translations'];
  361. }
  362. set_site_transient( 'update_themes', $new_update );
  363. }
  364. /**
  365. * Performs WordPress automatic background updates.
  366. *
  367. * @since 3.7.0
  368. */
  369. function wp_maybe_auto_update() {
  370. include_once ABSPATH . '/wp-admin/includes/admin.php';
  371. include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
  372. $upgrader = new WP_Automatic_Updater;
  373. $upgrader->run();
  374. }
  375. /**
  376. * Retrieves a list of all language updates available.
  377. *
  378. * @since 3.7.0
  379. */
  380. function wp_get_translation_updates() {
  381. $updates = array();
  382. $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' );
  383. foreach ( $transients as $transient => $type ) {
  384. $transient = get_site_transient( $transient );
  385. if ( empty( $transient->translations ) )
  386. continue;
  387. foreach ( $transient->translations as $translation ) {
  388. $updates[] = (object) $translation;
  389. }
  390. }
  391. return $updates;
  392. }
  393. /**
  394. * Collect counts and UI strings for available updates
  395. *
  396. * @since 3.3.0
  397. *
  398. * @return array
  399. */
  400. function wp_get_update_data() {
  401. $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0, 'translations' => 0 );
  402. if ( $plugins = current_user_can( 'update_plugins' ) ) {
  403. $update_plugins = get_site_transient( 'update_plugins' );
  404. if ( ! empty( $update_plugins->response ) )
  405. $counts['plugins'] = count( $update_plugins->response );
  406. }
  407. if ( $themes = current_user_can( 'update_themes' ) ) {
  408. $update_themes = get_site_transient( 'update_themes' );
  409. if ( ! empty( $update_themes->response ) )
  410. $counts['themes'] = count( $update_themes->response );
  411. }
  412. if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) {
  413. $update_wordpress = get_core_updates( array('dismissed' => false) );
  414. if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
  415. $counts['wordpress'] = 1;
  416. }
  417. if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() )
  418. $counts['translations'] = 1;
  419. $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations'];
  420. $titles = array();
  421. if ( $counts['wordpress'] )
  422. $titles['wordpress'] = sprintf( __( '%d WordPress Update'), $counts['wordpress'] );
  423. if ( $counts['plugins'] )
  424. $titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] );
  425. if ( $counts['themes'] )
  426. $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] );
  427. if ( $counts['translations'] )
  428. $titles['translations'] = __( 'Translation Updates' );
  429. $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : '';
  430. $update_data = array( 'counts' => $counts, 'title' => $update_title );
  431. /**
  432. * Filter the returned array of update data for plugins, themes, and WordPress core.
  433. *
  434. * @since 3.5.0
  435. *
  436. * @param array $update_data {
  437. * Fetched update data.
  438. *
  439. * @type array $counts An array of counts for available plugin, theme, and WordPress updates.
  440. * @type string $update_title Titles of available updates.
  441. * }
  442. * @param array $titles An array of update counts and UI strings for available updates.
  443. */
  444. return apply_filters( 'wp_get_update_data', $update_data, $titles );
  445. }
  446. function _maybe_update_core() {
  447. include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
  448. $current = get_site_transient( 'update_core' );
  449. if ( isset( $current->last_checked ) &&
  450. 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) &&
  451. isset( $current->version_checked ) &&
  452. $current->version_checked == $wp_version )
  453. return;
  454. wp_version_check();
  455. }
  456. /**
  457. * Check the last time plugins were run before checking plugin versions.
  458. *
  459. * This might have been backported to WordPress 2.6.1 for performance reasons.
  460. * This is used for the wp-admin to check only so often instead of every page
  461. * load.
  462. *
  463. * @since 2.7.0
  464. * @access private
  465. */
  466. function _maybe_update_plugins() {
  467. $current = get_site_transient( 'update_plugins' );
  468. if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) )
  469. return;
  470. wp_update_plugins();
  471. }
  472. /**
  473. * Check themes versions only after a duration of time.
  474. *
  475. * This is for performance reasons to make sure that on the theme version
  476. * checker is not run on every page load.
  477. *
  478. * @since 2.7.0
  479. * @access private
  480. */
  481. function _maybe_update_themes() {
  482. $current = get_site_transient( 'update_themes' );
  483. if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) )
  484. return;
  485. wp_update_themes();
  486. }
  487. /**
  488. * Schedule core, theme, and plugin update checks.
  489. *
  490. * @since 3.1.0
  491. */
  492. function wp_schedule_update_checks() {
  493. if ( !wp_next_scheduled('wp_version_check') && !defined('WP_INSTALLING') )
  494. wp_schedule_event(time(), 'twicedaily', 'wp_version_check');
  495. if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
  496. wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
  497. if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
  498. wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
  499. if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
  500. // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
  501. $next = strtotime( 'today 7am' );
  502. $now = time();
  503. // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
  504. while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
  505. $next += 12 * HOUR_IN_SECONDS;
  506. }
  507. $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
  508. // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
  509. $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
  510. wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
  511. }
  512. }
  513. if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
  514. return;
  515. add_action( 'admin_init', '_maybe_update_core' );
  516. add_action( 'wp_version_check', 'wp_version_check' );
  517. add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
  518. add_action( 'load-plugins.php', 'wp_update_plugins' );
  519. add_action( 'load-update.php', 'wp_update_plugins' );
  520. add_action( 'load-update-core.php', 'wp_update_plugins' );
  521. add_action( 'admin_init', '_maybe_update_plugins' );
  522. add_action( 'wp_update_plugins', 'wp_update_plugins' );
  523. add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 );
  524. add_action( 'load-themes.php', 'wp_update_themes' );
  525. add_action( 'load-update.php', 'wp_update_themes' );
  526. add_action( 'load-update-core.php', 'wp_update_themes' );
  527. add_action( 'admin_init', '_maybe_update_themes' );
  528. add_action( 'wp_update_themes', 'wp_update_themes' );
  529. add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 );
  530. add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' );
  531. add_action('init', 'wp_schedule_update_checks');