Skip to content

Commit

Permalink
Make the kitchensink button removable from plugins (#10964)
Browse files Browse the repository at this point in the history
  • Loading branch information
azaozz authored and youknowriad committed Nov 9, 2018
1 parent b9c909f commit b814d88
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
40 changes: 19 additions & 21 deletions lib/client-assets.php
Expand Up @@ -598,28 +598,26 @@ function gutenberg_register_scripts_and_styles() {
),
'toolbar1' => implode(
',',
array_merge(
apply_filters(
'mce_buttons',
array(
'formatselect',
'bold',
'italic',
'bullist',
'numlist',
'blockquote',
'alignleft',
'aligncenter',
'alignright',
'link',
'unlink',
'wp_more',
'spellchecker',
'wp_add_media',
),
'editor'
apply_filters(
'mce_buttons',
array(
'formatselect',
'bold',
'italic',
'bullist',
'numlist',
'blockquote',
'alignleft',
'aligncenter',
'alignright',
'link',
'unlink',
'wp_more',
'spellchecker',
'wp_add_media',
'kitchensink',
),
array( 'kitchensink' )
'editor'
)
),
'toolbar2' => implode(
Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/classic/edit.js
Expand Up @@ -115,6 +115,7 @@ export default class ClassicEdit extends Component {
}
} );

// TODO: the following is for back-compat with WP 4.9, not needed in WP 5.0. Remove it after the release.
editor.addButton( 'kitchensink', {
tooltip: _x( 'More', 'button to expand options' ),
icon: 'dashicon dashicons-editor-kitchensink',
Expand All @@ -127,11 +128,19 @@ export default class ClassicEdit extends Component {
},
} );

// Show the second, third, etc. toolbars when the `kitchensink` button is removed by a plugin.
editor.on( 'init', function() {
if ( editor.settings.toolbar1 && editor.settings.toolbar1.indexOf( 'kitchensink' ) === -1 ) {
editor.dom.addClass( ref, 'has-advanced-toolbar' );
}
} );

editor.addButton( 'wp_add_media', {
tooltip: __( 'Insert Media' ),
icon: 'dashicon dashicons-admin-media',
cmd: 'WP_Medialib',
} );
// End TODO.

editor.on( 'init', () => {
const rootNode = this.editor.getBody();
Expand Down

0 comments on commit b814d88

Please sign in to comment.