index.js
1 lines
| 1 | (()=>{"use strict";const e=window.wp.components,t=window.wp.data,s=window.wp.i18n,o=window.wp.plugins,n=window.wp.wordcount;let i={title:{selector:"#seopress_titles_title_meta",type:"text",key:"_seopress_titles_title"},description:{selector:"#seopress_titles_desc_meta",type:"text",key:"_seopress_titles_desc"},noindex:{selector:"#seopress_robots_index_meta",type:"checkbox",key:"_seopress_robots_index"}};document.addEventListener("DOMContentLoaded",(()=>{if(wp.plugins){if(null===document.querySelector("#seopress-js-module-seo-metabox")){const e=(e,s)=>{s.value="checkbox"==s.type?e.target.checked?"yes":"":e.target.value;const o=(0,t.select)("core/editor").getEditedPostAttribute("meta");(0,t.dispatch)("core/editor").editPost({meta:{...o,[s.key]:s.value}})};for(const[t,s]of Object.entries(i))jQuery(s.selector).on("change paste keyup",(function(t){e(t,s)}));jQuery("#seopress-tag-single-excerpt").click((function(){jQuery("#seopress_titles_desc_meta").trigger("paste")}))}(0,o.registerPlugin)("pre-publish-checklist",{render:r})}}));const r=()=>{const{isTyping:o,meta:i}=(0,t.useSelect)((e=>({isTyping:e("core/block-editor").isTyping(),meta:e("core/editor").getEditedPostAttribute("meta")})),[]);if(!i)return"";const r=(0,t.select)("core/editor").getEditedPostAttribute("content"),c=(0,n.count)(r,"words"),l=i?._seopress_titles_title||"",a=i?._seopress_titles_desc||"",p="yes"===i?._seopress_robots_index,d=React.createElement(e.Icon,{icon:"yes",style:{color:"green"}}),_=React.createElement(e.Icon,{icon:"no",style:{color:"red"}});let u=wp.editor.PluginPrePublishPanel;return void 0===u&&(u=wp.editPost.PluginPrePublishPanel),React.createElement(u,{title:(0,s.__)("SEO Checklist","wp-seopress"),initialOpen:!0},React.createElement("ul",null,React.createElement("li",{key:"wordCount"},c>300?d:_,React.createElement("strong",null,(0,s.__)("Word count: ","wp-seopress")),React.createElement("span",null,c)),React.createElement("li",{key:"metaTitle"},l?d:_,React.createElement("strong",null,l?(0,s.__)("Meta title is set.","wp-seopress"):(0,s.__)("Custom meta title is not set.","wp-seopress"))),React.createElement("li",{key:"metaDescription"},a?d:_,React.createElement("strong",null,a?(0,s.__)("Meta description is set.","wp-seopress"):(0,s.__)("Custom meta description is not set.","wp-seopress"))),React.createElement("li",{key:"metaIndex"},p?_:d,React.createElement("strong",null,p?(0,s.__)("This content is set to noindex.","wp-seopress"):(0,s.__)("This content is set to be indexed.","wp-seopress")))))}})(); |