Created
July 5, 2018 15:50
-
-
Save robertito13/c6e32531b70e92116d064bd20e384f69 to your computer and use it in GitHub Desktop.
Borrar etiquetas HTML del texto pegado en el editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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