Home › Forums › ACF PRO › ACF PRO WYSIWYG not getting changed default settings › Reply To: ACF PRO WYSIWYG not getting changed default settings
is it possible to edit other settings too?
i had a hook that works for the default wysiwyg.
but not for the acf_wysiwyg-fields. (it looks like my hook is not fully executed)
add_action( 'wp_tiny_mce_init', function () {
?>
<script>
function editShortcut_tiny_mce_init(ed) {
ed.on('init', function () {
// Note these lists may not be complete & that other tinymce plugins can add their own shortcuts anyway.
var ctrls = [ 'u', '1', '2', '3', '4', '5', '6', '7', '8', '9', 's', 'k', 'Alt+F', 'P' ];
var modKeys = [ 'c', 'r', 'l', 'j', 'q', 'u', 'o', 'n', 's', 'm', 'z', 't', 'd', 'h', 'o', 'x', 'a', 'w' ];
// Overwrite shortcuts with no-op function. Key sequences will still be captured.
for (var i = 0; i < ctrls.length; i++ ) {
this.addShortcut('ctrl+' + ctrls[i], '', function () {});
}
for (var i = 0; i < modKeys.length; i++ ) {
this.addShortcut('alt+shift+' + modKeys[i], '', function () {});
}
});
}
</script>
<?php
});
function my_acf_editor( $mceInit, $editor_id ) {
$mceInit['setup'] = 'editShortcut_tiny_mce_init';
// What goes into the 'formatselect' list
$mceInit['block_formats'] = 'Header 3=h3;Header 4=h4;Header 5=h5;Paragraph=p;Code=code';
$mceInit['paste_word_valid_elements'] = '-strong/b,-em/i,-p,-ol,-ul,-li,-h3,-h4,-h5,-h6,-p,-table[width],-tr,-td[colspan|rowspan|width],-th,-thead,-tfoot,-tbody,-a[href|name],br,del';
$mceInit['paste_strip_class_attributes'] = 'all';
$mceInit['toolbar1'] = 'bold,italic,formatselect,bullist,numlist,blockquote,link,unlink,undo,redo';
return $mceInit;
}
add_filter('tiny_mce_before_init', 'my_acf_editor')
i need a solution that works inside function.php or better, inside my custom plugin.
can anyone help me? please.
my aim is: to have a verry simple wysiwyg that only allow things defined by me.
only edit toolbar is not enough, because the user can avoid these restrictions with shortkeys and/or copy&paste from word.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.