Limit WP site editors. How To Make WordPress Hard For Clients To Mess Up.
<?php
// put this into functions.php
//to toggle the WYSIWYG editor will 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);
// Removes bold and italic quicktags from text editor
function emersothis_quicktags_settings( $qtInit ) {
//To disable ALL butons it must be set to "," (not "")
$qtInit['buttons'] = 'more,';
return $qtInit;
}
add_filter('quicktags_settings', 'emersonthis_quicktags_settings');
// 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'
);
// Remove media buttons
function emersonthis_remove_add_media(){
# do this conditionally if you want to be more selective
remove_action( 'media_buttons', 'media_buttons' );
}
add_action('admin_head', 'emersonthis_remove_add_media');
// Disable Theme Customizer Options
// If you are working on a child theme, the parent theme may offer customization options that are inappropriate for the child. The customization options may be unused in your child theme, or have the potential to break things.
// Remove customizer options.
function emersonthis_remove_customizer_options( $wp_customize ) {
// $wp_customize->remove_section( 'static_front_page' );
// $wp_customize->remove_section( 'title_tagline' );
$wp_customize->remove_section( 'colors' );
$wp_customize->remove_section( 'header_image' );
$wp_customize->remove_section( 'background_image' );
// $wp_customize->remove_section( 'nav' );
// $wp_customize->remove_section( 'themes' );
// $wp_customize->remove_section( 'featured_content' );
// $wp_customize->remove_panel( 'widgets' );
}
add_action( 'customize_register',
'emersonthis_remove_customizer_options',
30);
// Hide Unused Dashboard Menu Items
function emersonthis_custom_menu_page_removing() {
// remove_menu_page( 'index.php' ); //Dashboard
// remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
// remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
// remove_menu_page( 'themes.php' ); //Appearance
// remove_menu_page( 'plugins.php' ); //Plugins
// remove_menu_page( 'users.php' ); //Users
// remove_menu_page( 'tools.php' ); //Tools
// remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'emersonthis_custom_menu_page_removing' );
// If the goal is to actually prevent a user from accessing those controls, then you will need to modify the capabilities of the user’s role.
global $wp_roles; // global class
$role = 'author';
$cap = 'delete_published_posts';
$wp_roles->remove_cap( $role, $cap );
// Adds instruction text after the post title input
function emersonthis_edit_form_after_title() {
$tip = '<strong>TIP:</strong> To create a single line break use SHIFT+RETURN. By default, RETURN creates a new paragraph.';
echo '<p style="margin-bottom:0;">'.$tip.'</p>';
}
add_action(
'edit_form_after_title',
'emersonthis_edit_form_after_title'
);
<?php
// put this into wp-config.php
define( 'DISALLOW_FILE_EDIT', true );
?>