Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/d802d9730734ee2d7d661f8c9624a270 to your computer and use it in GitHub Desktop.
Save westonruter/d802d9730734ee2d7d661f8c9624a270 to your computer and use it in GitHub Desktop.
Add button to dismiss changeset locked notification in Customizer without taking over the lock from the other user
wp.customize.notifications.bind( 'add', function( notification ) {
if ( 'changeset_locked' === notification.code ) {
notification.render = (function( render ) {
return function() {
var li = render.call( notification ), button;
button = jQuery( '<button type="button" class="button button-secondary">Dismiss</button>' );
button.on( 'click', function() {
notification.parent.remove( notification.code );
} );
li.find( '.action-buttons' ).append( button );
return li;
};
})( notification.render );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment