How do I have my plugin pop up with that New version available. Upgrade Automatically dialog to appear when my plugin has a new version? Specifically for plugins not hosted on the WP.org repository.

  • 2
    Are you asking specifically about plugins that aren't hosted in the WordPress.org repository? If so, you should make that clear in the question.
    – Ian Dunn
    Sep 28 '12 at 0:11

This library integrates auto-updates for privately hosted plugins. Looks great.

  • Ah that works brilliantly, since it is a commercial plugin and it's pretty easy to understand. Thank you.
    – Jared
    Mar 13 '11 at 12:46
  • Link only answers are discouraged. If something happens to that link the answer becomes useless. Please try to make your answer here stand alone.
    – s_ha_dum
    Apr 6 '14 at 14:12

The easiest way I can think of to do this is to have your plugin "phone home" to check a URL on your website that returns the current version of your plugin.

That way, your plugin (installed on another website) can check its version against the "current" version on your website to see if it's the same or newer.

Edit: sample code

I should point out before you implement this: this will add a banner across the top of the screen. If you're just looking to have your plugin show an update available in the menu down the left, I think it automagically does that when you upload the new version to the Wordpress repository. If you do want the banner across the top, proceed.

I would create a template specifically for this page so that the header and footer were not included:


    // Template Name: Bare Template

    while (have_posts()) : the_post();


That way, all that will get printed is the page content, which is good for what we're doing.

Next, set up a page that uses this template, say, "latest-plugin-version". If you view this page in your browser now, all it should say is the text from the page with no extra html.

In your plugin, create a function that prints out your notice. I've used inline styles in the example, you can use classes if you want.

function yourpluginname_check_for_new_version() {

    /* You probably shouldn't check for updates more than once a day, 
    for everyone's bandwidth's sake. */

    $last_check = get_option('yourpluginname_lastcheck');
    if ( $last_check + 86400 > time() ) { return; }

    // If we're still here, check your site for a new version.

    $current_version = get_option('yourpluginname_version');
    $latest_version = file_get_contents('http://www.yourdomain.com/latest-plugin-version/');

    if ( $current_version != $latest_version ) {
        <div style="background: #FFDDDD; color: red; width: 600px; 
                    margin: 20px auto; padding: 10px; text-align: center;
                    border: 2px red solid;">
            There's a new version of MY PLUGIN available! You should upgrade now.

    // Log that we've checked for an update now.
    update_option('yourpluginname_lastcheck', time());


And then, to tie it in so that it runs the function:

add_action('admin_notices', 'yourpluginname_check_for_new_version');

Now, in your installation function, you should add an option for the version number to be saved in the user's Wordpress:

update_option( 'yourpluginname_version', '2.0' );

You can use update_option instead of add_option, as it will add the option if it doesn't already exist.

That should about do it.

  • That makes sense, can you show me an example of how to do this or a link to something similar? Thanks.
    – Jared
    Mar 13 '11 at 10:34
  • Sample code added. Mar 13 '11 at 12:44
  • 2
    Using the WordPress transient and HTTP API would be a much better idea than the above code.
    – Wyck
    Jul 15 '11 at 22:43

There is a free plugin that allows autoupgrade for privately hosted plugins: https://github.com/meglio/wp-upgrademe

  • 1
    Link only answers are discouraged. If something happens to that link the answer becomes useless. Please try to make your answer here stand alone.
    – s_ha_dum
    Apr 6 '14 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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