• We’ve been using the plugin for a while now, and it’s working fine.

    However, ONLY when we visit .../wp-admin/nav-menus.php, to edit our site’s menu, do we get the following error:

    CRITICAL Cannot redeclare add_attributes_to_admin_script() (previously declared in [redacted]/wp-content/plugins/afterpay-payment-gateway-for-woocommerce/class-wc-gateway-afterpay.php:507) in [redacted]/wp-content/plugins/afterpay-payment-gateway-for-woocommerce/class-wc-gateway-afterpay.php op de lijn 507

    I cannot figure out why it is redeclared. There is no other code that uses the same method, and it seems like it’s clashing with itself, in the same file. As if the plugin is initialized twice?

    Do you have an idea what it could be?

    • This topic was modified 3 years, 5 months ago by druut.
    • This topic was modified 3 years, 5 months ago by druut.
    • This topic was modified 3 years, 5 months ago by druut.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter druut

    (@emkemk)

    It’s clashing with another plugin we’re using, called Max Mega Menu. That’s due to the fact that Max Mega Menu calls do_action( 'admin_enqueue_scripts', 'widgets.php' ) for that specific page.

    This means admin_enqueue_scripts gets fired twice, and therefore the Riverty plugin’s callback function for admin_enqueue_scripts gets declared twice.

    The easiest solution would be to wrap it with an if statement:

    if ( ! function_exists('add_attributes_to_admin_script') ) {
        ...
    }
    • This reply was modified 3 years, 5 months ago by druut.
    • This reply was modified 3 years, 5 months ago by druut.
    • This reply was modified 3 years, 5 months ago by druut.
    Thread Starter druut

    (@emkemk)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘CRITICAL Cannot redeclare add_attributes_to_admin_script()’ is closed to new replies.