Advertisement
Guest User

New Action Hook Line 257

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