diff --git a/v3/onesignal-admin/onesignal-admin.js b/v3/onesignal-admin/onesignal-admin.js
index 8892fc2..1db13df 100644
--- a/v3/onesignal-admin/onesignal-admin.js
+++ b/v3/onesignal-admin/onesignal-admin.js
@@ -3,6 +3,10 @@ window.addEventListener("DOMContentLoaded", () => {
const sendToMobileInfoDiv = document.querySelector(".mobile-app .information");
const utmParamsHelpIcon = document.querySelector(".utm-params .help");
const utmParamsInfoDiv = document.querySelector(".utm-params .information");
+ const customPostTypesHelpIcon = document.querySelector(".custom-post-types .help");
+ const customPostTypesInfoDiv = document.querySelector(".custom-post-types .information");
+ const notificationOnPostFromPluginHelpIcon = document.querySelector(".notification-on-post-from-plugin .help");
+ const notificationOnPostFromPluginInfoDiv = document.querySelector(".notification-on-post-from-plugin .information");
const setupToggleAction = (helpIcon, infoDiv) => {
if (helpIcon && infoDiv) {
@@ -15,6 +19,8 @@ window.addEventListener("DOMContentLoaded", () => {
setupToggleAction(sendToMobileHelpIcon, sendToMobileInfoDiv);
setupToggleAction(utmParamsHelpIcon, utmParamsInfoDiv);
+ setupToggleAction(customPostTypesHelpIcon, customPostTypesInfoDiv);
+ setupToggleAction(notificationOnPostFromPluginHelpIcon, notificationOnPostFromPluginInfoDiv);
});
window.addEventListener("DOMContentLoaded", () => {
@@ -24,13 +30,17 @@ window.addEventListener("DOMContentLoaded", () => {
const autoSendCheckbox = document.querySelector("#auto-send");
const sendToMobileCheckbox = document.querySelector("#send-to-mobile");
const saveButton = document.querySelector("#save-settings-button");
+ const customPostTypesInput = document.querySelector("#custom-post-types");
+ const notificationOnPostFromPluginCheckbox = document.querySelector("#notification-on-post-from-plugin");
- if (appIdInput && apiKeyInput && autoSendCheckbox && sendToMobileCheckbox && utmInput && saveButton) {
+ if (appIdInput && apiKeyInput && autoSendCheckbox && sendToMobileCheckbox && utmInput && saveButton && customPostTypesInput && notificationOnPostFromPluginCheckbox) {
const initialAppId = appIdInput.value;
const initialApiKey = apiKeyInput.value;
const initialUtmInput = utmInput.value;
const initialAutoSend = autoSendCheckbox.checked;
const initialSendToMobile = sendToMobileCheckbox.checked;
+ const initialCustomPostTypes = customPostTypesInput.value;
+ const initialNotificationOnPostFromPlugin = notificationOnPostFromPluginCheckbox.checked;
function isValidUUID(uuid) {
const uuidRegex =
@@ -60,8 +70,10 @@ window.addEventListener("DOMContentLoaded", () => {
const utmChanged = utmInput.value !== initialUtmInput;
const autoSendChanged = autoSendCheckbox.checked !== initialAutoSend;
const sendToMobileChanged = sendToMobileCheckbox.checked !== initialSendToMobile;
+ const customPostTypesChanged = customPostTypesInput.value !== initialCustomPostTypes;
+ const notificationOnPostFromPluginChanged = notificationOnPostFromPluginCheckbox.checked !== initialNotificationOnPostFromPlugin;
- return appIdChanged || apiKeyChanged || autoSendChanged || sendToMobileChanged || utmChanged;
+ return appIdChanged || apiKeyChanged || autoSendChanged || sendToMobileChanged || utmChanged || customPostTypesChanged || notificationOnPostFromPluginChanged;
}
function toggleSaveButton() {
@@ -87,9 +99,10 @@ window.addEventListener("DOMContentLoaded", () => {
});
utmInput.addEventListener("input", toggleSaveButton);
-
autoSendCheckbox.addEventListener("change", toggleSaveButton);
sendToMobileCheckbox.addEventListener("change", toggleSaveButton);
+ customPostTypesInput.addEventListener("input", toggleSaveButton);
+ notificationOnPostFromPluginCheckbox.addEventListener("change", toggleSaveButton);
// Initial state on page load
toggleSaveButton();
diff --git a/v3/onesignal-admin/onesignal-admin.php b/v3/onesignal-admin/onesignal-admin.php
index c14c552..6098440 100644
--- a/v3/onesignal-admin/onesignal-admin.php
+++ b/v3/onesignal-admin/onesignal-admin.php
@@ -36,10 +36,18 @@ function admin_files()
$onesignal_settings['utm_additional_url_params'] = sanitize_text_field($_POST['utm_additional_url_params']);
}
+ if (isset($_POST['allowed_custom_post_types'])) {
+ $onesignal_settings['allowed_custom_post_types'] = sanitize_text_field($_POST['allowed_custom_post_types']);
+ }
+
// Save the auto send notifications setting
$auto_send = isset($_POST['onesignal_auto_send']) ? 1 : 0;
$onesignal_settings['notification_on_post'] = $auto_send;
+ // Save the notification on post from plugin setting
+ $notification_on_post_from_plugin = isset($_POST['notification_on_post_from_plugin']) ? 1 : 0;
+ $onesignal_settings['notification_on_post_from_plugin'] = $notification_on_post_from_plugin;
+
// Save the mobile subscribers setting
$send_to_mobile = isset($_POST['onesignal_send_to_mobile']) ? 1 : 0;
$onesignal_settings['send_to_mobile_platforms'] = $send_to_mobile;
@@ -147,6 +155,31 @@ function onesignal_admin_page()
+
+
+