WordPress: Enable the theme editor for Multisite

March 25, 2013

Let me start out by saying that I do not recommend using this method. I am writing it down to remember later if needed. There are some very good security reasons why editing themes is not allowed in WordPress multisite. In this particular instance the theme editor was required as there was literally no other method to alter theme files. It should also be noted that this method alters core WordPress files.  That means if you upgrade you will lose your changes. If you do not upgrade though you are a chump. Either way you lose. When if have time to develop a better method I will update you here.

So here we go. In order to enable the theme editor in a WordPress Multisite install you will need to open the theme-editor.php file at

wp-admin/theme-editor.php

At the beginning of the file comment the following lines ( please comment and not remove so you can restore them later! )

if ( is_multisite() && ! is_network_admin() ) {
	wp_redirect( network_admin_url( 'theme-editor.php' ) );
	exit();
}

if ( !current_user_can('edit_themes') )
	wp_die('
'.__('You do not have sufficient permissions to edit templates for this site.').'

');

This section of the file should now look like

/*
if ( is_multisite() && ! is_network_admin() ) {
	wp_redirect( network_admin_url( 'theme-editor.php' ) );
	exit();
}

if ( !current_user_can('edit_themes') )
	wp_die('
'.__('You do not have sufficient permissions to edit templates for this site.').'

'); */

Remember, this is very insecure! Use at your own risk and expect in an uncontrolled environment that you WILL be hacked.

One thought on “WordPress: Enable the theme editor for Multisite

  1. Shaun Geisert (November 6, 2016)

    Hey there, just to make the above code more secure, I wouldn’t comment out both if statements, but would instead do this:

    /*
    if ( is_multisite() && ! is_network_admin() ) {
    wp_redirect( network_admin_url( ‘theme-editor.php’ ) );
    exit();
    }
    */

    if ( !is_admin() )
    wp_die(”.__(‘You do not have sufficient permissions to edit templates for this site.’).”);