How can I add HTML code to the post editor
Quote from hariharakumar on October 31, 2017, 1:03 pmI want to add some code snippets to the forum post. How can I do that?
I want to add some code snippets to the forum post. How can I do that?
Quote from 风起云落 on November 1, 2017, 4:31 amI have solved this problem, you need to install a code highlight plugin, or support the code highlight theme, in addition, the focus is [crossed, focus] if the theme inside the use of WordPress comes with the_content function, you may need to add the following The plugin is provided into the filter.
For example, my code is the theme of the code to prevent HTML escape
/* * 强制阻止WordPress代码转义,关于代码高亮可以看这里http://googlo.me/archives/2986.html */ function git_esc_html($content) { $regex = '/(<pre\s+[^>]*?class\s*?=\s*?[",\'].*?prettyprint.*?[",\'].*?>)(.*?)(<\/pre>)/sim'; return preg_replace_callback($regex, 'git_esc_callback', $content); } function git_esc_callback($matches) { $tag_open = $matches[1]; $content = $matches[2]; $tag_close = $matches[3]; //$content = htmlspecialchars($content, ENT_NOQUOTES, get_bloginfo('charset')); $content = esc_html($content); return $tag_open . $content . $tag_close; } add_filter('the_content', 'git_esc_html', 2); add_filter('comment_text', 'git_esc_html', 2);If you want the code to take effect inside the forum, you also need to add a line of code
add_filter('asgarosforum_filter_post_content', 'git_esc_html', 2);
I have solved this problem, you need to install a code highlight plugin, or support the code highlight theme, in addition, the focus is [crossed, focus] if the theme inside the use of WordPress comes with the_content function, you may need to add the following The plugin is provided into the filter.
For example, my code is the theme of the code to prevent HTML escape
/* * 强制阻止WordPress代码转义,关于代码高亮可以看这里http://googlo.me/archives/2986.html */ function git_esc_html($content) { $regex = '/(<pre\s+[^>]*?class\s*?=\s*?[",\'].*?prettyprint.*?[",\'].*?>)(.*?)(<\/pre>)/sim'; return preg_replace_callback($regex, 'git_esc_callback', $content); } function git_esc_callback($matches) { $tag_open = $matches[1]; $content = $matches[2]; $tag_close = $matches[3]; //$content = htmlspecialchars($content, ENT_NOQUOTES, get_bloginfo('charset')); $content = esc_html($content); return $tag_open . $content . $tag_close; } add_filter('the_content', 'git_esc_html', 2); add_filter('comment_text', 'git_esc_html', 2);
If you want the code to take effect inside the forum, you also need to add a line of code
add_filter('asgarosforum_filter_post_content', 'git_esc_html', 2);
Uploaded files:
Quote from hariharakumar on November 1, 2017, 7:25 amthat’s great, thanx
that’s great, thanx
Quote from Asgaros on November 2, 2017, 6:10 pmFor adding code-snippets to forum posts I am using the Enlighter WordPress plugin. I am also using it in this support forum and its working very well.
For adding code-snippets to forum posts I am using the Enlighter WordPress plugin. I am also using it in this support forum and its working very well.
Quote from hariharakumar on January 20, 2018, 9:00 amQuote from Asgaros on November 2, 2017, 6:10 pmFor adding code-snippets to forum posts I am using the Enlighter WordPress plugin. I am also using it in this support forum and its working very well.
Why I am not seeing all these formatting buttons on my Asgaros forum? I am also finding it difficult to find Enlighter button added to the format bar. I have installed the plugin and selected enable for frontend still it is not showing.
Quote from Asgaros on November 2, 2017, 6:10 pmFor adding code-snippets to forum posts I am using the Enlighter WordPress plugin. I am also using it in this support forum and its working very well.
Why I am not seeing all these formatting buttons on my Asgaros forum? I am also finding it difficult to find Enlighter button added to the format bar. I have installed the plugin and selected enable for frontend still it is not showing.
Quote from Asgaros on January 20, 2018, 12:50 pmHave you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
Have you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
Quote from hariharakumar on January 20, 2018, 1:25 pmQuote from Asgaros on January 20, 2018, 12:50 pmHave you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
No it is enabled, but disabling worked for me, thanks.
Quote from Asgaros on January 20, 2018, 12:50 pmHave you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
No it is enabled, but disabling worked for me, thanks.
Quote from tyru on April 6, 2020, 12:43 pmQuote from Asgaros on January 20, 2018, 12:50 pmHave you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
I have the same problem but I don’t find that checkbox in the forum settings…
Quote from Asgaros on January 20, 2018, 12:50 pmHave you disabled the “Use minimalistic editor”-checkbox in the forum-settings?
I have the same problem but I don’t find that checkbox in the forum settings…
Quote from tyru on April 7, 2020, 11:40 amI solved that by installing TinyMCE Advanced but I have now a display problem :
items in the menu of the message’s text editor are written in white on a white background, so does the window openning when I select “source code”…
My site has a black background and the default color for text is white, maybe this is why… but what can I do to change that for the text editor ?
I solved that by installing TinyMCE Advanced but I have now a display problem :
items in the menu of the message’s text editor are written in white on a white background, so does the window openning when I select “source code”…
My site has a black background and the default color for text is white, maybe this is why… but what can I do to change that for the text editor ?