Skip to content

Instantly share code, notes, and snippets.

@kjbenk
Created February 5, 2018 15:08
Show Gist options
  • Save kjbenk/93eeba2b4c3867b983349ffa2244ab33 to your computer and use it in GitHub Desktop.
Save kjbenk/93eeba2b4c3867b983349ffa2244ab33 to your computer and use it in GitHub Desktop.
WordPress: Remove Shortcake Add Post Element button
// Globally hide the TinyMCE media buttons so that we can alter them and show them
// once updated.
.wp-media-buttons {
display: none;
}
/**
* Update the media buttons.
*/
function updateMediaButtons() {
// Update the Add Media button text.
const addMediaButton = document.querySelectorAll('.insert-media.add_media');
if (addMediaButton) {
Array.prototype.forEach.call(addMediaButton, (button) => {
const newButton = button;
// Get the icon.
const addMediaButtonIcon = newButton.querySelector('span');
let newText = 'Add Media or Post Element';
if (addMediaButtonIcon) {
newText = addMediaButtonIcon.outerHTML + newText;
}
newButton.innerHTML = newText;
});
}
// Show the media buttons.
const mediaButtons = document.querySelectorAll('.wp-media-buttons');
if (mediaButtons) {
Array.prototype.forEach.call(mediaButtons, (buttons) => {
const newButtons = buttons;
newButtons.style.display = 'block';
});
}
}
updateMediaButtons();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment