PHP code example of bmd / github-wp-updater

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

    

bmd / github-wp-updater example snippets




use Bmd\GithubWpUpdater;


    __FILE__,
    [
        'github.user' => 'your-github-user-or-org',
        'github.repo' => 'your-plugin-repository',
        'github.branch' => 'main',
    ]
);

$updater->mount();


/**
 * Plugin Name: Example Plugin
 * Plugin URI:  https://github.com/acme/example-plugin
 * Version:     1.2.3
 * Requires at least: 6.5
 * Requires PHP: 8.2
 * Tested up to: 6.6
 */

use Bmd\GithubWpUpdater;

ashit( plugin_dir_url( __FILE__ ) ) . 'assets/banner-772x250.jpg',
            'high' => trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/banner-1544x500.jpg',
        ],
        'plugin.icons' => [
            'default' => trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/icon-256x256.jpg',
        ],
    ]
) )->mount();



use Bmd\GithubWpUpdater;

IR . '/example-plugin/example-plugin.php';

( new GithubWpUpdater(
    $plugin_root_file,
    [
        'github.user' => 'acme',
        'github.repo' => 'example-plugin',
        'github.branch' => 'main',
    ]
) )->mount();

'plugin.banners' => [
    'low' => 'https://example.com/path/to/banner-772x250.jpg',
    'high' => 'https://example.com/path/to/banner-1544x500.jpg',
]

'plugin.icons' => [
    'default' => 'https://example.com/path/to/icon-256x256.jpg',
]

add_filter( 'example_plugin_config', function ( $config ) {
    $config['plugin.icons']['default'] = 'https://cdn.example.com/icon-256x256.jpg';
    $config['plugin.banners']['high'] = 'https://cdn.example.com/banner-1544x500.jpg';

    return $config;
}, 20 );

add_filter( 'example_plugin_update_response', function ( $response ) {
    $response['tested'] = '6.6';
    return $response;
} );

add_filter( 'example_plugin_default_plugin_headers', function ( $headers ) {
    $headers['version'] = '1.2.3';
    return $headers;
} );



use Bmd\GithubWpUpdater;
use Bmd\GithubWpUpdater\Services\RemoteRequest;

$updater = new GithubWpUpdater( __FILE__, $config );
$updater->mount();

$service = $updater->getInstance( RemoteRequest::class );



use Bmd\GithubWpUpdater;

LE__,
    [
        'github.user' => 'your-org',
        'github.repo' => 'your-plugin-repo',
        'github.branch' => 'main',
    ]
) )->mount();