PHP code example of wplatest / updater

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

    

wplatest / updater example snippets





/**
 * Plugin Name: My Plugin
 * Version:     1.0.0
 * Update URI:  https://www.automagicwp.com
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

 => 'plugin_abc123',   // Plugin ID from the AutomagicWP dashboard
        'secret' => 'your-api-key',    // Optional: 

$updater = new PluginUpdater( array(
    'file'   => __FILE__,
    'id'     => 'plugin_abc123',
    'secret' => get_option( 'my_plugin_license_key' ),
) );

$config = $updater->get_config();

if ( $config ) {
    $client_name   = $config->clientName            ?? 'My Plugin';
    $primary_color = $config->primaryColor          ?? '#2563eb';
    $fg_color      = $config->primaryForegroundColor ?? '#ffffff';

    // Access free-form metadata
    $logo_url      = $config->metadata->logo_url      ?? '';
    $support_email = $config->metadata->support_email ?? '';
    $report_from   = $config->metadata->report_from   ?? '';
    $report_footer = $config->metadata->report_footer ?? '';

    // Feature flags stored in metadata
    $features      = (array) ( $config->metadata->features ?? array() );
    $multi_country = $features['multi_country'] ?? false;
}

$config = $updater->get_config( force: true );

add_action( 'admin_init', function () {
    register_setting( 'my_plugin_settings', 'my_plugin_license_key' );

    add_settings_field(
        'license_key',
        'License Key',
        function () {
            $key = get_option( 'my_plugin_license_key', '' );
            echo '<input type="password" name="my_plugin_license_key"
                         value="' . esc_attr( $key ) . '" class="regular-text">';
        },
        'my-plugin',
        'my_plugin_license_section'
    );
} );