The MU forums have moved to WordPress.org

installation of plugins (6 posts)

  1. prashantiyengar
    Member
    Posted 17 years ago #

    Hi,
    I just installed Wordpress MU and think its really fabulous. I had some trouble getting plugins for Wordpress working with wordpress mu. Specifically, when I'd try to activate any plugin, I would receive an error which looked like "Fatal error: Cannot redeclare class [classname.php] in file [filename.php].."

    I was able to solve this by editing the file in question and enclosing the class with the following code

    if (!class_exists("my_class")) {
    class my_class {
    // yada...
    }
    }

    I found this solution in a reply to a wordpress forum post at:
    http://wordpress.org/support/topic/52702?replies=7

    I've been able to install several wordpress plugins using this workaround. I dont know if this is likely to create problems later, but for now it seems to be doing fine.

    Just wanted to record it here in case someone else encounters the same problem.

  2. drmike
    Member
    Posted 17 years ago #

    Might help us help others if you gave us specifics :)

  3. prashantiyengar
    Member
    Posted 17 years ago #

    ?
    I thought this post was quite elaborate!
    Okay, lets take the example of the category2email plugin.

    When you copy the file cat2email.php to the plugins folder and activate it from the plugins interface, it generates this error.


    Fatal error: Cannot redeclare cat2email_menu() (previously declared in /{MYSERVERPATH}/wp-content/mu-plugins/cat2email.php:12) in /{MYSERVERPATH}/wp-content/mu-plugins/cat2email.php on line 11

    When you open the file cat2email.php, it looks like this

    <?php
    /*
    Plugin Name: cat2email
    Plugin URI: http://www.skippy.net/blog/plugins
    Description: Sends an email to a specified address on a per-category basis. Copyright 2005 Scott Merrill, licensed under the GPL.
    Version: 2.1
    Author: Scott Merrill
    Author URI: http://www.skippy.net/
    */
    function cat2email_menu() {
    add_management_page('Category To Email', 'Category2Email', 'manage_options', __FILE__, 'c2e_manage');
    }
    //////////////////
    function cat2email ($post_ID = 0) {
    global $wpdb, $c2e_token;
    if (! $post_ID) { return; }
    yada yada yada
    ?>

    What you need to do is to insert changes so that it looks like this:

    <?php
    /*
    Plugin Name: cat2email
    Plugin URI: http://www.skippy.net/blog/plugins
    Description: Sends an email to a specified address on a per-category basis. Copyright 2005 Scott Merrill, licensed under the GPL.
    Version: 2.1
    Author: Scott Merrill
    Author URI: http://www.skippy.net/
    */
    if (!function_exists("cat2email_menu")){
    function cat2email_menu() {
    add_management_page('Category To Email', 'Category2Email', 'manage_options', __FILE__, 'c2e_manage');
    }
    //////////////////
    }
    ?>

    Dont forget the trailing "}".
    I have tried this with many plugins and widgets.

    Hope this helps.

  4. Ovidiu
    Member
    Posted 17 years ago #

    at a first glance that looked nice, but I have this sort of problem with the rolemanager:

    after modifying a role I get this error:

    Fatal error: Cannot redeclare class rolemanager in /var/www/web5/web/wp-content/plugins/role-manager/role-manager.php on line 0

    but the change I wanted to do has been done. Now if I use what you suggest, I do not see the error anymore, the changes are done too, but I am on a blank page, so I'd rather be stuck with my error, at least I know there are some problems to be solved...

  5. stgoos
    Member
    Posted 17 years ago #

    Ovidiu,

    Did you ever manage to get Role Manager working with WPMU? I also want to use this plugin with WPMU but cannot find a hack to enable it properly :(

  6. dizzy99
    Member
    Posted 17 years ago #

    Have you tried the same plugins in the normal plugins directory instead of the mu plugins directory ?

    Silly question i know but your not copying the plugins into both directories by any chance ? Plugins and mu-plugins ?

    As the latter auto executes the plugin and would explain why your classes are already defined if you try and activate in the control panel.

    The only reason i ask is because of what you said

    Specifically, when I'd try to activate any plugin, I would receive an error which looked like "Fatal error: Cannot redeclare class [classname.php] in file [filename.php].."

About this Topic

  • Started 17 years ago by prashantiyengar
  • Latest reply from dizzy99