Riepilogo AI
Introduzione
Vuoi disattivare l'editor WYSIWYG che compare nelle impostazioni di conferma? Per impostazione predefinita, quando ti trovi nel generatore di moduli, vedrai l'editor WYSIWYG standard utilizzato da WordPress. Tuttavia, se desideri disattivare questo campo, puoi farlo facilmente aggiungendo poche righe di codice PHP. In questo tutorial ti guideremo passo dopo passo attraverso la procedura per disattivare questo editor.
Che cos'è un editor WYSIWYG? Si tratta di un editor visuale o di un campo di testo ricco. Quando si accede per la prima volta alla scheda Impostazioni di conferma dal costruttore di moduli, in genere si vedono due schede. Una è per l'editor di testo visivo (WYSIWYG) e l'altra è una scheda di testo semplice.

L'editor di testo semplice è in genere utilizzato più spesso dagli utenti che si trovano a proprio agio nella scrittura di HTML.
Aggiunta dello snippet per disabilitare l'editor WYSIWYG
Prima di creare il modulo, aggiungiamo lo snippet che disabiliterà l'editor. Per farlo, basta copiare e incollare questo snippet nel sito.
Se avete bisogno di aiuto per aggiungere gli snippet al vostro sito, consultate questo tutorial.
/**
Disable the WYSIWYG editor in the Confirmation settings.
@link https://wpforms.com/developers/how-to-disable-the-wysiwyg-editor-inside-the-confirmation-settings/
*/
function wpf_dev_builder_enqueues( $view ) {
wp_add_inline_script(
'wpforms-builder',
'(function( $ ) {
// Prevent crash: module reads tinymceDefaults.tinymce.toolbar1 before
// calling wp.editor.initialize — needs a valid object, not false.
// This runs synchronously so WPFormsBuilder is guaranteed to exist.
if ( typeof WPFormsBuilder !== "undefined" && WPFormsBuilder.settings ) {
WPFormsBuilder.settings.tinymceDefaults.tinymce = { toolbar1: "" };
}
$( document ).ready( function() {
// Layer 1: wp.editor.initialize intercept.
// Prevents tmce-active class + TinyMCE init flow for confirmation editors.
if ( typeof wp !== "undefined" && wp.editor && wp.editor.initialize && ! wp.editor.initialize.wpfPatched ) {
var wpInit = wp.editor.initialize;
wp.editor.initialize = function( id, settings ) {
if ( typeof id === "string" && /^wpforms[-]panel[-]field[_-]confirmations/.test( id ) ) {
settings = Object.assign( {}, settings, { tinymce: false } );
}
return _wpInit.call( this, id, settings );
};
wp.editor.initialize.wpfPatched = true;
}
// Layer 2: tinymce.init intercept.
// Belt-and-suspenders — catches TinyMCE even if wp.editor.initialize
// is called from a path our Layer 1 missed.
if ( typeof tinymce !== "undefined" && ! tinymce.init.wpfPatched ) {
var mceInit = tinymce.init;
tinymce.init = function( settings ) {
if ( settings && settings.selector && /wpforms[-]panel[-]field[-]confirmations/.test( settings.selector ) ) {
return;
}
return _mceInit.apply( this, arguments );
};
tinymce.init._wpfPatched = true;
}
// Layer 3: event fallback — re-init any editor that slipped through.
$( "#wpforms-builder" ).on( "wpformsBuilderConfirmationsReady", function() {
if ( typeof wp === "undefined" || ! wp.editor ) return;
$( ".wpforms-panel-field-confirmations-message" ).each( function() {
var id = $( this ).attr( "id" );
if ( ! id ) return;
wp.editor.remove( id );
wp.editor.initialize( id, { tinymce: false, quicktags: true } );
} );
} );
} );
} )( jQuery );'
);
}
add_action( 'wpforms_builder_enqueues', 'wpf_dev_builder_enqueues', 10, 1 );
In questo modo l'editor visivo (l'editor WYSIWYG) verrà disattivato completamente e vedrai solo l'editor di testo.

Volete anche disabilitare lo scorrimento automatico quando ci sono errori nel modulo? Consultate il nostro articolo su Come disabilitare l'effetto di scorrimento sugli errori di convalida dei campi.