Wordpres core-update theme renames theme folder name

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.com/repos/my-name/my-repo/releases/latest

I set the update package variable with https://api.github.com/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

Topic github git automatic-updates theme-development updates Wordpress

Category Web


My 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.com/afragen/github-updater

Any use?

Likewise, reviewing their implementation may give you clues as to how to address your issue.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.