+ Reply to Thread
Results 1 to 9 of 9

Thread: Using a non-official plugin repository

  1. #1
    Ryan's Avatar
    Ryan is online now WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,418

    Default Using a non-official plugin repository

    Do any of you have any tips or links to tutorials on how to use a different plugin repository for your WordPress plugin or theme?

    I have a few plugins which I don't want in the official repository (they're essentially useless to everyone but the two or three current users), but would also like to be able to have them use the automatic update feature. Unfortunately I haven't had much luck finding instructions on how to do it.

    I can't think of any other than Gravity Forms and Shopp which do it already, and I have no use for either of them so aren't interested in purchasing them just so that I can take a look under the hood. So if you know of any other plugins which do this I'd be keen to hear about them as I can probably just work it out from there.

    Any help greatly appreciated :)


    I'm currently emailing the users of the plugins with a new zip file, but that seems like a redundant and stupid way for me to be going about doing it so an improved system would be a lot better :)

  2. #2
    Elpie's Avatar
    Elpie is offline Here For The Peanuts
    Join Date
    Nov 2009
    Location
    New Zealand
    Posts
    108

    Default

    Check out Kaspar's post here: http://konstruktors.com/blog/wordpre...by-developers/

    This works for themes too.

  3. #3
    Ryan's Avatar
    Ryan is online now WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,418

    Default

    Wow, that seems awesomely simple :) I was expecting some sort of convoluted system involving a subversion repository and a bazillion lines of code just to make it work. But that looks like it just requires a zip file, a few lines of code in the plugin or theme and a small script running on your server to make it tick.

    Thanks a bunch :)

  4. #4
    Elpie's Avatar
    Elpie is offline Here For The Peanuts
    Join Date
    Nov 2009
    Location
    New Zealand
    Posts
    108

    Default

    Don't thank me, thank Kaspar

    I found his post when googling for api info. Getting the plugin update worked out was fairly straight-forward because its in the WP code. I got stuck on the server end and his post got me on the right path.

    @velofile on Twitter also has a script for updating the core which is really useful. She'll point you to it if you ask nicely
    Her script enables several blogs to be upgraded all at once, from her servers without clients needing to do anything. Very useful if you are managing sites for others.

  5. #5
    andrea_r's Avatar
    andrea_r is offline WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,279

    Default

    Oh, this is awesome. I was wondering the same.

  6. #6
    Ryan's Avatar
    Ryan is online now WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,418

    Default

    Jeeze, I've been swearing at this thing all evening. Except I just had a lightbulb moment and realised that I can't do http requests from localhost to localhost :p Hopefully have better luck tomorrow when I stick the repository out on the web somewhere :)

    I'm also wondering if whether changing the $plugin_base location could potentially give me the ability to have someone upgrade from a plugin in one folder, to a plugin in another folder, ie: get them to upgrade from an older plugin I wrote, to a newer one. I was going to do this by leaving an annoying notice in the admin panel asking them to upgrade, but I can just switch it automatically, that would be awesome! In fact ... I wonder if I can make the auto-upgrader do that with a .org hosted plugin? I'll hopefully find out tomorrow once I've done some more testing.

  7. #7
    Otto's Avatar
    Otto is offline Trac Master
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    770

    Default

    It's not really that difficult to make your own plugins check your own repository and update from your own servers and such. You don't really need anything complicated, it could be as simple as pulling a static file for a version number and the ZIP package information.

    The main gist of what you have to do is this:

    PHP Code:
    $up get_transient('update_plugins');

    $data = new stdClass;
    $data->slug 'plugin';
    $data->new_version '0.2';
    $data->url 'http://example.com/whatever';
    $data->package 'http://example.com/whatever/plugin-0.2.zip';
    $up->response['plugin/plugin.php'] = $data;

    set_transient('update_plugins'$up); 
    Whatever magical trickery you use to accomplish that will probably work fine. The easiest way would be simply to retrieve a text file (using wp_remote_get), compare the version numbers, and update the settings if the version numbers increased. That'd have the lowest server impact too.

    Now, in the example given earlier, he uses a filter on the transient_update_plugins, which is certainly one way to do it. This would not be my favorite way, mind you, because the get_transient for that happens too often, you're wasting resources.

    A better way would be to create your function and hook it to the existing wp_update_plugins action hook. Your function would do basically the same thing, except that you'd get and set the transient yourself. Using this action hook means you run at the same time the normal plugin updater does, without extraneous checks.

  8. #8
    iamfriendly is offline Hello World
    Join Date
    Mar 2010
    Location
    Manchester, UK
    Posts
    6

    Default

    Hello all!

    I've been using Kaspar's technique for a little while and been testing it with a new plugin I'm creating and it's been working flawlessly.

    However, I have a test set up which I have running on the nightly builds and as of 3.0, this method doesn't seem to work any more.

    By 'not work' I mean that WordPress isn't reporting that there is an update available in the plugins page. However, the basics of the technique do still work as it's reporting the new version number, it just doesn't seem that WP 3.0 isn't picking this up as an available update.

    Is this something Automattic are going to clamp down on, so that authors can't utilise their own repositories? Or is it just a possible beta-bug? Or perhaps a new method is needed for 3.0?

    Any thoughts and updates very much welcome :)

    Oh, P.S. - this is my first post, so hello one and all :)

  9. #9
    andrea_r's Avatar
    andrea_r is offline WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,279

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts