WP Smush Pro API not connected

I installed WP Smush Pro and in the settings I see "API not connected" and "Service Unavailable!" button at the bottom. I have disabled all cache plugins and still get the same message. Please advise.

  • Bojan Radonic
    • Head of Support

    Hey there @Rajeev,

    Hope you're well today welcome to the WPMU DEV Community!

    Do you have the WPMU DEV dashboard installed on that site? It's required to connect to our Smush server.

    If you have it installed can you check that you are indeed logged into your WPMU DEV Dashboard.

    Looking forward for your response.

    Best regards,
    Bojan

  • Hive Minder
    • Design Lord, Child of Thor

    Hi,

    I had the same issue. I found that when you have defined your API key in wp-config, SmushIt will not connect to the server. If however, you have the WPMUDev dashboard plugin installed and use the form based login method to login to your account, SmushIt will then connect to the server.

    My way of explanation, I took the following steps to resolved the issues:
    1. Removed my license key from wp-config.php
    2. Reloaded the WPMUDev dashboard in WordPress
    3. The login form then showed
    4. I logged into my account
    5. Went to the SmushIt page in the WordPress dashboard
    6. The API was then connected
    7. Readded the license key to wp-config.php
    8. SmushIt API keeps connected to the server

    WPMUDev, please can you fix this bug so that we don't have to follow these steps each time we activate the SmushIt plugin.

    Thanks,
    Mike

  • Michael Bissett
    • Recruit

    Hey @Hive Minder Dev Team,

    The login form method would ordinarily be used here (and you would need to have our Dashboard plugin installed, as our API requires that), but I would like to ask, when you had your license key (API Key?) entered into your wp-config.php, you did have our Dashboard plugin enabled, correct?

    What was the define that you used? :slight_smile:

    Please advise,
    Michael

  • Hive Minder
    • Design Lord, Child of Thor

    Hi,

    I did indeed have dashboard plugin installed and activated - I used it to install the SmushIt plugin :slight_smile:

    The issue might also have to do whether you are running WordPress locally or on staging/production. When I first had the issue and used the steps I outlined in an earlier post, I was running WordPress locally using Mamp Pro. I later pushed the site up to my staging environment and had no issues with the API connection.

    I am using the following constant in my wp-config file:
    define('WPMUDEV_APIKEY', 'foo');

    Regards,
    Mike

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    when you login to the dashboard, it adds the API key to one of the DB options tables, smushit actually uses this option in the DB to determine whether it will work or not, so you can actually uninstall the dashboard plugin afterwards as the key will stay in the DB (as long as you still have a valid subscription) it will continue working whether the dashboard is present or not.

    Hope this helps

  • Hive Minder
    • Design Lord, Child of Thor

    Ah right. So this exposes where the issue is...

    In your SmushIt plugin you haven't catered for the use-case (like me) where users have done the following:

    1. Installed WordPress
    2. Added the license key to wp-config
    3. Installed the dashboard plugin

    In such cases, because I have never used the login for in the dashboard plugin, there is no key written to the options table in the db. When I then try to install SmushIt, it's looking for that key in the database but it doesn't exist.

    It therefore suggests that the SmushIt plugin needs to be modified to look for the license key in both the options table and wp-config.php to see if it can find it in either place.

    Mike

  • Vaughan
    • Support/SLS MockingJay

    hi,

    Ok, I understand :slight_smile:

    I will have a word with the developer and see if we can get this added to the plugin.

    In the meantime, you can add this yourself.

    open the file wp-smushit-pro.php

    find the following line;

    $wpmudev_apikey = get_site_option( 'wpmudev_apikey' );

    Replace with;

    if(defined('WPMUDEV_APIKEY')) {
            $wpmudev_apikey = WPMUDEV_APIKEY;
        } else {
            $wpmudev_apikey = get_site_option( 'wpmudev_apikey' );
        }

    Hopefully that should work then & fall back to the DB option if APIKEY isn't defined.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.