My users post snippets code in comments.
I created a shortcode for this :
function post_codigo($atts,$content=""){
return '<code>'.$content.'</code>';
}
add_shortcode('codigo','post_codigo');
Problem is that html gets filtered before its wrapped into the code tags.
I think that if i can get the shortcode run before filters then i can use
function pre_esc_html($content) {
return preg_replace_callback(
'#(<code.*?>)(.*?)(</code>)#imsu',
create_function(
'$i',
'return $i[1].esc_html($i[2]).$i[3];'
),
$content
);
}
add_filter(
'the_content',
'pre_esc_html',
9
);
that i found around here. What you think?
UPDATED: Ok now i changed my shortcode to:
function post_codigo($atts,$content=""){
return '<code>'.esc_html($content).'</code>';
}
add_shortcode('codigo','post_codigo');
But it still adding
breaks and breaking the whole code into several tags