• I have a private theme that contains a .json and .zip, this works fine hooking into pre_set_site_transient_update_themes.

    However during the installation process it will download and unpack the zip into wp-content/upgrade with a random hash on the end of the filename, so theme.zip => theme-kw342.

    This is a problem as when it moves (and deletes the current theme) theme-kw342.zip into wp-content/themes it doesn’t rename the folder to theme, it keeps it as theme-kw342 which means my theme breaks.

    I have resorted to renaming the folder when it’s in wp-content/upgrade (by hooking into upgrader_source_selection) but it doesn’t seem right.

    Any ideas?

    This is a gist of my code, get_config and debug_log are helper function I have created.

    https://gist.github.com/connorjburton/3f9db2abf888f2192c73

    For reference, my theme.json:

    {
    	"new_version": "0.1.38",
    	"url": "http:\/\/urlhere.com\/updates.html",
    	"package": "http:\/\/urlhere.com\/theme.zip"
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you ding the checks for updates and the download manually? Have you tried the solution described here: http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/.

    (Sorry for the incomplete answer, but your question intrigued me to check it out online, and it is an interesting problem.)

    Perhaps you should add the theme name to your JSON file like this:

    {
        "name" : "My Cool Plugin",
        "slug" : "my-cool-plugin",
        "download_url" : "http://example.com/plugins/my-cool-plugin.zip",
        "version" : "2.0",
        "author" : "John Smith",
        "sections" : {
            "description" : "Plugin description here. Basic HTML allowed."
        }
    }
    Thread Starter connorjburton

    (@connorjburton)

    Okay sorted it, your .zip has to contain a folder with your theme name with your files inside that, if you just have a .zip with files in it, it won’t create the correct folder, it will keep the tempnam it sets when downloading/unpacking

    Whoah, this was so simple after all!

    🙂

    Hope it will save some time for users who have the same problem in the future!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Private theme is not installing new version with correct dir name’ is closed to new replies.