Skip to content

Instantly share code, notes, and snippets.

@serkanalgur
Created September 25, 2012 18:23
Show Gist options
  • Save serkanalgur/3783555 to your computer and use it in GitHub Desktop.
Save serkanalgur/3783555 to your computer and use it in GitHub Desktop.
function for comments shortcode
function phpcode($atts, $content = "") {
return '<pre class="php">'.esc_attr($content).'</pre>';
}
function csscode($atts, $content = "") {
return '<pre class="css">'.$content.'</pre>';
}
function htmlcode($atts, $content = "") {
return '<pre class="html">'.esc_html($content).'</pre>';
}
function init_common_shortcodes() {
add_shortcode('html', 'htmlcode');
add_shortcode('php', 'phpcode');
add_shortcode('css', 'csscode');
}
function init_comment_shortcodes() {
remove_all_shortcodes();
init_common_shortcodes();
add_filter('comment_text', 'do_shortcode');
}
init_common_shortcodes();
add_filter('comments_template', 'init_comment_shortcodes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment