Save Plugin Version Number as Option?

You need to save the version to the database– aka. save it “as an option”– so that your script has a comparison case. That is, your script should…

  1. Check the database for a version number
  2. Compare that version number to the new version number– a variable or constant in your plugin file.
  3. Update things if need be
  4. Save the new version number to the database

If all you have is a constant in your .php file. It always matches, meaning it is pretty much useless for any automated updating. Of course, you can keep track of the plugin versions with just the constant, but the point of saving it to the database is to be able to automatically update things when needed.

As you say, if the plugin is simple enough it may not be necessary.

Leave a Comment