Plugin: self-hosted auto-updates from Gitea via PUC (hc-8gb)
Vendors YahnisElsts/plugin-update-checker v5.7 under vendor/ and wires it to poll updates.json on the repo main branch. WP surfaces new versions via Dashboard → Updates on its normal twice-daily cadence. PUC is vendored (not a submodule) so Gitea's archive/main.zip — the download target — includes it. Folder rename on install is handled by PUC's built-in upgrader_source_selection filter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
69
vendor/plugin-update-checker/Puc/v5p7/Theme/Package.php
vendored
Normal file
69
vendor/plugin-update-checker/Puc/v5p7/Theme/Package.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace YahnisElsts\PluginUpdateChecker\v5p7\Theme;
|
||||
|
||||
use YahnisElsts\PluginUpdateChecker\v5p7\InstalledPackage;
|
||||
|
||||
if ( !class_exists(Package::class, false) ):
|
||||
|
||||
class Package extends InstalledPackage {
|
||||
/**
|
||||
* @var string Theme directory name.
|
||||
*/
|
||||
protected $stylesheet;
|
||||
|
||||
/**
|
||||
* @var \WP_Theme Theme object.
|
||||
*/
|
||||
protected $theme;
|
||||
|
||||
public function __construct($stylesheet, $updateChecker) {
|
||||
$this->stylesheet = $stylesheet;
|
||||
$this->theme = wp_get_theme($this->stylesheet);
|
||||
|
||||
parent::__construct($updateChecker);
|
||||
}
|
||||
|
||||
public function getInstalledVersion() {
|
||||
return $this->theme->get('Version');
|
||||
}
|
||||
|
||||
public function getAbsoluteDirectoryPath() {
|
||||
if ( method_exists($this->theme, 'get_stylesheet_directory') ) {
|
||||
return $this->theme->get_stylesheet_directory(); //Available since WP 3.4.
|
||||
}
|
||||
return get_theme_root($this->stylesheet) . '/' . $this->stylesheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a specific plugin or theme header.
|
||||
*
|
||||
* @param string $headerName
|
||||
* @param string $defaultValue
|
||||
* @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
|
||||
*/
|
||||
public function getHeaderValue($headerName, $defaultValue = '') {
|
||||
$value = $this->theme->get($headerName);
|
||||
if ( ($headerName === false) || ($headerName === '') ) {
|
||||
return $defaultValue;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function getHeaderNames() {
|
||||
return array(
|
||||
'Name' => 'Theme Name',
|
||||
'ThemeURI' => 'Theme URI',
|
||||
'Description' => 'Description',
|
||||
'Author' => 'Author',
|
||||
'AuthorURI' => 'Author URI',
|
||||
'Version' => 'Version',
|
||||
'Template' => 'Template',
|
||||
'Status' => 'Status',
|
||||
'Tags' => 'Tags',
|
||||
'TextDomain' => 'Text Domain',
|
||||
'DomainPath' => 'Domain Path',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
Reference in New Issue
Block a user