文件操作 - admin-notifications.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/popup-maker/dist/packages/admin-notifications.js
编辑文件内容
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{NotificationItem:()=>x,NotificationPanel:()=>C,STORE_NAME:()=>c,init:()=>O,store:()=>d});const n=window.wp.domReady;var i=e.n(n);const o=window.wp.element,a=window.wp.data,s=window.wp.apiFetch;var r=e.n(s);const c="popup-maker/admin-notifications",l={items:[],isLoading:!1,hasLoaded:!1,error:null},u={fetchStart:()=>({type:"FETCH_START"}),fetchSuccess:e=>({type:"FETCH_SUCCESS",items:e}),fetchError:e=>({type:"FETCH_ERROR",error:e}),dismissLocal:e=>({type:"DISMISS_LOCAL",code:e}),fetchNotifications:()=>async({dispatch:e})=>{e.fetchStart();try{const t=await r()({path:"/popup-maker/v2/notifications"});e.fetchSuccess(Array.isArray(t)?t:[])}catch(t){const n=t instanceof Error?t.message:"Unknown error";e.fetchError(n)}},dismiss:(e,t="")=>async({dispatch:n})=>{n.dismissLocal(e);try{await r()({path:"/popup-maker/v2/notifications/dismiss",method:"POST",data:{code:e,action:t}})}catch(e){console.warn("[PM] dismiss failed",e),n.fetchNotifications()}}},d=(0,a.createReduxStore)(c,{reducer:(e=l,t)=>{switch(t.type){case"FETCH_START":return{...e,isLoading:!0,error:null};case"FETCH_SUCCESS":return{...e,items:t.items,isLoading:!1,hasLoaded:!0};case"FETCH_ERROR":return{...e,isLoading:!1,hasLoaded:!0,error:t.error};case"DISMISS_LOCAL":return{...e,items:e.items.filter(e=>e.code!==t.code)};default:return e}},actions:u,selectors:{getNotifications:e=>e.items,getCount:e=>e.items.length,isLoading:e=>e.isLoading,hasLoaded:e=>e.hasLoaded,getError:e=>e.error}}),p=window.wp.components,m=window.popupMaker.i18n;function f(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=f(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}const h=function(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=f(e))&&(i&&(i+=" "),i+=t);return i},_="pum-notifications",y="pumOpenNotifications",w=()=>{if("undefined"!=typeof window&&window.history?.replaceState)try{const e=new URL(window.location.href);if(!e.searchParams.has(_))return;e.searchParams.delete(_),window.history.replaceState({},"",e.toString())}catch{}},g=window.ReactJSXRuntime,b={feature:(0,m.__)("What’s New","popup-maker"),recommendation:(0,m.__)("Tip for you","popup-maker"),announcement:(0,m.__)("Announcement","popup-maker"),offer:(0,m.__)("Offer","popup-maker"),warning:(0,m.__)("Heads up","popup-maker")},k={feature:"lightbulb",recommendation:"chart-line",announcement:"megaphone",offer:"tickets-alt",warning:"warning"},v=e=>({__html:e}),x=({notification:e})=>{const{dismiss:t}=(0,a.useDispatch)(c),[n,i]=(0,o.useState)(!1),[s,r]=(0,o.useState)(null),[l,u]=(0,o.useState)(""),d=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{null!==d.current&&window.clearTimeout(d.current)},[]);const f=n=>{const i=n.target,o=i?.closest?.("a");if(!o)return;const a=o.classList.contains("pum-dismiss"),s=o.getAttribute("href")||"";if(a){const i=o.dataset.reason||"maybe_later";"review_request"===e.code&&((e,t)=>{if("review_request"!==e.code||void 0===window.pum_review_api_url)return;const n=new window.URLSearchParams({trigger_group:window.pum_review_trigger?.group||"",trigger_code:window.pum_review_trigger?.code||"",reason:t&&"dismiss"!==t?t:"maybe_later",uuid:window.pum_review_uuid||""});window.fetch(window.pum_review_api_url,{method:"POST",body:n,keepalive:!0,credentials:"omit"}).catch(()=>{})})(e,i),s&&"#"!==s||n.preventDefault(),t(e.code,i)}};(0,o.useRef)(null),(0,o.useEffect)(()=>{document.querySelectorAll(`[data-code="${CSS.escape(e.code)}"] .pum-notification-item__body a`).forEach(e=>{const t=e.getAttribute("href")||"",n=/^https?:\/\//i.test(t);n&&!e.hasAttribute("target")&&e.setAttribute("target","_blank"),n&&!e.hasAttribute("rel")&&e.setAttribute("rel","noopener noreferrer")})},[e.code,e.message,e.html]);const _=e.icon||k[e.category]||"admin-generic",y=b[e.category]||e.category,x=t=>t.primary?"offer"===e.category?"pum-notification-cta pum-notification-cta--chip":"pum-notification-cta pum-notification-cta--link":"pum-notification-cta pum-notification-cta--muted";return(0,g.jsxs)("article",{className:h("pum-notification-item",`pum-notification-item--${e.category}`,{"is-dismissing":n}),"data-code":e.code,"data-category":e.category,children:[(0,g.jsx)("span",{className:"pum-notification-item__icon","aria-hidden":"true",children:(0,g.jsx)("span",{className:`dashicons dashicons-${_}`})}),(0,g.jsxs)("div",{className:"pum-notification-item__head",children:[(0,g.jsx)("span",{className:"pum-notification-item__category",children:y}),e.subtitle&&(0,g.jsx)("span",{className:"pum-notification-item__time",children:e.subtitle})]}),e.dismissible&&(0,g.jsx)("button",{type:"button",className:"pum-notification-item__dismiss","aria-label":(0,m.__)("Dismiss","popup-maker"),onClick:()=>{i(!0),d.current=window.setTimeout(()=>t(e.code,""),260)},children:(0,g.jsx)("span",{className:"dashicons dashicons-no-alt"})}),e.title&&(0,g.jsx)("h3",{className:"pum-notification-item__title",dangerouslySetInnerHTML:v(e.title)}),e.message&&(0,g.jsx)("div",{className:"pum-notification-item__body",onClick:f,dangerouslySetInnerHTML:v(e.message)}),e.html&&(0,g.jsx)("div",{className:"pum-notification-item__body pum-notification-item__body--legacy",onClick:f,dangerouslySetInnerHTML:v(e.html)}),e.actions.length>0&&(0,g.jsx)("div",{className:"pum-notification-item__actions",children:e.actions.map((n,i)=>{const o=`${e.code}-a-${i}`;if("link"===n.type&&n.href){const e=!0===n.external||"_blank"===n.target,t=e?void 0:()=>w();return(0,g.jsx)("a",{href:n.href,target:e?"_blank":void 0,rel:e?"noopener noreferrer":void 0,className:x(n),onClick:t,children:n.text},o)}return(0,g.jsx)("button",{type:"button",className:x(n),onClick:i=>((n,i)=>{if("iframe"===i.type&&i.href)return n.preventDefault(),r(i.href),void u(i.text);"link"===i.type&&i.href||(n.preventDefault(),t(e.code,i.action||"dismiss"))})(i,n),children:n.text},o)})}),s&&(0,g.jsxs)(p.Modal,{className:"pum-notification-item__iframe-modal",__experimentalHideHeader:!0,contentLabel:l||(0,m.__)("Details","popup-maker"),onRequestClose:()=>r(null),shouldCloseOnClickOutside:!0,shouldCloseOnEsc:!0,children:[(0,g.jsx)("button",{type:"button",className:"pum-notification-item__iframe-close","aria-label":(0,m.__)("Close","popup-maker"),onClick:()=>r(null),children:(0,g.jsx)("span",{className:"dashicons dashicons-no-alt"})}),(0,g.jsx)("iframe",{title:l||(0,m.__)("Details","popup-maker"),src:s,className:"pum-notification-item__iframe",sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"})]})]})},S=window.popupMaker.icons,N=({count:e,showCount:t,onClose:n})=>{const i=(0,m.sprintf)(/* translators: %d: number of unread notifications. */ /* translators: %d: number of unread notifications. */ (0,m._n)("%d unread notification","%d unread notifications",e,"popup-maker"),e);return(0,g.jsxs)("header",{className:"pum-notification-panel__header",children:[(0,g.jsxs)("div",{className:"pum-notification-panel__brand",children:[(0,g.jsx)(p.Icon,{icon:S.MarkColored,size:28,className:"pum-notification-panel__mark"}),(0,g.jsxs)("div",{className:"pum-notification-panel__brand-text",children:[(0,g.jsx)("span",{className:"pum-notification-panel__brand-label",children:(0,m.__)("Popup Maker","popup-maker")}),(0,g.jsxs)("h2",{className:"pum-notification-panel__title",children:[(0,m.__)("Notifications","popup-maker"),t&&(0,g.jsx)("span",{className:"pum-notification-panel__count","aria-label":i,children:e})]})]})]}),(0,g.jsx)(p.Button,{icon:"no-alt",label:(0,m.__)("Close","popup-maker"),showTooltip:!0,onClick:n})]})},j=[{key:"all",label:(0,m.__)("All","popup-maker")},{key:"feature",label:(0,m.__)("What’s New","popup-maker")},{key:"recommendation",label:(0,m.__)("Tips","popup-maker")},{key:"announcement",label:(0,m.__)("News","popup-maker")},{key:"offer",label:(0,m.__)("Offers","popup-maker")}],L=({counts:e,active:t,onChange:n})=>(0,g.jsx)("div",{className:"pum-notification-filters",children:j.map(i=>{const o=e[i.key]||0;return"all"!==i.key&&0===o?null:(0,g.jsxs)("button",{type:"button","data-filter":i.key,className:h("pum-notification-chip",{"is-active":t===i.key}),"aria-pressed":t===i.key,onClick:()=>n(i.key),children:["all"!==i.key&&(0,g.jsx)("span",{className:"pum-notification-chip__dot"}),i.label,(0,g.jsx)("span",{className:"pum-notification-chip__count",children:o})]},i.key)})}),E=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","),C=({initiallyOpen:e=!1})=>{const{isOpen:t,setIsOpen:n}=(({initiallyOpen:e=!1}={})=>{const[t,n]=(0,o.useState)(e),i=(0,o.useCallback)(e=>{n(e),e?(()=>{if("undefined"!=typeof window&&window.history?.pushState)try{const e=new URL(window.location.href);if("open"===e.searchParams.get(_))return;e.searchParams.set(_,"open"),window.history.pushState({},"",e.toString())}catch{}})():w()},[]);return(0,o.useEffect)(()=>{if(!t)return;const e=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,i]),(0,o.useEffect)(()=>{const e=e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const t=e.target;if(!t)return;const n=null!==t.closest("[data-pum-notifications-trigger]"),o=null!==t.closest("#wp-admin-bar-pum-notifications");(n||o)&&(e.preventDefault(),i(!0))};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[i]),(0,o.useEffect)(()=>{const e=()=>{try{const e="open"===new URL(window.location.href).searchParams.get(_);n(e)}catch{}};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),{isOpen:t,setIsOpen:i}})({initiallyOpen:e}),i=(0,o.useRef)(null);((e,t)=>{const n=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!e)return;n.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const i=t.current;let o=!1;if(i){const e=i.querySelectorAll(E)[0];e?e.focus():(i.hasAttribute("tabindex")||(i.setAttribute("tabindex","-1"),o=!0),i.focus())}const a=e=>{if("Tab"!==e.key||!i)return;const t=Array.from(i.querySelectorAll(E)).filter(e=>!e.hasAttribute("data-pum-trap-skip"));if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],a=document.activeElement;e.shiftKey&&a===n?(e.preventDefault(),o.focus()):e.shiftKey||a!==o||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),i&&o&&i.removeAttribute("tabindex");const e=n.current;e&&document.contains(e)&&e.focus(),n.current=null}},[e,t])})(t,i);const{items:s,isLoading:r,hasLoaded:l,counts:u,activeFilter:d,setActiveFilter:f,visibleItems:y}=(()=>{const[e,t]=(0,o.useState)("all"),{fetchNotifications:n}=(0,a.useDispatch)(c),{items:i,isLoading:s,hasLoaded:r}=(0,a.useSelect)(e=>{const t=e(c);return{items:t.getNotifications(),isLoading:t.isLoading(),hasLoaded:t.hasLoaded()}},[]);(0,o.useEffect)(()=>{n()},[n]);const l=(0,o.useMemo)(()=>{const e={all:i.length,feature:0,recommendation:0,announcement:0,offer:0,warning:0};return i.forEach(t=>{e[t.category]=(e[t.category]||0)+1}),e},[i]),u=(0,o.useMemo)(()=>"all"===e?i:i.filter(t=>t.category===e),[i,e]);return{items:i,isLoading:s,hasLoaded:r,counts:l,activeFilter:e,setActiveFilter:t,visibleItems:u}})();((e,t)=>{(0,o.useEffect)(()=>{if(!e)return;const n=document.querySelectorAll(".pum-notifications-marker"),i=document.getElementById("wp-admin-bar-pum-notifications");if(0===t)return n.forEach(e=>{e.style.display="none"}),void(i&&(i.style.display="none"));const o=(0,m.sprintf)(/* translators: %d: notification count. */ /* translators: %d: notification count. */ (0,m._n)("%d Popup Maker notification","%d Popup Maker notifications",t,"popup-maker"),t);if(n.forEach(e=>{e.style.display="",e.dataset.count=String(t),e.setAttribute("aria-label",o)}),i){i.style.display="";const e=i.querySelector(".pum-notifications-count");e&&(e.textContent=String(t))}},[e,t])})(l,s.length);const b=s.length>0;return(0,g.jsxs)(g.Fragment,{children:[t&&(0,g.jsx)("div",{className:"pum-notification-panel__backdrop",onClick:()=>n(!1),"aria-hidden":"true"}),(0,g.jsxs)("aside",{ref:i,className:h("pum-notification-panel",{"is-open":t}),role:"dialog","aria-modal":t?"true":"false","aria-hidden":t?void 0:"true","aria-label":(0,m.__)("Popup Maker notifications","popup-maker"),...t?{}:{inert:""},children:[(0,g.jsx)(N,{count:s.length,showCount:l&&b,onClose:()=>n(!1)}),l&&b&&(0,g.jsx)(L,{counts:u,active:d,onChange:f}),(0,g.jsxs)("div",{className:"pum-notification-panel__body",children:[r&&!l&&(0,g.jsx)("div",{className:"pum-notification-panel__loading",children:(0,g.jsx)(p.Spinner,{})}),l&&!b&&(0,g.jsx)("p",{className:"pum-notification-panel__empty",children:(0,m.__)("You’re all caught up. No notifications right now.","popup-maker")}),l&&b&&0===y.length&&(0,g.jsx)("p",{className:"pum-notification-panel__empty",children:(0,m.__)("Nothing in this category right now.","popup-maker")}),y.map(e=>(0,g.jsx)(x,{notification:e},e.code))]}),l&&b&&(0,g.jsx)("footer",{className:"pum-notification-panel__footer",children:(0,g.jsx)("span",{className:"pum-notification-panel__footer-note",children:(0,m.__)("Dismiss items you’re not interested in — we’ll remember.","popup-maker")})})]})]})},A="pum-notifications-panel-root",O=()=>{(0,a.register)(d);const e=(()=>{let e=document.getElementById(A);return e||(e=document.createElement("div"),e.id=A,document.body.appendChild(e)),e})();(0,o.createRoot)(e).render((0,g.jsx)(C,{initiallyOpen:(()=>{try{return"open"===new URL(window.location.href).searchParams.get(_)}catch{return!1}})()||(()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{const e=window.localStorage.getItem(y);if(!e)return!1;window.localStorage.removeItem(y);const t=JSON.parse(e);return"number"==typeof t?.exp&&t.exp>Date.now()}catch{try{window.localStorage.removeItem(y)}catch{}return!1}})()}))};i()(O),(window.popupMaker=window.popupMaker||{}).adminNotifications=t})();
修改文件时间
将文件时间修改为当前时间的前一年
删除文件