Enabling Hidden MCE Buttons in WordPress [Enable Unlink Button] without Plugin (functions.php)

How to Enable hidden MCE buttons in WordPress?

In WordPress 4.9, unlink button has been removed but you can add desired hidden buttons by your functions.php!

In implementing TinyMCE WordPress chooses to avoid a messy editor by not displaying many of the available buttons. In some cases creating a custom MCE button is unnecessary because a button already exists that does what you want and you just need to add it to one of the rows of buttons to have access. Common examples include the hr (horizontal rule), sub (subscript) and sup (superscript) buttons, as well as the powerful styleselect button mentioned above. See the full list of buttons on the TinyMCE site: http://archive.tinymce.com/wiki.php?title=TinyMCE3x%3AButtons%2Fcontrols&showmsg=edit

As of WordPress 3.9 and TinyMCE 4.0 sup has been renamed to superscript and sub has been renamed to subscript.

Hidden buttons can be enabled by filtering the array of buttons for the row you wish to edit. The filter for the second row is mce_buttons_2 https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_buttons,_mce_buttons_2,_mce_buttons_3,_mce_buttons_4, while mce_buttons_3 https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_buttons,_mce_buttons_2,_mce_buttons_3,_mce_buttons_4 will create a new third row of buttons.

function my_mce_buttons_2( $buttons ) {	
	/**
	 * Add in a core button that's disabled by default
	 */
        $buttons[] = 'unlink';
        $buttons[] = 'underline';
	$buttons[] = 'superscript';
	$buttons[] = 'subscript';

	return $buttons;
}
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );

https://codex.wordpress.org/TinyMCE_Custom_Buttons

https://orbisius.com/blog/how-to-remove-some-tinymce-buttons-from-the-wordpress-editor-p4240

https://wordpress.org/support/topic/unlink-in-editor-menu/#post-9964651 https://stackoverflow.com/questions/36705610/link-unlink-buttons-missing-in-wordpress-editor

Alternative plugins:

Advanced Editor Tools (previously TinyMCE Advanced)

WP Edit

How to Remove Some TinyMCE Buttons from the WordPress Editor

Sometimes you want to customize the look and feel of WordPress.

There are many ways to remove some buttons from the WordPress richtext editor (TinyMCE).

You can target the button with CSS and hide it OR you can remove the button by using a WordPress filter for that.

Either way can work depending on how much time you current have.

To target the elements we need to hook into mce_buttons and mce_external_plugins WordPress filters.

The function that we register will receive the data in this format:

array (
	0 => 'formatselect',
	1 => 'bold',
	2 => 'italic',
	3 => 'underline',
	4 => 'forecolor',
	5 => 'bullist',
	6 => 'numlist',
	7 => 'blockquote',
	8 => 'alignleft',
	9 => 'aligncenter',
	10 => 'alignright',
	11 => 'alignfull',
	12 => 'wp_adv',
	13 => 'some_plugin_name',
	14 => 'another_plugin_name',
	99 => 'orbisius_child_theme_creator',
);

To remove the buttons you don’t need you can use this code. Make sure you replace “some-plugin” text with the ID that you’d like to remove.

/**
* Add this to a custom plugin of yours or functions.php of the current theme.
* author: Slavi Marinov | https://orbisius.com
* Post link: https://orbisius.com/p4240
*/

add_filter( 'mce_buttons', 'orbisius_custom_fix_remove_tinymce_buttons' );
add_filter( 'mce_external_plugins', 'orbisius_custom_fix_remove_tinymce_buttons' );

/**
 * rm some tinymce buttons.
 * @param array $buttons
 * @return array
 */
function orbisius_custom_fix_remove_tinymce_buttons( $buttons ) {
	foreach ($buttons as $idx => $id ) {
		if (stripos($id, 'some-plugin') !== false) {
			unset($buttons[$idx]);
		}
	}

	return $buttons;
}
///////////////////////////////////////////////////

Related Posts