Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've researched this a few times, yet my searching does not reveal much except custom code which may or may not be good wordpress practice.

As of the latest releases, has a hook been added to the plugin update process? I'm asking because its a very basic need, yet I do not see it added to the codex (yet).

If not, what is the common and best practice developers employ?

EDIT: Just to clarify, I'm not talking about activation - but about updating - that way if there are changes in database or otherwise it can be addressed.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I don't think an action has been added. You can look at version details for any version and see any new actions added.

The WordPress Way to run code on plugin update is what is described here:

The proper way to handle an upgrade path is to only run an upgrade procedure when you need to. Ideally, you would store a “version” in your plugin’s database option, and then a version in the code. If they do not match, you would fire your upgrade procedure, and then set the database option to equal the version in the code. This is how many plugins handle upgrades, and this is how core works as well.

and with code example here:

function myplugin_update_db_check() {
    global $jal_db_version;
    if (get_site_option( 'jal_db_version' ) != $jal_db_version) {
        jal_install();
    }
}
add_action( 'plugins_loaded', 'myplugin_update_db_check' );
share|improve this answer
    
Thank you - I'll simply use that method then. WP really has to add an action for this :D –  user1915665 May 20 at 2:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.