From 2e7534bae70ccce6bde7ff35c885cb2c0bdafa26 Mon Sep 17 00:00:00 2001 From: sherwinski Date: Wed, 13 May 2026 22:01:56 -0700 Subject: [PATCH] fix: [SDK-4340] skip enqueueing metabox assets for disallowed post types When viewing a Custom Post Type that has not been added to "Additional Custom Post Types" in the OneSignal admin settings, the metabox PHP correctly skips rendering, but the metabox JS/CSS were still enqueued on every post edit screen. The JS would then log a console error because the expected DOM elements (os_update, os_options, etc.) were missing. Gate the enqueue with the same onesignal_is_post_type_allowed() check already used to register the metabox so the script only loads when the metabox is actually present. --- v3/onesignal-metabox/onesignal-metabox.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v3/onesignal-metabox/onesignal-metabox.php b/v3/onesignal-metabox/onesignal-metabox.php index 9a9d23c..4c56580 100644 --- a/v3/onesignal-metabox/onesignal-metabox.php +++ b/v3/onesignal-metabox/onesignal-metabox.php @@ -123,6 +123,10 @@ function onesignal_metabox($post) function onesignal_meta_files() { + if (!onesignal_is_post_type_allowed(get_post_type())) { + return; + } + $cache_buster = ceil(time() / 3600); // updates every hour wp_enqueue_script( 'onesignal_metabox_js',