There may be multiple ways to do that, I believe the easiest way to do it is to create an entry in the options table that stores the current version and compare it against the version number of the plugin stored in a constant. Here is how it works (suppose that “version” is the name of the entry in the options table):
- User installs plugin for the first time,
- Plugin checks if “version” is in the options table,
- If “version” is not set, display information,
- Update the value of “version” with new number,
- (Some days pass)
- Developer releases a new version of the plugin,
- User downloads and install the new version of the plugin,
- Plugin extracts “version” from the options table,
- If “version” is different than number in PHP file…
- (Repeat from step 4)
You can use “update_option” to set and update the version number in the options table, and create a constant in the main PHP file that powers the plugin that contains the version number of the latest update. This code illustrates what I just explained:
<?php
define('PLUGIN_VERSION', '1.0.1');
$display_info = false;
$tracker = 'plugin_version';
$local_version = get_option($tracker);
if ($local_version !== PLUGIN_VERSION) {
$display_info = true;
update_option($tracker, PLUGIN_VERSION);
}
if ( $display_info === true ) {
/* Display info about the installation or update. */
}
?>