mirror of
https://gh.wpcy.net/https://github.com/YahnisElsts/plugin-update-checker.git
synced 2026-04-27 01:52:19 +08:00
Move most GitHub and BitBucket stuff to a general "VCS checker" class and put service-specific logic in API classes that follow a common interface.
Rationale: Upon further reflection, there's no need to have different theme & plugin checker implementations for each Git hosting service. The overall update detection algorithm stays the same. Only the API and authentication are different.
Not entirely happy with the code duplication in Vcs_PluginUpdateChecker and Vcs_ThemeUpdateChecker. Traits would be one solution, but can't use that in PHP 5.2. There's probably a "good enough" way to achieve the same thing through composition, but I haven't figured it out yet.
For private GH repositories, use setAuthentication('access_token_here') instead of setAccessToken().
22 lines
No EOL
449 B
PHP
22 lines
No EOL
449 B
PHP
<?php
|
|
if ( !interface_exists('Puc_v4_Vcs_BaseChecker', false) ):
|
|
|
|
interface Puc_v4_Vcs_BaseChecker {
|
|
/**
|
|
* Set the repository branch to use for updates. Defaults to 'master'.
|
|
*
|
|
* @param string $branch
|
|
* @return $this
|
|
*/
|
|
public function setBranch($branch);
|
|
|
|
/**
|
|
* Set authentication credentials.
|
|
*
|
|
* @param array|string $credentials
|
|
* @return $this
|
|
*/
|
|
public function setAuthentication($credentials);
|
|
}
|
|
|
|
endif; |