In version 4.1 of /wp-includes/update.php around line 674, there's this line:

add_action('wp_version_check', 'wp_version_check');

I searched through all the wordpress core files for a do_action('wp_version_check') to see where the aforementioned action might get fired. But, I did not find anything. I even added my own action onto the event to see if it gets picked up, but to no avail.

What is the function doing?

  • I haven't looked into it in-depth, but I know WP stores the last time it did a version check in a transient, so it's not going to check again until the transient expires. – Milo Feb 5 '15 at 23:08
  • @Milo: thanks for the reply. Just so I'm clear, the wordpress scheduler will implicitly fire the wp_version_check event? Because there is this bit of code: wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); – awei Feb 5 '15 at 23:11
  • I haven't looked at source to see exactly how it works, so I can't say exactly when (or if, or how!) that action gets fired, sorry. I can do some investigating on it later. – Milo Feb 5 '15 at 23:13
  • @Milo: thx. you got me pointed in the right direction – awei Feb 5 '15 at 23:21

The function checks your version of WP for possible updates. It appears that there is a transient in the database named 'update_core', so it's stored in the $wpdb->options table as '_site_transient_update_core'. The value of that transient is a serialized object that has information, I'm not an expert on wp_version_check, but it uses that transient to keep track of when to next check for a new version. It checks for things like your Wordpress version, php version, mysql version, language, if your MU and if so how many blogs you have, user base and it sends that information to api.wordpress.org. I'm guessing that Wordpress Core Developers use that information to decide on what is important to the community as well ( so to answer your question it seems to do a few things ) WP Updates are important and most people wouldn't check for updates by themselves. It looks like it does all this on the admin side, so it won't lag your front end page loads and it also won't check immediately after a failed check, to prevent hanging your website up if the api.wordpress.org server doesn't respond.

In the future, I know that WP plans on making all updates 'Automagically' so that users with little computer knowledge won't be at a disadvantage because they opted not to go with a WP update. I'm sure that someone else may have more knowledge on the subject. I thought the question was interesting so I opened up my IDE and peeked around a bit.


Thx to previous comments and this answer, I think figured out what's going on.

  1. wp-includes/update.php sets the action with add_action('wp_version_check', 'wp_version_check');
  2. if/when cron fires, wp-includes/cron.php will run wp_cron() which in turn will run spawn_cron() defined in same file.
  3. spawn_cron() does an AJAX call to /wp-cron.php which will call do_action_ref_array() with the wp_version_check event and ultimately fire the wp_version_check() function.
  • 1
    Thx for the response. I actually found what's occurring. I'll accept your answer and edit it with a little more detail. – awei Feb 5 '15 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.