Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.