The MU forums have moved to WordPress.org

request: theme editor for admin (44 posts)

  1. andrea_r
    Moderator
    Posted 18 years ago #

    Well, the stuff is there in the code, near as I can tell (didn't look too close at the last build). What about enabling the theme editor area just for the site admins? It's a huge pain going into the server just to tweak a theme for users. So much so, that when I go to edit a theme in any regular WP, I start heading off to the filemanager. sigh.

    Yeah, yeah, I know -write a plugin.:) Just tossing it out here instead of leaving it in my brain, where it is quite crowded.

  2. dsader
    Member
    Posted 18 years ago #

    I enjoy userthemes.php because it does exactly what you ask. Admin is only user able to edit "system themes" any other can only edit "My themes" if I enable users one by one. By default everyone's editor is disabled.

    You've got to try it. Download from wpmudev.

    Drop in mu-plugin and you are done. Start editing themes. Every file(first level anyway) from every theme in same editor window in same drop down menu.

    A sideeffect is the blogs.dir folders now each get a themes folder where user themes are copied. Keep an eye on disk space quotas, error_logs can get big fast. I use cpanel's disk usage viewer to see if any theme folders are oddly huge. For example K2 based themes need massaging when its path to blogs-header.php changes. Striped plus needed an overhaul to correct paths. And these two themes are my favorites.

  3. mickemus
    Member
    Posted 18 years ago #

    You can limit the space for each user but I'm not sure if it is only related to the blog or if it's tied to the blogs.dir folder. If so then you can pop upload-space-plugin.php in the mu-plugins folder and limit the the upload space for each blog. Plugin is here: http://stuart.amanzi.co.nz

  4. Ovidiu
    Member
    Posted 17 years ago #

    hello,

    as I have had some difficulties using userthemes.php I am interested to enable the editor, temporary until I finish setting up the new blog I am working on, because I used the editor a lot in wp - I know its dangerous, but for now I am the only user socan someone tell me how exactly to re-enable the editor for wpmu 1.0 ?

    I found another post around here but it seems to be missing some important hints or it was using another wpmu version...

    P.S. the problems I got with userthemes are that if I enable the plugin it works ok, but when I click on Presentation => MyThemes => copy to my themes I get this error:

    Warning: mkdir() expects at most 2 parameters, 3 given in /var/www/web5/web/wp-content/plugins/userthemes.php on line 77

    If I cut out the 3rd argument which is "true" I get no error but still nothing happens....

  5. drmike
    Member
    Posted 17 years ago #

    I hate to be a pain but would someone post line 77 of that file please. I don't use the plugin myself. :)

  6. dsader
    Member
    Posted 17 years ago #

    Here's the function in my userthemes.php up to the end of the case 'copy':

    the mkdir ..."true" line(77-ish) is down here somewhere

    function my_themes() {
    $this->get_all_themes();
    $page = $_GET['page'];
    switch ($_GET['action']) {
    //Important TODO: make sure to strip ..'s and such
    case 'edit':
    if (get_option('ut_use_use_theme') != 1)
    $this->flip_mode();
    header("Location: /wp-admin/theme-editor.php?theme={$_GET['theme']}");
    break;
    case 'copy':
    $copyTheme = $_GET['theme'];
    if (!isset($copyTheme)) {
    $message = "Error: No theme selected";
    return;
    }
    $dest = $this->get_user_theme_root() . '/' . $copyTheme ;
    while (file_exists($dest . $suffix))
    $suffix = $suffix + 1;
    mkdir($dest . $suffix, 0755, true);
    $src = $this->get_system_theme_root() . '/' . $copyTheme;
    exec("/bin/cp -R $src/* $dest$suffix");
    exec("/bin/chmod -R 755 $dest$suffic"); //This is terrible
    if (count($this->userThemes) == 1) {
    //This is the first theme, so prepare the db for the switch
    $keys = array_keys($this->userThemes);
    update_option('ut_backup_user_template', $this->userThemes[$keys[0]]['Template']);
    update_option('ut_backup_user_stylesheet', $this->userThemes[$keys[0]]['Stylesheet']);
    }
    $message = "Succesfully created a copy of '$copyTheme'";
    break;

  7. drmike
    Member
    Posted 17 years ago #

    Would you please stick in the following right before that mkdir line:

    echo $dist $suffix;

    And post what you get.

    Thanks,
    -drmike

  8. Ovidiu
    Member
    Posted 17 years ago #

    you meant: echo "$dist $suffix"; I guess

    this is the result:

    Warning: mkdir() expects at most 2 parameters, 3 given in /var/www/web5/web/wp-content/mu-plugins/userthemes.php on line 78

    Successfully created a copy of 'CorporateLook'

    no changes, still the same error - no other output...
    I tried activating the theme I wanted to copy first, still the same error...

  9. Ovidiu
    Member
    Posted 17 years ago #

    ok, I guess I found out why we get those errors. I found someone explaining a similar problem with another plugin:


    Downloads: I keep getting a mkdir() error: "Warning: mkdir() expects at most 2 parameters, 3 given in […]''
    Please use the latest snapshot version (dated 14.09.2005 or above). PHP versions < 5.0.0 do not support recursive
    directory creation via mkdir().

    so it seems this plugin too, is only compatible with php version > 5

  10. twcaaron
    Member
    Posted 17 years ago #

    My host shows that they are running php5 with php4 simultaneously, but I still see the error as well. This has potential to be a really slick plugin... if only we could get it to work ;)

    Here's what I'm seeing after modifying my file as indicated:
    /var/www/web5/web/wp-content/mu-plugins/userthemes.php on line 78

    Aaron

  11. andrea_r
    Moderator
    Posted 17 years ago #

    Well, I actually read the code for the original post.

    The theme editor is gone because of this line near the top:
    wp_die( "The theme editor is disabled" );

    So, I replaced it with this:
    if( is_site_admin() == false ) {
    die( __('You do not have permission to access this page.') );
    }

    Which enables it. It still doesn't show up as an option on the menu, and I haven't tested this, so standard disclaimers apply.

    (note: this edits the original themes on the server, which means any chages affect every user using that theme.)

  12. pmilano1
    Member
    Posted 17 years ago #

    Is there a fix to make this php4 friendly?

  13. kp2575
    Member
    Posted 17 years ago #

    I did the change that andrea recommended, but I am seeing a different error that I googled and cannot find posted anywhere else in these forums.

    Warning: Invalid argument supplied for foreach() in public_html/wp-content/mu-plugins/1573835887_userthemes.php on line 167

  14. kp2575
    Member
    Posted 17 years ago #

    Also do we have a solution for the line 77 problem?

  15. kp2575
    Member
    Posted 17 years ago #

    I also get a third error message besides the line 77 problem and the 167:

    Warning: array_keys() [function.array-keys]: The first argument should be an array in public_html/wp-content/mu-plugins/1573835887_userthemes.php on line 85

  16. dsader
    Member
    Posted 17 years ago #

    Load a theme, change your theme, copy a theme, delete a theme. I recall seeing an occaisional theme/usertheme annoyance when there are no themes in the user's theme folder.

    I think the code need a tweak in it somewhere if the user's theme folder has no themes. I never looked and the problem went away.

  17. demonicume
    Member
    Posted 17 years ago #

    any working versions of this plugin?

  18. dsader
    Member
    Posted 17 years ago #

  19. Farms
    Member
    Posted 17 years ago #

    'onya dsader :)

  20. demonicume
    Member
    Posted 17 years ago #

    dsader - i've been struggling to get that damn thing working for about a month. i feel like i owe you something.

    question, how do i make it available for my users? it works fine for me, but i want my users to have access to it. i'm not seeing the option.

    thanks!

  21. Lucifix
    Member
    Posted 17 years ago #

    @dsader: i tried to use your theme and i get this error:
    [14-Jul-2007 15:38:50] PHP Warning: mkdir() expects at most 2 parameters, 3 given in /home/.../wp-content/plugins/userthemes.php on line 72

    Line 72
    mkdir($dest . $suffix, 0755, true);

    And where the hell can I find line function validate_current_theme in admin-functions.php? :)

    Thanks!!!

  22. Lucifix
    Member
    Posted 17 years ago #

    My mistake:

    [14-Jul-2007 15:47:56] PHP Warning: mkdir() expects at most 2 parameters, 3 given in /home/.../wp-content/mu-plugins/userthemes.php on line 72

  23. demonicume
    Member
    Posted 17 years ago #

    you running php 5+?

  24. dsader
    Member
    Posted 17 years ago #

    Demonicume, I am running PHP 5+. It is enabled for each user under the Site Admin menu.

  25. dsader
    Member
    Posted 17 years ago #

    Lucifx, try changing line 72 from

    mkdir($dest . $suffix, 0755, true);

    to

    mkdir($dest . $suffix, 0755);

    Reference: http://us2.php.net/manual/en/function.mkdir.php

  26. demonicume
    Member
    Posted 17 years ago #

    are all Admins supposed to have a Site Admin menu? only blog one on my site has 'site admin'. if something is wrong, this would explain a few other things for me.

  27. lunabyte
    Member
    Posted 17 years ago #

    If you are logged in as a site admin, you should have that menu available anywhere. At least, all my sites are that way.

    A regular blog admin will not ever see a "site admin" menu.

  28. demonicume
    Member
    Posted 17 years ago #

    DOH - one of my plugins - Lighter Admin Drop Menus - was causing the usertheme manager page not to load.

    great work, DS. i owe you big-big on this one.

  29. Lucifix
    Member
    Posted 17 years ago #

    @dsader: now I recived this error:
    [16-Jul-2007 09:35:29] PHP Warning: mkdir(/home/.../wp-content/blogs.dir/61/themes/sunrise-10) [function.mkdir]: No such file or directory in /home/.../wp-content/mu-plugins/userthemes.php on line 72

    @demonicume: my host is using PHP 4.4.2

  30. demonicume
    Member
    Posted 17 years ago #

    sorry to keep posting on this, but i'm not sure whats going on. i've activated some blogs. my some of my users are editing themes just fine. others dont see the options. when i log in as the user, i dont see the userthemes options, either. i've disabled/re-enabled, cleared cache, tried it from different browsers, from different machines. looking at the code, i cant see any reason it might not be working for everyone - but i'm hardly an expert.

    any ideas?

    ===edit===
    it seems that when if i - as admin - begin the process by copying to Userthemes first, then the options appear. i'm going to test this a few mo times ad get back to you. thanks.

About this Topic

  • Started 18 years ago by andrea_r
  • Latest reply from rahjabodyart