WordPress is not only a popular platform, it is a highly versatile kind of CMS that has a number of features to make it flexible to meet the needs of a wide range of users. Developers sometimes find these features and options troublesome since if the clients fiddle with them carelessly, they can undermine a carefully designed custom theme. Here are a few steps to prevent the clients from messing up with WordPress.

How To Prevent Your Clients Messing Up WordPress

Disable the theme editor and plugins

It is rather not necessary for anyone to live-edit your plugins or custom theme through the WordPress dashboard. Those unfamiliar with the platform can easily break a site by meddling with the codes. It can also be a security threat. Add the following snippet to the wp-config.php file to disable the theme and plugin editors.

define( ‘DISALLOW_FILE_EDIT’, true );

Disable the visual and text editors

Even on a well-designed custom theme, the WordPress WYSIWYG editor can support unlimited formatting options. If the clients meddle with the font sizes and text colors, it can turn the site ugly and also spoil the text alignment and positioning. Completely disabling the visual editor can help avoid this problem. If you add the following snippet to your theme’s function.php file. This will make the tab to toggle the WYSIWYG editor to disappear.

function emersonthis_disable_visual_editor(){

    # add logic here if you want to permit it selectively

    return false;

}

add_filter(‘user_can_richedit’ , ’emersonthis_disable_visual_editor’, 50);

Even after doing this, you will find the bold and italic buttons seen on the plain text editor. Though most clients might not be tempted to use these buttons, it is advisable to remove them if there is no need for them.

Removing bold and italic quicktags from the text editor

You will see quicktag buttons wrapping the selected text with tags <strong> and <em>. If you add the following code to your theme’s functions.php file, the authors will no more have the bold or italics buttons.

# Removes bold and italic quicktags from text editor

function emersothis_quicktags_settings( $qtInit  ) {

    //To disable ALL bbuttons it must be set to “,” (not “”)

    $qtInit[‘buttons’] = ‘more,’;

    return $qtInit;

}

add_filter(‘quicktags_settings’, ’emersonthis_quicktags_settings’);

Though this will rule out the possibility for your client to italicize the complete article, this process will not make it impossible to manually write mark up into the text editor. If you wish to make the user format the text on their own, you can leave the visual editor enabled. However, disable the specific buttons independently.

How to disable the buttons on the visual editor

The reason why you might sometimes need to leave the visual editor enabled is when the authors have to write long posts or pages that have a typical internal structure. For instance, an author writing a long article may need to retain the ability to add subheadings. To address this situation, you can set up a custom class for every subsection and disable the formatting buttons that you will not need.

It is a tricky job to modify the TinyMCE editor of the WordPress API as you will have to look up the code names meant for each button that you wish to remove. By removing the “kitchen sink” button, you can toggle the entire second row containing the most troublemaking buttons. To do this, add the following code to your theme’s functions.php file.  

# Remove visual editor buttons

function emersonthis_tinymce_buttons($buttons)

{

    # Remove the text color selector

    $remove = array(‘wp_adv’); //Add other button names to this array

    # Find the array key and then unset

    return array_diff($buttons,$remove);

}

add_filter(

    ‘mce_buttons’,

    ’emersonthis_tinymce_buttons’

);

The way to figure out the code name of the button you wish to remove is to inspect the markup of the form. While writing, every button has a class name beginning with mce-i- followed by the code name that you will have to input in the array above.