I'm using this ages old, but still well working, plugin (source code here) to auto escape html inside <code>.

All is well and good until I tried to use short codes to form the <pre><code> blocks.

This is the short code code I use:

// HTML code block
function short_code_markup( $atts, $content = null ) {
    return "<pre data-language='HTML' class='language-markup'><code>" . $content . "</code></pre>";
add_shortcode( 'html', 'short_code_markup' );

Does it have something to do with the order the scripts being executed?

Here are the filters the plugin applies:

add_filter('content_save_pre', 'pri_cae_mask', 28);
add_filter('content_save_pre', 'pri_cae_unmask', 72);
add_filter('the_content', 'pri_cae_mask', 1);
add_filter('the_content', 'pri_cae_unmask_replace', 99);

add_filter('excerpt_save_pre', 'pri_cae_mask', 28);
add_filter('excerpt_save_pre', 'pri_cae_unmask', 72);
add_filter('the_excerpt', 'pri_cae_mask', 1);
add_filter('the_excerpt', 'pri_cae_unmask_replace', 99);

add_filter('pre_comment_content', 'pri_cae_mask', 4);
add_filter('pre_comment_content', 'pri_cae_unmask', 36);
add_filter('comment_save_pre', 'pri_cae_mask', 28);
add_filter('comment_save_pre', 'pri_cae_unmask', 72);
add_filter('comment_text', 'pri_cae_mask', 1);
add_filter('comment_text', 'pri_cae_unmask_replace_addpre', 99);

Thanks a lot advanced :)

  • I've deleted my answer because after a test your code works for me. Only problem I noticed is that the plugin throw some notices because the use of an undeclared variable. – gmazzap Sep 10 '13 at 14:48
  • That's weird, I've tried to disable all my plugins (expect the auto escape) and emptied my whole functions.php file (expect the short codes). Also tried it locally and on server and nothing seemed to work really. Thanks a lot for your effort! Well appreciated :) – any_h Sep 10 '13 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.