radishconcepts / WordPress-GitHub-Plugin-Updater

This class is meant to be used with your Github hosted WordPress plugins. The purpose of the class is to allow your WordPress plugin to be updated whenever you push out a new version of your plugin; similarly to the experience users know and love with the WordPress.org plugin repository.
https://github.com/jkudish/WordPress-GitHub-Plugin-Updater
826 stars 193 forks source link

ManageWP API integration #12

Closed sc0ttkclark closed 11 years ago

sc0ttkclark commented 12 years ago

Any thoughts on integrating the ManageWP API so that the GitHub updater can notify ManageWP through it's hooks that there's a new version for the plugin and where to get it?

http://managewp.com/api

// mwp_premium_update_notification filter (REQUIRED)
//
// Hook to this filter to provide the new version of your plugin if available
//
// input: $premium_updates array
// output: modified array, containing the current version number of your plugin
//
// 

add_filter('mwp_premium_update_notification', 'myplugin_mwp_update_notification');

if( !function_exists('myplugin_mwp_update_notification') ) {
    function myplugin_mwp_update_notification( $premium_updates ){

        if( !function_exists( 'get_plugin_data' ) )
            include_once( ABSPATH.'wp-admin/includes/plugin.php');

        $myplugin['type'] = 'plugin';

        // EDIT HERE
        $myplugin = get_plugin_data( __FILE__ );   // or path to your main plugin file, we expect it to have standard header with plugin info               
        $myplugin['new_version'] = '1.4';  // edit your plugin's new version (extract this from your own options, etc..)

        array_push($premium_updates, $myplugin);
        return $premium_updates;
    }
}

// mwp_premium_perform_update filter (REQUIRED)
//
// Hook to this filter to instruct ManageWP How to upgrade your plugin
//

add_filter('mwp_premium_perform_update', 'myplugin_mwp_perform_update');

if( !function_exists('myplugin_mwp_perform_update') ) {
    function myplugin_mwp_perform_update( $premium_updates ){

        if( !function_exists( 'get_plugin_data' ) )
            include_once( ABSPATH.'wp-admin/includes/plugin.php');

        $my_addon['type'] = 'plugin';

        // EDIT HERE
        $my_addon = get_plugin_data(  __FILE__ );   // or path to your main plugin file, we expect it to have standard header with plugin info      

        $my_addon['url'] = 'http://mysite.com/file.zip';    // Provide URL to the archive file with the new version of your plugin (easiest)
        $my_addon['callback'] = 'my_update_callback';       // *OR* Provide your own callback function that will perform the update when called (we will simply call when the user select to upgrade)
        $my_addon['slug'] = 'plugindir/pluginfile.php';     // *OR* Provide the plugin slug if you hook on to WordPress upgrade transients for your plugin upgrade

        array_push($premium_updates, $my_addon);

        return $premium_updates;
    }
}

// mwp_premium_update_check filter (OPTIONAL)
//
// Hook to this filter if you want ManageWP to be able to force check for updates
//
// We call this when the user clicks "Refresh" in their ManageWP Dashboard

add_filter('mwp_premium_update_check', 'myplugin_mwp_update_check');

if( !function_exists('myplugin_mwp_update_check') ) {
    function myplugin_mwp_update_check( $update ){

        if( !function_exists( 'get_plugin_data' ) )
            include_once( ABSPATH.'wp-admin/includes/plugin.php');

        // EDIT HERE
        $my_addon = get_plugin_data(  __FILE__ );   // or path to your main plugin file, we expect it to have standard header with plugin info  
        $my_addon['callback'] = 'my_update_callback'; // Provide the callback function which will force an update check for your plugin

        array_push($update, $my_addon);

        return $update;
    }
}

/**********************************************

        Integration for Premium THEMES 

*********************************************/

// mwp_premium_update_notification filter (REQUIRED)
//
// Hook to this filter to provide the new version of your plugin if available
//
// input: $premium_updates array
// output: modified array, containing the current version number of your plugin
//
/

add_filter('mwp_premium_update_notification',  'mytheme_mwp_update_notification' );

if(!function_exists('mytheme_mwp_update_notification')) {
    function mytheme_mwp_update_notification( $premium_update ){

        if( !function_exists( 'get_theme_data' ) )
            include_once( ABSPATH.'wp-admin/includes/theme.php');

        $mytheme['type'] = 'theme'; 

        // EDIT HERE
        $mytheme = get_theme_data( dirname( __FILE__ ).'/style.css' ); // or path to your main css file, we expect it to have standard header with theme info
        $mytheme['new_version'] = '1.6'; // your theme's new version

        array_push($premium_update, $mytheme);
        return $premium_update;
    }
}

// mwp_premium_perform_update filter (REQUIRED)
//
// Hook to this filter to instruct ManageWP How to upgrade your theme
//

add_filter('mwp_premium_perform_update', 'mytheme_mwp_perform_update');

if( !function_exists('mytheme_mwp_perform_update') ) {
    function mytheme_mwp_perform_update( $update ){

        if( !function_exists( 'get_theme_data' ) )
            include_once( ABSPATH.'wp-admin/includes/theme.php');

        $my_addon['type'] = 'theme';

        // EDIT HERE
        $my_addon = get_theme_data( dirname( __FILE__ ).'/style.css' ); // or path to your main css file, we expect it to have standard header with theme info

        $my_addon['url'] = 'http://mysite.com/file.zip';    // Provide URL to the archive file with the new version of your theme (easiest)
        $my_addon['callback'] = 'my_update_callback';       // *OR* Provide your own callback function that will perform the update when called (we will simply call when the user select to upgrade)
        $my_addon['slug'] = 'twentyeleven';                             // *OR* Provide the plugin slug if you hook on to WordPress upgrade transients for your plugin upgrade

        array_push($update, $my_addon);

        return $update;
    }
}

// mwp_premium_update_check filter (OPTIONAL)
//
// Hook to this filter if you want ManageWP to be able to force check for updates
//
// We call this when the user clicks "Refresh" in their ManageWP Dashboard

add_filter('mwp_premium_update_check', 'mytheme_mwp_update_check');

if( !function_exists('mytheme_mwp_update_check') ) {
    function mytheme_mwp_update_check( $update ){

        if( !function_exists( 'get_theme_data' ) )
            include_once( ABSPATH.'wp-admin/includes/theme.php');

        // EDIT HERE
        $my_addon = get_theme_data( dirname( __FILE__ ).'/style.css' ); // or path to your main css file, we expect it to have standard header with theme info
        $my_addon['callback'] = 'my_update_callback';  // provide your callback function which will refresh transient or check for your internal update system when called

        array_push($update, $my_addon);

        return $update;
    }
}
sc0ttkclark commented 12 years ago

I'm fairly certain any hooks for ManageWP would first have to check:

if ( is_plugin_active( 'worker/init.php' ) ) {
// do whatever
}

Plugin in reference is here: http://wordpress.org/extend/plugins/worker/

jkudish commented 12 years ago

Cool, never thought of that integration. If you can get it working, I'll happily merge it in. Otherwise, something I can look at in a few weeks, but not on my immediate radar :)

sc0ttkclark commented 12 years ago

Sounds good to me, I'll have a go at this and post a pull request when it's ready.

jkudish commented 12 years ago

any progress on this @sc0ttkclark? just curious :)

sc0ttkclark commented 11 years ago

Hey long time no follow up (on my part), no progress on this. I haven't been using ManageWP a whole lot lately so it hadn't been a major thing for me right now. (mostly working locally)

jkudish commented 11 years ago

Marking this as resolved; I just don't see it happening right now or being a priority.

doriansavage commented 7 years ago

hello. still not a priotity ? :)