Updates for a private plugin?

Since WordPress v5.8, it is a lot simpler to create yourself a basic version of custom plugin update functionality.

Step 1

Create JSON file on your server. It will contain info about latest version number of your plugin(s) and link to ZIP file(s) for WordPress to automatically download it when update is triggered.

Example location: https://my-domain.com/custom-plugins/plugins-info.json

Example content:

{
    "my-plugin/my-plugin.php":{
        "version":"1.1",
        "package":"https://my-domain.com/custom-plugins/my-plugin.zip"
    }
}

You can add multiple plugins info to that JSON. Just ensure that plugin key for each is in directory_name/file_name.php format.

Of course, only when plugin version in JSON is larger than version you have installed, WordPress will show you that new version is available.

For full list of plugin(s) data you can set in JSON file, check $update parameter here

Step 2

Add “Update URI” to plugin’s main file (comment section). It should link to your custom JSON file you created in step 1.

<?php
/**
 * Plugin Name: My plugin
 * Version:     1.0
 * Update URI:  https://my-domain.com/custom-plugins/plugins-info.json
 * 
 */

Step 3

Add this code to custom plugin’s main file (or to functions.php)

IMPORTANT: Change “my-domain.com” inside add_filter function to actual domain you are using for JSON file.

if( ! function_exists( 'my_plugin_check_for_updates' ) ){
    
    function my_plugin_check_for_updates( $update, $plugin_data, $plugin_file ){
        
        static $response = false;
        
        if( empty( $plugin_data['UpdateURI'] ) || ! empty( $update ) )
            return $update;
        
        if( $response === false )
            $response = wp_remote_get( $plugin_data['UpdateURI'] );
        
        if( empty( $response['body'] ) )
            return $update;
        
        $custom_plugins_data = json_decode( $response['body'], true );
        
        if( ! empty( $custom_plugins_data[ $plugin_file ] ) )
            return $custom_plugins_data[ $plugin_file ];
        else
            return $update;
        
    }
    
    add_filter('update_plugins_my-domain.com', 'my_plugin_check_for_updates', 10, 3);
    
}

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş