Changeset 3436041
- Timestamp:
- 01/09/2026 03:27:42 PM (3 months ago)
- Location:
- push-notification/trunk
- Files:
-
- 9 edited
-
assets/public/app-pwaforwp.js (modified) (1 diff)
-
assets/public/app-pwaforwp.min.js (modified) (1 diff)
-
assets/public/app.js (modified) (1 diff)
-
assets/public/app.min.js (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
inc/admin/admin.php (modified) (4 diffs)
-
inc/frontend/pn-frontend.php (modified) (8 diffs)
-
push-notification.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
push-notification/trunk/assets/public/app-pwaforwp.js
r3383362 r3436041 4 4 firebase.initializeApp(config); 5 5 } 6 firebase.analytics();7 6 if(!messaging) 8 7 { -
push-notification/trunk/assets/public/app-pwaforwp.min.js
r3383362 r3436041 1 var config=pnScriptSetting.pn_config;if(firebase.apps.length||firebase.initializeApp(config), firebase.analytics(),!messaging)var messaging=firebase.messaging();function pushnotification_load_messaging(){messaging.onTokenRefresh((()=>{messaging.getToken().then((e=>{console.log("Token refreshed."),push_notification_setTokenSentToServer(!1),sendTokenToServer(e),resetUI()})).catch((e=>{console.log("Unable to retrieve refreshed token ",e),showToken("Unable to retrieve refreshed token ",e)}))})),addEventListener("load",(function(){if(null==function(e){for(var t=null,n=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "==a.charAt(0);)a=a.substring(1,a.length);0==a.indexOf(n)&&(t=a.substring(n.length,a.length))}return null===t&&localStorage.getItem(e)&&localStorage.getItem(e+"_expiry")>Date.now()&&(t=localStorage.getItem(e)),t}("pn_notification_block")){if(window.history.length<pnScriptSetting.popup_show_afternpageview)return!1;if("1"==pnScriptSetting.superpwa_apk_only){if("apk"!=sessionStorage.getItem("superpwa_mode"))return!1}if("1"==pnScriptSetting.pwaforwp_apk_only){if("apk"!=sessionStorage.getItem("pwaforwp_mode"))return!1}var e=1e3;pnScriptSetting.popup_show_afternseconds&&(e=1e3*parseInt(pnScriptSetting.popup_show_afternseconds)),setTimeout((function(){var e=document.getElementsByClassName("pn-wrapper");e.length>0&&(e[0].style.display="flex")}),e)}document.getElementById("pn-activate-permission_link_nothanks")&&document.getElementById("pn-activate-permission_link_nothanks").addEventListener("click",(function(){var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime());var t=document.getElementsByClassName("pn-wrapper");t&&(t[0].style.display="none")}));document.getElementById("pn-activate-permission_link")&&document.getElementById("pn-activate-permission_link").addEventListener("click",(function(){var e=document.getElementsByClassName("pn-wrapper");e&&(e[0].style.display="none"),messaging.requestPermission().then((function(){console.log("Notification permission granted.");var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,document.cookie="notification_permission=granted;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime()),localStorage.getItem("notification_permission","granted"),push_notification_isTokenSentToServer()?console.log("Token already saved"):push_notification_getRegToken()})).catch((function(e){if(Notification&&"denied"==Notification.permission){console.log("Notification permission denied.");var t=new Date;t.setDate(t.getDate()+pnScriptSetting.notification_popup_show_again),document.cookie="pn_notification_block=true;expires="+t+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",t.getTime())}else console.log("Unable to get permission to notify.",e)}))}))})),messaging.onMessage((function(e){console.log("Message received. ",e),notificationTitle=e.data.title,notificationOptions={body:e.data.body,icon:e.data.icon,image:e.data.image,vibrate:[100,50,100],data:{dateOfArrival:Date.now(),primarykey:e.data.currentCampaign,url:e.data.url}};var t=new Notification(notificationTitle,notificationOptions);t.onclick=function(n){n.preventDefault(),window.open(e.data.url,"_blank");var o=new XMLHttpRequest;o.open("POST",pnScriptSetting.ajax_url,!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send("campaign="+e.data.currentCampaign+"&nonce="+pnScriptSetting.nonce+"&action=pn_noteclick_subscribers"),t.close()}})),navigator.clearAppBadge?navigator.clearAppBadge():navigator.clearExperimentalAppBadge?navigator.clearExperimentalAppBadge():window.ExperimentalBadge&&window.ExperimentalBadge.clear()}function push_notification_getRegToken(e){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}function push_notification_setTokenSentToServer(e){window.localStorage.setItem("sentToServer",e?"1":"0")}function push_notification_isTokenSentToServer(){return"1"===window.localStorage.getItem("sentToServer")}function sendTokenToServer(e){push_notification_isTokenSentToServer()?console.log("Token already sent to server so won't send it again unless it changes"):(console.log("Sending token to server..."),push_notification_saveToken(e))}function pn_get_checket_cats(e,t){e.checked&&pn_cat_value.push(e.checked)}function push_notification_saveToken(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){4==this.readyState&&200==this.status&&(200==this.responseText.status&&push_notification_setTokenSentToServer(!0),console.log(this.responseText))};var n=pnScriptSetting.auto_segment_enabled||!1,o=[],i=[];if(console.log("Auto-segment enabled:",n),console.log("Auto categories:",pnScriptSetting.auto_categories),console.log("Auto authors:",pnScriptSetting.auto_authors),n)o=pnScriptSetting.auto_categories||[],i=pnScriptSetting.auto_authors||[],console.log("Using auto data - categories:",o,"authors:",i);else{const e=document.querySelectorAll("#pn-categories-checkboxes input:checked");for(var a=0;a<=e.length-1;a++)o.push(e[a].value);const t=document.querySelectorAll("#pn-author-checkboxes input:checked");for(a=0;a<=t.length-1;a++)i.push(t[a].value);console.log("Using manual selection - categories:",o,"authors:",i)}var r=[...i].join(","),s=[...o].join(",");console.log("Final category string:",s),console.log("Final author string:",r);var c=pushnotificationFCMGetOS(),p=pushnotificationFCMbrowserclientDetector(),l=window.location.href;t.open("POST",pnScriptSetting.ajax_url,!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.send("token_id="+e+"&category="+s+"&author="+r+"&user_agent="+p+"&os="+c+"&nonce="+pnScriptSetting.nonce+"&action=pn_register_subscribers&url="+l)}pushnotification_load_messaging();var pushnotificationFCMbrowserclientDetector=function(){var e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,n=/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,i=!o&&!!window.StyleMedia,a=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),r=(a||e)&&!!window.CSS;if(navigator.userAgent.match("CriOS"))return"Chrome ios";n=!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);var s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return n&&s?"Safari ios":n?"Safari":t?"Firefox":a?"Chrome":e?"Opera":o?"IE":i?"Edge":r?"Blink":void 0},pushnotificationFCMGetOS=function(){var e=window.navigator.userAgent,t=window.navigator.platform,n=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?n="Mac OS":-1!==["iPhone","iPad","iPod"].indexOf(t)?n="iOS":-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?n="Windows":/Android/.test(e)?n="Android":!n&&/Linux/.test(t)&&(n="Linux"),n};"0"==pnScriptSetting.pn_token_exists&&setTimeout((function(){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}),2e3),setTimeout((function(){if(document.querySelector(".pn-bell-button")){document.querySelector(".pn-bell-button").addEventListener("click",(()=>{document.cookie="pn_notification_block=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",localStorage.removeItem("pn_notification_block"),location.reload()}))}}),2e3);1 var config=pnScriptSetting.pn_config;if(firebase.apps.length||firebase.initializeApp(config),!messaging)var messaging=firebase.messaging();function pushnotification_load_messaging(){messaging.onTokenRefresh((()=>{messaging.getToken().then((e=>{console.log("Token refreshed."),push_notification_setTokenSentToServer(!1),sendTokenToServer(e),resetUI()})).catch((e=>{console.log("Unable to retrieve refreshed token ",e),showToken("Unable to retrieve refreshed token ",e)}))})),addEventListener("load",(function(){if(null==function(e){for(var t=null,n=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "==a.charAt(0);)a=a.substring(1,a.length);0==a.indexOf(n)&&(t=a.substring(n.length,a.length))}return null===t&&localStorage.getItem(e)&&localStorage.getItem(e+"_expiry")>Date.now()&&(t=localStorage.getItem(e)),t}("pn_notification_block")){if(window.history.length<pnScriptSetting.popup_show_afternpageview)return!1;if("1"==pnScriptSetting.superpwa_apk_only){if("apk"!=sessionStorage.getItem("superpwa_mode"))return!1}if("1"==pnScriptSetting.pwaforwp_apk_only){if("apk"!=sessionStorage.getItem("pwaforwp_mode"))return!1}var e=1e3;pnScriptSetting.popup_show_afternseconds&&(e=1e3*parseInt(pnScriptSetting.popup_show_afternseconds)),setTimeout((function(){var e=document.getElementsByClassName("pn-wrapper");e.length>0&&(e[0].style.display="flex")}),e)}document.getElementById("pn-activate-permission_link_nothanks")&&document.getElementById("pn-activate-permission_link_nothanks").addEventListener("click",(function(){var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime());var t=document.getElementsByClassName("pn-wrapper");t&&(t[0].style.display="none")}));document.getElementById("pn-activate-permission_link")&&document.getElementById("pn-activate-permission_link").addEventListener("click",(function(){var e=document.getElementsByClassName("pn-wrapper");e&&(e[0].style.display="none"),messaging.requestPermission().then((function(){console.log("Notification permission granted.");var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,document.cookie="notification_permission=granted;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime()),localStorage.getItem("notification_permission","granted"),push_notification_isTokenSentToServer()?console.log("Token already saved"):push_notification_getRegToken()})).catch((function(e){if(Notification&&"denied"==Notification.permission){console.log("Notification permission denied.");var t=new Date;t.setDate(t.getDate()+pnScriptSetting.notification_popup_show_again),document.cookie="pn_notification_block=true;expires="+t+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",t.getTime())}else console.log("Unable to get permission to notify.",e)}))}))})),messaging.onMessage((function(e){console.log("Message received. ",e),notificationTitle=e.data.title,notificationOptions={body:e.data.body,icon:e.data.icon,image:e.data.image,vibrate:[100,50,100],data:{dateOfArrival:Date.now(),primarykey:e.data.currentCampaign,url:e.data.url}};var t=new Notification(notificationTitle,notificationOptions);t.onclick=function(n){n.preventDefault(),window.open(e.data.url,"_blank");var o=new XMLHttpRequest;o.open("POST",pnScriptSetting.ajax_url,!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send("campaign="+e.data.currentCampaign+"&nonce="+pnScriptSetting.nonce+"&action=pn_noteclick_subscribers"),t.close()}})),navigator.clearAppBadge?navigator.clearAppBadge():navigator.clearExperimentalAppBadge?navigator.clearExperimentalAppBadge():window.ExperimentalBadge&&window.ExperimentalBadge.clear()}function push_notification_getRegToken(e){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}function push_notification_setTokenSentToServer(e){window.localStorage.setItem("sentToServer",e?"1":"0")}function push_notification_isTokenSentToServer(){return"1"===window.localStorage.getItem("sentToServer")}function sendTokenToServer(e){push_notification_isTokenSentToServer()?console.log("Token already sent to server so won't send it again unless it changes"):(console.log("Sending token to server..."),push_notification_saveToken(e))}function pn_get_checket_cats(e,t){e.checked&&pn_cat_value.push(e.checked)}function push_notification_saveToken(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){4==this.readyState&&200==this.status&&(200==this.responseText.status&&push_notification_setTokenSentToServer(!0),console.log(this.responseText))};var n=pnScriptSetting.auto_segment_enabled||!1,o=[],i=[];if(console.log("Auto-segment enabled:",n),console.log("Auto categories:",pnScriptSetting.auto_categories),console.log("Auto authors:",pnScriptSetting.auto_authors),n)o=pnScriptSetting.auto_categories||[],i=pnScriptSetting.auto_authors||[],console.log("Using auto data - categories:",o,"authors:",i);else{const e=document.querySelectorAll("#pn-categories-checkboxes input:checked");for(var a=0;a<=e.length-1;a++)o.push(e[a].value);const t=document.querySelectorAll("#pn-author-checkboxes input:checked");for(a=0;a<=t.length-1;a++)i.push(t[a].value);console.log("Using manual selection - categories:",o,"authors:",i)}var r=[...i].join(","),s=[...o].join(",");console.log("Final category string:",s),console.log("Final author string:",r);var c=pushnotificationFCMGetOS(),p=pushnotificationFCMbrowserclientDetector(),l=window.location.href;t.open("POST",pnScriptSetting.ajax_url,!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.send("token_id="+e+"&category="+s+"&author="+r+"&user_agent="+p+"&os="+c+"&nonce="+pnScriptSetting.nonce+"&action=pn_register_subscribers&url="+l)}pushnotification_load_messaging();var pushnotificationFCMbrowserclientDetector=function(){var e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,n=/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,i=!o&&!!window.StyleMedia,a=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),r=(a||e)&&!!window.CSS;if(navigator.userAgent.match("CriOS"))return"Chrome ios";n=!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);var s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return n&&s?"Safari ios":n?"Safari":t?"Firefox":a?"Chrome":e?"Opera":o?"IE":i?"Edge":r?"Blink":void 0},pushnotificationFCMGetOS=function(){var e=window.navigator.userAgent,t=window.navigator.platform,n=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?n="Mac OS":-1!==["iPhone","iPad","iPod"].indexOf(t)?n="iOS":-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?n="Windows":/Android/.test(e)?n="Android":!n&&/Linux/.test(t)&&(n="Linux"),n};"0"==pnScriptSetting.pn_token_exists&&setTimeout((function(){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}),2e3),setTimeout((function(){if(document.querySelector(".pn-bell-button")){document.querySelector(".pn-bell-button").addEventListener("click",(()=>{document.cookie="pn_notification_block=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",localStorage.removeItem("pn_notification_block"),location.reload()}))}}),2e3); -
push-notification/trunk/assets/public/app.js
r3383362 r3436041 18 18 console.log('Pushnotification not supported '); 19 19 } 20 }) 21 firebase.analytics(); 20 }) 22 21 function pushnotification_load_messaging(reg){ 23 22 // [START refresh_token] -
push-notification/trunk/assets/public/app.min.js
r3383362 r3436041 1 var config=pnScriptSetting.pn_config;firebase.apps.length||firebase.initializeApp(config);var swsource=pnScriptSetting.swsource;const messaging=firebase.messaging();function pushnotification_load_messaging(e){if(messaging.onTokenRefresh((()=>{messaging.getToken().then((e=>{console.log("Token refreshed."),push_notification_setTokenSentToServer(!1),sendTokenToServer(e),resetUI()})).catch((e=>{console.log("Unable to retrieve refreshed token ",e),showToken("Unable to retrieve refreshed token ",e)}))})),null==function(e){for(var t=null,n=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "==a.charAt(0);)a=a.substring(1,a.length);0==a.indexOf(n)&&(t=a.substring(n.length,a.length))}return null===t&&localStorage.getItem(e)&&localStorage.getItem(e+"_expiry")>Date.now()&&(t=localStorage.getItem(e)),t}("pn_notification_block")){if(window.history.length<pnScriptSetting.popup_show_afternpageview)return!1;pnScriptSetting.popup_show_afternseconds&&1e3*parseInt(pnScriptSetting.popup_show_afternseconds);var t=document.getElementsByClassName("pn-wrapper");setTimeout((function(){t&&t[0]&&(t[0].style.display="flex")}),pnScriptSetting.popup_show_afternseconds)}document.getElementById("pn-activate-permission_link_nothanks").addEventListener("click",(function(){var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime());var t=document.getElementsByClassName("pn-wrapper");t&&(t[0].style.display="none")})),document.getElementById("pn-activate-permission_link").addEventListener("click",(function(){var e=document.getElementsByClassName("pn-wrapper");e&&(e[0].style.display="none"),messaging.requestPermission().then((function(){console.log("Notification permission granted.");var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,document.cookie="notification_permission=granted;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime()),localStorage.getItem("notification_permission","granted"),push_notification_isTokenSentToServer()?console.log("Token already saved"):push_notification_getRegToken()})).catch((function(e){if(Notification&&"denied"==Notification.permission){console.log("Notification permission denied.");var t=new Date;t.setDate(t.getDate()+pnScriptSetting.notification_popup_show_again),document.cookie="pn_notification_block=true;expires="+t+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",t.getTime())}else console.log("Unable to get permission to notify.",e)}))})),messaging.onMessage((function(t){console.log("Message received. ",t);let n=t.data.title,o={body:t.data.body,icon:t.data.icon,image:t.data.image,vibrate:[100,50,100],data:{dateOfArrival:Date.now(),primarykey:t.data.currentCampaign,url:t.data.url}};e.showNotification(n,o)})),navigator.clearAppBadge?navigator.clearAppBadge():navigator.clearExperimentalAppBadge?navigator.clearExperimentalAppBadge():window.ExperimentalBadge&&window.ExperimentalBadge.clear()}function push_notification_getRegToken(e){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}function push_notification_setTokenSentToServer(e){window.localStorage.setItem("sentToServer",e?"1":"0")}function push_notification_isTokenSentToServer(){return"1"===window.localStorage.getItem("sentToServer")}function sendTokenToServer(e){push_notification_isTokenSentToServer()?console.log("Token already sent to server so won't send it again unless it changes"):(console.log("Sending token to server..."),push_notification_saveToken(e))}function pn_get_checket_cats(e,t){e.checked&&pn_cat_value.push(e.checked)}function push_notification_saveToken(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){4==this.readyState&&200==this.status&&(200==this.responseText.status&&push_notification_setTokenSentToServer(!0),console.log(this.responseText))};var n=pnScriptSetting.auto_segment_enabled||!1,o=[],i=[];if(console.log("Auto-segment enabled:",n),console.log("Auto categories:",pnScriptSetting.auto_categories),console.log("Auto authors:",pnScriptSetting.auto_authors),n)o=pnScriptSetting.auto_categories||[],i=pnScriptSetting.auto_authors||[],console.log("Using auto data - categories:",o,"authors:",i);else{const e=document.querySelectorAll("#pn-categories-checkboxes input:checked");for(var a=0;a<=e.length-1;a++)o.push(e[a].value);const t=document.querySelectorAll("#pn-author-checkboxes input:checked");for(a=0;a<=t.length-1;a++)i.push(t[a].value);console.log("Using manual selection - categories:",o,"authors:",i)}var r=[...i].join(","),s=[...o].join(",");console.log("Final category string:",s),console.log("Final author string:",r);var c=pushnotificationFCMGetOS(),p=pushnotificationFCMbrowserclientDetector(),g=window.location.href;t.open("POST",pnScriptSetting.ajax_url,!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.send("token_id="+e+"&category="+s+"&author="+r+"&user_agent="+p+"&os="+c+"&nonce="+pnScriptSetting.nonce+"&action=pn_register_subscribers&url="+g)}window.addEventListener("load",(function(){"serviceWorker"in navigator?navigator.serviceWorker.register(swsource,{scope:pnScriptSetting.scope}).then((function(e){messaging.useServiceWorker(e),pushnotification_load_messaging(e),console.log("Congratulations!!Service Worker Registered ServiceWorker scope: ",e.scope)})).catch((function(e){console.log("ServiceWorker registration failed: ",e)})):console.log("Pushnotification not supported ")})) ,firebase.analytics();var pushnotificationFCMbrowserclientDetector=function(){var e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,n=/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,i=!o&&!!window.StyleMedia,a=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),r=(a||e)&&!!window.CSS;if(navigator.userAgent.match("CriOS"))return"Chrome ios";n=!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);var s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return n&&s?"Safari ios":n?"Safari":t?"Firefox":a?"Chrome":e?"Opera":o?"IE":i?"Edge":r?"Blink":void 0},pushnotificationFCMGetOS=function(){var e=window.navigator.userAgent,t=window.navigator.platform,n=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?n="Mac OS":-1!==["iPhone","iPad","iPod"].indexOf(t)?n="iOS":-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?n="Windows":/Android/.test(e)?n="Android":!n&&/Linux/.test(t)&&(n="Linux"),n};"0"==pnScriptSetting.pn_token_exists&&setTimeout((function(){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}),2e3);1 var config=pnScriptSetting.pn_config;firebase.apps.length||firebase.initializeApp(config);var swsource=pnScriptSetting.swsource;const messaging=firebase.messaging();function pushnotification_load_messaging(e){if(messaging.onTokenRefresh((()=>{messaging.getToken().then((e=>{console.log("Token refreshed."),push_notification_setTokenSentToServer(!1),sendTokenToServer(e),resetUI()})).catch((e=>{console.log("Unable to retrieve refreshed token ",e),showToken("Unable to retrieve refreshed token ",e)}))})),null==function(e){for(var t=null,n=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "==a.charAt(0);)a=a.substring(1,a.length);0==a.indexOf(n)&&(t=a.substring(n.length,a.length))}return null===t&&localStorage.getItem(e)&&localStorage.getItem(e+"_expiry")>Date.now()&&(t=localStorage.getItem(e)),t}("pn_notification_block")){if(window.history.length<pnScriptSetting.popup_show_afternpageview)return!1;pnScriptSetting.popup_show_afternseconds&&1e3*parseInt(pnScriptSetting.popup_show_afternseconds);var t=document.getElementsByClassName("pn-wrapper");setTimeout((function(){t&&t[0]&&(t[0].style.display="flex")}),pnScriptSetting.popup_show_afternseconds)}document.getElementById("pn-activate-permission_link_nothanks").addEventListener("click",(function(){var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime());var t=document.getElementsByClassName("pn-wrapper");t&&(t[0].style.display="none")})),document.getElementById("pn-activate-permission_link").addEventListener("click",(function(){var e=document.getElementsByClassName("pn-wrapper");e&&(e[0].style.display="none"),messaging.requestPermission().then((function(){console.log("Notification permission granted.");var e=new Date;e.setDate(e.getDate()+parseInt(pnScriptSetting.notification_popup_show_again)),document.cookie="pn_notification_block=true;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,document.cookie="notification_permission=granted;expires="+e.toUTCString()+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",e.getTime()),localStorage.getItem("notification_permission","granted"),push_notification_isTokenSentToServer()?console.log("Token already saved"):push_notification_getRegToken()})).catch((function(e){if(Notification&&"denied"==Notification.permission){console.log("Notification permission denied.");var t=new Date;t.setDate(t.getDate()+pnScriptSetting.notification_popup_show_again),document.cookie="pn_notification_block=true;expires="+t+";path="+pnScriptSetting.cookie_scope,localStorage.setItem("pn_notification_block",!0),localStorage.setItem("pn_notification_block_expiry",t.getTime())}else console.log("Unable to get permission to notify.",e)}))})),messaging.onMessage((function(t){console.log("Message received. ",t);let n=t.data.title,o={body:t.data.body,icon:t.data.icon,image:t.data.image,vibrate:[100,50,100],data:{dateOfArrival:Date.now(),primarykey:t.data.currentCampaign,url:t.data.url}};e.showNotification(n,o)})),navigator.clearAppBadge?navigator.clearAppBadge():navigator.clearExperimentalAppBadge?navigator.clearExperimentalAppBadge():window.ExperimentalBadge&&window.ExperimentalBadge.clear()}function push_notification_getRegToken(e){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}function push_notification_setTokenSentToServer(e){window.localStorage.setItem("sentToServer",e?"1":"0")}function push_notification_isTokenSentToServer(){return"1"===window.localStorage.getItem("sentToServer")}function sendTokenToServer(e){push_notification_isTokenSentToServer()?console.log("Token already sent to server so won't send it again unless it changes"):(console.log("Sending token to server..."),push_notification_saveToken(e))}function pn_get_checket_cats(e,t){e.checked&&pn_cat_value.push(e.checked)}function push_notification_saveToken(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){4==this.readyState&&200==this.status&&(200==this.responseText.status&&push_notification_setTokenSentToServer(!0),console.log(this.responseText))};var n=pnScriptSetting.auto_segment_enabled||!1,o=[],i=[];if(console.log("Auto-segment enabled:",n),console.log("Auto categories:",pnScriptSetting.auto_categories),console.log("Auto authors:",pnScriptSetting.auto_authors),n)o=pnScriptSetting.auto_categories||[],i=pnScriptSetting.auto_authors||[],console.log("Using auto data - categories:",o,"authors:",i);else{const e=document.querySelectorAll("#pn-categories-checkboxes input:checked");for(var a=0;a<=e.length-1;a++)o.push(e[a].value);const t=document.querySelectorAll("#pn-author-checkboxes input:checked");for(a=0;a<=t.length-1;a++)i.push(t[a].value);console.log("Using manual selection - categories:",o,"authors:",i)}var r=[...i].join(","),s=[...o].join(",");console.log("Final category string:",s),console.log("Final author string:",r);var c=pushnotificationFCMGetOS(),p=pushnotificationFCMbrowserclientDetector(),g=window.location.href;t.open("POST",pnScriptSetting.ajax_url,!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.send("token_id="+e+"&category="+s+"&author="+r+"&user_agent="+p+"&os="+c+"&nonce="+pnScriptSetting.nonce+"&action=pn_register_subscribers&url="+g)}window.addEventListener("load",(function(){"serviceWorker"in navigator?navigator.serviceWorker.register(swsource,{scope:pnScriptSetting.scope}).then((function(e){messaging.useServiceWorker(e),pushnotification_load_messaging(e),console.log("Congratulations!!Service Worker Registered ServiceWorker scope: ",e.scope)})).catch((function(e){console.log("ServiceWorker registration failed: ",e)})):console.log("Pushnotification not supported ")}));var pushnotificationFCMbrowserclientDetector=function(){var e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,n=/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,i=!o&&!!window.StyleMedia,a=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),r=(a||e)&&!!window.CSS;if(navigator.userAgent.match("CriOS"))return"Chrome ios";n=!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);var s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;return n&&s?"Safari ios":n?"Safari":t?"Firefox":a?"Chrome":e?"Opera":o?"IE":i?"Edge":r?"Blink":void 0},pushnotificationFCMGetOS=function(){var e=window.navigator.userAgent,t=window.navigator.platform,n=null;return-1!==["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(t)?n="Mac OS":-1!==["iPhone","iPad","iPod"].indexOf(t)?n="iOS":-1!==["Win32","Win64","Windows","WinCE"].indexOf(t)?n="Windows":/Android/.test(e)?n="Android":!n&&/Linux/.test(t)&&(n="Linux"),n};"0"==pnScriptSetting.pn_token_exists&&setTimeout((function(){messaging.getToken().then((function(e){e?(push_notification_saveToken(e),console.log(e),push_notification_setTokenSentToServer(!0)):(console.log("No Instance ID token available. Request permission to generate one."),push_notification_setTokenSentToServer(!1))})).catch((function(e){console.log("An error occurred while retrieving token. ",e),push_notification_setTokenSentToServer(!1)}))}),2e3); -
push-notification/trunk/changelog.txt
r3406744 r3436041 1 = 1.47 (09 January 2026) = 2 * Fixed: GA Cookies Rejected Due to Invalid Domain from Plugin’s analytics.js Script #178 3 * Fixed: Push notificaion is not working when theme does not have wp_footer() #176 4 * Fixed: Push notifications loads before jQuery creating error #173 5 1 6 = 1.46 (01 December 2025) = 2 7 * Added: Promotion Banner BFCM #177 -
push-notification/trunk/inc/admin/admin.php
r3383362 r3436041 144 144 wp_enqueue_media(); 145 145 wp_enqueue_style( 'wp-color-picker' ); 146 wp_enqueue_script( 'push_notification_script', PUSH_NOTIFICATION_PLUGIN_URL."assets/main-admin-script{$min}.js", array( 'wp-color-picker' ), PUSH_NOTIFICATION_PLUGIN_VERSION, true ); 147 wp_enqueue_script('push_notification_script', PUSH_NOTIFICATION_PLUGIN_URL."assets/main-admin-script{$min}.js", array('jquery'), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 146 wp_enqueue_script('push_notification_script', PUSH_NOTIFICATION_PLUGIN_URL."assets/main-admin-script{$min}.js", array('jquery', 'wp-color-picker'), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 148 147 wp_enqueue_style('push-notification-style', PUSH_NOTIFICATION_PLUGIN_URL."assets/main-admin-style{$min}.css", array('dashboard'), PUSH_NOTIFICATION_PLUGIN_VERSION, 'all'); 149 148 wp_enqueue_style('push-notification_select2', PUSH_NOTIFICATION_PLUGIN_URL.'assets/select2.min.css', array('dashboard'), PUSH_NOTIFICATION_PLUGIN_VERSION, 'all' ); 150 wp_enqueue_script('push_notification_select2', PUSH_NOTIFICATION_PLUGIN_URL.'assets/select2.min.js', array( ),PUSH_NOTIFICATION_PLUGIN_VERSION, true );149 wp_enqueue_script('push_notification_select2', PUSH_NOTIFICATION_PLUGIN_URL.'assets/select2.min.js', array( 'jquery' ),PUSH_NOTIFICATION_PLUGIN_VERSION, true ); 151 150 wp_enqueue_script('select2-extended-script', PUSH_NOTIFICATION_PLUGIN_URL. 'assets/select2-extended.min.js', array( 'jquery' ), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 152 151 … … 586 585 esc_html__('Popup show after n pages view', 'push-notification'),// Title 587 586 array( $this, 'pn_key_popupshowafternpageview_callback'),// Callback 587 'push_notification_user_settings_section', // Page slug 588 'push_notification_notification_settings_section' // Settings Section ID 589 ); 590 add_settings_field( 591 'pn_key_banner_location_select', // ID 592 esc_html__('Popup Banner Load Location', 'push-notification'),// Title 593 array( $this, 'pn_key_banner_location_callback'),// Callback 588 594 'push_notification_user_settings_section', // Page slug 589 595 'push_notification_notification_settings_section' // Settings Section ID … … 1529 1535 ); 1530 1536 PN_Field_Generator::get_input_select('notification_position', 'bottom-left', $data, 'pn_push_on_publish', ''); 1537 } 1538 1539 public function pn_key_banner_location_callback(){ 1540 $data = array( 1541 'footer'=> esc_html__('Footer (Recommended)', 'push-notification'), 1542 'body'=> esc_html__('Body', 'push-notification'), 1543 'header'=> esc_html__('Header', 'push-notification'), 1544 ); 1545 PN_Field_Generator::get_input_select('banner_location', 'footer', $data, 'pn_push_on_publish', ''); 1531 1546 } 1532 1547 … … 2507 2522 'posttypes'=> array("post","page"), 2508 2523 'notification_position'=> 'bottom-left', 2524 'banner_location'=> 'footer', 2509 2525 'popup_banner_message'=> esc_html__('Enable Notifications', 'push-notification'), 2510 2526 'popup_banner_accept_btn'=> esc_html__('OK', 'push-notification'), -
push-notification/trunk/inc/frontend/pn-frontend.php
r3383362 r3436041 34 34 return false; 35 35 } 36 // Get banner location setting 37 $settings = push_notification_settings(); 38 $banner_location = isset($settings['banner_location']) ? $settings['banner_location'] : 'footer'; 39 36 40 if( function_exists('pwaforwp_init_plugin') ){ 37 41 $addNotification = false; … … 46 50 47 51 add_action("wp_enqueue_scripts", array($this, 'pwaforwp_enqueue_pn_scripts'), 34 ); 48 add_action("wp_footer", array($this, 'pn_notification_confirm_banner'), 34);52 $this->pn_add_banner_hook($banner_location); 49 53 } 50 54 }elseif(function_exists('superpwa_addons_status')){ 51 55 add_filter( 'superpwa_manifest', array($this, 'manifest_add_gcm_id') ); 52 56 add_action("wp_enqueue_scripts", array($this, 'superpwa_enqueue_pn_scripts'), 34 ); 53 add_action("wp_footer", array($this, 'pn_notification_confirm_banner'), 34);57 $this->pn_add_banner_hook($banner_location); 54 58 add_filter( "superpwa_sw_template", array($this, 'superpwa_add_pn_swcode'),10,1); 55 59 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reasone: Not processing form … … 61 65 //manifest 62 66 add_action('wp_head',array($this, 'manifest_add_homescreen'),1); 63 add_action("wp_footer", array($this, 'pn_notification_confirm_banner'), 34);67 $this->pn_add_banner_hook($banner_location); 64 68 //create manifest 65 69 add_action( 'rest_api_init', array( $this, 'register_manifest_rest_route' ) ); … … 364 368 ?> 365 369 <script type="text/javascript"> 366 jQuery(document).ready(function($) { 367 $("body").on("click", ".pn_js_custom_pagination", function(e) { 368 e.preventDefault(); 369 var page = $(this).attr('page'); 370 var atts = $('#pn_campaings_custom_div').attr('attr'); 371 var shortcode_attr = JSON.parse(atts); 372 $.ajax({ 373 url: pn_setings.ajaxurl, 374 type: "post", 375 dataType: 'html', 376 data: { 377 action: 'pn_get_compaigns_front', 378 page: page, 379 nonce: pn_setings.remote_nonce, 380 attr: shortcode_attr 381 }, 382 success: function(response) { 383 $("#pn_campaings_custom_div").html(response); 384 }, 385 error: function() { 386 alert("Something went wrong."); 370 (function() { 371 'use strict'; 372 373 // Wait for DOM to be ready 374 if (document.readyState === 'loading') { 375 document.addEventListener('DOMContentLoaded', initPagination); 376 } else { 377 initPagination(); 378 } 379 380 function initPagination() { 381 // Null check for pn_setings 382 if (typeof pn_setings === 'undefined' || !pn_setings) { 383 console.error('pn_setings is not defined'); 384 return; 385 } 386 387 // Null check for required pn_setings properties 388 if (!pn_setings.ajaxurl || !pn_setings.remote_nonce) { 389 console.error('pn_setings.ajaxurl or pn_setings.remote_nonce is missing'); 390 return; 391 } 392 393 // Event delegation on body 394 document.body.addEventListener('click', function(e) { 395 // Check if clicked element or its parent has the pagination class 396 var target = e.target.closest('.pn_js_custom_pagination'); 397 if (!target) { 398 return; 387 399 } 400 401 e.preventDefault(); 402 403 // Null check for page attribute 404 var page = target.getAttribute('page'); 405 if (!page) { 406 console.error('Page attribute is missing'); 407 return; 408 } 409 410 // Null check for campaigns div 411 var campaignsDiv = document.getElementById('pn_campaings_custom_div'); 412 if (!campaignsDiv) { 413 console.error('pn_campaings_custom_div element not found'); 414 return; 415 } 416 417 // Null check for attr attribute 418 var atts = campaignsDiv.getAttribute('attr'); 419 if (!atts) { 420 console.error('attr attribute is missing'); 421 return; 422 } 423 424 // Parse JSON with error handling 425 var shortcode_attr; 426 try { 427 shortcode_attr = JSON.parse(atts); 428 } catch (error) { 429 console.error('Failed to parse JSON from attr attribute:', error); 430 alert('Invalid data format.'); 431 return; 432 } 433 434 // Prepare form data 435 var formData = new FormData(); 436 formData.append('action', 'pn_get_compaigns_front'); 437 formData.append('page', page); 438 formData.append('nonce', pn_setings.remote_nonce); 439 formData.append('attr', JSON.stringify(shortcode_attr)); 440 441 // Make AJAX request using fetch API 442 fetch(pn_setings.ajaxurl, { 443 method: 'POST', 444 body: formData 445 }) 446 .then(function(response) { 447 if (!response.ok) { 448 throw new Error('Network response was not ok'); 449 } 450 return response.text(); 451 }) 452 .then(function(html) { 453 if (html && campaignsDiv) { 454 campaignsDiv.innerHTML = html; 455 } else { 456 throw new Error('Empty response received'); 457 } 458 }) 459 .catch(function(error) { 460 console.error('Error fetching campaigns:', error); 461 alert('Something went wrong.'); 462 }); 388 463 }); 389 } );390 }) ;464 } 465 })(); 391 466 </script> 392 467 <?php … … 664 739 wp_enqueue_script('pn-script-app-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/application.min.js', array(), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 665 740 666 wp_enqueue_script('pn-script-analytics', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/analytics.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true);667 $data = "window.dataLayer = window.dataLayer || [];668 function gtag(){dataLayer.push(arguments);}669 gtag('js', new Date());";670 wp_add_inline_script('pn-script-analytics', $data, 'after');671 672 741 wp_enqueue_script('pn-script-messaging-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/messaging.min.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 673 742 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; … … 679 748 wp_enqueue_script('pn-script-app-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/application.min.js', array(), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 680 749 681 wp_enqueue_script('pn-script-analytics', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/analytics.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true);682 $data = "window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());";683 wp_add_inline_script('pn-script-analytics', $data, 'after');684 750 wp_enqueue_script('pn-script-messaging-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/messaging.min.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 685 751 $settings = $this->json_settings(); … … 690 756 public function superpwa_enqueue_pn_scripts(){ 691 757 wp_enqueue_script('pn-script-app-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/application.min.js', array(), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 692 wp_enqueue_script('pn-script-analytics', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/analytics.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true);693 $data = "window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());";694 wp_add_inline_script('pn-script-analytics', $data, 'after');695 758 wp_enqueue_script('pn-script-messaging-frontend', PUSH_NOTIFICATION_PLUGIN_URL.'assets/public/messaging.min.js', array('pn-script-app-frontend'), PUSH_NOTIFICATION_PLUGIN_VERSION, true); 696 759 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; … … 953 1016 } 954 1017 return $device; 1018 } 1019 1020 /** 1021 * Add banner hook based on selected location with fallback 1022 */ 1023 function pn_add_banner_hook($location = 'footer'){ 1024 switch($location){ 1025 case 'header': 1026 // Hook to wp_head 1027 add_action('wp_head', array($this, 'pn_notification_confirm_banner'), 999); 1028 break; 1029 case 'body': 1030 // Hook to wp_body_open (WordPress 5.2+) 1031 add_action('wp_body_open', array($this, 'pn_notification_confirm_banner'), 1); 1032 break; 1033 case 'footer': 1034 default: 1035 // Default: Hook to wp_footer 1036 add_action('wp_footer', array($this, 'pn_notification_confirm_banner'), 34); 1037 break; 1038 } 955 1039 } 956 1040 -
push-notification/trunk/push-notification.php
r3406744 r3436041 5 5 Description: Push Notifications allow admins to automatically notify their audience whenever new content or custom notices are published on the site. 6 6 Author: Magazine3 7 Version: 1.4 67 Version: 1.47 8 8 Author URI: http://pushnotifications.io/ 9 9 Text Domain: push-notification … … 18 18 define('PUSH_NOTIFICATION_PLUGIN_DIR', plugin_dir_path( __FILE__ )); 19 19 define('PUSH_NOTIFICATION_PLUGIN_URL', plugin_dir_url( __FILE__ )); 20 define('PUSH_NOTIFICATION_PLUGIN_VERSION', '1.4 6');20 define('PUSH_NOTIFICATION_PLUGIN_VERSION', '1.47'); 21 21 define('PUSH_NOTIFICATION_PLUGIN_BASENAME', plugin_basename(__FILE__)); 22 22 … … 302 302 </div>'; 303 303 } 304 305 /* * BFCM Banner Integration306 * Loads assets from assets/css and assets/js307 */308 add_action('admin_enqueue_scripts', 'push_notification_enqueue_bfcm_assets');309 310 function push_notification_enqueue_bfcm_assets($hook) {311 312 313 if ( $hook !== 'toplevel_page_push-notification') {314 return;315 }316 317 // 2. define settings318 $expiry_date_str = '2025-12-25 23:59:59';319 $offer_link = 'https://pushnotifications.io/home/upgrade';320 321 // 3. Expiry Check (Server Side)322 if ( current_time('timestamp') > strtotime($expiry_date_str) ) {323 return;324 }325 326 // 4. Register & Enqueue CSS327 wp_enqueue_style(328 'pn-bfcm-style',329 PUSH_NOTIFICATION_PLUGIN_URL. 'assets/css/bfcm-style.css',330 array(),331 PUSH_NOTIFICATION_PLUGIN_VERSION332 );333 334 // 5. Register & Enqueue JS335 wp_enqueue_script(336 'pn-bfcm-script',337 PUSH_NOTIFICATION_PLUGIN_URL. 'assets/js/bfcm-script.js',338 array('jquery'), // jQuery dependency339 PUSH_NOTIFICATION_PLUGIN_VERSION,340 true341 );342 343 // 6. Data Pass (PHP to JS)344 wp_localize_script('pn-bfcm-script', 'bfcmData', array(345 'targetDate' => $expiry_date_str,346 'offerLink' => $offer_link347 ));348 } -
push-notification/trunk/readme.txt
r3406744 r3436041 4 4 Tested up to: 6.9 5 5 Requires PHP: 5.6.20 6 Stable tag: 1.4 66 Stable tag: 1.47 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 102 102 103 103 == Changelog == 104 = 1.47 (09 January 2026) = 105 * Fixed: GA Cookies Rejected Due to Invalid Domain from Plugin’s analytics.js Script #178 106 * Fixed: Push notificaion is not working when theme does not have wp_footer() #176 107 * Fixed: Push notifications loads before jQuery creating error #173 108 109 = 1.46 (01 December 2025) = 110 * Added: Promotion Banner BFCM #177 111 * Tested: WordPress version upto 6.9 112 104 113 = 1.45 (23 October 2025) = 105 114 * Fixed: Push notification changes were not reflected in the multisite setup. #168
Note: See TracChangeset
for help on using the changeset viewer.