Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating from GitHub adds an undesired suffix to the plugin folder name. #1

Closed
brasofilo opened this issue Dec 18, 2012 · 4 comments
Closed

Comments

@brasofilo
Copy link

If we use a GitHub zip file as download_url, e.g., https://github.com/user/git-name/archive/master.zip, the updated plugin receives an extra folder suffix: /wp-content/plugins/plugin-slug-master/.

I made a hack to deal with this, but wonder if there'd be a better alternative...

add_filter('upgrader_source_selection', 'ultra_hack', 1, 3);
function ultra_hack( $source, $remote_source, $thiz )
{
    if( not_my_plugin() )
        return $source;

    $path_parts = pathinfo($source);
    $newsource = trailingslashit($path_parts['dirname']). trailingslashit('plugin-slug');
    rename($source, $newsource);
    return $newsource;
}
@jaredatch
Copy link

Another plugin that is similar to this, yet tailored for GH is https://github.com/jkudish/WordPress-GitHub-Plugin-Updater

@brasofilo
Copy link
Author

Thanks, @jaredatch 👍

@YahnisElsts
Copy link
Owner

@brasofilo I don't think there is a non-hacky way to accomplish that. The plugin suggested by @jaredatch uses a similar hack to rename the destination directory, except it relies on the "upgrader_post_install" filter instead of "upgrader_source_selection".

@brasofilo
Copy link
Author

@YahnisElsts , yep, discovered that two days ago... Thanks for the feedback!

YahnisElsts added a commit that referenced this issue Dec 30, 2018
Renaming all of the clases and updating version numbers.
@webmaster20 webmaster20 mentioned this issue Sep 17, 2020
YahnisElsts added a commit that referenced this issue Oct 15, 2022
The notice: "Passing null to parameter #1 ($string) of type string is deprecated". This could be triggered because some update fields can be null, like the upgrade notice field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants