Make WordPress Core

Changeset 38218


Ignore:
Timestamp:
08/08/2016 10:48:33 PM (8 years ago)
Author:
jorbin
Message:

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.

Location:
trunk/src/wp-admin/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/theme.js

    r38084 r38218  
    598598        wp.updates.maybeRequestFilesystemCredentials( event );
    599599
    600         $( document ).on( 'wp-install-theme-success', function( event, response ) {
     600        $( document ).on( 'wp-theme-install-success', function( event, response ) {
    601601            if ( _this.model.get( 'id' ) === response.slug ) {
    602602                _this.model.set( { 'installed': true } );
     
    800800        wp.updates.maybeRequestFilesystemCredentials( event );
    801801
    802         $( document ).one( 'wp-delete-theme-success', function( event, response ) {
     802        $( document ).one( 'wp-theme-delete-success', function( event, response ) {
    803803            _this.$el.find( '.close' ).trigger( 'click' );
    804804            $( '[data-slug="' + response.slug + '"' ).css( { backgroundColor:'#faafaa' } ).fadeOut( 350, function() {
     
    973973        wp.updates.maybeRequestFilesystemCredentials( event );
    974974
    975         $( document ).on( 'wp-install-theme-success', function() {
     975        $( document ).on( 'wp-theme-install-success', function() {
    976976            _this.model.set( { 'installed': true } );
    977977        } );
  • trunk/src/wp-admin/js/updates.js

    r38209 r38218  
    10721072            $message;
    10731073
    1074         $document.trigger( 'wp-install-theme-success', response );
     1074        $document.trigger( 'wp-theme-install-success', response );
    10751075
    10761076        $message = $card.find( '.button-primary' )
     
    12441244        wp.a11y.speak( wp.updates.l10n.deleted, 'polite' );
    12451245
    1246         $document.trigger( 'wp-delete-theme-success', response );
     1246        $document.trigger( 'wp-theme-delete-success', response );
    12471247    };
    12481248
Note: See TracChangeset for help on using the changeset viewer.