When I click on "Update now" the plugin gets installed, but I'm getting the following error:
The plugin "test/test.php" has been deactivated due to an error: Plugin file does not exist.
Also, I can see on the file structure the plugin has been installed using a random suffix (test-wmAX6O) instead of just using test for the folder name.
I'm returning the following on check_for_plugin_update:
$plugin_info = array( 'slug' => 'test', 'id' => 'test/test.php', 'plugin' => 'test/test.php', 'new_version' => $remote_version->version, 'url' => $remote_version->info_url, 'package' => $remote_version->download_url, 'requires_php' => '', 'compatibility' => new stdClass(), ); $checked_data->response['test/test.php'] = (object) $plugin_info; return $checked_data; Which gets called in the main file test/test.php in the constructor:
public function __construct() { .... $this->force_plugin_update_check(); add_action( 'pre_set_site_transient_update_plugins', array($this, 'check_for_plugin_update') ); } function force_plugin_update_check(){ delete_site_transient('update_plugins'); wp_update_plugins(); // Force a fresh update check } The plugin's main file test/test.php also contains the following header comments:
<?php /** * Plugin Name: Test * Plugin URI: https://test.io * Description: A brief description of the plugin. * Text Domain: test * Version: 1.1.1 * Author: XXXX * Author URI: https://test.io * License: GPL2 * @package test **/ Am I missing something?
It looks like there's a problem with the "slug" but I can't see why.
I can't find any good documentation on pre_set_site_transient_update_plugins anywhere on WordPress, so I'm a bit lost here.
Update URI:field for the plugin header and theupdate_plugins_{$hostname}filters. Ignoring that, wouldn't the transient be set when the plugin updates are checked, so your filter would be added after rather than before? Order matters!update_plugins_or theUpdate URII've read the article multiple times but I still don't understand how that helps with the updates. Any place where I can see a code example?pre_set_site_transient_update_pluginsforsite_transient_update_pluginsbut still not working. Same problem.