WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#37216 closed defect (bug) (fixed)

Shiny Updates: Trigger event handler when updating theme

Reported by: DavidAnderson Owned by: swissspidy
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.6
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:
PR Number:

Description

I develop WP's most-installed backup plugin (UpdraftPlus) which, among other things, can take a backup immediately before a plugin or theme update.

This is integrated with "shiny updates" for plugins (since WP 4.2), thanks to previous co-operation over issues that arose during WP 4.2 development. (Before a shiny plugin update takes place, a dialog pops up (much like the filesystem credentials box can in WP itself), takes a backup, then goes away and allows the update to proceed).

We've been looking at the shiny-updates-for-themes code, and have an issue on wp-admin/themes.php. There's currently no easy way to know when the visitor clicks the 'update' link, because the handler in wp-admin/js/theme.js blocks all other event handlers when it is clicked.

The attached patch rectifies this, by triggering an event early in wp.updates.updateTheme, which thus allows other plugins to take appropriate action.

Attachments (2)

trigger-on-theme-update.patch (491 bytes) - added by DavidAnderson 3 years ago.
Trigger event when a shiny theme update is requested
37216.diff (388 bytes) - added by swissspidy 3 years ago.

Download all attachments as: .zip

Change History (13)

@DavidAnderson
3 years ago

Trigger event when a shiny theme update is requested

#2 @DavidAnderson
3 years ago

Yup. Those are the tickets opened and which helped us to keep automatic pre-upgrade backups possible when "shiny updates" was added for plugins back in WP 4.2.

#3 @DavidAnderson
3 years ago

  • Summary changed from Trigger event handler when updating theme to Shiny Updates: Trigger event handler when updating theme

#4 @DavidAnderson
3 years ago

@jorbin : Do you have any tips on how I can get attention for this issue? It seems to be slipping under the radar, and currently means that existing functionality in our plugin will be broken, with no way to fix it, in WP 4.6.

#5 @DavidAnderson
3 years ago

  • Type changed from enhancement to defect (bug)

@swissspidy
3 years ago

#6 @swissspidy
3 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.6

For plugin updates there's a $document.trigger( 'wp-plugin-updating' ); line. We need the same for theme updates.

@DavidAnderson Would 37216.diff solve the issue?

#7 @DavidAnderson
3 years ago

Thank you. This patch resolves it for me.

#8 @DavidAnderson
3 years ago

I found an unrelated bug whilst testing, though: #37285

#9 @swissspidy
3 years ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 37970:

Update/Install: Trigger a JS event when updating a theme.

For plugins a 'wp-plugin-updating' event is triggered, for themes there's now the 'wp-theme-updating' equivalent.

Props DavidAnderson.
Fixes #37216.

#10 @jorbin
3 years ago

In 38218:

Updates: Standardize JS Custom Event Names

Custom JS events are triggered on the document in order for plugins to have something to hook into. The standard began in #31819 is dash separated and begins with wp to signify the namespace, followed by the subject of our action ( "theme", "plugin", etc.) followed by the action and an optional indicator of status ( "install-success", "deleting" ).

This brings some of the theme hooks in line with the standard. As of now, all plugin actions in src/wp-admin/js/updates.js have an equal corresponding theme action.

Fixes #37598.
See #37512, #37216, #31819.
Props olarmarius, ocean90.

#11 @jorbin
3 years ago

In 38219:

Updates: Standardize JS Custom Event Names

Merges [38218] in to 4.6 branch.

Custom JS events are triggered on the document in order for plugins to have something to hook into. The standard began in #31819 is dash separated and begins with wp to signify the namespace, followed by the subject of our action ( "theme", "plugin", etc.) followed by the action and an optional indicator of status ( "install-success", "deleting" ).

This brings some of the theme hooks in line with the standard. As of now, all plugin actions in src/wp-admin/js/updates.js have an equal corresponding theme action.

Fixes #37598.
See #37512, #37216, #31819.
Props olarmarius, ocean90.

Note: See TracTickets for help on using tickets.