fatal error "Cannot redeclare class OAuthSignatureMethod_HMAC_S with elegant themes extra and d

Comments plus causing fatal error “Cannot redeclare class OAuthSignatureMethod_HMAC_SHA1” with elegant themes extra and divi but works fine with other themes.

Extra and Divi themes working fine with other plugins so may be nothing wrong with those.

  • Predrag Dubajic
    • Support

    Hey Vin,

    Hope you’re doing well today :slight_smile:

    Those themes and Comments+ plugin are probably both using OAuth and that could cause such issues.

    Can you go to Settings > Comments Plus panel, enable “Pages on my website already use javascript from Facebook” option and see if it works after that?

    Best regards,

    Predrag

  • Vin
    • Flash Drive

    Hi Predrag

    Thanks for your reply. This is what I did:

    Deleted Comments plus

    Changed the themes back to default

    Installed and activated Comments Plus anb enabled “Pages on my website already use javascript from Facebook” and added client ids to Google and Facebook

    Changed the theme back to extra

    Same error

    Please help

    Thanks

  • Adam Czajczyk
    • Support Gorilla

    Hello Vin,

    It seems that the theme includes some add-on/plugin that’s forcing WP to load some library that’s using “OAuthSignaturemethod_HMAC_SHA1” class.

    The issue here is that such class should be called with PHP

    if (!exists

    condition. Our plugin does that so it seems that none of the themes you tried (except default one) does it the proper way. Therefore, if plugin declares class before theme does (which is a default WP workflow) an error comes up.

    That said, it would be great to contact theme developers and point it out to them as it may be causing also other issues with other themes/for other users.

    The “quick and dirty” hack would be to force Comments+ plugin to initialize after the theme is already loaded and setup. Please note however that it’s not recommended to edit plugin files directly and it may lead to other unexpected issues. Also the changes may be lost upon plugin’s update so that’d be at your own risk.

    The “hack” would be to edit /wp-content/plugins/comments-plus/comments-plus.php file

    and change its last line from

    add_action('plugins_loaded', 'wdcp_initialize');

    to

    add_action('after_setup_theme', 'wdcp_initialize');

    or

    add_action('init', 'wdcp_initialize');

    or

    add_action('wp_loaded', 'wdcp_initialize');

    One of these fixes should do the trick I think. Please make sure though that prior to making changes you made a full backup of your site. Let me also stress out again that this is not a recommended way of fixing the issue and the only solid and WP-compliant solution here would be to convince theme developers to update their themes to declare “OAuthSignaturemethod_HMAC_SHA1” class conditionally.

    Best regards,

    Adam

  • Vin
    • Flash Drive

    Hi Adam

    Thanks it worked.

    I tried all 3.

    add_action(‘after_setup_theme’, ‘wdcp_initialize’:wink:; — Didn’t work

    add_action(‘init’, ‘wdcp_initialize’:wink:; & add_action(‘wp_loaded’, ‘wdcp_initialize’:wink:; – Worked fine

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.