From syntax highlight
-
The contact form can contain html code.
I suggest to add this code into ContactForm7:add_action( 'admin_enqueue_scripts', function (string $hook): void { if ($hook === 'toplevel_page_wpcf7' && isset($_GET['post'])) { $type = 'text/html'; $settings = wp_enqueue_code_editor( [ 'type' => $type, 'htmlhint' => ['space-tab-mixed-disabled' => 'space'], 'codemirror' => ['indentWithTabs' => false] ] ); if ($settings !== false) { wp_add_inline_script( 'code-editor', sprintf( <<<'EOF' jQuery(function () { const codemirror = wp.codeEditor.initialize('wpcf7-form', %s).codemirror wpcf7.taggen.insert = content => { let cursor = codemirror.getCursor() codemirror.replaceRange(content, cursor) cursor = codemirror.getCursor() codemirror.focus() codemirror.setCursor(cursor) } }) EOF, wp_json_encode($settings) ) ); } } } );This will activate CodeMirror code editor integrated in WordPress and highlight HTML code if it is used in a Contact Form.
The topic ‘From syntax highlight’ is closed to new replies.