I'm trying to auto update a theme only when it's a minor update. I know I can use the auto_update_{$type} filter where $type = theme. The only examples of using that filter I've seen have been using the callback __return_true and not utilizing the second parameter $item.

add_filter( 'auto_update_theme', '__return_true' );

My problem is that I don't want to auto upgrade on major version changes. I was hoping the second parameter passed to the filter would contain some information on the versions, but I can find nothing in the source code.

1 Answer 1


It is one element of the response Array that's a property of the object stored in the update_plugins or update_themes site transient.

That transient looks like this (var_dump()ed):

object(stdClass)#1 (4) {
  array(1) {
    object(stdClass)#2 (11) {
      string(21) "w.org/plugins/akismet"
      string(7) "akismet"
      string(19) "akismet/akismet.php"
      string(5) "4.0.3"
      string(38) "https://wordpress.org/plugins/akismet/"
      string(56) "https://downloads.wordpress.org/plugin/akismet.4.0.3.zip"
      array(3) {
        string(59) "https://ps.w.org/akismet/assets/icon-128x128.png?rev=969272"
        string(59) "https://ps.w.org/akismet/assets/icon-256x256.png?rev=969272"
        string(59) "https://ps.w.org/akismet/assets/icon-256x256.png?rev=969272"
      array(2) {
        string(61) "https://ps.w.org/akismet/assets/banner-772x250.jpg?rev=479904"
        string(61) "https://ps.w.org/akismet/assets/banner-772x250.jpg?rev=479904"
      array(0) {
      string(5) "4.9.4"
      object(stdClass)#3 (0) {

So the $item for a plugin update will look like the akismet/akismet.php element in the response Array, meaning you can access the version with $item->new_version.

It is however important to note that there's zero guarantee that plugins and themes all use the same version numbering system. For example, in a WordPress version X.Y.Z, Y is a major version and Z is a minor version (and X is just for show, apparently), but in WooCommerce X is a major version and Y is a minor version. Every plugin and theme could be different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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