1 line
9.4 KiB
JavaScript
1 line
9.4 KiB
JavaScript
(()=>{var e={20:(e,t,o)=>{"use strict";var n=o(677),r=Symbol.for("react.element"),s=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,o){var n,s={},c=null,u=null;for(n in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)l.call(t,n)&&!a.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:r,type:e,key:c,ref:u,props:s,_owner:i.current}}t.jsx=c,t.jsxs=c},848:(e,t,o)=>{"use strict";e.exports=o(20)},677:e=>{e.exports=function(){return this.React}()},419:e=>{e.exports=function(){return this.lodash}()},89:e=>{e.exports=function(){return this.wp.blockEditor}()},545:e=>{e.exports=function(){return this.wp.blocks}()},959:e=>{e.exports=function(){return this.wp.components}()},897:e=>{e.exports=function(){return this.wp.compose}()},987:e=>{e.exports=function(){return this.wp.data}()},601:e=>{e.exports=function(){return this.wp.element}()},873:e=>{e.exports=function(){return this.wp.hooks}()},75:e=>{e.exports=function(){return this.wp.i18n}()},933:e=>{e.exports=function(){return this.wp.primitives}()},567:e=>{e.exports=function(){return this.wp.serverSideRender}()},172:e=>{e.exports=function(){return this.wp.url}()}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,o),s.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);(()=>{"use strict";var e=o(75),t=o(419),n=o(897),r=o(873),s=o(987),l=o(601),i=o(89),a=o(959),c=o(933),u=o(848);!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path),!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path),!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path),!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path);const g=!(0,t.isUndefined)(wp.primitives)?(0,u.jsx)(c.SVG,{width:"20",height:"20",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:(0,u.jsx)(c.Path,{d:"M11 7H9.49c-.63 0-1.25.3-1.59.7L7 5H4.13l-2.39 7h1.69l.74-2H7v4H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h7c1.1 0 2 .9 2 2v2zM6.51 9H4.49l1-2.93zM10 8h7c1.1 0 2 .9 2 2v7c0 1.1-.9 2-2 2h-7c-1.1 0-2-.9-2-2v-7c0-1.1.9-2 2-2zm7.25 5v-1.08h-3.17V9.75h-1.16v2.17H9.75V13h1.28c.11.85.56 1.85 1.28 2.62-.87.36-1.89.62-2.31.62-.01.02.22.97.2 1.46.84 0 2.21-.5 3.28-1.15 1.09.65 2.48 1.15 3.34 1.15-.02-.49.2-1.44.2-1.46-.43 0-1.49-.27-2.38-.63.7-.77 1.14-1.77 1.25-2.61h1.36zm-3.81 1.93c-.5-.46-.85-1.13-1.01-1.93h2.09c-.17.8-.51 1.47-1 1.93l-.04.03s-.03-.02-.04-.03z"})}):"translation",d=(!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path),!(0,t.isUndefined)(wp.primitives)&&(c.SVG,c.Path),!(0,t.isUndefined)(wp.primitives)),p=()=>d?(0,u.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:(0,u.jsx)(c.Path,{d:"M1.50002 4L6.00002 8L10.5 4",strokeWidth:"1.5"})}):"submenu";const h=function({language:e}){return(0,t.isNil)(e)?(0,u.jsx)("span",{className:"pll-translation-icon",children:g}):(0,t.isEmpty)(e.flag_url)?(0,u.jsxs)("abbr",{children:[e.slug,(0,u.jsx)("span",{className:"screen-reader-text",children:e.name})]}):(0,u.jsx)("span",{className:"pll-select-flag",children:(0,u.jsx)("img",{src:e.flag_url,alt:e.name,title:e.name,className:"flag"})})};function f({handleChange:e,children:t,selectedLanguage:o=null,defaultValue:n=""}){const r=o?.slug?o.slug:n;return(0,u.jsxs)("div",{id:"select-post-language",children:[(0,u.jsx)(h,{language:o}),t&&(0,u.jsx)("select",{value:r,onChange:t=>e(t),id:"pll_post_lang_choice",name:"pll_post_lang_choice",className:"post_lang_choice",children:t})]})}function _({languages:e}){return Array.from(e.values()).map((({slug:e,name:t,w3c:o})=>(0,u.jsx)("option",{value:e,lang:o,children:t},e)))}const m="pll/metabox";o(172);const w=()=>new Promise((function(e){let t=(0,s.subscribe)((function(){const o=(0,s.select)(m)?.getLanguages();o?.size>0&&(t(),e())}))}));if(document.getElementById("widgets-editor")||document.getElementById("customize-controls")){const o={type:"string",default:"every"},c=function(e,n){return["core/widget-area","core/legacy-widget"].find((e=>e===n))||(e.attributes=(0,t.assign)(e.attributes,{pll_lang:o})),e};(0,r.addFilter)("blocks.registerBlockType","pll/lang-choice",c);const g=(0,n.createHigherOrderComponent)((n=>r=>{const c=(0,s.select)(m).getLanguages(),{pll_lang:g}=r.attributes,d=!(0,t.isNil)(g),p=c.get(g);return(0,u.jsxs)(l.Fragment,{children:[(0,u.jsx)(n,{...r}),d&&(0,u.jsx)(i.InspectorControls,{children:(0,u.jsxs)(a.PanelBody,{title:(0,e.__)("Languages","polylang-pro"),children:[(0,u.jsx)("label",{children:(0,e.__)("The block is displayed for:","polylang-pro")}),(0,u.jsxs)(f,{selectedLanguage:p,handleChange:e=>{const t=e.currentTarget.value;r.setAttributes({pll_lang:t})},defaultValue:o.default,children:[(0,u.jsxs)("option",{value:o.default,children:[(0,e.__)("All languages","polylang-pro")," "]}),(0,u.jsx)(_,{languages:c})]})]})})]})}),"withInspectorControl");w().then((function(){(0,r.addFilter)("editor.BlockEdit","pll/lang-choice-with-inspector-controls",g)}))}var x=o(545),b=o(567),j=o.n(b);const v=pll_block_editor_blocks_settings;function y(e){const o=function(o){return()=>{const n=e.attributes[o],{setAttributes:r}=e;let s,l,i={[o]:!n};switch(o){case"show_names":s="show_flags",l=!e.attributes[s];break;case"show_flags":s="show_names",l=!e.attributes[s]}"show_names"!==o&&"show_flags"!==o||n&&l&&(i=(0,t.assign)(i,{[s]:l})),r(i)}},n=o("dropdown"),r=o("show_names"),s=o("show_flags"),l=o("force_home"),i=o("hide_current"),c=o("hide_if_no_translation"),{dropdown:g,show_names:d,show_flags:p,force_home:h,hide_current:f,hide_if_no_translation:_}=e.attributes;return{ToggleControlDropdown:function(){return(0,u.jsx)(a.ToggleControl,{label:v.dropdown,checked:g,onChange:n})},ToggleControlShowNames:function(){return(0,u.jsx)(a.ToggleControl,{label:v.show_names,checked:d,onChange:r})},ToggleControlShowFlags:function(){return(0,u.jsx)(a.ToggleControl,{label:v.show_flags,checked:p,onChange:s})},ToggleControlForceHome:function(){return(0,u.jsx)(a.ToggleControl,{label:v.force_home,checked:h,onChange:l})},ToggleControlHideCurrent:function(){return(0,u.jsx)(a.ToggleControl,{label:v.hide_current,checked:f,onChange:i})},ToggleControlHideIfNoTranslations:function(){return(0,u.jsx)(a.ToggleControl,{label:v.hide_if_no_translation,checked:_,onChange:c})}}}const C=(0,e.__)("Language switcher","polylang-pro"),k=(0,e.__)("Add a language switcher to allow your visitors to select their preferred language.","polylang-pro"),T=(0,e.__)("Language switcher settings","polylang-pro");(0,x.registerBlockType)("polylang/language-switcher",{title:C,description:k,icon:g,category:"widgets",example:{},edit:e=>{const{dropdown:t}=e.attributes,{ToggleControlDropdown:o,ToggleControlShowNames:n,ToggleControlShowFlags:r,ToggleControlForceHome:s,ToggleControlHideCurrent:c,ToggleControlHideIfNoTranslations:g}=y(e);return(0,u.jsxs)(l.Fragment,{children:[(0,u.jsx)(i.InspectorControls,{children:(0,u.jsxs)(a.PanelBody,{title:T,children:[(0,u.jsx)(o,{}),!t&&(0,u.jsx)(n,{}),!t&&(0,u.jsx)(r,{}),(0,u.jsx)(s,{}),!t&&(0,u.jsx)(c,{}),(0,u.jsx)(g,{})]})}),(0,u.jsx)(a.Disabled,{children:(0,u.jsx)(j(),{block:"polylang/language-switcher",attributes:e.attributes})})]})}});const S="polylang/navigation-language-switcher";function B(e,t,o,n){return e.map((e=>({...n(e,t,o),innerBlocks:B(e.innerBlocks,t,o,n)})))}(0,x.registerBlockType)(S,{title:C,description:k,icon:g,category:"widgets",parent:["core/navigation"],attributes:{dropdown:{type:"boolean",default:!1},show_names:{type:"boolean",default:!0},show_flags:{type:"boolean",default:!1},force_home:{type:"boolean",default:!1},hide_current:{type:"boolean",default:!1},hide_if_no_translation:{type:"boolean",default:!1}},transforms:{from:[{type:"block",blocks:["core/navigation-link"],transform:()=>(0,x.createBlock)(S)}]},usesContext:["textColor","customTextColor","backgroundColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","fontSize","customFontSize","showSubmenuIcon","openSubmenusOnClick","style"],example:{},edit:e=>{const{dropdown:t}=e.attributes,{showSubmenuIcon:o,openSubmenusOnClick:n}=e.context,{ToggleControlDropdown:r,ToggleControlShowNames:s,ToggleControlShowFlags:c,ToggleControlForceHome:g,ToggleControlHideCurrent:d,ToggleControlHideIfNoTranslations:p}=y(e);return(0,u.jsxs)(l.Fragment,{children:[(0,u.jsx)(i.InspectorControls,{children:(0,u.jsxs)(a.PanelBody,{title:T,children:[(0,u.jsx)(r,{}),(0,u.jsx)(s,{}),(0,u.jsx)(c,{}),(0,u.jsx)(g,{}),!t&&(0,u.jsx)(d,{}),(0,u.jsx)(p,{})]})}),(0,u.jsx)(a.Disabled,{children:(0,u.jsxs)("div",{className:"wp-block-navigation-item",children:[(0,u.jsx)(j(),{block:S,attributes:e.attributes,className:"wp-block-navigation__container block-editor-block-list__layout"}),P(o,n,t)]})})]})}});const N=(e,o,n)=>{if("core/navigation-link"===e.name&&"#pll_switcher"===e.attributes?.url){const e=(0,t.find)(o,{url:"#pll_switcher"}),r=e.meta._pll_menu_item,s=(0,x.createBlock)(S,r);return n[e.id]=s.clientId,s}return e},P=(e,t,o)=>(e||t)&&o?(0,u.jsx)("span",{className:"wp-block-navigation__submenu-icon",children:(0,u.jsx)(p,{})}):null;(0,r.addFilter)("blocks.navigation.__unstableMenuItemsToBlocks","polylang/include-language-switcher",((e,t)=>({...e,innerBlocks:B(e.innerBlocks,t,e.mapping,N)})))})(),this["polylang-pro"]={}})(); |