The MU forums have moved to WordPress.org

Theme Editor (23 posts)

  1. cOffEEtArIaN
    Member
    Posted 15 years ago #

    Hi all , I was looking for "Theme Editor" for my WordPress MU 2.8.1 and since it was disabled and by searching online looked like there are not that many good suggestions I looked at the code and if anyone wants to have The built-in Theme Editor they will need to edit one (1) file only and does not need to upload anything.

    File is "mu.php" located under "/wp-admin/includes" folder.

    to edit from WordPress MU 2.8.1:
    line 532
    from: "unset( $submenu['themes.php'][10] ); // always remove the themes editor"
    to: "//unset( $submenu['themes.php'][10] ); // always remove the themes editor"

    line 1190
    from :"if ( strpos( $_SERVER['PHP_SELF'], $page ) ) {"
    to:"if ( strpos( $_SERVER['PHP_SELF'], $page ) && !is_site_admin() ) {"

  2. andrea_r
    Moderator
    Posted 15 years ago #

    and by searching online looked like there are not that many good suggestions

    that's because they were all suggestions that worked previous to 2.8.1, which changed how the theme editor was disabled.

    Glad you tracked it down.

  3. honewatson
    Member
    Posted 15 years ago #

    Around line 1174 blank out the following also:

    /*
    $pages = array( 'theme-editor.php', 'plugin-editor.php' );
    foreach( $pages as $page ) {
    if ( strpos( $_SERVER['PHP_SELF'], $page ) ) {
    wp_die( __('Page disabled by the administrator') );
    }
    }
    */

  4. cOffEEtArIaN
    Member
    Posted 15 years ago #

    /*
    $pages = array( 'theme-editor.php', 'plugin-editor.php' );
    foreach( $pages as $page ) {
    if ( strpos( $_SERVER['PHP_SELF'], $page ) ) {
    wp_die( __('Page disabled by the administrator') );
    }
    }
    */

    actually you don't need to remove them , just need to change to "if ( strpos( $_SERVER['PHP_SELF'], $page ) && !is_site_admin() ) {" so that only Admin have access to it ..

  5. cafespain
    Member
    Posted 15 years ago #

    Remember though, if you change a theme, it changes for ALL blogs that have that theme. And if you make an error on that theme, then all the blogs using it will be unavailable until you fix it.

    Just saying.

  6. andrea_r
    Moderator
    Posted 15 years ago #

    Yep. But it's a handy workaround if you're trying to tweak a theme before going live and ftp is taking for-freaking-ever. ;P

  7. kalchas
    Member
    Posted 15 years ago #

    I wound up needing to re-enable the theme editor for a client who's used to using it. Of course you always want to be careful when editing themes on MU because the changes are global (affect all blogs/sites using the install).

    Initially, I wanted to try something like:
    remove_action( 'admin_init', 'disable_some_pages' );

    in my plugin, which, of course, doesn't work. But since I really like to tread lightly when editing core files, I wasn't happy making all the changes suggested here in the core. I wound up instead commenting out:
    add_action( 'admin_init', 'disable_some_pages' );
    from line 1205 of /wp-admin/includes/mu.php and adding in my own customized 'disable_some_pages' function into the plugin (copied the core function, then edited it inside of the plugin).

    My 'disable_some_pages' function is wrapped into a class that owns the plugin, so I add it back in like this:
    add_action( 'admin_init', array ( &$myPluginNameHere, 'disable_some_pages' ));

    I'd publish more of the source code here, but it's a premium plugin I'm working on for a specific client, and I don't think they'd be too happy with me if I did.

    Anyhow, hope that's at least somewhat helpful as a possible alternate approach.

    Btw, I also chose to modify the 'if' statements with && is_site_admin() to re-enable the pages I wanted to have available.

  8. davist11
    Member
    Posted 15 years ago #

    Just as an update on this, in 2.8.4a

    this change is on line 55 not 532
    from: "unset( $submenu['themes.php'][10] ); // always remove the themes editor"
    to: "//unset( $submenu['themes.php'][10] ); // always remove the themes editor"

    this change is on line 1218 not 1190
    from :"if ( strpos( $_SERVER['PHP_SELF'], $page ) ) {"
    to:"if ( strpos( $_SERVER['PHP_SELF'], $page ) && !is_site_admin() ) {"

  9. ChisomoK
    Member
    Posted 15 years ago #

    you guys are Godsends =D
    thanks.

  10. dickkirkland
    Member
    Posted 15 years ago #

    When using the "userthemes" plugin, the new version seems to activate the theme editor on a blog by blog basis, which seems safer to me. Performing the edits above will produce what seems to be 2 theme editors in the left menu of the blog using userthemes. Using the userthemes plugin seems to make it easier on the admin, not having to enable the them editor as stated above.

    This is a great thread, don't get me wrong. I'm sure there is a scenario when the steps above are needed vs. using userthemes. I just thought I'd mention this as I'm doing the latter.

  11. andrea_r
    Moderator
    Posted 15 years ago #

    As far as I know, the userthemes plugin gives each user their own copy of the theme to work with. themes are no longer shared in that case.

    I've enabled the theme editor as above in some cases because it's been quicker than other ways I had available for quick theme edits (while doing dev work), or it's my own install or a locked-down install.

    In other installs I've one of the CSS editor plugins for users to tweak & override the css of their themes.

  12. missou55
    Member
    Posted 15 years ago #

    I'm sorry but I didn't understand what I have to do.
    Can you resum please from the beginin ?

  13. Andrepan
    Member
    Posted 15 years ago #

    Update on 2.8.5.2

    The changes are on line 556 and 1128 instead of 532 and 1190

  14. kesness
    Member
    Posted 15 years ago #

    Just want to say, this works, and is awesome! Thanks a lot!

  15. Neo2000
    Member
    Posted 14 years ago #

    Note: I am a n00b at this

    Didnt work for me :(

    I have WPMU and BuddyPress running before i tried to change the mu.php file. Nothing i've done to the mu.php file seems to work. Heck, i even changed the error message hoping to see if it was reaching there but for some reason it wasn't.

  16. ancawonka
    Member
    Posted 14 years ago #

    Neo2000: That's usually a sign that you are editing the wrong file... :)

  17. kgjerstad
    Member
    Posted 14 years ago #

    The plugin "Userthemes Revisited" doesn't work on my Wordpress MU 2.8.4 with Buddypress 1.1.3.

    The entire plugin features work except for the editor window itself.

    http://wpmudevorg.wordpress.com/project/Userthemes-Revisited

  18. jmorganson
    Member
    Posted 14 years ago #

    Locations for v2.9.1 are 697 and 1378.

    I am guessing that this will be an option inside the admin interface going forward after the merge. Does anyone know?

  19. andrea_r
    Moderator
    Posted 14 years ago #

    It isn't so far.

    Feel free to file a trac ticket.

    http://core.trac.wordpress.org

  20. jmorganson
    Member
    Posted 14 years ago #

    I filed a ticket here

    In the mean time I found a plugin to do this for anyone looking to do this without hacking the core files.

    http://wordpress.org/extend/plugins/enable-theme-and-plugin-editor/

  21. jmorganson
    Member
    Posted 14 years ago #

    Opps, there was a ticket already started for this here. Lots of discussion on this in that ticket.

    Looks like for now its been enabled in the current codebase. Grabbing the latest copy is another option to get the editor back.

  22. DanYork
    Member
    Posted 14 years ago #

    I found that the location in WPMU v2.9.2 was line 569 and line 1147.

    Thanks for writing this up. For quick tweaks to a theme it's nice to offer site admins the option of using the Theme Editor.

  23. andrea_r
    Moderator
    Posted 14 years ago #

    And in 3.0 it's enabled for super admins by default.

About this Topic

  • Started 15 years ago by cOffEEtArIaN
  • Latest reply from andrea_r