← Back
Editing: index.js
(()=>{"use strict";const e=window.lodash,t=window.wp.element,n=window.wp.data,o=window.wp.compose,i=window.wp.components;var r=(0,t.forwardRef)(({icon:e,size:n=24,style:o,...i},r)=>{const s=e.props.style,d=s||o?{...s,...o}:void 0;return(0,t.cloneElement)(e,{width:n,height:n,...i,...d?{style:d}:{},ref:r})});const s=window.wp.primitives,d=window.ReactJSXRuntime;var c=(0,d.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{fill:"none"},stroke:"currentColor",strokeWidth:"1.5",children:(0,d.jsx)(s.Path,{d:"M12 16V11M12 9.5V8M19.25 12C19.25 16.0041 16.0041 19.25 12 19.25C7.99594 19.25 4.75 16.0041 4.75 12C4.75 7.99594 7.99594 4.75 12 4.75C16.0041 4.75 19.25 7.99594 19.25 12Z",strokeLinejoin:"round"})});const l=window.wp.i18n,p=window._expDataLayer||[],u=window.wp.plugins;var a=(0,d.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{fill:"none"},stroke:"currentColor",strokeWidth:"1.5",children:(0,d.jsx)(s.Path,{d:"M7 12L10 15L17 8"})});const w=window.wp.editPost,m=window.wp.coreData,x="wpex-expert-banner-hidden";(0,u.registerPlugin)("wpex-eb-settings-plugin",{icon:"",render:function(){const{saveEditedEntityRecord:e}=(0,n.useDispatch)("core"),[t,o]=(0,m.useEntityProp)("root","site",wpexExpertBanner.optionHidden);return(0,d.jsx)(w.PluginMoreMenuItem,{as:i.MenuItem,id:x,icon:t?null:a,onClick:()=>{o(!t),e("root","site")},children:(0,l.__)("Hire an expert","gd-system-plugin")})}});const g=(0,o.pure)((0,o.compose)([(0,n.withSelect)(t=>{const{getPostType:n,getEntityRecord:o}=t("core"),{getEditedPostAttribute:i}=t("core/editor"),r=n(i("type"));return{hireExpertHidden:o("root","site")?.[wpexExpertBanner.optionHidden]??!1,isViewable:(0,e.get)(r,["viewable"],!1),editorToolbar:document.querySelector(".edit-post-header__settings")}}),(0,o.ifCondition)(({hireExpertHidden:e})=>!e),(0,o.ifCondition)(({isViewable:e})=>e),(0,o.ifCondition)(({editorToolbar:e})=>!!e)])(function(e){const{editorToolbar:n}=e,[o,s]=(0,t.useState)(null),[u,a]=(0,t.useState)(!1),[w,m]=(0,t.useState)(!1),[g,h]=(0,t.useState)(null),b=(0,t.useRef)(null);(0,t.useEffect)(()=>{const e=document.createElement("div");e.id="wpex-eb-container",n.parentNode.insertBefore(e,n),s(e)},[n]),(0,t.useEffect)(function(){w&&(document.querySelector(".interface-more-menu-dropdown > button")?.click?.(),setTimeout(()=>{const e=document.getElementById(x);if(!e)return;e.focus();const t=e.getBoundingClientRect();h(new DOMRect(t.x+20,t.y,t.width,t.height))},200),m(!1))},[w,h]);const f=e=>{e.stopPropagation(),e.preventDefault()};if((0,t.useEffect)(()=>{if(g)return document.addEventListener("mousedown",f),document.addEventListener("click",f),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("click",f)}},[g]),!o)return null;const v=b.current?.getBoundingClientRect(),y=new DOMRect(v?.x,v?.y+10,v?.width,v?.height);return(0,t.createPortal)((0,d.jsxs)(d.Fragment,{children:[g&&(0,d.jsxs)(i.Popover,{anchorRect:g,className:"wpex-eb-tooltip",focusOnMount:!1,noArrow:!1,offset:50,position:"middle right",children:[(0,d.jsx)("p",{className:"wpex-eb-tooltip__title",children:(0,l.__)("Just so you know…","gd-system-plugin")}),(0,d.jsx)("p",{className:"wpex-eb-tooltip__description",children:(0,l.__)('Here you can enable or disable "Hire an expert"',"gd-system-plugin")}),(0,d.jsx)("button",{className:"wpex-eb-tooltip__button",onClick:e=>h(null),children:(0,l.__)("Got it","gd-system-plugin")})]}),(0,d.jsx)("span",{ref:b,children:(0,d.jsx)(r,{icon:c,onClick:()=>a(e=>!e)})}),u&&(0,d.jsx)(i.Popover,{className:"wpex-eb-tooltip wpex-eb-tooltip--black",anchorRect:y,noArrow:!1,focusOnMount:!1,position:"middle top",children:(0,d.jsx)("div",{children:(0,t.createInterpolateElement)((0,l.__)("To disable this option, go to the <button>Tools</button> menu.","gd-system-plugin"),{button:(0,d.jsx)(i.Button,{variant:"link",id:"wpex-eb-open-settings",onClick:()=>{a(!1),m(!0)}})})})}),(0,d.jsx)("a",{id:"wpex-expert-banner",target:"_blank",href:"https://www.godaddy.com/websites/web-design",rel:"noopener noreferrer",onClick:()=>(({eid:e,type:t="click",data:n=null})=>{p.push({schema:"add_event",version:"v1",data:{eid:`${e}.${t}`,type:t,custom_properties:n}})})({eid:"wp.editor.expert/wpex_expert/expert.link"}),children:(0,l.__)("Hire an expert","gd-system-plugin")}),(0,d.jsx)("div",{id:"wpex-eb-divider"})]}),o)}));document.addEventListener("DOMContentLoaded",()=>{const e=document.createElement("div");document.getElementById("editor").appendChild(e),(0,t.render)((0,d.jsx)(g,{}),e)})})();
Save File
Cancel