I've got a theme that checks for a new version on GitHub. When it finds a new version it downloads it and install it. The problem is that it installs the theme with a different folder name than previous. Resulting errors.
I call the updater with hook pre_set_site_transient_update_themes
In it I check the GitHub api with:
I set the update package
variable with .1.0
Where 0.1.0
is the latest version.
So if I install a theme manually the theme root folder is called something like: my-theme
. Updating the theme downloads a new set of files with a different theme folder name. Something like my-theme-3d547d1
. Next update its again being renamed, something like my-theme-58fa412
.
How can I prevent this? Is this something on the GitHub side where I rename the target's zip file name or Something wordpress side, where it renames the zip after download and before install?
#in short#
Wordpress renames the theme folder when fetching theme update from GitHub, how to prevent this
I've got a theme that checks for a new version on GitHub. When it finds a new version it downloads it and install it. The problem is that it installs the theme with a different folder name than previous. Resulting errors.
I call the updater with hook pre_set_site_transient_update_themes
In it I check the GitHub api with: https://api.github/repos/my-name/my-repo/releases/latest
I set the update package
variable with https://api.github/repos/my-name/my-repo/zipball/0.1.0
Where 0.1.0
is the latest version.
So if I install a theme manually the theme root folder is called something like: my-theme
. Updating the theme downloads a new set of files with a different theme folder name. Something like my-theme-3d547d1
. Next update its again being renamed, something like my-theme-58fa412
.
How can I prevent this? Is this something on the GitHub side where I rename the target's zip file name or Something wordpress side, where it renames the zip after download and before install?
#in short#
Wordpress renames the theme folder when fetching theme update from GitHub, how to prevent this
Share Improve this question edited Feb 17, 2021 at 9:30 Tim asked Feb 16, 2021 at 9:22 TimTim 1671 silver badge7 bronze badges 2- 1 WordPress wouldn't be renaming the folder anything like that. This is likely the folder/zip name given by GitHub, and you'll need to account for it in your code. – Jacob Peattie Commented Feb 16, 2021 at 9:49
- @JacobPeattie, correct. It removes the current theme version folder and inserts a new theme version with a folder name bases on the name of the downloaded zip file. – Tim Commented Feb 17, 2021 at 9:32
1 Answer
Reset to default 1My first instinct upon reading this was that a Wordpress Plugin may give you more control over this behaviour. Have you considered writing a plugin to pull and apply the updates?
A quick Google on the subject found this:
https://github/afragen/github-updater
Any use?
Likewise, reviewing their implementation may give you clues as to how to address your issue.