[wp-trac] [WordPress Trac] #9757: Allow Plugin/Theme updates from a uploaded .zip file.

WordPress Trac noreply at wordpress.org
Sun Oct 22 11:38:51 UTC 2017


#9757: Allow Plugin/Theme updates from a uploaded .zip file.
------------------------------------------+-----------------------------
 Reporter:  hakre                         |       Owner:
     Type:  feature request               |      Status:  new
 Priority:  high                          |   Milestone:  Future Release
Component:  Upgrade/Install               |     Version:  2.8
 Severity:  normal                        |  Resolution:
 Keywords:  dev-feedback has-patch early  |     Focuses:
------------------------------------------+-----------------------------
Changes (by imath):

 * keywords:  dev-feedback has-patch needs-refresh early => dev-feedback
     has-patch early


Comment:

 Hi,

 As i'm currently working on this feature for one of my plugin, i'm
 suggesting this alternative approach. I agree it would be interesting to
 upload / unzip / explore the uploaded plugin into another temporary folder
 then ask the user if he wants to update a matching existing plugin with
 the uploaded one, delete the old plugin, move the temporary folder etc...
 It would probably allow to check if the version is upper etc..

 On the other hand, I think it's a lot of file manipulation and probably
 edits into the Plugin Upgrader class. The alternative approach is to
 consider a replace process instead of an update process. There can be
 cases when you updated a plugin, something's going wrong with your site's
 configuration and you need to come back to a previous version of the
 updated plugin to fix the issue with your site.

 In [https://core.trac.wordpress.org/attachment/ticket/9757/9757.1.patch
 9757.1.patch], i'm using JavaScript to get the Zip filename and use this
 as the plugin's slug to check for existing plugin thanks to a Rest API
 request. If there is no match, it doesn't change anything to the process,
 if there's one, then it adds some information before the "Install Now"
 button and a "Cancel" button after it to reset the form, see screenshot
 beneath.

 [[Image(https://cldup.com/lZ4aB9e_0W.png)]]

 When the user clicks on "Install Now" the process is very similar to an
 update, and there is very few edits to `Plugin_Upgrader::upgrade()`. As
 the process is a bit different, strings need to be a bit different in this
 case though, because we don't know if the user is upgrading or downgrading
 the plugin. That's why the patch is taking this in account as you can see
 beneath :

 [[Image(https://cldup.com/HcneJO4PUj.png)]]

 "Replacing the installed version" & "Plugin replaced successfully" are the
 new strings.

 NB: the patch is using the `wp.apiRequest` (introduced in 4.9, btw thanks
 a lot and congrats to people who worked on it 👍) And the script where is
 located this API is not loaded on multisite configs. There's probably a
 good reason for this but at the same time as some widgets are using it, i
 guess they could fail on multisite configs..)

 If you think it's an interesting approach, I can give a hand during 5.0
 dev cycle to carry on improving the patch and adding Themes support. Else,
 i'll be happy to give my feedbacks on @psykro 's approach.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/9757#comment:83>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list