Do I still need to include the update scripts in version 1.2 so people can update the plugin from v1.1 directly to v1.3?
Yes.
Is there a way for WordPress to automatically download v1.2, run the update scripts, and then download v1.3...
No.
...is there a way to flag v1.3 of my plugin and say, "you need v1.2 or higher of this plugin for this update to work"?
Typically, a plugin author will store the version of their plugin in the options table. Then, either on init
or admin_init
, compare it to the currently running version (and subsequently run any appropriate updates if required, and update the version in the options table).
function wpse_144165_admin_init() {
// If your plugin will fail on the front-end if not upgraded (typically due to
// a drastic change in code), you'll need to perform this operation on "init".
wpse_144165_upgrade();
}
add_action( 'admin_init', 'wpse_144165_admin_init' );
function wpse_144165_upgrade() {
if ( $version = get_option( 'my_version' ) ) {
if ( version_compare( $version, MY_CURRENT_VERSION ) === -1 ) {
// Perform upgrade(s), typically in another function/class that you extend
// over versions to support updates from 1.0 upwards.
update_option( 'my_version', MY_CURRENT_VERSION );
}
}
}
function wpse_144165_activation() {
// Do pre-upgrade stuff.
wpse_144165_upgrade();
// Do post-upgrade stuff.
}
register_activation_hook( __file__, 'wpse_144165_activation' );
This technique of version checking accomodates for users who still upgrade via good old FTP, since WordPress will never fire any re-activation hooks.