6

Is it possible to remove the 'Custom...' option in the editors colour picker to prevent the user adding custom colours?

enter image description here

1 Answer 1

5

Yes, it is possible to remove the custom colors option from tinyMCE.

WordPress bundles a tinyMCE plugin to handle the custom colors functionality. The tiny_mce_plugins filter can be used to remove this bundled plugin which is identified by the key colorpicker.

Note that removing the custom colors option will not affect users' ability to select colors using the default color swatches.

/**
 * Remove the Color Picker plugin from tinyMCE. This will
 * prevent users from adding custom colors. Note, the default color
 * palette is still available (and customizable by developers) via
 * textcolor_map using the tiny_mce_before_init hook.
 * 
 * @param array $plugins An array of default TinyMCE plugins.
 */
add_filter( 'tiny_mce_plugins', 'wpse_tiny_mce_remove_custom_colors' );
function wpse_tiny_mce_remove_custom_colors( $plugins ) {       

    foreach ( $plugins as $key => $plugin_name ) {
        if ( 'colorpicker' === $plugin_name ) {
            unset( $plugins[ $key ] );
            return $plugins;            
        }
    }

    return $plugins;            
}
1
  • 1
    This works great! Cheers
    – Joe Buckle
    Jul 6, 2017 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.