• Resolved Ward Graham

    (@eagrayhamgmailcom)


    This will fix the dismiss problem of the retirement banner. This works for me. However please test and take preclusions when editing files directly. Enjoy!

    Append this directly to the end of USPS-simple-shipping.php. This bypasses the broken JavaScript enqueue process and manually sets the exact site transient the plugin is looking for (uspssimple-retirement-notice).

    // --- USPS Simple Notice Hotfix ---
    add_action('wp_ajax_usps_simple_force_dismiss', function() {
    set_site_transient('uspssimple-retirement-notice', true, 0);
    wp_die();
    });

    add_action('admin_footer', function() {
    if (get_site_transient('uspssimple-retirement-notice')) {
    return;
    }
    ?>
    <script>
    jQuery(document).ready(function($) {
    // Use event delegation to catch the click before WP core removes the element
    $(document).on('click', '.notice[data-dismissible="uspssimple-retirement-notice"] .notice-dismiss', function() {
    $.post(ajaxurl, {
    action: 'usps_simple_force_dismiss'
    });
    });
    });
    </script>
    <?php
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Ward Graham

    (@eagrayhamgmailcom)

    Bug Report: Missing/Broken JS for Retirement Notice Dismissal

    The USPS WebTools API Retirement notice reappears on every page load.

    While src/Plugin.php correctly evaluates DismissibleNotices::dismissed($noticeId) on line 65, and DismissibleNotices.php contains the logic to set the site transient, the frontend JavaScript required to fire the AJAX request (dismiss-notice.js) is either missing from the build, failing to enqueue, or failing to bind to the .notice-dismiss element generated by WordPress core.

    Proposed Structural Fix:
    Ensure DismissibleNotices::init() is being called during bootstrap, and verify dismiss-notice.js is included in the production build.

    If the script is present but failing due to a race condition with WP Core’s notice teardown, use event delegation to ensure the AJAX call fires:

    javascript $(document).on('click', '.notice[data-dismissible="uspssimple-retirement-notice"] .notice-dismiss', function() { // AJAX POST logic here });

    Alternatively, you can append this self-contained polyfill to the main plugin file to handle the transient state directly:

    php add_action('wp_ajax_usps_simple_force_dismiss', function() { set_site_transient('uspssimple-retirement-notice', true, 0); wp_die(); }); add_action('admin_footer', function() { if (get_site_transient('uspssimple-retirement-notice')) return; ?> <script> jQuery(document).ready(function($) { $(document).on('click', '.notice[data-dismissible="uspssimple-retirement-notice"] .notice-dismiss', function() { $.post(ajaxurl, { action: 'usps_simple_force_dismiss' }); }); }); </script> <?php });

    Plugin Author Dan

    (@dangoodman)

    Thank you for the report.

    The retirement notice has been removed in 1.18.0.

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

You must be logged in to reply to this topic.