PHP code example of wp-forge / wp-update-handler

1. Go to this page and download the library: Download wp-forge/wp-update-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-forge / wp-update-handler example snippets



/**
 * Plugin Name: My Plugin
 */

ter;

$url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint

new PluginUpdater( __FILE__, $url );



/**
 * Plugin Name: My Plugin
 */

ter;

$file = __FILE__; // Can be absolute path to main plugin file, or the plugin basename.
$url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint

$pluginUpdater = new PluginUpdater( $file, $url );

/*
 * Keys are the fields that WordPress is expecting (look at the WP Plugin Info API response).
 * Values are the keys returned by your custom API.
 * 
 * Use dot notation to map nested keys.
 */
$pluginUpdater->setDataMap(
  [
    '


/**
 * Theme Name: My Theme
 */

ater;

$url = 'https://my-update-api.com/theme/theme-name'; // Custom API GET endpoint

new ThemeUpdater( wp_get_theme('my-theme'), $url );



/**
 * Theme Name: My Theme
 */

ater;

$theme = wp_get_theme('my-theme'); // Get the theme's WP_Theme instance.
$url = 'https://my-update-api.com/themes/theme-name'; // Custom API GET endpoint

$themeUpdater = new ThemeUpdater( $file, $url );

/*
 * Keys are the fields that WordPress is expecting (look at the WP Theme Info API response).
 * Values are the keys returned by your custom API.
 * 
 * Use dot notation to map nested keys.
 */
$themeUpdater->setDataMap(
  [
    ';