pierrebalian of Rocket55 Web Team
4/20/2018 - 4:15 PM

remove buttons from wordpress tinyMCE editor

/**
 * Removes buttons from the first row of the tiny mce editor
 *
 *
 * @param    array    $buttons    The default array of buttons
 * @return   array                The updated array of buttons that exludes some items
 */
add_filter( 'mce_buttons', 'mmi_remove_tiny_mce_buttons_from_editor');
function mmi_remove_tiny_mce_buttons_from_editor( $buttons ) {
	$remove_buttons = array(
		'alignleft',
		'aligncenter',
		'alignright',
	);
	foreach ( $buttons as $button_key => $button_value ) {
		if ( in_array( $button_value, $remove_buttons ) ) {
			unset( $buttons[ $button_key ] );
		}
	}
	return $buttons;
}
/**
 * Removes buttons from the second row (kitchen sink) of the tiny mce editor
 *
 *
 * @param    array    $buttons    The default array of buttons in the kitchen sink
 * @return   array                The updated array of buttons that exludes some items
 */
add_filter( 'mce_buttons_2', 'mmi_remove_tiny_mce_buttons_from_kitchen_sink');
function mmi_remove_tiny_mce_buttons_from_kitchen_sink( $buttons ) {
	$remove_buttons = array(
        //'formatselect', // format dropdown menu for <p>, headings, etc
        //'underline',
	);
	foreach ( $buttons as $button_key => $button_value ) {
		if ( in_array( $button_value, $remove_buttons ) ) {
			unset( $buttons[ $button_key ] );
		}
	}
	return $buttons;
}