• Resolved Bettega

    (@bettega)


    Greetings,

    I have a multisite installs with six sites and six themes (one for each site). The themes are activated on a per-site basis (super-admin->sites->edit).

    Is there a way to grant to the site admin the permission to edit the theme allowed for his site? It seems that only a super-admin can edit themes, that’s true?

Viewing 8 replies - 16 through 23 (of 23 total)
  • jrue

    (@jrue)

    Hi All, I found the issues. It was two things.

    First: the Fatal Error I had was because I stupidly named the plugin the same name “theme-editor.php” Once I changed to something unique, that error went away.

    The permissions error dallasm was getting was fixed by commenting out a few additional lines of code in wp-admin/theme-editor.php

    Here is what needs to be commented out:

    /*
    if ( is_multisite() && ! is_network_admin() ) {
    	wp_redirect( network_admin_url( 'theme-editor.php' ) );
    	exit();
    }
    
    if ( !current_user_can('edit_themes') )
    	wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
    */

    Thanks again for the plugin. Works perfectly. I need these for a controlled classroom instruction where each student will have a unique theme they are editing, so there is no concern of one person editing a theme that another WP site is using.

    jroakes

    (@jroakes)

    Glad you got it working!

    jroakes

    (@jroakes)

    You might want to use the following code…

    /*
    if ( is_multisite() && ! is_network_admin() ) {
    	wp_redirect( network_admin_url( 'theme-editor.php' ) );
    	exit();
    }
    */
    
    if ( !is_admin() )
    	wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');

    …instead of just commenting out both if statements. The first if statement is ok because it is just really checking to see if this is a MU install. The second one checks to see if you should be there. I would at least put an is_admin() test.

    I also need for single site admins to be able to edit their themes, but I don´t understand the first part: “1. Place this text in a file in the wp-content/mu-plugins/ folder.” I created a .php file within the plugins folder. Or I have to create a folder and then a .php? I am not a programmer! can some one explain the whole thing “for dummies” please?

    This is what I did:

    1. created wp-content/plugins/chachacha.php
    2. chachacha.php has the code:

    <?php
    add_action(‘admin_menu’, ‘_add_themes_utility_editor’, 102);

    function _add_themes_utility_editor() {
    // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook
    add_submenu_page(‘themes.php’, _x(‘Editor’, ‘theme editor’), _x(‘Editor’, ‘theme editor’), ‘switch_themes’, ‘theme-editor.php’);}

    // get the the role object
    $editor = get_role(‘administrator’);
    // add $cap capability to this role object
    $editor->add_cap(‘edit_theme_options’);
    $editor->add_cap(‘edit_themes’);

    ?>

    3. “comment out” (that I guess is to put /* and */ at the beggining and end of the thing to be commented out)

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

    if ( !current_user_can(‘edit_themes’) )
    wp_die(‘<p>’.__(‘You do not have sufficient permissions to edit templates for this site.’).'</p>’);
    */

    4. Changed:

    $themes = get_themes();
    With:
    $themes = get_allowed_themes(); (notice I put a space before and after the = sign)

    5. Went to one users dashboard and … nothing… The edit link does not show. I am frustrated it´s been 3 days looking for this functionality…

    I am using WP 3.1.2 Multisite and BuddyPress.

    Thank you! and pls somebody pls help me!!! (as if I was a 3 year old!)

    @donmcint

    In order for a plugin to show up in the admin, you have to put some comment code at the top so that WordPress will detect is as a plugin. At the top of “chachacha.php” add the following:

    <?php
    /*
    Plugin Name: Theme Editor
    Plugin URI: http://wordpress.org/extend/plugins/
    Description: Allows Theme Editor in MU
    Author: jroakes
    Version: 0.1
    */

    After that, go into network admin, not just the admin of each site.

    Hope this helps.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    However…

    This is what I did:

    1. created wp-content/plugins/chachacha.php
    2. chachacha.php has the code:

    And

    “1. Place this text in a file in the wp-content/mu-plugins/ folder.”

    is your problem. Move the file to MU-PLUGINS. If the folder doesn’t exist, you can safely create it.

    And you don’t need a plugin header for files in mu-plugins, though they’re nice 🙂

    Thx guys!! It worked!!

    My suggestion to WordPress is to let WP Multisites installs to have it own Theme and Plugin repository folders and when a member creates a site he should be able to use the themes and plugins, but copied in their own sub.site so they can edit without changing other member´s themes and plugins.

    Thank you JRUE and IPSTENU!!!!!!!!!!

    Donald.

    PS: and JROAKES for creating it!!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    That would defeat the point of MultiSite, alas.

    The idea of MultiSite is ‘You’re running your own version of WP.com’

    You can’t edit your theme there (you can edit CSS, and other per-theme settings, but NOT the theme files). Can’t edit plugins either.

    There IS a reason for this: If someone can edit your PHP files, then they can use that to write code that gives them access to the REST of your install and, logically, your server. It’s a HUGE security hole, and WP would rather protect you.

    If everyone needs to be able to customize their themes and plugins, you’re better off with multiple single, separate, sites.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Multisite Theme Edit’ is closed to new replies.