Skip to content

Instantly share code, notes, and snippets.

@alisterscott
Last active April 12, 2016 15:58
Show Gist options
  • Save alisterscott/d4afc3c629a0eb74a1e77080894d2454 to your computer and use it in GitHub Desktop.
Save alisterscott/d4afc3c629a0eb74a1e77080894d2454 to your computer and use it in GitHub Desktop.
A UserScript to prompt on publish for the WordPress.com Calypso client
// ==UserScript==
// @name WordPress Calypso Warn on Publish
// @version 0.1
// @description Warn on publish
// @author Alister Scott
// @match https://wpcalypso.wordpress.com/*
// @match http://calypso.localhost:3000/*
// @match https://wordpress.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
console.log('WordPress Calypso Warn on Publish script loaded!');
document.addEventListener('click', function(event) {
var classNames = event.target.className;
if ( ( typeof(classNames) === 'string') && ( ( classNames.indexOf( 'editor-ground-control__publish-button' ) > -1 ) || classNames.indexOf( 'editor-publish-button' ) > -1 ) ) {
var response = confirm("You are about to publish your post or page which will immediately send this to all your followers. Are you sure?");
if (response === false) {
event.stopPropagation();
event.preventDefault();
}
}
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment