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.26k stars 410 forks source link

Is it possible to disable the "update now" link completely? #417

Open borademircan opened 3 years ago

borademircan commented 3 years ago

We have a plugin sold in a marketplace and we only want to display a message that the plugin needs an update rather than an "update now" link. Is this possible?

Or, are we able to customize the message?

Thanks!

YahnisElsts commented 3 years ago

The simplest way to do that would be to remove the download_url field from the update information. If there is no download URL, WordPress will still show a notification that an update is available, but it won't include the "update now" link. Instead, it will say something like "Automatic update is unavailable for this plugin". The user won't be able to install the update using the admin dashboard.

This update checker doesn't provide a way to customize the update notification; those notifications are part of WordPress core. It doesn't look like WordPress has a convenient hook you could use, either. If you want to change the notification message, you might have to either use the gettext filter to modify the text, or hide the notification entirely and replace it with your own.

borademircan commented 3 years ago

Thank you Yahnis,

Meanwhile, I found a way to append a text to the original update text. Here's how to do it if anyone is interested:

add_action( 'in_plugin_update_message-' . 'your_path/to_main_file.php', 'addUpgradeMessageLink');

function addUpgradeMessageLink () {
    echo sprintf( ' ' . esc_html__( 'Your text with %slink%s here.', 'your_domain' ), '<a href="your_url_here">', '</a>' );
}
YahnisElsts commented 3 years ago

Ah, good find. I had forgotten about that hook.