← Back
Editing: cta-admin.js
(()=>{"use strict";const e={n:t=>{const r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{if(Array.isArray(r))for(var o=0;o<r.length;){var s=r[o++],i=r[o++];e.o(t,s)?0===i&&o++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:r[o++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.hasOwn(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{ListBulkActionsRegistry:()=>$,ListConsumer:()=>z,ListFiltersRegistry:()=>re,ListOptionsRegistry:()=>le,ListProvider:()=>H,ListQuickActionsRegistry:()=>X,getGlobalVars:()=>_e,getListBulkActions:()=>q,getListFilters:()=>ne,getListOptions:()=>ue,getListQuickActions:()=>te,init:()=>De,registerListBulkAction:()=>J,registerListBulkActionGroup:()=>W,registerListFilter:()=>se,registerListFilterGroup:()=>ie,registerListOption:()=>ce,registerListOptionGroup:()=>pe,registerListQuickAction:()=>K,registerListQuickActionGroup:()=>ee,useList:()=>Q,useListBulkActions:()=>U,useListFilters:()=>oe,useListOptions:()=>ae,useListQuickActions:()=>Y});var r={};e.r(r),e.d(r,{deleteBulkAction:()=>Se,disableBulkAction:()=>Ce,enableBulkAction:()=>ye,exportBulkAction:()=>Te,trashBulkAction:()=>Ae});var o={};e.r(o),e.d(o,{statusFilter:()=>Pe,typeFilter:()=>Be});var s={};e.r(s),e.d(s,{exportListOption:()=>Ne,importListOption:()=>Re});var i={};e.r(i),e.d(i,{deleteQuickAction:()=>Ee,editQuickAction:()=>Fe,trashQuickAction:()=>Le});const n=window.popupMaker.useQueryParams,l=window.wp.domReady;var a=e.n(l);const c=window.wp.hooks,p=window.wp.element,u=window.wp.data,d=window.popupMaker.data;function m(e){var t,r,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=m(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}const h=function(){for(var e,t,r=0,o="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=m(e))&&(o&&(o+=" "),o+=t);return o},g=window.popupMaker.i18n,x=window.wp.components,v=window.popupMaker.layout;(0,p.forwardRef)(({icon:e,size:t=24,...r},o)=>(0,p.cloneElement)(e,{width:t,height:t,...r,ref:o}));const k=window.wp.primitives,j=window.ReactJSXRuntime;var _=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm3.8 10.7-1.1 1.1-2.7-2.7-2.7 2.7-1.1-1.1 2.7-2.7-2.7-2.7 1.1-1.1 2.7 2.7 2.7-2.7 1.1 1.1-2.7 2.7 2.7 2.7Z"})}),f=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),w=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})}),b=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"})}),y=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"})}),C=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M17.031 4.703 15.576 4l-1.56 3H14v.03l-2.324 4.47H9.5V13h1.396l-1.502 2.889h-.95a3.694 3.694 0 0 1 0-7.389H10V7H8.444a5.194 5.194 0 1 0 0 10.389h.17L7.5 19.53l1.416.719L15.049 8.5h.507a3.694 3.694 0 0 1 0 7.39H14v1.5h1.556a5.194 5.194 0 0 0 .273-10.383l1.202-2.304Z"})}),A=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),S=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})}),T=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"})}),M=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})}),P=(0,j.jsx)(k.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,j.jsx)(k.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})});const B=window.wp.htmlEntities,R=window.popupMaker.utils,N=window.popupMaker.icons,F=window.popupMaker.ctaEditor,L=window.popupMaker.components,E=window.popupMaker.coreData,D=()=>{},O={callToActions:[],filteredCallToActions:[],bulkSelection:[],setBulkSelection:()=>{},updateCallToAction:(e,t)=>Promise.resolve(!1),deleteCallToAction:(e,t=!1)=>Promise.resolve(!1),isLoading:!1,isDeleting:!1,filters:{status:"all",searchText:"",type:"all"},setFilters:D,sortConfig:{orderby:"id",order:L.SortDirection.ASC},setSortConfig:D},I=(0,p.createContext)(O),V=I,G=V.Provider,z=V.Consumer,H=({value:e={},children:t})=>{const[r,o]=(0,p.useState)([]),[s,i]=(0,n.useQueryParams)({orderby:(0,n.withDefault)(n.StringParam,"id"),order:(0,n.withDefault)(n.StringParam,L.SortDirection.ASC)}),[l,a]=(0,n.useQueryParams)({status:(0,n.withDefault)(n.StringParam,"all"),searchText:(0,n.withDefault)(n.StringParam,""),type:(0,n.withDefault)(n.StringParam,"all")}),c=()=>a({status:void 0,searchText:void 0,type:void 0});(0,p.useEffect)(()=>c,[]);const d=(0,u.useSelect)(e=>e(E.callToActionStore).getCallToActions(),[]),m=(0,u.useSelect)(e=>e(E.callToActionStore).isResolving("getCallToActions"),[]),h=(0,u.useSelect)(e=>e(E.callToActionStore).isResolving("deleteCallToAction"),[]),{updateCallToAction:g,deleteCallToAction:x}=(0,u.useDispatch)(E.callToActionStore),v=(0,p.useMemo)(()=>{if(!d)return[];const e=d.filter(e=>"all"===l.status||l.status===e.status).filter(e=>!l.searchText||!l.searchText.length||e.title.rendered.toLowerCase().indexOf(l.searchText.toLowerCase())>=0||e.excerpt.rendered&&e.excerpt.rendered.toLowerCase().indexOf(l.searchText.toLowerCase())>=0).filter(e=>"all"===l.type||l.type===e.settings.type);return null!==s&&e.sort((e,t)=>{const r=e=>{switch(s.orderby){case"id":return e.id;case"type":return e.settings.type;case"conversions":return e.stats?.conversions??0;default:return e.title.rendered.toLowerCase()}},o=r(e),i=r(t);return o<i?s.order===L.SortDirection.ASC?-1:1:o>i?s.order===L.SortDirection.ASC?1:-1:0}),e},[d,l,s]);return(0,j.jsx)(G,{value:{...e,bulkSelection:r,setBulkSelection:o,filters:l,setFilters:a,callToActions:d,filteredCallToActions:v,isLoading:m,isDeleting:h,updateCallToAction:g,deleteCallToAction:x,sortConfig:s,setSortConfig:i},children:t})},Q=()=>(0,p.useContext)(I),Z=window.popupMaker.registry,$=(0,Z.createRegistry)({name:"cta-editor/list-bulk-actions",groups:{status:{priority:10,label:"Status"},trash:{priority:20,label:"Trash"},export:{priority:30,label:"Export"}}}),U=()=>$.useItems(),J=$.register,W=$.registerGroup,q=()=>$.getItems(),X=(0,Z.createRegistry)({name:"cta-editor/list-quick-actions",groups:{general:{priority:10},trash:{priority:20}}}),Y=()=>X.useItems(),K=X.register,ee=X.registerGroup,te=()=>X.getItems(),re=(0,Z.createRegistry)({name:"cta-editor/list-filters",groups:{core:{priority:10,label:"Core"},advanced:{priority:20,label:"Advanced"}},defaultGroup:"core"}),oe=()=>re.useItems(),se=re.register,ie=re.registerGroup,ne=()=>re.getItems(),le=(0,Z.createRegistry)({name:"cta-editor/list-options",groups:{import:{priority:10,label:"Import"}}}),ae=()=>le.useItems(),ce=le.register,pe=le.registerGroup,ue=()=>le.getItems(),de=()=>{const e=(0,p.useRef)(void 0),t=(0,p.useRef)(),[r,o]=(0,p.useState)(!1),s=U(),{bulkSelection:i=[]}=Q(),n={};if(0===i.length)return null;const l=({group:t})=>{if(!t||t===e.current)return null;const r=e.current;return e.current=t,r?(0,j.jsx)("hr",{}):null};return(0,j.jsx)(j.Fragment,{children:(0,j.jsx)(x.Dropdown,{className:"list-table-bulk-actions",contentClassName:"list-table-bulk-actions__popover",placement:"bottom left",focusOnMount:"firstElement",open:r,popoverProps:{noArrow:!1,anchor:{getBoundingClientRect:()=>t.current?.getBoundingClientRect()||new DOMRect},onClose:()=>{o(!1)},onFocusOutside:()=>{o(!1)}},renderToggle:()=>(0,j.jsxs)(x.Flex,{children:[(0,j.jsx)("span",{className:"selected-items",children:(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g._n)("%d item selected","%d items selected",i.length,"popup-maker"),i.length)}),(0,j.jsxs)(x.Button,{className:"popover-toggle",ref:e=>{t.current=e},"aria-label":(0,g.__)("Bulk Actions","popup-maker"),variant:"secondary",onClick:()=>o(!r),"aria-expanded":r,icon:N.CheckAll,iconSize:20,children:[(0,g.__)("Bulk Actions","popup-maker"),(0,j.jsx)(x.Icon,{className:"toggle-icon",icon:r?w:f})]})]}),renderContent:({onClose:t})=>(e.current=void 0,(0,j.jsx)(x.NavigableMenu,{orientation:"vertical",children:s.map(({id:e,group:r,render:o})=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(l,{group:r}),(0,j.jsx)(o,{...n,onClose:t})]},e))}))})})},me=({values:e})=>{const t=(0,p.useRef)(void 0),r=Y(),o={values:e};if(0===r.length)return null;const s=({group:e})=>{if(!e||e===t.current)return null;const r=t.current;return t.current=e,r?(0,j.jsx)("span",{children:"|"}):null};return(0,j.jsx)("div",{className:"item-actions",children:(t.current=void 0,(0,j.jsx)(j.Fragment,{children:r.map(({id:e,group:t,render:r})=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(s,{group:t}),(0,j.jsx)(r,{...o})]},e))}))})},he=()=>{const{filters:e={},setFilters:t,callToActions:r=[],filteredCallToActions:o=[]}=Q(),s=oe(),i=(0,p.useRef)(void 0),n=(0,p.useCallback)(({group:e})=>e&&e!==i.current?(i.current,i.current=e,null):null,[]),l=(0,p.useCallback)(()=>(i.current=void 0,(0,j.jsx)(j.Fragment,{children:s.map(({id:s,group:i,render:l})=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(n,{group:i}),(0,j.jsx)(l,{filters:e,setFilters:t,onClose:()=>{},items:r,filteredItems:o})]},s))})),[s,e,t,r,o,n]);return 0===s.length?null:(0,j.jsx)("div",{className:"list-table-filters",children:l()})},ge=()=>{const e=(0,p.useRef)(),t=(0,p.useRef)(void 0),[r,o]=(0,p.useState)(!1),s=ae(),i={};if(0===s.length)return null;const n=({group:e})=>{if(!e||e===t.current)return null;const r=t.current;return t.current=e,r?(0,j.jsx)("hr",{}):null};return(0,j.jsx)(x.Dropdown,{className:"list-table-options-menu",contentClassName:"list-table-options-menu__popover",placement:"bottom left",focusOnMount:"firstElement",open:r,popoverProps:{noArrow:!1,anchor:{getBoundingClientRect:()=>e.current?.getBoundingClientRect()||new DOMRect},onClose:()=>{o(!1)},onFocusOutside:()=>{o(!1)}},renderToggle:()=>(0,j.jsx)(x.Button,{className:"popover-toggle","aria-label":(0,g.__)("Additional options","popup-maker"),icon:S,onClick:()=>o(!r),"aria-expanded":r,ref:t=>{e.current=t}}),renderContent:({onClose:e})=>(t.current=void 0,(0,j.jsx)(x.NavigableMenu,{orientation:"vertical",children:s.map(({id:t,group:r,render:o})=>(0,j.jsxs)(p.Fragment,{children:[(0,j.jsx)(n,{group:r}),(0,j.jsx)(o,{...i,onClose:e})]},t))}))})},{cta_types:xe}=window.popupMakerCtaAdmin,ve=()=>{const{setEditorId:e}=(0,F.useEditor)(),[t,r]=(0,p.useState)(!1),[o,s]=(0,p.useState)(),i=()=>s(void 0);return(0,j.jsx)(H,{children:(0,j.jsx)(z,{children:({isLoading:s,bulkSelection:n=[],setBulkSelection:l=R.noop,filteredCallToActions:a=[],updateCallToAction:c=R.noop,filters:{searchText:p=""},setFilters:u,sortConfig:d,setSortConfig:m})=>(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(L.ConfirmDialogue,{...o,onClose:i}),(0,j.jsxs)("div",{className:"list-table-container",children:[(0,j.jsxs)("div",{className:"list-table-header",children:[(0,j.jsxs)("div",{className:"list-search",children:[(0,j.jsx)(x.Icon,{icon:T}),(0,j.jsx)(x.TextControl,{placeholder:(0,g.__)("Search Calls to Action…","popup-maker"),value:p??"",onChange:e=>u({searchText:""!==e?e:void 0}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})]}),(0,j.jsx)(de,{}),0===n.length&&(0,j.jsx)(x.Button,{className:"filters-toggle",variant:"secondary",onClick:()=>{r(!t)},"aria-expanded":t,icon:N.FilterLines,iconSize:20,text:t?(0,g.__)("Hide Filters","popup-maker"):(0,g.__)("Filters","popup-maker")}),(0,j.jsx)(ge,{})]}),t&&(0,j.jsx)(he,{}),(0,j.jsx)(L.ListTable,{isLoading:s,selectedItems:n,onSelectItems:e=>l(e),items:s?[]:a,columns:{enabled:()=>(0,j.jsx)(x.Tooltip,{text:(0,g.__)("Enable or disable the call to action","popup-maker"),placement:"top-end",children:(0,j.jsx)("span",{children:(0,j.jsx)(x.Icon,{icon:y})})}),title:(0,g.__)("Name","popup-maker"),description:(0,g.__)("Description","popup-maker"),type:(0,g.__)("Type","popup-maker"),conversions:(0,g.__)("Conversions","popup-maker"),status:(0,g.__)("Status","popup-maker")},sortableColumns:["type","title","conversions"],onSort:(e,t)=>{m({orderby:e,order:t})},initialSort:d,rowClasses:e=>[`call-to-action-${e.id}`,`status-${e.status}`],renderCell:(t,r)=>{const o=r.status,s="trash"===o,i="publish"===o;switch(t){case"enabled":return(0,j.jsx)(x.ToggleControl,{label:"","aria-label":(0,g.__)("Enable or disable the call to action","popup-maker"),checked:i,disabled:s,onChange:e=>{c({id:r.id,status:e?"publish":"draft"})},__nextHasNoMarginBottom:!0});case"status":return s?(0,j.jsx)(x.Icon,{"aria-label":(0,g.__)("In Trash","popup-maker"),icon:M,size:20}):(0,j.jsx)("span",{children:i?(0,g.__)("Enabled","popup-maker"):(0,g.__)("Disabled","popup-maker")});case"title":return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.Button,{variant:"link",onClick:()=>e(r.id),children:(0,B.decodeEntities)(r.title.rendered)}),(0,j.jsx)(me,{values:r})]});case"conversions":return r.stats?.conversions??0;case"type":return(e=>{const t=Object.values(xe).find(({key:t})=>t===e);return t?.label??""})(r.settings.type);case"description":return(0,B.decodeEntities)(r.excerpt?.raw||"");default:return r[t]??r.settings[t]??""}}})]})]})})})},ke=()=>{const{setEditorId:e}=(0,F.useEditor)(),t=(0,u.useSelect)(e=>e(E.callToActionStore).getCallToActions(),[]),r=(0,u.useSelect)(e=>e(E.callToActionStore).isResolving("getCallToActions"),[]),o=t?.length??0;return(0,j.jsxs)("header",{className:"popup-maker-call-to-actions-view__header",children:[(0,j.jsx)("h1",{className:"view-title wp-heading-inline",children:(0,g.__)("Calls to Action","popup-maker")}),(0,j.jsx)("span",{className:"item-count",children:r?(0,j.jsx)(x.Spinner,{}):(0,g.sprintf)(/* translators: %d: number of items. */ /* translators: %d: number of items. */ (0,g._n)("%d item","%d items",o,"popup-maker"),o)}),(0,j.jsx)(x.Button,{className:"add-call-to-action",onClick:()=>{e("new")},variant:"primary",children:(0,g.__)("Add Call to Action","popup-maker")})]})},je=()=>{const e=(0,p.useRef)({}),{notices:t,isEditorActive:r}=(0,u.useSelect)(e=>({notices:e(E.callToActionStore).getNotices(),isEditorActive:e(E.callToActionStore).isEditorActive()}),[]),{removeNotice:o}=(0,u.useDispatch)(E.callToActionStore),s=(0,p.useCallback)(t=>{e.current[t]&&(clearTimeout(e.current[t]),delete e.current[t]),o(t)},[o]);return(0,p.useLayoutEffect)(()=>{t.forEach(t=>{if(e.current[t.id])return;const r=t.id?.startsWith("field-error-");r||F.DEBUG_MODE||(e.current[t.id]=setTimeout(()=>{s(t.id)},3e3))})},[t,s]),!t.length||r?null:(0,j.jsx)("div",{className:"notices",children:t.map(e=>(0,j.jsx)(x.Notice,{status:e.status,isDismissible:e.isDismissible,onRemove:()=>s(e.id),children:e.content},e.id))})},_e=()=>"undefined"!=typeof window&&window.popupMaker.globalVars?window.popupMaker.globalVars:{version:"1.0.0",wpVersion:6.5,pluginUrl:"",assetsUrl:"",adminUrl:"",nonce:"",permissions:{edit_ctas:!1,edit_popups:!1,edit_popup_themes:!1,mange_settings:!1}},fe=(0,F.withQueryParams)((0,F.withModal)(F.Editor)),we=()=>{const{permissions:e={edit_ctas:!1}}=_e(),{edit_ctas:t}=e;return t?(0,j.jsxs)("div",{className:"call-to-action-list",children:[(0,j.jsx)(je,{}),(0,j.jsx)(ke,{}),(0,j.jsx)(ve,{}),(0,j.jsx)(fe,{})]}):(0,j.jsxs)("div",{className:"call-to-action-list permission-denied",children:[(0,j.jsx)(je,{}),(0,j.jsx)("h3",{children:(0,g.__)("Permission Denied","popup-maker")}),(0,j.jsx)("p",{children:(0,j.jsx)("strong",{children:(0,g.__)("You do not have permission to manage Calls to Action.","popup-maker")})})]})},be=()=>{const{permissions:e={edit_ctas:!1}}=_e(),{edit_ctas:t}=e,[{view:r="call-to-actions"},o]=(0,n.useQueryParams)({tab:n.StringParam,view:n.StringParam}),s=(0,p.useMemo)(()=>{let e=[];return t&&e.push({name:"call-to-actions",title:(0,g.__)("Calls to Action","popup-maker"),className:"call-to-actions",pageTitle:(0,g.__)("Popup Maker - Calls to Action","popup-maker"),heading:(0,g.__)("Popup Maker - Calls to Action","popup-maker"),comp:we}),e=(0,c.applyFilters)("popupMaker.callToActionEditor.views",[...e],{view:r,setParams:o}),e},[r,o,t]),i=s.find(e=>e.name===r),l=i?.comp?i.comp:()=>(0,j.jsx)(j.Fragment,{});return(0,p.useEffect)(()=>{document.title=s.find(e=>e.name===r)?.pageTitle??(0,g.__)("Popup Maker","popup-maker")},[r,s]),(0,j.jsxs)(v.AppLayout,{className:h(["popup-maker-call-to-actions-page",`view-${r}`]),children:[(0,j.jsx)(v.AppHeader,{navTabId:"call-to-actions",tabs:s,currentTab:r??void 0,onTabChange:e=>o({view:e})}),(0,j.jsx)(v.AppContent,{children:(0,j.jsx)(l,{})}),(0,j.jsx)(x.Popover.Slot,{})]})},ye={id:"enable",group:"status",priority:5,render:()=>{const e=(0,u.useRegistry)(),{bulkSelection:t=[],setBulkSelection:r}=Q(),{getCallToAction:o}=(0,u.useSelect)(e=>({getCallToAction:e(E.callToActionStore).getCallToAction}),[]),{createNotice:s,updateCallToAction:i}=(0,u.useDispatch)(E.callToActionStore);return 0===t.length?null:t.some(e=>{const t=o(e);return"publish"!==t?.status})?(0,j.jsx)(x.Button,{icon:A,text:(0,g.__)("Enable","popup-maker"),onClick:()=>{e.batch(()=>{const e=t.length;t.forEach(e=>{const t=o(e);t?.id===e&&i({id:e,status:"publish"},!1,!1)}),r([]),s("success",(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g._n)("%d call to action enabled.","%d calls to action enabled.",e,"popup-maker"),e),{id:"bulk-enable"})})}}):null}},Ce={id:"disable",group:"status",priority:6,render:()=>{const{bulkSelection:e=[],setBulkSelection:t}=Q(),r=(0,u.useRegistry)(),{getCallToAction:o}=(0,u.useSelect)(e=>({getCallToAction:e(E.callToActionStore).getCallToAction}),[]),{createNotice:s,updateCallToAction:i}=(0,u.useDispatch)(E.callToActionStore);return 0===e.length?null:e.some(e=>{const t=o(e);return"draft"!==t?.status})?(0,j.jsx)(j.Fragment,{children:(0,j.jsx)(x.Button,{icon:C,text:(0,g.__)("Disable","popup-maker"),onClick:()=>{r.batch(()=>{const r=e.length;e.forEach(e=>{const t=o(e);t?.id===e&&i({id:e,status:"draft"},!1,!1)}),t([]),s("success",(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g._n)("%d call to action disabled.","%d calls to action disabled.",r,"popup-maker"),r),{id:"bulk-disable"})})}})}):null}},Ae={id:"trash",group:"trash",priority:5,render:()=>{const[e,t]=(0,p.useState)(),{bulkSelection:r=[],setBulkSelection:o,deleteCallToAction:s}=Q(),i=(0,u.useRegistry)(),{getCallToAction:n}=(0,u.useSelect)(e=>({getCallToAction:e(E.callToActionStore).getCallToAction}),[]),{createNotice:l}=(0,u.useDispatch)(E.callToActionStore);return 0===r.length?null:r.some(e=>{const t=n(e);return"trash"!==t?.status})?(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(L.ConfirmDialogue,{...e,onClose:()=>t(void 0)}),(0,j.jsx)(x.Button,{text:(0,g.__)("Trash","popup-maker"),icon:M,onClick:()=>{t({isDestructive:!0,message:(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g.__)("Are you sure you want to trash %d items?","popup-maker"),r.length),callback:()=>{i.batch(()=>{const e=r.length;r.forEach(e=>s(e,!1,!1)),o([]),l("success",(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g._n)("%d call to action moved to trash.","%d calls to action moved to trash.",e,"popup-maker"),e),{id:"bulk-trash"})})}})}})]}):null}},Se={id:"delete",group:"trash",priority:6,render:()=>{const[e,t]=(0,p.useState)(),{bulkSelection:r=[],setBulkSelection:o}=Q(),s=(0,u.useRegistry)(),{createNotice:i,deleteCallToAction:n}=(0,u.useDispatch)(E.callToActionStore);return 0===r.length?null:(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(L.ConfirmDialogue,{...e,onClose:()=>t(void 0)}),(0,j.jsx)(x.Button,{text:(0,g.__)("Delete Permanently","popup-maker"),icon:_,isDestructive:!0,onClick:()=>{t({isDestructive:!0,message:(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g.__)("Are you sure you want to premanently delete %d items?","popup-maker"),r.length),callback:()=>{s.batch(()=>{const e=r.length;r.forEach(e=>n(e,!0,!1)),o([]),i("success",(0,g.sprintf)( // translators: %d: number of items. // translators: %d: number of items. (0,g._n)("%d call to action deleted.","%d calls to action deleted.",e,"popup-maker"),e),{id:"bulk-delete"})})}})}})]})}},Te={id:"export",group:"export",priority:5,render:()=>{const[e,t]=(0,p.useState)(!1),r=(0,p.useRef)(null);return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(x.Popover,{anchor:r.current,onClose:()=>t(!1),children:(0,j.jsxs)(x.Flex,{direction:"column",gap:"16px",justify:"center",align:"center",className:"pmp-popover-content",style:{padding:"16px",minWidth:"350px"},children:[(0,j.jsx)(x.Icon,{icon:N.Mark,size:28}),(0,j.jsx)("h3",{style:{margin:0},children:(0,g.__)("Quick exports with Popup Maker Pro","popup-maker")}),(0,j.jsx)("p",{style:{margin:0},children:(0,g.__)("Popup Maker Pro gives you the power to import & export your calls to action to a JSON file in seconds.","popup-maker")}),(0,j.jsx)(x.Button,{variant:"primary",href:"https://wppopupmaker.com/pricing/?utm_source=popup-maker&utm_medium=cta-editor&utm_campaign=export-cta",target:"_blank",children:(0,g.__)("Learn more or upgrade today","popup-maker")})]})}),(0,j.jsxs)(x.Flex,{direction:"row",justify:"space-between",onMouseEnter:()=>t(!0),style:{cursor:"pointer",paddingRight:"10px",pointerEvents:"all"},children:[(0,j.jsx)(x.Button,{icon:b,text:(0,g.__)("Export","popup-maker"),disabled:!0,showTooltip:!0,label:(0,g.__)("Export is available with Popup Maker Pro","popup-maker"),ref:r}),(0,j.jsx)(x.Icon,{icon:N.Mark,size:14})]})]})}},Me={all:(0,g.__)("All","popup-maker"),publish:(0,g.__)("Enabled","popup-maker"),draft:(0,g.__)("Disabled","popup-maker"),pending:(0,g.__)("Pending","popup-maker"),trash:(0,g.__)("Trash","popup-maker"),future:(0,g.__)("Future","popup-maker"),private:(0,g.__)("Private","popup-maker")},Pe={id:"status",priority:10,group:"core",render:({filters:e,setFilters:t,onClose:r,items:o,filteredItems:s})=>{const[i,n]=(0,p.useState)(!1),l=(0,p.useRef)(null),a=(0,p.useMemo)(()=>o.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e.all++,e),{all:0}),[o]),c=(0,p.useMemo)(()=>s.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e.all++,e),{all:0}),[s]),u=e?.status??"all";return(0,j.jsxs)("div",{className:h(["list-table-filter list-table-filter--status",i?"is-active":""]),children:[(0,j.jsxs)(x.Button,{className:"filter-button",onClick:()=>n(!i),ref:l,children:[(0,j.jsxs)("span",{className:"filter-label",children:[(0,g.__)("Status","popup-maker"),":"]})," ",(0,j.jsx)("span",{className:"filter-selection",children:Me[u]}),(0,j.jsx)(x.Icon,{className:"filter-icon",icon:i?w:f})]}),i&&l.current&&(0,j.jsx)(x.Popover,{className:"list-table-filters__popover",anchor:l.current,onClose:()=>{n(!1),r()},position:"bottom right",onFocusOutside:()=>{n(!1),r()},children:(0,j.jsx)(x.RadioControl,{label:(0,g.__)("Status","popup-maker"),hideLabelFromVision:!0,selected:u,options:Object.entries(Me).filter(([e])=>{return(a[u]??0)>0?(t=e,Boolean(c?.[t])):(a[e]??0)>0;var t}).map(([e,t])=>({label:`${t} (${c[e]??0})`,value:e})),onChange:e=>{t({status:e}),n(!1),r()}})})]})}},Be={id:"type",group:"core",render:({filters:e,setFilters:t,onClose:r,items:o,filteredItems:s})=>{const[i,n]=(0,p.useState)(!1),l=(0,p.useRef)(null),a=(0,p.useMemo)(()=>{const{cta_types:e}=window.popupMakerCtaAdmin;return Object.values(e).reduce((e,{key:t,label:r})=>({...e,[t]:r}),{all:(0,g.__)("All","popup-maker")})},[]),c=(0,p.useMemo)(()=>o.reduce((e,t)=>{const r=t.settings.type;return e[r]=(e[r]??0)+1,e.all++,e},{all:0}),[o]),u=(0,p.useMemo)(()=>s.reduce((e,t)=>{const r=t.settings.type;return e[r]=(e[r]??0)+1,e.all++,e},{all:0}),[s]);return(0,j.jsxs)("div",{className:h(["list-table-filter list-table-filter--type",i?"is-active":""]),children:[(0,j.jsxs)(x.Button,{className:"filter-button",onClick:()=>n(!i),ref:l,children:[(0,j.jsxs)("span",{className:"filter-label",children:[(0,g.__)("Type","popup-maker"),":"]})," ",(0,j.jsx)("span",{className:"filter-selection",children:Object.prototype.hasOwnProperty.call(a,e?.type??"all")?a[e?.type??"all"]:a.all}),(0,j.jsx)(x.Icon,{className:"filter-icon",icon:i?w:f})]}),i&&l.current&&(0,j.jsx)(x.Popover,{className:"list-table-filters__popover",anchor:l.current,onClose:()=>{n(!1),r()},position:"bottom right",onFocusOutside:()=>{n(!1),r()},children:(0,j.jsx)(x.RadioControl,{label:(0,g.__)("Type","popup-maker"),hideLabelFromVision:!0,selected:e?.type??"all",options:Object.entries(a).filter(([t])=>(c[e?.type??"all"]??0)>0?(e=>Boolean(u?.[e]))(t):(c[t]??0)>0).map(([e,t])=>({label:`${t} (${u[e]??0})`,value:e})),onChange:e=>{t({type:"all"===e?void 0:e}),n(!1),r()}})})]})}},Re={id:"import",group:"export",render:()=>{const[e,t]=(0,p.useState)(!1),r=(0,p.useRef)(null);return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(x.Popover,{anchor:r.current,onClose:()=>t(!1),children:(0,j.jsxs)(x.Flex,{direction:"column",gap:"16px",justify:"center",align:"center",style:{padding:"16px",minWidth:"350px"},children:[(0,j.jsx)(x.Icon,{icon:N.Mark,size:28}),(0,j.jsx)("h3",{style:{margin:0},children:(0,g.__)("Quick imports with Popup Maker Pro","popup-maker")}),(0,j.jsx)("p",{style:{margin:0},children:(0,g.__)("Popup Maker Pro gives you the power to import your calls to action from a JSON file in seconds.","popup-maker")}),(0,j.jsx)(x.Button,{variant:"primary",href:"https://wppopupmaker.com/pricing/?utm_source=popup-maker&utm_medium=cta-editor&utm_campaign=import-cta",target:"_blank",children:(0,g.__)("Learn more or upgrade today","popup-maker")})]})}),(0,j.jsxs)(x.Flex,{direction:"row",justify:"space-between",onMouseEnter:()=>t(!0),style:{cursor:"pointer",paddingRight:"10px",pointerEvents:"all"},children:[(0,j.jsx)(x.Button,{icon:P,text:(0,g.__)("Import","popup-maker"),disabled:!0,showTooltip:!0,label:(0,g.__)("Import is available with Popup Maker Pro","popup-maker"),ref:r}),(0,j.jsx)(x.Icon,{icon:N.Mark,size:14})]})]})}},Ne={id:"export",group:"export",render:()=>{const[e,t]=(0,p.useState)(!1),r=(0,p.useRef)(null);return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsx)(x.Popover,{anchor:r.current,onClose:()=>t(!1),children:(0,j.jsxs)(x.Flex,{direction:"column",gap:"16px",justify:"center",align:"center",className:"pmp-popover-content",style:{padding:"16px",minWidth:"350px"},children:[(0,j.jsx)(x.Icon,{icon:N.Mark,size:28}),(0,j.jsx)("h3",{style:{margin:0},children:(0,g.__)("Quick exports with Popup Maker Pro","popup-maker")}),(0,j.jsx)("p",{style:{margin:0},children:(0,g.__)("Popup Maker Pro gives you the power to import & export your calls to action to a JSON file in seconds.","popup-maker")}),(0,j.jsx)(x.Button,{variant:"primary",href:"https://wppopupmaker.com/pricing/?utm_source=popup-maker&utm_medium=cta-editor&utm_campaign=export-cta",target:"_blank",children:(0,g.__)("Learn more or upgrade today","popup-maker")})]})}),(0,j.jsxs)(x.Flex,{direction:"row",justify:"space-between",onMouseEnter:()=>t(!0),style:{cursor:"pointer",paddingRight:"10px",pointerEvents:"all"},children:[(0,j.jsx)(x.Button,{icon:b,text:(0,g.__)("Export","popup-maker"),disabled:!0,showTooltip:!0,label:(0,g.__)("Export is available with Popup Maker Pro","popup-maker"),ref:r}),(0,j.jsx)(x.Icon,{icon:N.Mark,size:14})]})]})}},Fe={id:"edit",group:"general",priority:-1,render:({values:e})=>{const{setEditorId:t}=(0,F.useEditor)();return(0,j.jsxs)(j.Fragment,{children:[`${(0,g.__)("ID","popup-maker")}: ${e.id}`,(0,j.jsx)(x.Button,{text:(0,g.__)("Edit","popup-maker"),variant:"link",onClick:()=>t(e.id)})]})}},Le={id:"trash",group:"trash",priority:11,render:({values:e})=>{const[t,r]=(0,p.useState)(),o=(0,u.useSelect)(e=>e(E.callToActionStore).isResolving("deleteCallToAction"),[]),{deleteCallToAction:s,updateCallToAction:i}=(0,u.useDispatch)(E.callToActionStore),n="trash"===e.status;return(0,j.jsxs)(j.Fragment,{children:[t&&(0,j.jsx)(L.ConfirmDialogue,{...t,onClose:()=>r(void 0)}),(0,j.jsx)(x.Button,{text:n?(0,g.__)("Untrash","popup-maker"):(0,g.__)("Trash","popup-maker"),variant:"link",isDestructive:!0,isBusy:!!o,onClick:()=>n?i({id:e.id,status:"draft"}):s(e.id)})]})}},Ee={id:"delete",group:"trash",priority:12,render:({values:e})=>{const[t,r]=(0,p.useState)(),o=(0,u.useSelect)(e=>e(E.callToActionStore).isResolving("deleteCallToAction"),[]),{deleteCallToAction:s}=(0,u.useDispatch)(E.callToActionStore);return"trash"===e.status?(0,j.jsxs)(j.Fragment,{children:[t&&(0,j.jsx)(L.ConfirmDialogue,{...t,onClose:()=>r(void 0)}),(0,j.jsx)(x.Button,{text:(0,g.__)("Delete Permanently","popup-maker"),variant:"link",isDestructive:!0,isBusy:!!o,onClick:()=>r({message:(0,g.__)("Are you sure you want to premanently delete this call to action?","popup-maker"),callback:()=>{s(e.id,!0)},isDestructive:!0})})]}):null}},De=()=>{const e=document.getElementById("popup-maker-call-to-actions-root-container");e&&(Object.values(r).forEach(e=>{J(e)}),Object.values(s).forEach(e=>{ce(e)}),Object.values(i).forEach(e=>{K(e)}),Object.values(o).forEach(e=>{se(e)}),(0,c.doAction)("popupMaker.ctaAdmin.init"),(0,p.createRoot)(e).render((0,j.jsx)(n.BrowserRouter,{children:(0,j.jsx)(n.QueryParamProvider,{adapter:n.ReactRouter6Adapter,children:(0,j.jsx)(u.RegistryProvider,{value:d.registry,children:(0,j.jsx)(be,{})})})})))};a()(De),(window.popupMaker=window.popupMaker||{}).ctaAdmin=t})();
Save File
Cancel