YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.27k stars 411 forks source link

installed plugin on view details showing "install Now" instead "latest Version installed" #552

Open Thiararapeter opened 10 months ago

Thiararapeter commented 10 months ago

Hello, There is an issue with installed plugin. when i click open view detail and te plugin is installed, be button should be "latest verson installed" but am getting "install now button" mostly works but after plugin updates, yes the plugin is installed but on view details plugin have "install now" attached will demonstrate what am trying to say.

image image

Thiararapeter commented 10 months ago

also when plugin not activated but installed shows " image

YahnisElsts commented 10 months ago

Are you saying that the "View details" link shows up even when your plugin is inactive? That would be unusual since the update checker obviously cannot add the "View details" link when it's not running. Is there something else that's adding the link?

krassomatiker commented 1 month ago

Hello, same here. When i click open view detail and the plugin is installed, the button should be "Activ" not "Install now". plugin

YahnisElsts commented 1 month ago

After some research, it looks like this happens when the plugin slug is different from the name of the plugin directory. As a test, I took a plugin hosted on worpdress.org - a plugin that doesn't use PUC - and renamed its directory from slug to foo-slug. The button text also changed from "Active" to "Install Now".

The WP core function that detects the plugin state is install_plugin_install_status() in /wp-admin/includes/plugin-install.php. It doesn't look like there's a way to filter its input or output. Theoretically, PUC could change the slug in the update API response before it gets to install_plugin_install_status(), but I suspect that might break something else. The slug is used in a bunch of other places and it would take a while to find all of them and carefully verify that using the directory name instead would be safe.

Since the same problem can happen with plugins not using PUC, perhaps it's not something to be fixed on this end? In most cases, if you pick a slug that matches the directory name, and the user doesn't rename the plugin for some reason, it should be fine.

krassomatiker commented 4 weeks ago

My mistake, you are right. It was the wrong slug. Thank you for the fast help and the great plugin!