Search code examples
wordpresswordpress-themingediting

Disable WordPress theme editing from dashboard


I'm working on a client's WordPress website with only the WP dashboard access. I enabled WP theme editing option to add a CSS code snippet. But I'm worried about his website's security. Now I want to disable editing by using dashboard access only. How can it be possible? I tried to find out settings, but no luck.


Solution

  • If I understand the question correctly, you want to disable editing files via the WordPress Admin in a browser? To do so, just add this line to your functions.php file.

    define('DISALLOW_FILE_EDIT', true);
    

    To do this from the WordPress Admin, just go under Appearance > Editor. Then choose functions.php from the right-hand navigation. Just remember: if you only have access to the files using the WordPress Admin editor, then you will lose access yourself. If this is the case, consider using the following snippet:

    if ( !current_user_can('manage_options') ){
        define('DISALLOW_FILE_EDIT', true);
    }
    

    That will only disable the Editor for non-admin users.