Issues with auto_update_theme filter
-
I am trying to leverage the
auto_update_theme
filter for keeping twentyfifteen up to date automatically: I cannot simply have the filter __return_true because I do not necessarily want any other themes to be updated.In trying to modify the plugin example from the codex, this is what I currently have for code:
public function include_with_auto_update_themes ( $update, $item ) { $themesToUpdate[] = 'twentyfifteen'; $themeName = $item->slug; if ( in_array( trim( $themeName ), $themesToUpdate ) ) { return true; // return true to allow update to go ahead } else { return $update; } } add_filter('auto_update_theme', array(&$this, 'include_with_auto_update_themes'), 10, 2);
When this executes, I end up with a PHP error telling me that “slug” is undefined
[21-Jul-2015 19:24:19 UTC] PHP Notice: Undefined property: stdClass::$slug in /srv/www/wordpress-default/wp-content/plugins/updatetheme/updatetheme.php on line 541
I’ve also tried $item->textdomain, thinking perhaps $item was a WP_Theme object, but I got the same “undefined property” error.
I’ve tried to trace the $item variable back through core, but all I keep seeing are references to the “update offering” and I haven’t been able to determine what exactly this thing IS. Since it is being used inside the filter function, I’ve also had little luck trying to debug the variable since calling var_dump() or trying to throw debugging info to the console does not trigger on the active window due to (I assume) where this code executes deep inside WP.
I thought this was going to be fairly straightforward, but I’m at a bit of a loss now. Any help is appreciated, thanks!
- The topic ‘Issues with auto_update_theme filter’ is closed to new replies.