Come rimuovere il pulsante "Aggiungi modulo" dall'editor TinyMCE

Utilizzate l'editor classico per il vostro sito WordPress e volete rimuovere il pulsante Aggiungi modulo dall'editor TinyMCE? Utilizzando il PHP è possibile disabilitare facilmente questo pulsante. In questa guida vi mostreremo lo snippet PHP necessario per rimuovere il pulsante "Aggiungi modulo" dall'editor TinyMCE.

Quando WPForms è installato, nelle opzioni dell'editor TinyMCE viene visualizzato un pulsante Aggiungi modulo per qualsiasi tipo di post di WordPress quando si utilizza l'editor classico.

Come rimuovere il pulsante "aggiungi modulo" dall'editor TinyMCE

Questo pulsante può essere facilmente rimosso aggiungendo al sito lo snippet di codice riportato di seguito.

Rimozione del pulsante Aggiungi modulo

In questo esempio specifico, stiamo nascondendo l'elemento Aggiungi modulo su pagine e post. Tuttavia, è possibile sostituire page e post con qualsiasi nome di tipo di post.

/**
 * Remove the 'Add Form' WPForms TinyMCE button.
 *
 * In the function below we disable displaying the 'Add Form' button
 * on pages and posts. You can replace 'page' and 'post' with your desired post type.
 *
 * @link   https://wpforms.com/developers/remove-add-form-button-from-tinymce-editor/
 */

function wpf_dev_remove_media_button( $display ) {

	$screen = get_current_screen();

	if ( 'page' == $screen->post_type || 'post' == $screen->post_type ) {
		return false;

	} 
	return $display;
}
add_filter( 'wpforms_display_media_button', 'wpf_dev_remove_media_button', 10, 1 );

Ed ecco fatto! Ora avete disabilitato il pulsante Aggiungi modulo dall'editor. Volete disabilitare il completamento automatico sui browser? Date un'occhiata al nostro tutorial su Come disabilitare il completamento automatico del browser per i campi dei moduli.

Filtro di riferimento

wpforms_display_media_button

FAQ

D: Posso utilizzarlo per altri tipi di post?

R: Assolutamente sì! In questo esempio, includiamo pagine, post e il tipo di post Woocommerce product.

/**
 * Remove the 'Add Form' WPForms TinyMCE button.
 *
 * In the function below we disable displaying the 'Add Form' button
 * on pages and posts. You can replace 'page' and 'post' with your desired post type.
 *
 * @link   https://wpforms.com/developers/remove-add-form-button-from-tinymce-editor/
 */
 
function wpf_dev_remove_media_button( $display ) {
 
    $screen = get_current_screen();
 
    if ( 'page' == $screen->post_type || 'product' == $screen->post_type || 'post' == $screen->post_type ) {
        return false;
 
    } 
    return $display;
}
add_filter( 'wpforms_display_media_button', 'wpf_dev_remove_media_button', 10, 1 );