Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Can we change WYSIWYG - basic editor buttons?
-
Hi @JuTu83, @compass
GREAT NEWS!
I've added in the ability to FULLY customize the WYSIWYG toolbars!
You will need to download the latest nightly build on Github, but once you do that, you can use this code to edit / add to / remove from the toolbars<?php
add_filter( 'acf/fields/wysiwyg/toolbars', 'my_toolbars' );
function my_toolbars( $toolbars )
{
// Uncomment to view format of $toolbars
/*
echo '< pre >';
print_r($toolbars);
echo '< /pre >';
die;
*/
// Add a new toolbar called "Very Simple"
// - this toolbar has only 1 row of buttons
$toolbars['Very Simple'] = array();
$toolbars['Very Simple'][1] = array('bold', 'italic', 'underline');
// Edit the "Full" toolbar and remove 'code'
// - delet from array code from http://stackoverflow.com/questions/7225070/php-array-delete-by-value-not-key
if( ($key = array_search('code', $toolbars['Full'][2])) !== false )
{
unset( $toolbars['Full'][2][$key] );
}
// remove the 'Basic' toolbar completely
unset( $toolbars['Baisc'] );
// return $toolbars - IMPORTANT!
return $toolbars;
}
?>
Cheers
Elliot -
This really is great news! :)
And it's working like a charm, great job Elliot! -
I've been following this post and was excited to see you've added this functionality.
I've given it a test this morning and it works a dream.
If anyone uses the plugin 'TinyMCE Advanced' you can easily mirror the settings so that the ACF WYSIWYG matches the default WP editor using this code within your function:for( $i = 1; $i <= 4; $i++ ) {
$toolbars[ 'Full' ][ $i ] = get_option( 'tadv_btns' . $i );
} -
Really great! Thank you Elliot!
-
Man, you rule! This was just what i was missing in acf. I´m loving the gallery field which i hadn´t used yet!
-
That's super, thanks Elliot!
Just one question:
if i simply want to override the "Full" toolbar, the "// Edit the "Full" toolbar and remove 'code'" lines aren't necessary to apply, right? Can i comment them?
Ive tried my way and the "modified" full toolbar shows correctly but i don't know if all go correctly under the hood, i simply commented them because with wp debug mode set true i had an error report in backend that said "Udefined offset: 2".
Here's my modified code to override the "Full" toolbar:add_filter( 'acf/fields/wysiwyg/toolbars' , 'my_toolbars' );
function my_toolbars( $toolbars ){
// Uncomment to view format of $toolbars
/*
echo '< pre >';
print_r($toolbars);
echo '< /pre >';
die;
*/
// Add a new toolbar called "Very Simple"
// - this toolbar has only 1 row of buttons
$toolbars['Full' ] = array();
$toolbars['Full' ][1] = array(
'formatselect',
'undo',
'redo',
'bold',
'italic',
'underline',
'strikethrough',
'bullist',
'numlist',
'blockquote',
'justifyleft',
'justifycenter',
'justifyright',
'justifyfull',
'link',
'unlink',
'spellchecker',
'pastetext',
'pasteword',
'removeformat',
'charmap',
'outdent',
'indent',
'fullscreen',
'wp_help'
);
// Edit the "Full" toolbar and remove 'code'
// - delet from array code from http://stackoverflow.com/questions/7225070/php-array-delete-by-value-not-key
//if( ($key = array_search('code' , $toolbars['Full' ][2])) !== false ){
// unset( $toolbars['Full' ][2][$key] );
//}
// remove the 'Basic' toolbar completely
unset( $toolbars['Basic' ] );
// return $toolbars - IMPORTANT!
return $toolbars;
} -