### Initializing Plugin Update Checker (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet demonstrates how to include the Plugin Update Checker library and initialize an update checker instance for a GitHub repository. It shows how to specify the repository URL, the main plugin/theme file path, a unique slug, set the stable branch, and optionally configure authentication for private repositories. ```php require 'plugin-update-checker/plugin-update-checker.php'; use YahnisElsts\PluginUpdateChecker\v5\PucFactory; $myUpdateChecker = PucFactory::buildUpdateChecker( 'https://github.com/user-name/repo-name/', __FILE__, 'unique-plugin-or-theme-slug' ); //Set the branch that contains the stable release. $myUpdateChecker->setBranch('stable-branch-name'); //Optional: If you're using a private repository, specify the access token like this: $myUpdateChecker->setAuthentication('your-token-here'); ``` -------------------------------- ### Initializing BitBucket Plugin Update Checker (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet shows how to initialize the Plugin Update Checker for a BitBucket repository. It includes setting up the update checker instance, optionally configuring OAuth authentication for private repositories, and optionally specifying a stable branch. ```php require 'plugin-update-checker/plugin-update-checker.php'; use YahnisElsts\PluginUpdateChecker\v5\PucFactory; $myUpdateChecker = PucFactory::buildUpdateChecker( 'https://bitbucket.org/user-name/repo-name', __FILE__, 'unique-plugin-or-theme-slug' ); //Optional: If you're using a private repository, create an OAuth consumer //and set the authentication credentials like this: //Note: For now you need to check "This is a private consumer" when //creating the consumer to work around #134: // https://github.com/YahnisElsts/plugin-update-checker/issues/134 $myUpdateChecker->setAuthentication(array( 'consumer_key' => '...', 'consumer_secret' => '...' )); //Optional: Set the branch that contains the stable release. $myUpdateChecker->setBranch('stable-branch-name'); ``` -------------------------------- ### Initialize Plugin Update Checker (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This PHP code snippet demonstrates how to initialize the Plugin Update Checker library. It requires the library file (unless using Composer), imports the necessary class, and then builds an update checker instance using the URL of the JSON file, the path to the main plugin/theme file, and a unique slug. ```php require 'path/to/plugin-update-checker/plugin-update-checker.php'; use YahnisElsts\PluginUpdateChecker\v5\PucFactory; $myUpdateChecker = PucFactory::buildUpdateChecker( 'https://example.com/path/to/details.json', __FILE__, //Full path to the main plugin file or functions.php. 'unique-plugin-or-theme-slug' ); ``` -------------------------------- ### Initialize Plugin Update Checker for Self-Hosted GitLab with Subgroups (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md Initializes the plugin update checker for a repository hosted on a self-hosted GitLab instance that uses subgroups. It requires the full repository URL, the main plugin/theme file path, a unique slug, and specifies the subgroup path within the GitLabApi constructor. ```php use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\PluginUpdateChecker; use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitLabApi; $myUpdateChecker = new PluginUpdateChecker( new GitLabApi( 'https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', null, 'subgroup-level1/subgroup-level2/subgroup-level3' ), __FILE__, 'unique-plugin-or-theme-slug' ); ``` -------------------------------- ### Initialize Plugin Update Checker for GitLab.com (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md Initializes the plugin update checker for a repository hosted on GitLab.com using the PucFactory. It requires the repository URL, the main plugin/theme file path, and a unique slug. Optionally, an access token can be set for private repositories. ```php require 'plugin-update-checker/plugin-update-checker.php'; use YahnisElsts\PluginUpdateChecker\v5\PucFactory; $myUpdateChecker = PucFactory::buildUpdateChecker( 'https://gitlab.com/user-name/repo-name/', __FILE__, 'unique-plugin-or-theme-slug' ); //Optional: If you're using a private repository, specify the access token like this: $myUpdateChecker->setAuthentication('your-token-here'); ``` -------------------------------- ### Enabling Release Assets for GitHub Updates (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet shows how to enable the use of release assets when using GitHub releases for updates. Call this method after initializing the update checker instance. ```php $myUpdateChecker->getVcsApi()->enableReleaseAssets(); ``` -------------------------------- ### Setting Stable Tag in readme.txt (text) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet shows the format for the `Stable tag` header in a `readme.txt` file, used by the update checker to identify the latest stable version when using tags. ```text Stable tag: v1.2.3 ``` -------------------------------- ### Initialize Plugin Update Checker for Self-Hosted GitLab (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md Initializes the plugin update checker for a repository hosted on a self-hosted GitLab instance using the PluginUpdateChecker and GitLabApi classes. It requires the server URL, the main plugin/theme file path, and a unique slug. Authentication and branch options can be added separately. ```php use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\PluginUpdateChecker; use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitLabApi; $myUpdateChecker = new PluginUpdateChecker( new GitLabApi('https://myserver.com/user-name/repo-name/'), __FILE__, 'unique-plugin-or-theme-slug' ); //Optional: Add setAuthentication(...) and setBranch(...) as shown above. ``` -------------------------------- ### Theme Update Details JSON (Self-hosted) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This JSON structure provides the necessary details for a self-hosted theme update. It includes the theme version, a URL for a page with update details (shown when the user clicks 'View details'), and the download URL for the new version. This file is hosted on your server and read by the update checker library. ```json { "version": "2.0", "details_url": "https://example.com/version-2.0-details.html", "download_url": "https://example.com/example-theme-2.0.zip" } ``` -------------------------------- ### Plugin Update Details JSON (Self-hosted) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This JSON structure provides the necessary details for a self-hosted plugin update. It includes the plugin name, version, download URL for the new version, and a description section. This file is hosted on your server and read by the update checker library. ```json { "name" : "Plugin Name", "version" : "2.0", "download_url" : "https://example.com/plugin-name-2.0.zip", "sections" : { "description" : "Plugin description here. You can use HTML." } } ``` -------------------------------- ### Setting Update Checker Branch (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet demonstrates how to explicitly set the branch that the update checker should monitor for version changes, particularly useful when using a stable branch strategy for releases. ```php $updateChecker->setBranch('branch-name'); ``` -------------------------------- ### Setting Stable Branch for GitHub Updates (PHP) Source: https://github.com/bowefrankema/guildenberg-helper/blob/main/plugin-update-checker/README.md This snippet demonstrates how to explicitly set the branch that contains the stable release for the update checker to monitor. PUC will check the Version header in the main file on this branch. ```php $updateChecker->setBranch('branch-name'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.