承接 wpboilerplate/wpb-updater-checker-github 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wpboilerplate/wpb-updater-checker-github

Composer 安装命令:

composer require wpboilerplate/wpb-updater-checker-github

包简介

Composer to autoload the Updater via Github

README 文档

README

A Composer library that gives any GitHub-hosted WordPress plugin automatic update notifications inside the WordPress admin, using the Plugin Update Checker library.

Requirements

  • PHP 7.4+
  • WordPress 5.0+
  • Composer
  • A GitHub repository for the plugin you want to auto-update

Internal Composer dependencies (pulled in automatically):

Package Constraint
yahnis-elsts/plugin-update-checker dev-master
automattic/jetpack-autoloader ^5.0

Installation

Add the library to the composer.json of your WordPress project or plugin:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/WPBoilerplate/wpb-updater-checker-github"
        }
    ],
    "require": {
        "wpboilerplate/wpb-updater-checker-github": "dev-main"
    }
}

Then install:

composer install

Make sure Composer's autoloader is loaded in your plugin or theme:

require_once __DIR__ . '/vendor/autoload.php';

GitHub Repository Settings

The following settings must be in place on each GitHub repo you want to track:

1. Repository visibility

  • Public repo: works out of the box — no token needed.
  • Private repo: requires a GitHub Personal Access Token (PAT) with at least repo scope. See GitHub PAT docs.

2. Plugin version header

The Version field in your plugin's main PHP file must be kept up to date — this is what WordPress (and the update checker) reads to decide whether an update is available:

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

Bump this value and push to your release branch to trigger update notifications.

3. Release branch

Decide which branch holds your stable releases (commonly main or stable). The checker watches this branch's Version header. Keep feature work on other branches and only merge to the release branch when ready.

4. GitHub Releases (optional — only if using release-assets)

If you set 'release-assets' => true, the updater will look for a ZIP file attached to a GitHub Release instead of downloading the branch archive. In that case:

  • Create a GitHub Release tagged to match the version (e.g. v1.2.0).
  • Attach the plugin ZIP as a release asset.
  • The release tag must exist on the release branch.

Usage

Basic — single plugin

In your plugin's main file, after loading Composer's autoloader:

require_once __DIR__ . '/vendor/autoload.php';

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

Private repository

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
] );

Store tokens in wp-config.php as constants rather than hard-coding them:

// 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 : '',
] );

Using GitHub Release assets

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,
] );

Multiple plugins via the filter

If you manage several GitHub-hosted plugins, register all of them through a single filter instead of creating multiple class instances:

// 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;
} );

Package Configuration Reference

Key Type Required Default Description
repo string Yes Full GitHub repository URL
file_path string Yes Absolute path to the plugin's main PHP file
name_slug string Yes Unique plugin slug (must be unique across all registered packages)
release_branch string No 'main' Branch the updater watches for new versions
token string No '' GitHub PAT — required for private repos
release-assets bool No false When true, downloads update ZIPs from GitHub Release assets

How Updates Are Delivered

  1. You push a commit to the release branch with a bumped Version header (or publish a GitHub Release with an asset if release-assets is enabled).
  2. When an admin visits the WordPress dashboard, the Plugin Update Checker queries GitHub and compares versions.
  3. WordPress shows the standard "update available" notice on the Plugins screen.
  4. Admins can update the plugin with one click, exactly like a plugin from WordPress.org.

Troubleshooting

Symptom Likely cause Fix
No update notice after pushing a new version Version header not bumped Bump Version: in the main plugin file and push
404 / authentication errors Private repo without a token Add a valid token to the package config
Update notice but download fails Wrong file_path Ensure file_path is the absolute path to the plugin's main PHP file
Update shows but wrong ZIP downloaded release-assets mismatch Set 'release-assets' => true only if you attach ZIP assets to GitHub Releases
Updates checked too infrequently Plugin Update Checker cache Clear transients via WP-CLI: wp transient delete --all

License

GPL-2.0-or-later

wpboilerplate/wpb-updater-checker-github 适用场景与选型建议

wpboilerplate/wpb-updater-checker-github 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plugin」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wpboilerplate/wpb-updater-checker-github 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wpboilerplate/wpb-updater-checker-github 我们能提供哪些服务?
定制开发 / 二次开发

基于 wpboilerplate/wpb-updater-checker-github 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-07-24