HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/epamokos.kaunokolegija.lt/wp-content/plugins/lifterlms/blocks/access-plan-button/index.js
(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.blocks,n=window.wp.components,s=window.wp.blockEditor,a=window.wp.i18n,o=window.wp.serverSideRender;var r=e.n(o);const i=window.wp.apiFetch;var c=e.n(i);const m=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/access-plan-button","title":"Access Plan Button","category":"llms-blocks","description":"Outputs a button which links to the purchase page for a LifterLMS access plan. Useful if you’re creating custom sales pages for courses or memberships.","textdomain":"lifterlms","attributes":{"classes":{"type":"string"},"id":{"type":"string"},"size":{"type":"string","default":"default"},"type":{"type":"string","default":"primary"},"text":{"type":"string","default":"Buy Now"},"llms_visibility":{"type":"string"},"llms_visibility_in":{"type":"string"},"llms_visibility_posts":{"type":"string"}},"editorScript":"file:./index.js"}'),p=window.wp.primitives;(0,l.registerBlockType)(m,{icon:()=>(0,t.createElement)(p.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512"},(0,t.createElement)(p.Path,{d:"M592 416H48c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48h544c26.5 0 48 21.5 48 48v224c0 26.5-21.5 48-48 48z"})),edit:e=>{var l;const{attributes:o,setAttributes:i}=e,p=(0,s.useBlockProps)(),[u,d]=(0,t.useState)([]),[h,b]=(0,t.useState)(!1),[y,f]=(0,t.useState)("");(0,t.useEffect)((()=>{const e=setTimeout((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";b(!0),c()({path:`/llms/v1/access-plans?per_page=10&search=${encodeURIComponent(e)}`}).then((e=>{const l=e.map((e=>({label:e.title.rendered,value:e.id.toString()})));d(l),t&&!l.some((e=>e.value===t))&&c()({path:`/llms/v1/access-plans?include=${t}`}).then((e=>{d([...l,...e.map((e=>({label:e.title.rendered,value:e.id.toString()})))])})).catch((()=>{}))})).catch((e=>{"AbortError"!==e.name&&d([])})).finally((()=>{b(!1)}))}(y,o.id)),300);return()=>clearTimeout(e)}),[y,o]);const w=(0,t.useMemo)((()=>{let e=(0,a.__)("No Access Plans found matching your selection. This block will not be displayed.","lifterlms");return!o.id&&u.length>0&&(e=(0,a.__)("No Access Plan selected. Please choose an Access Plan from the block sidebar panel.","lifterlms")),(0,t.createElement)(r(),{block:m.name,attributes:o,LoadingResponsePlaceholder:()=>(0,t.createElement)(n.Spinner,null),ErrorResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-error"},(0,a.__)("Error loading content. Please check block settings are valid. This block will not be displayed.","lifterlms")),EmptyResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-empty"},e)})}),[o]);return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(s.InspectorControls,null,(0,t.createElement)(n.PanelBody,{title:(0,a.__)("Access Plan Button Settings","lifterlms")},(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.ComboboxControl,{label:(0,a.__)("Access Plan","lifterlms"),value:null!==(l=o.id)&&void 0!==l?l:"",options:u,onChange:e=>i({id:e}),isLoading:h,onFilterValueChange:f,allowReset:!0,help:(0,a.__)("Select the access plan to display a button for.","lifterlms")})),(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.BaseControl,{help:(0,a.__)("Controls the size of the button.","lifterlms")},(0,t.createElement)(n.Flex,{direction:"column"},(0,t.createElement)(n.BaseControl.VisualLabel,null,(0,a.__)("Size","lifterlms")),(0,t.createElement)(n.ButtonGroup,null,["Default","Large","Small"].map((e=>{const l=e.toLowerCase();return(0,t.createElement)(n.Button,{key:l,isPrimary:l===o.size,onClick:()=>i({size:l})},e)})))))),(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.SelectControl,{label:(0,a.__)("Type","lifterlms"),help:(0,a.__)("Controls the style of the button. Your theme and/or custom CSS may alter the colors defined by these styles.","lifterlms"),value:o.type,options:[{label:(0,a.__)("Primary","lifterlms"),value:"primary"},{label:(0,a.__)("Secondary","lifterlms"),value:"secondary"},{label:(0,a.__)("Action","lifterlms"),value:"action"},{label:(0,a.__)("Danger","lifterlms"),value:"danger"}],onChange:e=>i({type:e})})),(0,t.createElement)(n.PanelRow,null,(0,t.createElement)(n.TextControl,{label:(0,a.__)("Text","lifterlms"),help:(0,a.__)("The text to display on the button.","lifterlms"),value:o.text,onChange:e=>i({text:e})})))),(0,t.createElement)("div",p,(0,t.createElement)(n.Disabled,null,w)))}})})();