Skip to content

Instantly share code, notes, and snippets.

@robertito13
Created July 5, 2018 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertito13/c6e32531b70e92116d064bd20e384f69 to your computer and use it in GitHub Desktop.
Save robertito13/c6e32531b70e92116d064bd20e384f69 to your computer and use it in GitHub Desktop.
Borrar etiquetas HTML del texto pegado en el editor
<?php
function wp_clean_on_paste( $in ) {
$in['paste_preprocess'] = "function( plugin, args ) {
var whitelist = 'a,p,span,b,strong,i,em,h3,h4,h5,h6,ul,li,ol';
var stripped = jQuery('<div>' + args.content + '</div>');
var els = stripped.find('*').not(whitelist);
for (var i = els.length - 1; i >= 0; i--) {
var e = els[i];
jQuery(e).replaceWith(e.innerHTML);
}
stripped.find('*').removeAttr('id').removeAttr('class').removeAttr('align');
args.content = stripped.html();
}";
return $in;
}
add_filter( 'tiny_mce_before_init', 'wp_clean_on_paste' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment