I am writing a Wordpress plugin for setting automatic updates for individual plugins. I am unable to verify that the 'auto_update_plugin' filter is working. Anything I put into the callback function returns nothing. As if the function is never called.

The filter:

add_filter( 'auto_update_plugin', array( $this, 'l7wau_auto_update_specific_plugins' ), 10, 2 );

The callback function:

     * Update specific plugins. Got this from Wordpress codex.
    function l7wau_auto_update_specific_plugins( $update, $item ) {

        // Array for adding the path to file. Use for 3.8.1 and below.
        $new_plugin_array = array();
        $this->plugin_slug = 'changed'; //Test to see if it is working. Nothing here.

         * Get the array of names/slugs to set to auto-update
         * Added the folder/file.php because the actual slug is not 
         * the file name.  It is the plugin folder and file with header use for 3.8.1 and below.
        $plugins = $this->l7wau_get_array_plugins_to_update();

        if ( in_array( $item->slug, $plugins ) ) {
            return true; // Always update plugins in this array
        } else {
            return $update; // Else, use the normal API response to decide whether to update or not

It turns out that the above does work. It just takes 12 hours for the automatic update cycle to happen. On thing I did change was the importance number for 10 to 20.

add_filter( 'auto_update_plugin', array( $this, 'l7wau_auto_update_specific_plugins' ), 20, 2 );

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.