Skip to content

fix: repoint notice-dismiss callback to Notification::dismiss (regular_dismiss does not exist)#1

Closed
ineagu wants to merge 1 commit into
masterfrom
fix/notification-dismiss-callback
Closed

fix: repoint notice-dismiss callback to Notification::dismiss (regular_dismiss does not exist)#1
ineagu wants to merge 1 commit into
masterfrom
fix/notification-dismiss-callback

Conversation

@ineagu

@ineagu ineagu commented Jun 16, 2026

Copy link
Copy Markdown

Problem

Promotions::load() registers the notice-dismiss AJAX handler against a method that does not exist:

// src/Modules/Promotions.php
if ( get_option( $this->option_neve, false ) !== true ) {
    add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' );
}

Notification::regular_dismiss is defined nowhere in the SDK (git log -S "function regular_dismiss" is empty across history). The real handler is Notification::dismiss, which the SDK already references for this exact action (e.g. the remove_action( …, [ 'ThemeisleSDK\Modules\Notification', 'dismiss' ] ) in the neve-themes-popular branch).

When the broken callback is reached — a user dismissing a review notice (<product_key>_review_flag) or a promo notice on a non-Neve site — WordPress invokes it through WP_Hook and PHP fatals:

Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback,
class ThemeisleSDK\Modules\Notification does not have a method "regular_dismiss"
in wp-includes/class-wp-hook.php:341

→ HTTP 500 / blank admin page on dismiss.

Why it's intermittent (and portfolio-wide)

  • The callback is registered by the Promotions module for any product bundling the SDK — not plugin-specific. Reproduced identically with Otter (otter_review_flag) and FreshRank (freshrank_ai_review_flag).
  • Present in every 3.3.x release checked; introduced long ago and never had a matching method definition.
  • Neve sites are immune — the themeisle_sdk_promotions_neve_installed !== true gate closes, so the bad callback is never registered.
  • On non-Neve sites it's latent until the broken callback is actually reached (i.e. Notification::dismiss doesn't wp_die() first), which is why many sites never hit it.

Fix

One line: point the callback at the existing Notification::dismiss. It's idempotent with the registration already done in Notification::load() (identical static callback + priority de-duplicates in WP_Hook), so sites that were never hitting the bug see no behavioural change; sites that were fataling now dismiss cleanly.

Verified locally against the real Notification class by dispatching the hook exactly as class-wp-hook.php:341 does: with the fix the dismiss succeeds; before it, the verbatim production TypeError is raised.

🤖 Generated with Claude Code

Promotions::load() registered the notice-dismiss AJAX handler against
`ThemeisleSDK\Modules\Notification::regular_dismiss`, a method that does
not exist anywhere in the SDK (the real handler is `Notification::dismiss`,
which the SDK already references for this same action elsewhere).

On a non-Neve site (`themeisle_sdk_promotions_neve_installed !== true`)
the gated branch registers this callback. When the broken callback is
reached as a user dismisses a review/promo notice, WordPress calls it via
WP_Hook (call_user_func_array) and PHP fatals:

    Uncaught TypeError: call_user_func_array(): Argument #1 ($callback)
    must be a valid callback, class ThemeisleSDK\Modules\Notification
    does not have a method "regular_dismiss"

The result is an HTTP 500 / blank admin page on dismiss. This affects
every product bundling the SDK (verified across versions 3.3.x); Neve
sites are spared only because the gate closes before the registration.

Fix: point the callback at the existing `Notification::dismiss`. It is
idempotent with the registration in `Notification::load()` (same static
callback + priority de-dupes in WP_Hook), so behaviour is unchanged on
sites that were never hitting the bug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ineagu

ineagu commented Jun 16, 2026

Copy link
Copy Markdown
Author

@HardeepAsrani I got this by change on my ionutn site from freshrank and I know we sometimes get 1 star reviews from users and I was trying to find a root cause, I replicated & tested the fix, not sure if I am missing anything

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a fatal error in the Promotions module by repointing the wp_ajax_themeisle_sdk_dismiss_notice AJAX handler from a non-existent ThemeisleSDK\Modules\Notification::regular_dismiss method to the existing ThemeisleSDK\Modules\Notification::dismiss method, preventing invalid-callback crashes when dismissing SDK notices.

Changes:

  • Update the Promotions module’s notice-dismiss AJAX callback to ThemeisleSDK\Modules\Notification::dismiss.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ineagu

ineagu commented Jun 16, 2026

Copy link
Copy Markdown
Author

Closing — opened against the wrong repo. Moved to the canonical repo: Codeinwp/themeisle-sdk-main.

@ineagu ineagu closed this Jun 16, 2026
@ineagu ineagu deleted the fix/notification-dismiss-callback branch June 16, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants