Question

I have this repo on Github - https://github.com/ronakg/awesome-flickr-gallery-plugin. It's a wordpress plugin for creating a photo gallery from your photos stored on Flickr.

Now what I want to achieve is - when I create a new release zip for my plugin, it should not use the tag name.

For example, I create releases 3.5.0 and 3.6.0. The folder structure for both the releases should be same.

awesome-flickr-gallery-plugin
  /index.php
  /README.txt
  .
  .

Right now it creates the release zipfiles like this:

awesome-flickr-gallery-plugin-3.5.0
   /index.php
   /README.txt
   .
   .

This is important for me as I want to serve this zip files directly as WordPress plugin updates for my users. This different file structure breaks the plugin update process in WordPress.

Any ideas?

Was it helpful?

Solution

I faced a similar problem with the prefix -master and solved with the following filter upgrader_source_selection. My repository is github-plugin-for-wordpress, adjust for your own.

/**
 * Access this plugin’s working instance
 *
 * @wp-hook plugins_loaded
 * @return  object of this class
 */
public function plugin_setup()
{
    add_filter( 'upgrader_source_selection', array( $this, 'rename_github_zip' ), 1, 3);
}

/**
 * Removes the prefix "-master" when updating from GitHub zip files
 * 
 * See: https://github.com/YahnisElsts/plugin-update-checker/issues/1
 * 
 * @param string $source
 * @param string $remote_source
 * @param object $thiz
 * @return string
 */
public function rename_github_zip( $source, $remote_source, $thiz )
{
    if(  strpos( $source, 'github-plugin-for-wordpress') === false )
        return $source;

    $path_parts = pathinfo( $source );
    $newsource = trailingslashit( $path_parts['dirname'] ) . trailingslashit( 'github-plugin-for-wordpress' );
    rename( $source, $newsource );
    return $newsource;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top