• I’m working on a new version of a plugin, and would like to use WP 2.8’s new widget API. Without additional measures, this would break backward compatibility. I’m not sure how many people would be affected by this, but this could be a potential support nightmare.

    Does the automatic plugin upgrade feature check the version info in the readme.txt and warn users if the new version of the plugin no longer supports their older WP version? Does it upgrade if users ignore this warning?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Dunno if it checks and warns, but yes it will upgrade if told to do so, even if it breaks something.

    If you want to keep backward compatibility, you need to have code in the plugin check for the functionality you need (via function_exists or class_exists) before you use that functionality.

    Frankly, I wouldn’t bother with it. Backward compatibility maintenance is a nightmare.

    Thread Starter Roy Tanck

    (@roytanck)

    That’s what I’d like to avoid if at all possible. We’re making so many changes that it makes sense to rewrite the widget code using the new API. If we’d test for functions and use older things if needed we’d end up with two plugins, joined at the hip.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Yep, that’s pretty much correct. However, consider just keeping the old plugin in there for the old case.

    Basically, move the old widget into a separate file. Then in the first file do something like this:

    if (!function_exists('something_i_need_for_new_widget')) {
    include 'old-widget.php';
    return; // return from this plugin file, not executing the rest of what follows...
    }
    function new_widget_code() ... blah ...

    Then you can just leave the old widget there in that file and not mess with it anymore. Do all your dev work on the new widget.

    Yeah, I’m pretty fond of using function_exists() to check for the presence of functionality, such as cURL, the HTTP API, the new widget API, etc.

    I remember when I was first trying to figure out a good way to detect the environment around my code and know what’s available to me, I was delighted to discover a simple function that did the trick (at least for me).

    -WC

    Thread Starter Roy Tanck

    (@roytanck)

    Otto, that’s probably the way to go. The current version is pretty stable, and I see no issues with keeping it as a fallback. I’ll be sure to include warning about running older WP versions to the ‘old’ code, the more people upgrade the better.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Does automatic plugin upgrade to incompatible new version?’ is closed to new replies.