Here’s what I would suggest – store your theme version in the database, compare it with your package version, if there’s a difference then load in your upgrade/install operations:
define( 'THEME_PREFIX_VERSION', 'X.X' );
/**
* Run upgrade/install.
*/
function theme_prefix_install() {
require_once dirname( __file__ ) . '/install.php';
}
if ( version_compare( get_option( 'theme_prefix_version' ), THEME_PREFIX_VERSION, '<' ) )
add_action( 'init', 'theme_prefix_install' );
Then in install.php
:
if ( ! defined( 'THEME_PREFIX_VERSION' ) )
exit;
$version = get_option( 'theme_prefix_version' );
if ( version_compare( $version, '1.0', '<' ) ) {
// Upgrade code required for version 1.0
}
if ( version_compare( $version, '1.1', '<' ) ) {
// Upgrade code required for version 1.1
}
// And so forth
// All updated, store current package version
update_option( 'theme_prefix_version', THEME_PREFIX_VERSION );