简体   繁体   中英

How to add Tinymce 6 add php code in textarea?

how to add a php code in the editor textarea in tinyMCE 6?

Example: https://i.stack.imgur.com/nCM5x.jpg I need to execute php code in the editor block (page builder dev).

(my old textarea without tinyMCE working and execute php, tinyMCE not execute and delete the php code in textarea after save)

Thanks for help ! Dear Florian

you can use the protect attribute of the TinyMCE configuration:

protect: [ /<\?php[\s\S]*?\?>/g // Protect php code ],

or :

Use placeholders in your text, like this:

<h1 class="">__PHPCODE__<h1>

Then before the text is sent to database, replace the placeholders with the variables you want:

$yourtext = strtr($yourtext, ['__PHPCODE__' => $title]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM