PHP code example of wpboilerplate / wpb-updater-checker-github

1. Go to this page and download the library: Download wpboilerplate/wpb-updater-checker-github 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/ */

    

wpboilerplate / wpb-updater-checker-github example snippets




/**
 * Plugin Name: My Plugin
 * Version:     1.2.0
 */



new WPBoilerplate_Updater_Checker_Github( [
    'repo'           => 'https://github.com/YourOrg/your-plugin',
    'file_path'      => __FILE__,
    'name_slug'      => 'your-plugin',
    'release_branch' => 'main',
] );

new WPBoilerplate_Updater_Checker_Github( [
    'repo'           => 'https://github.com/YourOrg/your-private-plugin',
    'file_path'      => __FILE__,
    'name_slug'      => 'your-private-plugin',
    'release_branch' => 'main',
    'token'          => 'ghp_xxxxxxxxxxxxxxxxxxxx', // GitHub PAT
] );

// wp-config.php
define( 'MY_PLUGIN_GITHUB_TOKEN', 'ghp_xxxxxxxxxxxxxxxxxxxx' );

// plugin file
new WPBoilerplate_Updater_Checker_Github( [
    'repo'      => 'https://github.com/YourOrg/your-private-plugin',
    'file_path' => __FILE__,
    'name_slug' => 'your-private-plugin',
    'token'     => defined( 'MY_PLUGIN_GITHUB_TOKEN' ) ? MY_PLUGIN_GITHUB_TOKEN : '',
] );

new WPBoilerplate_Updater_Checker_Github( [
    'repo'           => 'https://github.com/YourOrg/your-plugin',
    'file_path'      => __FILE__,
    'name_slug'      => 'your-plugin',
    'release_branch' => 'main',
    'release-assets' => true,
] );

// Instantiate once (empty constructor is fine) to register the admin_init hook.
new WPBoilerplate_Updater_Checker_Github();

add_filter( 'wpboilerplate_updater_checker_github', function ( $packages ) {
    $packages[] = [
        'repo'           => 'https://github.com/YourOrg/plugin-one',
        'file_path'      => WP_PLUGIN_DIR . '/plugin-one/plugin-one.php',
        'name_slug'      => 'plugin-one',
        'release_branch' => 'main',
    ];
    $packages[] = [
        'repo'           => 'https://github.com/YourOrg/plugin-two',
        'file_path'      => WP_PLUGIN_DIR . '/plugin-two/plugin-two.php',
        'name_slug'      => 'plugin-two',
        'release_branch' => 'stable',
        'token'          => defined( 'PLUGIN_TWO_TOKEN' ) ? PLUGIN_TWO_TOKEN : '',
    ];
    return $packages;
} );