• Hi,

    Great plugin! I’ve found a bug in the code which generates double error notices throughout WordPress. On lines 155–159 in the file soundcloud-is-gold.php, the plugin has the following code:

    // display default admin notice
    function soundcloud_is_gold_add_settings_errors() {
        settings_errors();
    }
    add_action('admin_notices', 'soundcloud_is_gold_add_settings_errors');

    This takes care of displaying any error messages as well as the confirmation when the plugin saves data. However, since the code is not written to display those messages only on the SoundCloud is Gold Settings admin page, it also, unfortunately, displays these notice messages on all other Settings pages, including Settings->General. Since WordPress already takes care of adding the notices to those pages, this results in double notices throughout. Go to Settings->General, click Save Changes, and you will see two messages letting you know that data was saved, rather than one.

    The above code should be wrapped in a check that only adds the settings_errors() to the soundcloud-is-gold settings page, no others. Replace the above code with the following and it will fix it:

    // display default admin notice
    function soundcloud_is_gold_add_settings_errors() {
        if (get_current_screen()->parent_base === 'soundcloud-is-gold/soundcloud-is-gold') {
    	    settings_errors();
        }
    }
    add_action('admin_notices', 'soundcloud_is_gold_add_settings_errors');

    Hope this helps others.
    David

    The page I need help with: [log in to see the link]

  • The topic ‘Bug Report with Fix: Plugin Generates Double “Settings Saved” messages’ is closed to new replies.