laipower/wp-content/plugins/subscribe2/gutenberg/sidebar.min.js

1 line
2.6 KiB
JavaScript

var privateSetting="";wp.apiFetch({path:"/s2/v1/settings/private"}).then(function(e){privateSetting=e}),wp.apiFetch({path:"/s2/v1/settings/s2meta_default"}).then(function(e){var t=wp.data.select("core/editor").getEditedPostAttribute("meta")._s2mail;""===t&&("0"===e?t="yes":"1"===e&&(t="no"),wp.data.dispatch("core/editor").editPost({meta:{_s2mail:t}}),wp.data.dispatch("core/editor").savePost())}),function(e,t,i,s,r,n,o,a){var c=e.registerPlugin,d=t.createElement,u=i.__,b=t.Fragment,l=s.PluginSidebar,p=s.PluginSidebarMoreMenuItem,m=r.PanelBody,h=r.PanelRow,f=r.CheckboxControl,v=r.Button,g=n.select,P=n.dispatch,w=n.withSelect,S=n.withDispatch,C=(0,o.compose)(w(function(e,t){return{metaChecked:"no"===e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}}),S(function(e,t){return{setMetaChecked:function(i){var s=!0===i?"no":"yes";e("core/editor").editPost({meta:{[t.fieldName]:s}}),e("core/editor").savePost()}}}))(function(e){return d(f,{label:u("Check here to disable sending of an email notification for this post/page","subscribe2"),checked:e.metaChecked,onChange:function(t){e.setMetaChecked(t)}})}),k=function(){return d(m,{title:u("Subscribe2 Resend","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Resend the notification email of this post to current subscribers:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:N},u("Resend Notification","subscribe2"))))},A=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/preview/"+e}),P("core/notices").createInfoNotice(u("Attempt made to send email preview","subscribe2"))},N=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/resend/"+e}),P("core/notices").createInfoNotice(u("Attempt made to resend email notification","subscribe2"))};c("subscribe2-sidebar",{render:function(){return d(b,{},d(p,{target:"s2-sidebar",icon:"email"},u("Subscribe2 Sidebar","subscribe2")),d(l,{name:"s2-sidebar",title:u("Subscribe2 Sidebar","subscribe2"),icon:"email",isPinned:!0,isPinnable:!0,togglePin:!0,togglesidebar:!1},d(m,{title:u("Subscribe2 Override","subscribe2"),initialOpen:!0},d(h,{},d(C,{fieldName:"_s2mail"}))),d(m,{title:u("Subscribe2 Preview","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Send preview email of this post to currently logged in user:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:A},u("Send Preview","subscribe2")))),"publish"===g("core/editor").getEditedPostAttribute("status")?k():"private"===g("core/editor").getEditedPostAttribute("status")&&"yes"===privateSetting?k():void 0))}})}(wp.plugins,wp.element,wp.i18n,wp.editPost,wp.components,wp.data,wp.compose,wp.apiFetch);