관리-도구
편집 파일: primary-term.k8873mmr.js
import{v as m,o as _,c as g,C as p,a as u,E as x,b as E,Y as k}from"./js/runtime-dom.esm-bundler.h3clfjuw.js";import{l as v}from"./js/index.nd8elblc.js";import{l as $}from"./js/index.npoectbv.js";import{l as b}from"./js/index.moogjen0.js";import{l as d,u as B,G as T,b as P,e as A,E as L,F as C}from"./js/index.jlplx4ex.js";import{e as D}from"./js/elemLoaded.f718isk5.js";import{s as I}from"./js/metabox.imp54zfh.js";import{S as M}from"./js/Information.djrr3pec.js";import{S as N}from"./js/Caret.hnvbzqgq.js";import"./js/translations.b896ab1m.js";import{_ as S}from"./js/_plugin-vue_export-helper.oebm7xum.js";import{a as y,_ as w}from"./js/default-i18n.hohxoesu.js";import"./js/helpers.cti0cl6i.js";const H={getTerms:async e=>{const{apiFetch:o}=window.wp,{addQueryArgs:t}=window.wp.url,n=c(e);return await o({path:t(`/wp/v2/${n.restBase}`,{per_page:-1,orderby:"count",order:"desc",_fields:"id,name"})})},getSelectedTerms:e=>{const o=c(e);return window.wp.data.select("core/editor").getEditedPostAttribute(o.restBase)||[]}},q={getTerms:async e=>{var r;const o=[],t=c(e);return(((r=document.getElementById(`${t.name}checklist`))==null?void 0:r.querySelectorAll("li"))||[]).forEach(s=>{const a=s.querySelector("input").value,i=s.querySelector("label").innerText;o.push({id:parseInt(a,10),name:i.trim()})}),new Promise(s=>{s(o)})},getSelectedTerms:e=>{var r;const o=[],t=c(e);return(((r=document.getElementById(`${t.name}checklist`))==null?void 0:r.querySelectorAll("input:checked"))||[]).forEach(s=>{o.push(parseInt(s.value,10))}),o}},l=()=>{var t;return d(),(((t=B().aioseo.postData)==null?void 0:t.taxonomies)||[]).filter(n=>n.primaryTermSupport===!0)},U=e=>l().some(o=>e===o.name),c=e=>{const o=l().filter(t=>e===t.name);return o.length?o[0]:{}},F=e=>T()?H.getSelectedTerms(e):q.getSelectedTerms(e),f="all-in-one-seo-pack",V={setup(){return{postEditorStore:P()}},components:{SvgCircleInformation:M,SvgClose:N},props:{taxonomy:String},data(){return{selectedTerms:[],strings:{didYouKnow:y(w("Did you know that %1$s Pro allows you to choose a %2$sprimary category%3$s for your posts? This feature works hand in hand with our powerful Breadcrumbs template to give you full navigational control to help improve your search rankings!",f),"AIOSEO","<strong>","</strong>"),learnMoreLink:y('<a href="%1$s" target="_blank" rel="noreferrer nofollow">%2$s<span class="link-right-arrow"> →</span></a>',A.getDocUrl("primaryTerm"),w("Learn more",f))}}},computed:{canShowUpsell(){const{options:e}=this.postEditorStore.currentPost;return!e.primaryTerm.productEducationDismissed&&1<this.selectedTerms.length}},methods:{updateSelectedTerms(){this.selectedTerms=F(this.taxonomy)}},mounted(){this.updateSelectedTerms(),window.aioseoBus.$on("updateSelectedTerms",this.updateSelectedTerms)},beforeUnmount(){window.aioseoBus.$off("updateSelectedTerms",this.updateSelectedTerms)}},Y={key:0,class:"aioseo-primary-term-cta"},K=["innerHTML"],O=["innerHTML"];function Q(e,o,t,n,r,s){const a=m("svg-circle-information"),i=m("svg-close");return s.canShowUpsell?(_(),g("div",Y,[p(a,{width:"15",height:"15"}),u("p",{innerHTML:r.strings.didYouKnow},null,8,K),u("p",{innerHTML:r.strings.learnMoreLink},null,8,O),p(i,{onClick:x(n.postEditorStore.disablePrimaryTermEducation,["stop"])},null,8,["onClick"])])):E("",!0)}const R=S(V,[["render",Q]]),j={components:{PrimaryTerm:R},props:{taxonomy:String}},G={class:"aioseo-app aioseo-primary-term"};function z(e,o,t,n,r,s){const a=m("primary-term");return _(),g("div",G,[p(a,{taxonomy:t.taxonomy},null,8,["taxonomy"])])}const J=S(j,[["render",z]]);if(T()&&window.wp){const{createElement:e,Fragment:o}=window.wp.element,{addFilter:t}=window.wp.hooks,{createHigherOrderComponent:n}=window.wp.compose,{subscribe:r}=window.wp.data;t("editor.PostTaxonomyType","aioseo/primary-term",n(s=>a=>{const{slug:i}=a;return U(i)?e(o,{},e(s,a),e("div",{id:`aioseo-primary-term-${i}`},e("div",{className:"aioseo-primary-term-app",taxonomy:i}))):e(s,a)},"withInspectorControls")),r(()=>{window.aioseoBus.$emit("updateSelectedTerms")})}(L()||C())&&(d(),l().forEach(e=>{var n;const o=(n=document.getElementById(`${e.name}div`))==null?void 0:n.querySelector(".inside");if(!o)return;const t=document.createElement("div");t.setAttribute("id",`aioseo-primary-term-${e.name}`),t.setAttribute("class","aioseo-primary-term-app"),t.setAttribute("taxonomy",e.name),o.append(t),function(r){r(`#${e.name}checklist`).on("change",'input[type="checkbox"]',()=>{window.aioseoBus.$emit("updateSelectedTerms")}),r(`#${e.name}checklist`).on("wpListAddEnd",()=>{window.aioseoBus.$emit("updateSelectedTerms")})}(window.jQuery)}));const h=e=>{if(!e)return;const o=e.getAttribute("taxonomy");let t=k({...J,name:"Standalone/PrimaryTerm"},{taxonomy:o});t=v(t),t=$(t),t=b(t),d(t),t.mount(e)};if(I()&&window.aioseo&&window.aioseo.currentPost&&window.aioseo.currentPost.context==="post"){const e=document.getElementsByClassName("aioseo-primary-term-app");Array.prototype.forEach.call(e,o=>h(o)),D(".aioseo-primary-term-app","aioseoPrimaryTerm"),document.addEventListener("animationstart",function(o){o.animationName==="aioseoPrimaryTerm"&&h(o.target)},{passive:!0})}