PHP code example of shazzad / plugin-updater

1. Go to this page and download the library: Download shazzad/plugin-updater 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/ */

    

shazzad / plugin-updater example snippets



// Initialize the updater (autoloaded via Composer)
new \Shazzad\PluginUpdater\Integration(
    'https://your-api-server.com/api',  // API URL
    plugin_basename( __FILE__ ),        // Plugin file path
    'your-product-id',                  // Product ID
    true,                              // Enable licensing
    true,                              // Display admin menu
    'My Plugin License',               // Menu label
    'plugins.php',                     // Parent menu
    10                                 // Menu priority
);

new \Shazzad\PluginUpdater\Integration(
    'https://api.example.com',
    plugin_basename( __FILE__ ),
    'my-plugin-id'
);

( new \Shazzad\PluginUpdater\Integration(
    'https://api.example.com',
    plugin_basename( __FILE__ ),
    'my-plugin-id',
    true,                           // Enable licensing
    true,                           // Show admin menu
    'My Plugin Updates',            // Menu label
    'tools.php',                    // Under Tools menu
    20                              // Menu priority
) )->setMeta( [
    'php_version' => function () { return phpversion(); },
    'theme'       => function () { return get_stylesheet(); },
] );

( new \Shazzad\PluginUpdater\Integration(
    'https://api.example.com',
    plugin_basename( __FILE__ ),
    'my-plugin-id'
) )->setMeta( [
    'php_version'          => function () { return phpversion(); },
    'theme'                => function () { return get_stylesheet(); },
    'memory_limit'         => ini_get( 'memory_limit' ),
    'active_plugins_count' => function () {
        return count( get_option( 'active_plugins' ) );
    },
] );

// Under Tools menu
'menu_parent' => 'tools.php'

// Under Settings menu
'menu_parent' => 'options-general.php'

// Top-level menu
'menu_parent' => null

/src/
├── Integration.php    # Core state, license helpers, and subsystem wiring
├── Client.php        # API client with typed methods (ping, check_license, updates, details)
├── Updater.php       # Update checks and WordPress integration
├── Admin.php         # WordPress admin interface
└── Tracker.php       # Plugin tracking and license sync