Stackable – Page Builder Gutenberg Blocks - Version 0.5

Version Description

  • Fixed: compatibility with Gutenberg 3.1.0
  • Fixed: Button line-height with Gutenberg 3.1.0
Download this release

Release Info

Developer bfintal
Plugin Icon 128x128 Stackable – Page Builder Gutenberg Blocks
Version 0.5
Comparing to
See all releases

Code changes from version 0.4 to 0.5

dist/blocks.build.js CHANGED
@@ -1 +1 @@
1
- !function(e){function t(l){if(n[l])return n[l].exports;var o=n[l]={i:l,l:!1,exports:{}};return e[l].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,l){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:l})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";n.d(t,"g",function(){return c}),n.d(t,"a",function(){return i}),n.d(t,"e",function(){return u}),n.d(t,"c",function(){return m}),n.d(t,"k",function(){return s}),n.d(t,"l",function(){return p}),n.d(t,"n",function(){return b}),n.d(t,"b",function(){return d}),n.d(t,"m",function(){return g}),n.d(t,"d",function(){return h}),n.d(t,"h",function(){return w}),n.d(t,"f",function(){return f}),n.d(t,"i",function(){return y}),n.d(t,"o",function(){return v}),n.d(t,"j",function(){return C});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},o=function(e){return wp.element.createElement("defs",null,wp.element.createElement("linearGradient",l({},e,{gradientTransform:"rotate(90)"}),wp.element.createElement("stop",{offset:"0%",stopColor:"#2FDDD1",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"20%",stopColor:"#30A2E3",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"50%",stopColor:"#F56FAE",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"100%",stopColor:"#FFC58E",stopOpacity:"1"})))},r=1,a=function(){return"stk-icon-"+r++},c=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"20",height:"20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M512 96c-111.118 0-215.584 43.272-294.156 121.844S96 400.882 96 512s43.272 215.584 121.844 294.156S400.882 928 512 928s215.584-43.272 294.156-121.844S928 623.118 928 512s-43.272-215.584-121.843-294.156S623.118 96 512 96zm0-96c282.77 0 512 229.23 512 512s-229.23 512-512 512S0 794.77 0 512 229.23 0 512 0zm-64 704h128v128H448zm0-512h128v384H448z"}))},i=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M17 5H3c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm1 7c0 .6-.4 1-1 1H3c-.6 0-1-.4-1-1V7c0-.6.4-1 1-1h14c.6 0 1 .4 1 1v5z"}))},u=function(){return wp.element.createElement(i,null)},m=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M4 9h12v2H4V9z"}))},s=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M8.54 12.74c0-.87-.24-1.61-.72-2.22-.73-.92-2.14-1.03-2.96-.85-.34-1.93 1.3-4.39 3.42-5.45L6.65 1.94C3.45 3.46.31 6.96.85 11.37 1.19 14.16 2.8 16 5.08 16c1 0 1.83-.29 2.48-.88.66-.59.98-1.38.98-2.38zm9.43 0c0-.87-.24-1.61-.72-2.22-.73-.92-2.14-1.03-2.96-.85-.34-1.93 1.3-4.39 3.42-5.45l-1.63-2.28c-3.2 1.52-6.34 5.02-5.8 9.43.34 2.79 1.95 4.63 4.23 4.63 1 0 1.83-.29 2.48-.88.66-.59.98-1.38.98-2.38z"}))},p=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 14 32"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M0 29h5.833L0 23h5V9H0l5.833-6H0V0h14v3H8.167L14 9H9v14h5l-5.833 6H14v3H0v-3z"}))},b=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 13 12.916010856628418"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M5.68 12.916a.5.5 0 0 1-.397-.196L3.208 10H1.463C.656 10 0 9.428 0 8.621V1.463C0 .656.656 0 1.463 0h10.074C12.344 0 13 .656 13 1.463v7.158C13 9.428 12.344 10 11.537 10H8.151l-2.073 2.72a.504.504 0 0 1-.398.196zM1.463 1A.464.464 0 0 0 1 1.463v7.158c0 .255.208.463.463.463h1.993a.5.5 0 0 1 .397.196l1.827 2.312L7.507 9.28a.502.502 0 0 1 .397-.196h3.633A.464.464 0 0 0 12 8.621V1.463A.464.464 0 0 0 11.537 1H1.463zm1.193 2h7.828c.284.024.514.207.514.49a.498.498 0 0 1-.514.496H2.656a.499.499 0 0 1-.514-.496c.001-.283.231-.466.514-.49zm0 3h7.828c.284.024.514.207.514.49a.498.498 0 0 1-.514.496H2.656a.499.499 0 0 1-.514-.496c.001-.283.231-.466.514-.49z"}))},d=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 16 14"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M10 0c-.17 0-.36.05-.52.14C8.04 1.02 4.5 3.58 3 4c-1.38 0-3 .67-3 2.5S1.63 9 3 9c.3.08.64.23 1 .41V14h2v-3.45c1.34.86 2.69 1.83 3.48 2.31.16.09.34.14.52.14.52 0 1-.42 1-1V1c0-.58-.48-1-1-1zm0 12c-.38-.23-.89-.58-1.5-1-.16-.11-.33-.22-.5-.34V2.31c.16-.11.31-.2.47-.31.61-.41 1.16-.77 1.53-1v11zm2-6h4v1h-4V6zm0 2l4 2v1l-4-2V8zm4-6v1l-4 2V4l4-2z"}))},g=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 896 1023"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M821 491q-41-41-95-60 62-26 100-82t38-125q0-93-65.5-158.5T640 0q-71 0-128.5 41T430 147q-32-39-77-61t-97-22q-93 0-158.5 65.5T32 288q0 69 38 125t100 82q-54 19-95 60Q0 630 0 736v191q0 40 28 68t68 28h320q31 0 55.5-18t34.5-46h294q40 0 68-28t28-68V672q0-106-75-181zM527 111q47-47 113-47t113 47 47 113-47 113-113 47-113-47-47-113 47-113zM143 401q-47-47-47-113t47-113 113-47 113 47 47 113-47 113-113 47-113-47zm305 526q0 13-9.5 22.5T416 959H96q-13 0-22.5-9.5T64 927V736q0-79 56.5-135.5T256 544t136 56q1 2 2 3 54 55 54 133v191zm-27-387q-36-30-79-45 43-18 75.5-52t48.5-78q36 44 88 66-54 19-95 60-22 23-38 49zm411 323q0 13-9.5 22.5T800 895H512V736q0-80-46-146 15-30 38-53 57-57 136-57t135.5 56.5T832 672v191z"}))},h=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 32 8"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M4 0C1.79 0 0 1.79 0 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm24 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zM16 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"}))},w=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 21.027502059936523 10.284000396728516"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M3.028 10.284a1 1 0 0 1-1-1V2.902l-.553.276A1 1 0 1 1 .58 1.389l2-1a.998.998 0 0 1 1.447.895v8a1 1 0 0 1-1 1zm9 0h-5a1.002 1.002 0 0 1-.707-1.707l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001a1.33 1.33 0 0 0-.393.948 1 1 0 0 1-2 0c0-.894.348-1.733.98-2.364C8.273 0 10.472 0 11.735 1.264c.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.98 2.364L9.443 8.284h2.586a1 1 0 0 1 0 2zm7.955-5.623a2.725 2.725 0 0 0 .545-1.627 2.753 2.753 0 0 0-2.75-2.75 2.739 2.739 0 0 0-2.44 1.484 1 1 0 1 0 1.776.92.75.75 0 1 1 .664 1.096 1 1 0 0 0 0 2c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25a1 1 0 0 0-2 0c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25a3.23 3.23 0 0 0-1.045-2.373z"}))},f=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 32 38"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M0 0h32v38H0V0zm3 3v32h26V3H3zm2 2h22v7H5V5zm0 9h14v19H5V14zm16 19V14h6v19h-6zM6 6v5h20V6H6z"}))},y=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 1024 896"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M960 0H64Q38 0 19 19T0 64v768q0 26 19 45t45 19h896q26 0 45-19t19-45V64q0-26-19-45T960 0zM64 64h896v714L724 430q-7-12-21-14t-25 7L524 548 350 305q-10-14-28-13t-26 17L64 757V64zm855 768H97l231-447 184 255 179-145zM737 190q13 0 22.5 9.5T769 222t-9.5 22.5T737 254t-22.5-9.5T705 222t9.5-22.5T737 190zm0-64q-40 0-68 28t-28 68 28 68 68 28 68-28 28-68-28-68-68-28z"}))},v=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 38 26"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M2 0h34a2 2 0 0 1 2 2v22a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm5.77 4C6.24 4 5 5.511 5 7.375v11.25C5 20.489 6.24 22 7.77 22h15.46c1.53 0 2.77-1.511 2.77-3.375V16l6 5h1V5h-1l-6 5V7.375C26 5.511 24.76 4 23.23 4H7.77z"}))},C=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 448 448"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M416 32V0H256L0 288l160 160 23.471-23.904L208 448l240-272V32h-32zM160 425.371L22.39 288 262.621 16H400v137.377l-216.555 247.99-11.34 11.363L160 425.371zm272-255.994L208 425.371l-13.182-12.65L416 160V48h16v121.377z"}),wp.element.createElement("path",{d:"M320 128c17.645 0 32-14.355 32-32s-14.355-32-32-32-32 14.355-32 32 14.355 32 32 32zm0-48c8.836 0 16 7.163 16 16s-7.164 16-16 16-16-7.163-16-16 7.164-16 16-16z"}))}},function(e,t){var n={utf8:{stringToBytes:function(e){return n.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(n.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(3),n(6),n(9),n(12),n(15),n(21),n(24),n(27),n(30),n(33),n(36),n(39),n(42),n(45),n(49),n(52),n(55),n(58)},function(e,t,n){"use strict";var l=n(4),o=(n.n(l),n(5)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.RangeControl,u=(c.TextControl,wp.blocks),m=u.registerBlockType,s=u.InspectorControls,p=function(e){var t=e.attributes.height;return wp.element.createElement("div",{style:{height:t+"px"}})},b=function(e){var t=e.isSelected,n=e.attributes.height;return[!!t&&wp.element.createElement(s,{key:"inspector"},wp.element.createElement(i,{label:a("Height"),value:n,min:"30",max:"200",onChange:function(t){e.setAttributes({height:t})}})),wp.element.createElement("div",{className:e.className,style:{height:n+"px"}})]};m("ugb/spacer",{title:a("Spacer"),icon:r.l,category:"layout",keywords:[a("Spacer"),a("Stackable")],attributes:{height:{default:50,type:"number"}},edit:b,save:p})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(7),o=(n.n(l),n(8)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.blocks,i=c.registerBlockType,u=c.InspectorControls,m=c.ColorPalette,s=c.BlockControls,p=c.AlignmentToolbar,b=wp.components,d=b.PanelColor,g=b.RangeControl,h=function(e){var t=e.attributes,n=t.height,l=t.width,o=t.color,r=t.alignment;return wp.element.createElement("div",{className:"ugb-divider"},wp.element.createElement("hr",{align:r,style:{backgroundColor:o,width:l+"%",height:n}}))},w=function(e){var t=e.isSelected,n=e.attributes,l=n.height,o=n.width,r=n.color,c=n.alignment;return[t&&wp.element.createElement(s,{key:"controls"},wp.element.createElement(p,{value:c,onChange:function(t){e.setAttributes({alignment:t})}})),t&&wp.element.createElement(u,{key:"inspector"},wp.element.createElement(g,{label:a("Height"),value:l,min:"1",max:"10",onChange:function(t){e.setAttributes({height:t})}}),wp.element.createElement(g,{label:a("Width"),value:o,min:"10",max:"100",step:"0.1",onChange:function(t){e.setAttributes({width:t})}}),wp.element.createElement(d,{title:a("Divider Color"),colorValue:r,initialOpen:!1},wp.element.createElement(m,{value:r,onChange:function(t){return e.setAttributes({color:t})}}))),wp.element.createElement("div",{className:"ugb-divider",style:{paddingTop:8,paddingBottom:8}},wp.element.createElement("hr",{align:c,style:{marginTop:0,marginBottom:0,backgroundColor:r,width:o+"%",height:l}}))]};i("ugb/divider",{title:a("Divider"),icon:r.c,category:"layout",keywords:[a("Divider"),a("Stackable")],attributes:{height:{default:1,type:"number"},width:{default:50,type:"number"},color:{type:"string",default:"#dddddd"},alignment:{type:"string",default:"center"}},edit:w,save:h})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(10),o=(n.n(l),n(11)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.blocks,i=c.registerBlockType,u=c.InspectorControls,m=c.BlockControls,s=c.AlignmentToolbar,p=c.RichText,b=c.ColorPalette,d=c.UrlInput,g=wp.components,h=g.PanelColor,w=g.Dashicon,f=g.IconButton,y=g.SelectControl,v=g.RangeControl,C=function(e){var t=e.isSelected,n=(e.className,e.setAttributes),l=e.attributes,o=l.url,r=l.text,c=l.color,i=l.textColor,g=l.size,C=l.textAlignment,E=l.cornerButtonRadius,x=[{value:"small",label:a("Small")},{value:"normal",label:a("Normal")},{value:"medium",label:a("Medium")},{value:"large",label:a("Large")}];return[t&&wp.element.createElement(m,{key:"controls"},wp.element.createElement(s,{value:C,onChange:function(e){n({textAlignment:e})}})),t&&wp.element.createElement(u,{key:"inspector"},wp.element.createElement(y,{label:a("Size"),value:g,options:x.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){n({size:e})}}),wp.element.createElement(v,{label:a("Corner Radius"),value:E,min:"1",max:"50",onChange:function(e){return n({cornerButtonRadius:e})}}),wp.element.createElement(h,{title:a("Background Color"),colorValue:c,initialOpen:!1},wp.element.createElement(b,{value:c,onChange:function(e){return n({color:e})}})),wp.element.createElement(h,{title:a("Text Color"),colorValue:i,initialOpen:!1},wp.element.createElement(b,{value:i,onChange:function(e){return n({textColor:e})}}))),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+C},wp.element.createElement(p,{tagName:"span",placeholder:a("Enter Text"),value:r,onChange:function(e){return n({text:e})},formattingControls:["bold","italic","strikethrough"],className:"wp-ugb-button ugb-button-"+g,style:{backgroundColor:c,color:i,borderRadius:E+"px"},isSelected:t,keepPlaceholderOnFocus:!0})),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+C},wp.element.createElement(w,{icon:"admin-links"}),wp.element.createElement(d,{value:o,onChange:function(e){return n({url:e})}}),wp.element.createElement(f,{icon:"editor-break",label:a("Apply"),type:"submit"}))]},E=function(e){var t=e.attributes,n=t.url,l=t.text,o=t.textAlignment,r=t.color,a=t.textColor,c=t.size,i=t.cornerButtonRadius,u={backgroundColor:r,color:a,borderRadius:i+"px"};return wp.element.createElement("div",{className:"ugb-button-"+o},wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+c,style:u},l))};i("ugb/button",{title:a("Button"),icon:r.a,category:"layout",keywords:[a("Button"),a("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},text:{type:"array",source:"children",selector:"a"},textAlignment:{type:"string",default:"center"},color:{type:"string",default:"#2091e1"},textColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4}},edit:C,save:E})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(13),o=(n.n(l),n(14)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.blocks,i=c.registerBlockType,u=c.InspectorControls,m=c.BlockControls,s=c.RichText,p=c.AlignmentToolbar,b=c.ColorPalette,d=c.UrlInput,g=wp.components,h=g.PanelColor,w=g.IconButton,f=g.Dashicon,y=g.SelectControl,v=g.RangeControl,C=function(e){var t=e.isSelected,n=e.setAttributes,l=e.attributes,o=l.url,r=l.text,c=l.color,i=l.size,g=l.textAlignment,C=l.cornerButtonRadius,E=l.borderThickness,x=[{value:"small",label:a("Small")},{value:"normal",label:a("Normal ")},{value:"medium",label:a("Medium")},{value:"large",label:a("Large")}];return[t&&wp.element.createElement(m,{key:"controls"},wp.element.createElement(p,{value:g,onChange:function(e){n({textAlignment:e})}})),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+g},wp.element.createElement(s,{tagName:"span",placeholder:a("Enter Text"),value:r,onChange:function(e){return n({text:e})},formattingControls:["bold","italic","strikethrough"],className:"wp-ugb-button ugb-button-"+i+" ugb-ghost-button",style:{borderColor:c,color:c,borderRadius:C+"px",borderWidth:E+"px"},isSelected:t,keepPlaceholderOnFocus:!0}),t&&wp.element.createElement(u,{key:"inspector"},wp.element.createElement(y,{label:a("Size"),value:i,options:x.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){n({size:e})}}),wp.element.createElement(v,{label:a("Corner Radius"),value:C,min:"1",max:"50",onChange:function(e){return n({cornerButtonRadius:e})}}),wp.element.createElement(v,{label:a("Border Thickness"),value:E,min:"1",max:"10",onChange:function(e){return n({borderThickness:e})}}),wp.element.createElement(h,{title:a("Button Color"),colorValue:c,initialOpen:!1},wp.element.createElement(b,{value:c,onChange:function(e){return n({color:e})}})))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+g},wp.element.createElement(f,{icon:"admin-links"}),wp.element.createElement(d,{value:o,onChange:function(e){return n({url:e})}}),wp.element.createElement(w,{icon:"editor-break",label:a("Apply"),type:"submit"}))]},E=function(e){var t=e.attributes,n=t.url,l=t.text,o=t.textAlignment,r=t.color,a=t.size,c=t.cornerButtonRadius,i=t.borderThickness,u={borderColor:r,color:r,borderRadius:c+"px",borderWidth:i+"px"};return wp.element.createElement("div",{className:"ugb-button-"+o},wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+a+" ugb-ghost-button",style:u},l))};i("ugb/ghost-button",{title:a("Ghost Button"),icon:r.e,category:"layout",keywords:[a("Ghost Button"),a("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},text:{type:"array",source:"children",selector:"a"},textAlignment:{type:"string",default:"center"},color:{type:"string"},textColor:{type:"string"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:"4"},borderThickness:{type:"number",default:"1"}},edit:C,save:E})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(16),o=(n.n(l),n(17)),r=(n.n(o),n(18)),a=n.n(r),c=n(0),i=wp.i18n.__,u=wp.components,m=u.withState,s=u.SelectControl,p=u.PanelColor,b=u.ToggleControl,d=wp.blocks,g=d.registerBlockType,h=d.InspectorControls,w=d.RichText,f=d.ColorPalette,y=d.BlockControls,v=function(e){var t=[{value:"success",label:i("Success")},{value:"error",label:i("Error")},{value:"warning",label:i("Warning")},{value:"info",label:i("Information")}],n=e.isSelected,l=e.editable,o=e.setState,r=e.setAttributes,a=(e.className,e.attributes),c=a.text,u=a.color,m=a.textColor,d=a.notifType,g=a.dismissible;return[n&&wp.element.createElement(y,{key:"controls"}),wp.element.createElement("div",{key:"editable",className:"ugb-notification type-"+d+" dismissible-"+g},g&&wp.element.createElement("span",{key:"button",className:"close-button"},wp.element.createElement("svg",{viewBox:"0 0 28.3 28.3",style:{fill:m}},wp.element.createElement("path",{d:"M52.4-166.2c3.2,0,3.2-5,0-5C49.2-171.2,49.2-166.2,52.4-166.2L52.4-166.2z"}),wp.element.createElement("path",{d:"M16.8,13.9L26.9,3.8c0.6-0.6,0.6-1.5,0-2.1s-1.5-0.6-2.1,0L14.7,11.8L4.6,1.7C4,1.1,3.1,1.1,2.5,1.7s-0.6,1.5,0,2.1l10.1,10.1L2.5,24c-0.6,0.6-0.6,1.5,0,2.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4L14.7,16l10.1,10.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4c0.6-0.6,0.6-1.5,0-2.1L16.8,13.9z"}))),wp.element.createElement(w,{tagName:"p",placeholder:e.attributes.text.default,value:c,isSelected:n&&"content"===l,onFocus:function(e){return function(){o({editable:e})}}("content"),onChange:function(e){return r({text:e})},className:"wp-ugb-notif notif-"+d,style:{backgroundColor:u,color:m}}),n&&wp.element.createElement(h,{key:"inspector"},wp.element.createElement(b,{label:i("Dismissible"),checked:g,onChange:function(){return r({dismissible:!g})}}),wp.element.createElement(s,{label:i("Notification Type"),value:d,options:t.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){r({notifType:e})}}),wp.element.createElement(p,{title:i("Background Color"),colorValue:u,initialOpen:!1},wp.element.createElement(f,{value:u,onChange:function(e){return r({color:e})}})),wp.element.createElement(p,{title:i("Text Color"),colorValue:m,initialOpen:!1},wp.element.createElement(f,{value:m,onChange:function(e){return r({textColor:e})}}))))]},C=function(e){var t=e.attributes,n=t.text,l=t.color,o=t.textColor,r=t.notifType,c=t.dismissible,i={backgroundColor:l,color:o},u=a()(n+r).substr(0,6);return wp.element.createElement("div",{className:"ugb-notification type-"+r+" dismissible-"+c,"data-uid":u},c&&wp.element.createElement("span",{key:"button",className:"close-button"},wp.element.createElement("svg",{viewBox:"0 0 28.3 28.3",style:{fill:o}},wp.element.createElement("path",{d:"M52.4-166.2c3.2,0,3.2-5,0-5C49.2-171.2,49.2-166.2,52.4-166.2L52.4-166.2z"}),wp.element.createElement("path",{d:"M16.8,13.9L26.9,3.8c0.6-0.6,0.6-1.5,0-2.1s-1.5-0.6-2.1,0L14.7,11.8L4.6,1.7C4,1.1,3.1,1.1,2.5,1.7s-0.6,1.5,0,2.1l10.1,10.1L2.5,24c-0.6,0.6-0.6,1.5,0,2.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4L14.7,16l10.1,10.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4c0.6-0.6,0.6-1.5,0-2.1L16.8,13.9z"}))),wp.element.createElement("p",{className:"wp-ugb-notif notif-"+r,style:i},n))};g("ugb/notification",{title:i("Notification"),icon:c.g,category:"layout",keywords:[i("Notification"),i("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:i("This is an informational alert, usually used for successful subscriptions, promo announcements, and the like.")},color:{type:"string"},textColor:{type:"string"},notifType:{type:"string",default:"success"},dismissible:{type:"boolean",default:!1}},edit:m({editable:"content"})(v),save:C})},function(e,t){},function(e,t){},function(e,t,n){!function(){var t=n(19),l=n(1).utf8,o=n(20),r=n(1).bin,a=function(e,n){e.constructor==String?e=n&&"binary"===n.encoding?r.stringToBytes(e):l.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||(e=e.toString());for(var c=t.bytesToWords(e),i=8*e.length,u=1732584193,m=-271733879,s=-1732584194,p=271733878,b=0;b<c.length;b++)c[b]=16711935&(c[b]<<8|c[b]>>>24)|4278255360&(c[b]<<24|c[b]>>>8);c[i>>>5]|=128<<i%32,c[14+(i+64>>>9<<4)]=i;for(var d=a._ff,g=a._gg,h=a._hh,w=a._ii,b=0;b<c.length;b+=16){var f=u,y=m,v=s,C=p;u=d(u,m,s,p,c[b+0],7,-680876936),p=d(p,u,m,s,c[b+1],12,-389564586),s=d(s,p,u,m,c[b+2],17,606105819),m=d(m,s,p,u,c[b+3],22,-1044525330),u=d(u,m,s,p,c[b+4],7,-176418897),p=d(p,u,m,s,c[b+5],12,1200080426),s=d(s,p,u,m,c[b+6],17,-1473231341),m=d(m,s,p,u,c[b+7],22,-45705983),u=d(u,m,s,p,c[b+8],7,1770035416),p=d(p,u,m,s,c[b+9],12,-1958414417),s=d(s,p,u,m,c[b+10],17,-42063),m=d(m,s,p,u,c[b+11],22,-1990404162),u=d(u,m,s,p,c[b+12],7,1804603682),p=d(p,u,m,s,c[b+13],12,-40341101),s=d(s,p,u,m,c[b+14],17,-1502002290),m=d(m,s,p,u,c[b+15],22,1236535329),u=g(u,m,s,p,c[b+1],5,-165796510),p=g(p,u,m,s,c[b+6],9,-1069501632),s=g(s,p,u,m,c[b+11],14,643717713),m=g(m,s,p,u,c[b+0],20,-373897302),u=g(u,m,s,p,c[b+5],5,-701558691),p=g(p,u,m,s,c[b+10],9,38016083),s=g(s,p,u,m,c[b+15],14,-660478335),m=g(m,s,p,u,c[b+4],20,-405537848),u=g(u,m,s,p,c[b+9],5,568446438),p=g(p,u,m,s,c[b+14],9,-1019803690),s=g(s,p,u,m,c[b+3],14,-187363961),m=g(m,s,p,u,c[b+8],20,1163531501),u=g(u,m,s,p,c[b+13],5,-1444681467),p=g(p,u,m,s,c[b+2],9,-51403784),s=g(s,p,u,m,c[b+7],14,1735328473),m=g(m,s,p,u,c[b+12],20,-1926607734),u=h(u,m,s,p,c[b+5],4,-378558),p=h(p,u,m,s,c[b+8],11,-2022574463),s=h(s,p,u,m,c[b+11],16,1839030562),m=h(m,s,p,u,c[b+14],23,-35309556),u=h(u,m,s,p,c[b+1],4,-1530992060),p=h(p,u,m,s,c[b+4],11,1272893353),s=h(s,p,u,m,c[b+7],16,-155497632),m=h(m,s,p,u,c[b+10],23,-1094730640),u=h(u,m,s,p,c[b+13],4,681279174),p=h(p,u,m,s,c[b+0],11,-358537222),s=h(s,p,u,m,c[b+3],16,-722521979),m=h(m,s,p,u,c[b+6],23,76029189),u=h(u,m,s,p,c[b+9],4,-640364487),p=h(p,u,m,s,c[b+12],11,-421815835),s=h(s,p,u,m,c[b+15],16,530742520),m=h(m,s,p,u,c[b+2],23,-995338651),u=w(u,m,s,p,c[b+0],6,-198630844),p=w(p,u,m,s,c[b+7],10,1126891415),s=w(s,p,u,m,c[b+14],15,-1416354905),m=w(m,s,p,u,c[b+5],21,-57434055),u=w(u,m,s,p,c[b+12],6,1700485571),p=w(p,u,m,s,c[b+3],10,-1894986606),s=w(s,p,u,m,c[b+10],15,-1051523),m=w(m,s,p,u,c[b+1],21,-2054922799),u=w(u,m,s,p,c[b+8],6,1873313359),p=w(p,u,m,s,c[b+15],10,-30611744),s=w(s,p,u,m,c[b+6],15,-1560198380),m=w(m,s,p,u,c[b+13],21,1309151649),u=w(u,m,s,p,c[b+4],6,-145523070),p=w(p,u,m,s,c[b+11],10,-1120210379),s=w(s,p,u,m,c[b+2],15,718787259),m=w(m,s,p,u,c[b+9],21,-343485551),u=u+f>>>0,m=m+y>>>0,s=s+v>>>0,p=p+C>>>0}return t.endian([u,m,s,p])};a._ff=function(e,t,n,l,o,r,a){var c=e+(t&n|~t&l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._gg=function(e,t,n,l,o,r,a){var c=e+(t&l|n&~l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._hh=function(e,t,n,l,o,r,a){var c=e+(t^n^l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._ii=function(e,t,n,l,o,r,a){var c=e+(n^(t|~l))+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,n){if(void 0===e||null===e)throw new Error("Illegal argument "+e);var l=t.wordsToBytes(a(e,n));return n&&n.asBytes?l:n&&n.asString?r.bytesToString(l):t.bytesToHex(l)}}()},function(e,t){!function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,l=0;n<e.length;n++,l+=8)t[l>>>5]|=e[n]<<24-l%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],l=0;l<e.length;l+=3)for(var o=e[l]<<16|e[l+1]<<8|e[l+2],r=0;r<4;r++)8*l+6*r<=8*e.length?n.push(t.charAt(o>>>6*(3-r)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],l=0,o=0;l<e.length;o=++l%4)0!=o&&n.push((t.indexOf(e.charAt(l-1))&Math.pow(2,-2*o+8)-1)<<2*o|t.indexOf(e.charAt(l))>>>6-2*o);return n}};e.exports=n}()},function(e,t){function n(e){return!!e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function l(e){return"function"===typeof e.readFloatLE&&"function"===typeof e.slice&&n(e.slice(0,0))}e.exports=function(e){return null!=e&&(n(e)||l(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var l=n(22),o=(n.n(l),n(23)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.withState,m=wp.blocks,s=m.registerBlockType,p=m.InspectorControls,b=m.RichText,d=m.ColorPalette,g=function(e){var t=e.isSelected,n=e.setAttributes,l=(e.className,e.attributes),o=l.color,r=l.text,c=l.borderColor;return[wp.element.createElement("blockquote",{key:"quote",className:"ugb-blockquote",style:{borderLeftColor:c}},wp.element.createElement(b,{tagName:"p",className:"ugb-blockquote-text",value:r,onChange:function(e){return n({text:e})},isSelected:t,style:{color:o}})),t&&wp.element.createElement(p,{key:"inspector"},wp.element.createElement(i,{title:a("Text Color"),colorValue:o,initialOpen:!1},wp.element.createElement(d,{value:o,onChange:function(e){return n({color:e})}})),wp.element.createElement(i,{title:a("Border Color"),colorValue:c,initialOpen:!1},wp.element.createElement(d,{value:c,onChange:function(e){return n({borderColor:e})}})))]},h=function(e){var t=e.attributes,n=t.color,l=t.text,o=t.borderColor;return wp.element.createElement("blockquote",{className:"ugb-blockquote",style:{borderLeftColor:o}},wp.element.createElement("p",{style:{color:n}},l))};s("ugb/blockquote",{title:a("Blockquote"),icon:r.k,category:"common",keywords:[a("Blockquote"),a("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:a("It's okay to acknowledge that life can get complicated, but we musn't forget the beauty in its simplicity, too. From the multitude of stars above, to freshly mowed grass in the morning, life is simply wonderful.")},color:{type:"string",default:"#424242"},borderColor:{type:"string",default:"#2091e1"}},edit:u({editable:"content"})(g),save:h})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(25),o=(n.n(l),n(26)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.withState,m=wp.blocks,s=m.registerBlockType,p=m.InspectorControls,b=m.RichText,d=m.ColorPalette,g=function(e){var t=e.isSelected,n=e.setAttributes,l=(e.className,e.attributes),o=l.color,r=l.text,c=l.borderColor;return[wp.element.createElement("blockquote",{key:"quote",className:"ugb-pullquote",style:{borderTopColor:c,borderBottomColor:c}},wp.element.createElement(b,{tagName:"p",className:"ugb-pullquote-text",value:r,onChange:function(e){return n({text:e})},placeholder:a("Write quote\u2026"),formattingControls:["bold","italic","strikethrough","link"],isSelected:t,keepPlaceholderOnFocus:!0,style:{color:o}})),t&&wp.element.createElement(p,{key:"inspector"},wp.element.createElement(i,{title:a("Text Color"),colorValue:o,initialOpen:!1},wp.element.createElement(d,{value:o,onChange:function(e){return n({color:e})}})),wp.element.createElement(i,{title:a("Border Color"),colorValue:c,initialOpen:!1},wp.element.createElement(d,{value:c,onChange:function(e){return n({borderColor:e})}})))]},h=function(e){var t=e.attributes,n=t.color,l=t.text,o=t.borderColor;return wp.element.createElement("blockquote",{className:"ugb-pullquote",style:{borderTopColor:o,borderBottomColor:o}},wp.element.createElement("p",{style:{color:n}},l))};s("ugb/pullquote",{title:a("Pullquote"),icon:r.k,category:"formatting",keywords:[a("Pullquote"),a("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:a("It's okay to acknowledge that life can get complicated, but we musn't forget the beauty in its simplicity, too. From the multitude of stars above, to freshly mowed grass in the morning, life is simply wonderful.")},color:{type:"string",default:"#2091e1"},borderColor:{type:"string",default:"#2091e1"}},edit:u({editable:"content"})(g),save:h})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(28),o=(n.n(l),n(29)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.Dashicon,m=c.IconButton,s=c.withState,p=c.SelectControl,b=c.RangeControl,d=wp.blocks,g=d.registerBlockType,h=d.InspectorControls,w=(d.BlockControls,d.AlignmentToolbar,d.RichText),f=d.ColorPalette,y=d.UrlInput,v=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.url,s=r.buttonText,d=r.ctaTitle,g=r.bodyText,v=r.color,C=r.textColor,E=r.size,x=r.borderButtonRadius,T=r.bodyTextColor,k=r.titleColor,N=r.bgColor,S=[{value:"small",label:a("Small")},{value:"normal",label:a("Normal")},{value:"medium",label:a("Medium")},{value:"large",label:a("Large")}],B=function(e){return function(){l({editable:e})}};return[wp.element.createElement("div",{key:"editable",className:"ugb-cta",style:{backgroundColor:N}},wp.element.createElement(w,{className:"ugb-cta-title",tagName:"h3",placeholder:a("Add Title"),value:d,onChange:function(e){return o({ctaTitle:e})},isSelected:t&&"ctaTitle"===n,onFocus:B("ctaTitle"),keepPlaceholderOnFocus:!0,style:{color:k}}),wp.element.createElement(w,{tagName:"p",value:g,className:"ugb-cta-bodyText",onChange:function(e){return o({bodyText:e})},isSelected:t&&"bodyText"===n,onFocus:B("bodyText"),placeholder:a("Write body text\u2026"),style:{color:T}}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-cta-button"},wp.element.createElement(w,{tagName:"span",placeholder:a("Add Text"),value:s,onChange:function(e){return o({buttonText:e})},isSelected:t&&"buttonText"===n,onFocus:B("buttonText"),className:"wp-ugb-button ugb-button-"+E,style:{backgroundColor:v,color:C,borderRadius:x+"px"},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement(h,{key:"inspector"},wp.element.createElement(p,{label:a("Button Size"),value:E,options:S.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(b,{label:a("Button Border Radius"),value:x,min:"1",max:"50",onChange:function(e){return o({borderButtonRadius:e})}}),wp.element.createElement(i,{title:a("Title Color"),colorValue:k,initialOpen:!1},wp.element.createElement(f,{value:v,onChange:function(e){return o({titleColor:e})}})),wp.element.createElement(i,{title:a("Body Text Color"),colorValue:T,initialOpen:!1},wp.element.createElement(f,{value:v,onChange:function(e){return o({bodyTextColor:e})}})),wp.element.createElement(i,{title:a("Button Background Color"),colorValue:v,initialOpen:!1},wp.element.createElement(f,{value:v,onChange:function(e){return o({color:e})}})),wp.element.createElement(i,{title:a("Button Text Color"),colorValue:C,initialOpen:!1},wp.element.createElement(f,{value:C,onChange:function(e){return o({textColor:e})}})),wp.element.createElement(i,{title:a("Background Color"),colorValue:N,initialOpen:!1},wp.element.createElement(f,{value:N,onChange:function(e){return o({bgColor:e})}})))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link"},wp.element.createElement(u,{icon:"admin-links"}),wp.element.createElement(y,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(m,{icon:"editor-break",label:a("Apply"),type:"submit"})))]},C=function(e){var t=e.attributes,n=t.url,l=t.buttonText,o=t.ctaTitle,r=t.bodyText,a=t.color,c=t.textColor,i=t.size,u=t.borderButtonRadius,m=t.bodyTextColor,s=t.titleColor,p=t.bgColor,b={backgroundColor:a,color:c,borderRadius:u+"px"};return wp.element.createElement("div",{className:"ugb-cta",style:{backgroundColor:p}},o&&!!o.length&&wp.element.createElement("h3",{className:"ugb-cta-title",style:{color:s}},o),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-cta-bodyText",style:{color:m}},r),l&&!!l.length&&wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-cta-button ugb-button-"+i,style:b},l))};g("ugb/cta",{title:a("Call to Action"),icon:r.b,category:"layout",keywords:[a("Call to Action"),a("Stackable"),a("CTA")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},ctaTitle:{type:"array",source:"children",selector:"h3",default:a("Get Started Today")},bodyText:{type:"array",source:"children",selector:"p",default:a("Get Stackable: Ultimate Gutenberg Blocks today.\xa0 Apart from adding new blocks, it gives Gutenberg users more options and settings to tinker with, expanding Gutenberg\u2019s functionality.")},buttonText:{type:"array",source:"children",selector:"a"},color:{type:"string",default:"#2091e1"},textColor:{type:"string",default:"#ffffff"},titleColor:{type:"string"},bodyTextColor:{type:"string"},bgColor:{type:"string"},size:{type:"string",default:"normal"},borderButtonRadius:{type:"number",default:4}},edit:s({editable:"content"})(v),save:C})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(31),o=(n.n(l),n(32)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.Button,m=c.withState,s=c.SelectControl,p=wp.blocks,b=p.registerBlockType,d=p.InspectorControls,g=p.RichText,h=p.ColorPalette,w=p.MediaUpload,f=p.BlockControls,y=(p.AlignmentToolbar,function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.testimonialTitle,m=r.testimonialTitleTwo,p=r.testimonialTitleThree,b=r.body,y=r.bodyTwo,v=r.bodyThree,C=r.position,E=r.positionTwo,x=r.positionThree,T=(r.href,r.hrefTwo,r.hrefThree,r.mediaID),k=r.mediaIDTwo,N=r.mediaIDThree,S=r.mediaURL,B=r.mediaURLTwo,L=r.mediaURLThree,F=r.columns,O=r.titleColor,I=r.posColor,A=r.bodyTextColor,P=r.iconColor,R=[{value:"1",label:a("One Column")},{value:"2",label:a("Two Column")},{value:"3",label:a("Three Column")}],z=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(f,null),t&&wp.element.createElement(d,{key:"inspector"},wp.element.createElement(s,{label:a("Column Number"),value:F,options:R.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(i,{title:a("Title Color"),colorValue:O,initialOpen:!1},wp.element.createElement(h,{value:O,onChange:function(e){return o({titleColor:e})}})),wp.element.createElement(i,{title:a("Position Color"),colorValue:I,initialOpen:!1},wp.element.createElement(h,{value:I,onChange:function(e){return o({posColor:e})}})),wp.element.createElement(i,{title:a("Body Text Color"),colorValue:A,initialOpen:!1},wp.element.createElement(h,{value:A,onChange:function(e){return o({bodyTextColor:e})}})),wp.element.createElement(i,{title:a("Icon Color"),colorValue:P,initialOpen:!1},wp.element.createElement(h,{value:P,onChange:function(e){return o({iconColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-testimonial column-"+F},wp.element.createElement("div",{className:"ugb-testimonial-column-one"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:T,render:function(e){return wp.element.createElement(u,{className:T?"":"button button-large",onClick:e.open},T?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+S+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:c,onChange:function(e){return o({testimonialTitle:e})},isSelected:t&&"testimonialTitle"===n,onFocus:z("testimonialTitle"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:C,className:"ugb-testimonial-position",onChange:function(e){return o({position:e})},isSelected:t&&"position"===n,onFocus:z("position"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:b,className:"ugb-testimonial-body",onChange:function(e){return o({body:e})},isSelected:t&&"body"===n,onFocus:z("body"),style:{color:A},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-testimonial-column-two"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURLTwo:e.url,mediaIDTwo:e.id})},type:"image",value:k,render:function(e){return wp.element.createElement(u,{className:k?"":"button button-large",onClick:e.open},k?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+B+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:m,onChange:function(e){return o({testimonialTitleTwo:e})},isSelected:t&&"testimonialTitleTwo"===n,onFocus:z("testimonialTitleTwo"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:E,className:"ugb-testimonial-position-two",onChange:function(e){return o({positionTwo:e})},isSelected:t&&"positionTwo"===n,onFocus:z("positionTwo"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:y,className:"ugb-testimonial-body-two",onChange:function(e){return o({bodyTwo:e})},isSelected:t&&"bodyTwo"===n,onFocus:z("bodyTwo"),style:{color:A},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-testimonial-column-three"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURLThree:e.url,mediaIDThree:e.id})},type:"image",value:N,render:function(e){return wp.element.createElement(u,{className:N?"":"button button-large",onClick:e.open},N?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+L+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:p,onChange:function(e){return o({testimonialTitleThree:e})},isSelected:t&&"testimonialTitleThree"===n,onFocus:z("testimonialTitleThree"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:x,className:"ugb-testimonial-position-three",onChange:function(e){return o({positionThree:e})},isSelected:t&&"positionThree"===n,onFocus:z("positionThree"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:v,className:"ugb-testimonial-body-three",onChange:function(e){return o({bodyThree:e})},isSelected:t&&"bodyThree"===n,onFocus:z("bodyThree"),style:{color:A},keepPlaceholderOnFocus:!0})))]}),v=function(e){var t=e.attributes,n=t.testimonialTitle,l=t.testimonialTitleTwo,o=t.testimonialTitleThree,r=t.body,a=t.bodyTwo,c=t.bodyThree,i=t.position,u=t.positionTwo,m=t.positionThree,s=t.mediaURL,p=t.mediaURLTwo,b=t.mediaURLThree,d=(t.mediaID,t.mediaIDTwo,t.mediaIDThree,t.titleColor),g=t.posColor,h=t.bodyTextColor,w=t.iconColor,f=t.columns,y=wp.element.createElement("div",{key:"button",className:"quote-icon"},wp.element.createElement("svg",{viewBox:"0 0 246 187.5",style:{fill:w}},wp.element.createElement("path",{d:"M98.5,0h-93C2.5,0,0,2.5,0,5.5v93c0,3,2.5,5.5,5.5,5.5h39c-1.7,15.5-8.8,50-39,50c-3,0-5.5,2.5-5.5,5.5V182c0,3,2.5,5.5,5.5,5.5c5.2,0,98.5-4.5,98.5-89v-93C104,2.5,101.5,0,98.5,0z"}),wp.element.createElement("path",{d:"M240.5,0h-93c-3,0-5.5,2.5-5.5,5.5v93c0,3,2.5,5.5,5.5,5.5h39c-1.7,15.5-8.8,50-39,50c-3,0-5.5,2.5-5.5,5.5V182c0,3,2.5,5.5,5.5,5.5c5.2,0,98.5-4.5,98.5-89v-93C246,2.5,243.5,0,240.5,0z"}),wp.element.createElement("path",{d:"M161.3-86.3c3.2,0,3.2-5,0-5C158.1-91.3,158.1-86.3,161.3-86.3L161.3-86.3z"})));return wp.element.createElement("div",{className:"ugb-testimonial column-"+f},wp.element.createElement("div",{className:"ugb-testimonial-column-one"},s?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+s+")"},"data-src":s}):y,n&&!!n.length&&wp.element.createElement("h4",{style:{color:d}},n),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-testimonial-position",style:{color:g}},i),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-testimonial-body",style:{color:h}},r)),f>1&&wp.element.createElement("div",{className:"ugb-testimonial-column-two"},p?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+p+")"},"data-src":p}):y,l&&!!l.length&&wp.element.createElement("h4",{style:{color:d}},l),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-testimonial-position-two",style:{color:g}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-testimonial-body-two",style:{color:h}},a)),f>2&&wp.element.createElement("div",{className:"ugb-testimonial-column-three"},b?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+b+")"},"data-src":b}):y,o&&!!o.length&&wp.element.createElement("h4",{style:{color:d}},o),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-testimonial-position-three",style:{color:g}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-testimonial-body-three",style:{color:h}},c)))};b("ugb/testimonial",{title:a("Testimonial"),icon:r.n,category:"common",keywords:[a("Testimonial"),a("Stackable")],attributes:{href:{type:"url"},hrefTwo:{type:"url"},hrefThree:{type:"url"},mediaID:{type:"number"},mediaIDTwo:{type:"number"},mediaIDThree:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-testimonial-column-one .testimonial-image",attribute:"data-src"},mediaURLTwo:{type:"string",source:"attribute",selector:".ugb-testimonial-column-two .testimonial-image",attribute:"data-src"},mediaURLThree:{type:"string",source:"attribute",selector:".ugb-testimonial-column-three .testimonial-image",attribute:"data-src"},testimonialTitle:{type:"array",source:"children",selector:".ugb-testimonial-column-one h4",default:a("Ben Adams")},testimonialTitleTwo:{type:"array",source:"children",selector:".ugb-testimonial-column-two h4",default:a("Alex Johnson")},testimonialTitleThree:{type:"array",source:"children",selector:".ugb-testimonial-column-three h4",default:a("Sammy Simpson")},position:{type:"array",source:"children",selector:".ugb-testimonial-position",default:a("Founder")},positionTwo:{type:"array",source:"children",selector:".ugb-testimonial-position-two",default:a("Editor")},positionThree:{type:"array",source:"children",selector:".ugb-testimonial-position-three",default:a("Programmer")},body:{type:"array",source:"children",selector:".ugb-testimonial-body",default:a("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},bodyTwo:{type:"array",source:"children",selector:".ugb-testimonial-body-two",default:a("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},bodyThree:{type:"array",source:"children",selector:".ugb-testimonial-body-three",default:a("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},titleColor:{type:"string"},posColor:{type:"string"},bodyTextColor:{type:"string"},iconColor:{type:"string"},columns:{type:"select",default:"1"}},edit:m({editable:"content"})(y),save:v})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(34),o=(n.n(l),n(35)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.Button,m=c.SelectControl,s=(c.TextControl,c.withState),p=wp.blocks,b=p.registerBlockType,d=p.InspectorControls,g=p.RichText,h=p.ColorPalette,w=p.MediaUpload,f=p.BlockControls,y=(p.AlignmentToolbar,function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.name,s=r.nameTwo,p=r.nameThree,b=r.des,y=r.desTwo,v=r.desThree,C=r.position,E=r.positionTwo,x=r.positionThree,T=(r.href,r.hrefTwo,r.hrefThree,r.mediaID),k=r.mediaIDTwo,N=r.mediaIDThree,S=r.mediaURL,B=r.mediaURLTwo,L=r.mediaURLThree,F=r.columns,O=r.nameColor,I=r.posColor,A=r.desColor,P=r.iconColor,R=r.shapes,z=[{value:"1",label:a("One Column")},{value:"2",label:a("Two Column")},{value:"3",label:a("Three Column")}],V=[{value:"square",label:a("Square")},{value:"circle",label:a("Circle")}],M=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(f,{key:"controls"}),t&&wp.element.createElement(d,{key:"inspector"},wp.element.createElement(m,{label:a("Image Shape"),value:R,options:V.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({shapes:e})}}),wp.element.createElement(m,{label:a("Column Number"),value:F,options:z.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(i,{title:a("Name Color"),colorValue:O,initialOpen:!1},wp.element.createElement(h,{value:O,onChange:function(e){return o({nameColor:e})}})),wp.element.createElement(i,{title:a("Position Color"),colorValue:I,initialOpen:!1},wp.element.createElement(h,{value:I,onChange:function(e){return o({posColor:e})}})),wp.element.createElement(i,{title:a("Description Color"),colorValue:A,initialOpen:!1},wp.element.createElement(h,{value:A,onChange:function(e){return o({desColor:e})}})),wp.element.createElement(i,{title:a("Icon Color"),colorValue:P,initialOpen:!1},wp.element.createElement(h,{value:P,onChange:function(e){return o({iconColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-team-member column-"+F+" image-"+R},wp.element.createElement("div",{className:"ugb-team-member-column-one"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:T,render:function(e){return wp.element.createElement(u,{className:T?"":"button button-large",onClick:e.open},T?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+S+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:c,onChange:function(e){return o({name:e})},isSelected:t&&"name"===n,onFocus:M("name"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:C,className:"ugb-team-member-position",onChange:function(e){return o({position:e})},isSelected:t&&"position"===n,onFocus:M("position"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:b,className:"ugb-team-member-des",onChange:function(e){return o({des:e})},isSelected:t&&"des"===n,onFocus:M("des"),style:{color:A},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-team-member-column-two"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURLTwo:e.url,mediaIDTwo:e.id})},type:"image",value:k,render:function(e){return wp.element.createElement(u,{className:k?"":"button button-large",onClick:e.open},k?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+B+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:s,onChange:function(e){return o({nameTwo:e})},isSelected:t&&"nameTwo"===n,onFocus:M("nameTwo"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:E,className:"ugb-team-member-position",onChange:function(e){return o({positionTwo:e})},isSelected:t&&"positionTwo"===n,onFocus:M("positionTwo"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:y,className:"ugb-team-member-des-two",onChange:function(e){return o({desTwo:e})},isSelected:t&&"desTwo"===n,onFocus:M("desTwo"),style:{color:A},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-team-member-column-three"},wp.element.createElement("div",null,wp.element.createElement(w,{onSelect:function(e){return o({mediaURLThree:e.url,mediaIDThree:e.id})},type:"image",value:N,render:function(e){return wp.element.createElement(u,{className:N?"":"button button-large",onClick:e.open},N?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+L+")"}}):a("Upload Image"))}})),wp.element.createElement(g,{tagName:"h4",value:p,onChange:function(e){return o({nameThree:e})},isSelected:t&&"nameThree"===n,onFocus:M("nameThree"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:x,className:"ugb-team-member-position",onChange:function(e){return o({positionThree:e})},isSelected:t&&"positionThree"===n,onFocus:M("positionThree"),style:{color:I},keepPlaceholderOnFocus:!0}),wp.element.createElement(g,{tagName:"p",value:v,className:"ugb-team-member-des-three",onChange:function(e){return o({desThree:e})},isSelected:t&&"desThree"===n,onFocus:M("desThree"),style:{color:A},keepPlaceholderOnFocus:!0})))]}),v=function(e){var t=e.attributes,n=t.name,l=t.nameTwo,o=t.nameThree,r=t.shapes,a=t.des,c=t.desTwo,i=t.desThree,u=t.position,m=t.positionTwo,s=t.positionThree,p=t.mediaURL,b=t.mediaURLTwo,d=t.mediaURLThree,g=(t.mediaID,t.mediaIDTwo,t.mediaIDThree,t.nameColor),h=t.posColor,w=t.desColor,f=(t.iconColor,t.columns);return wp.element.createElement("div",{className:"ugb-team-member column-"+f+" image-"+r},wp.element.createElement("div",{className:"ugb-team-member-column-one"},p&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+p+")"},"data-src":p}),n&&!!n.length&&wp.element.createElement("h4",{style:{color:g}},n),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-team-member-des",style:{color:w}},a)),f>1&&wp.element.createElement("div",{className:"ugb-team-member-column-two"},b&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+b+")"},"data-src":b}),l&&!!l.length&&wp.element.createElement("h4",{style:{color:g}},l),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-team-member-des-two",style:{color:w}},c)),f>2&&wp.element.createElement("div",{className:"ugb-team-member-column-three"},d&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+d+")"},"data-src":d}),o&&!!o.length&&wp.element.createElement("h4",{style:{color:g}},o),s&&!!s.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},s),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-team-member-des-three",style:{color:w}},i)))};b("ugb/team-member",{title:a("Team Member"),icon:r.m,category:"common",keywords:[a("Team Member"),a("Stackable")],attributes:{href:{type:"url"},hrefTwo:{type:"url"},hrefThree:{type:"url"},mediaID:{type:"number"},mediaIDTwo:{type:"number"},mediaIDThree:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-team-member-column-one .team-member-image",attribute:"data-src"},mediaURLTwo:{type:"string",source:"attribute",selector:".ugb-team-member-column-two .team-member-image",attribute:"data-src"},mediaURLThree:{type:"string",source:"attribute",selector:".ugb-team-member-column-three .team-member-image",attribute:"data-src"},name:{type:"array",source:"children",selector:".ugb-team-member-column-one h4",default:a("Ben Adams")},nameTwo:{type:"array",source:"children",selector:".ugb-team-member-column-two h4",default:a("Alex Johnson")},nameThree:{type:"array",source:"children",selector:".ugb-team-member-column-three h4",default:a("Sammy Simpson")},position:{type:"array",source:"children",selector:".ugb-team-member-column-one .ugb-team-member-position",default:a("Founder")},positionTwo:{type:"array",source:"children",selector:".ugb-team-member-column-two .ugb-team-member-position",default:a("Editor")},positionThree:{type:"array",source:"children",selector:".ugb-team-member-column-three .ugb-team-member-position",default:a("Programmer")},des:{type:"array",source:"children",selector:".ugb-team-member-des",default:a("Ben is the head of our small team. He loves walking his dog, Walter, when he has some free time.")},desTwo:{type:"array",source:"children",selector:".ugb-team-member-des-two",default:a("Alex handles all written content. She enjoys painting and playing softball on the weekends.")},desThree:{type:"array",source:"children",selector:".ugb-team-member-des-three",default:a("Sammy is our programmer. You'll usually find her nose in a book. She has a cat named Skitty.")},nameColor:{type:"string"},posColor:{type:"string"},desColor:{type:"string"},iconColor:{type:"string"},columns:{type:"select",default:"1"},shapes:{type:"select",default:"square"}},edit:s({editable:"content"})(y),save:v})},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(37),r=(n.n(o),n(38)),a=(n.n(r),n(0)),c=wp.i18n.__,i=wp.components.withState,u=wp.blocks,m=u.registerBlockType,s=u.RichText,p=u.BlockControls,b=function(e){return e.map?e.map(function(e){return e.children}):""},d=function(e){return e.map?e.map(function(e){return{children:e}}):""},g=function(e){var t=(e.focus,e.setFocus,e.editable),n=e.setAttributes,o=e.setState,r=e.className,a=e.isSelected,i=function(e){return function(){o({editable:e})}},u=e.attributes,m=u.text,g=u.moreLabel,h=u.moreText,w=u.lessLabel;return[a&&wp.element.createElement(p,{key:"controls"}),wp.element.createElement("div",{key:"expand",className:r},a&&wp.element.createElement("label",{className:"ugb-editor-label"},"Less text"),wp.element.createElement(s,l({multiline:"p",placeholder:e.attributes.text.default,value:b(m),onChange:function(e){return n({text:d(e)})},isSelected:a&&"text"===t,onFocus:i("text"),className:"ugb-expand-less-text"},"placeholder",c("Some short text that can be expanded to show more details."))),wp.element.createElement(s,l({tagName:"a",placeholder:e.attributes.moreLabel.default,value:g,isSelected:a&&"moreLabel"===t,onFocus:i("moreLabel"),onChange:function(e){return n({moreLabel:e})},formattingControls:["bold","italic","strikethrough"],className:"ugb-expand-more"},"placeholder",c("Show more"))),a&&wp.element.createElement("label",{className:"ugb-editor-label"},"More text"),a&&wp.element.createElement(s,l({multiline:"p",placeholder:e.attributes.moreText.default,value:b(h),isSelected:a&&"moreText"===t,onFocus:i("moreText"),onChange:function(e){return n({moreText:d(e)})},className:"ugb-expand-more-text"},"placeholder",c("Some short text that can be expanded to show more details. Some additional text that can only be seen when expanded."))),a&&wp.element.createElement(s,l({tagName:"a",placeholder:e.attributes.lessLabel.default,value:w,isSelected:a&&"lessLabel"===t,onFocus:i("lessLabel"),onChange:function(e){return n({lessLabel:e})},formattingControls:["bold","italic","strikethrough"],className:"ugb-expand-less"},"placeholder",c("Show less"))))]},h=function(e){var t=e.attributes,n=t.text,l=t.moreLabel,o=t.moreText,r=t.lessLabel;return wp.element.createElement("div",null,wp.element.createElement("div",{className:"ugb-expand-less-text"},n.map&&n.map(function(e,t){return wp.element.createElement("p",{key:t},e.children&&e.children.props.children)})),wp.element.createElement("div",{className:"ugb-expand-more-text",style:{display:"none"}},o.map&&o.map(function(e,t){return wp.element.createElement("p",{key:t},e.children&&e.children.props.children)})),wp.element.createElement("a",{className:"ugb-expand-button",href:"#"},wp.element.createElement("span",{className:"ugb-expand-more"},l),wp.element.createElement("span",{className:"ugb-expand-less",style:{display:"none"}},r)))};m("ugb/expand",{title:c("Expand / Show More"),icon:a.d,category:"formatting",keywords:[c("Expand"),c("Show more/less"),c("Stackable")],attributes:{text:{type:"array",source:"query",selector:".ugb-expand-less-text > p",query:{children:{source:"node"}},default:[]},moreText:{type:"array",source:"query",selector:".ugb-expand-more-text > p",query:{children:{source:"node"}},default:[]},moreLabel:{type:"array",source:"children",selector:".ugb-expand-more",default:c("Show more")},lessLabel:{type:"array",source:"children",selector:".ugb-expand-less",default:c("Show less")}},edit:i({editable:"text"})(g),save:h})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(40),o=(n.n(l),n(41)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.withState,m=c.SelectControl,s=wp.blocks,p=s.registerBlockType,b=s.InspectorControls,d=s.RichText,g=s.ColorPalette,h=(s.MediaUpload,s.BlockControls),w=(s.AlignmentToolbar,s.BlockAlignmentToolbar,function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.editable,o=e.setState,r=e.attributes,c=r.numberBox,u=r.numberBoxTwo,s=r.numberBoxThree,p=r.body,w=r.bodyTwo,f=r.bodyThree,y=r.name,v=r.nameTwo,C=r.nameThree,E=r.columns,x=r.numberBoxColor,T=r.nameColor,k=r.bodyTextColor,N=r.numberBGColor,S=[{value:"1",label:a("One Column")},{value:"2",label:a("Two Column")},{value:"3",label:a("Three Column")}],B=function(e){return function(){o({editable:e})}};return[n&&wp.element.createElement(h,{key:"controls"}),n&&wp.element.createElement(b,{key:"inspector"},wp.element.createElement(m,{label:a("Column Number"),value:E,options:S.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({columns:e})}}),wp.element.createElement(i,{title:a("Number Color"),colorValue:x,initialOpen:!1},wp.element.createElement(g,{value:x,onChange:function(e){return t({numberBoxColor:e})}})),wp.element.createElement(i,{title:a("Number Background Color"),colorValue:N,initialOpen:!1},wp.element.createElement(g,{value:N,onChange:function(e){return t({numberBGColor:e})}})),wp.element.createElement(i,{title:a("Name Color"),colorValue:T,initialOpen:!1},wp.element.createElement(g,{value:T,onChange:function(e){return t({nameColor:e})}})),wp.element.createElement(i,{title:a("Body Text Color"),colorValue:k,initialOpen:!1},wp.element.createElement(g,{value:k,onChange:function(e){return t({bodyTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-number-box column-"+E},wp.element.createElement("div",{className:"ugb-number-box-column-one"},wp.element.createElement(d,{tagName:"span",placeholder:c?c.default:"",value:c,onChange:function(e){return t({numberBox:e})},isSelected:n&&"numberBox"===l,onFocus:B("numberBox"),style:{color:x,backgroundColor:N},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"h4",value:y,className:"ugb-number-box-name",onChange:function(e){return t({name:e})},isSelected:n&&"name"===l,onFocus:B("name"),placeholder:a("Add name\u2026"),style:{color:T},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"p",value:p,className:"ugb-number-box-body",onChange:function(e){return t({body:e})},isSelected:n&&"body"===l,onFocus:B("body"),placeholder:a("Add body\u2026"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-number-box-column-two"},wp.element.createElement(d,{tagName:"span",placeholder:u?u.default:"",value:u,onChange:function(e){return t({numberBoxTwo:e})},isSelected:n&&"numberBoxTwo"===l,onFocus:B("numberBoxTwo"),style:{color:x,backgroundColor:N},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"h4",value:v,className:"ugb-number-box-name-two",onChange:function(e){return t({nameTwo:e})},isSelected:n&&"nameTwo"===l,onFocus:B("nameTwo"),placeholder:a("Add name\u2026"),style:{color:T},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"p",value:w,className:"ugb-number-box-body-two",onChange:function(e){return t({bodyTwo:e})},isSelected:n&&"bodyTwo"===l,onFocus:B("bodyTwo"),placeholder:a("Add body\u2026"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-number-box-column-three"},wp.element.createElement(d,{tagName:"span",placeholder:s?s.default:"",value:s,onChange:function(e){return t({numberBoxThree:e})},isSelected:n&&"numberBoxThree"===l,onFocus:B("numberBoxThree"),style:{color:x,backgroundColor:N},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"h4",value:C,className:"ugb-number-box-name-three",onChange:function(e){return t({nameThree:e})},isSelected:n&&"nameThree"===l,onFocus:B("nameThree"),placeholder:a("Add name\u2026"),style:{color:T},keepPlaceholderOnFocus:!0}),wp.element.createElement(d,{tagName:"p",value:f,className:"ugb-number-box-body-three",onChange:function(e){return t({bodyThree:e})},isSelected:n&&"bodyThree"===l,onFocus:B("bodyThree"),placeholder:a("Add body\u2026"),style:{color:k},keepPlaceholderOnFocus:!0})))]}),f=function(e){var t=e.attributes,n=t.numberBox,l=t.numberBoxTwo,o=t.numberBoxThree,r=t.body,a=t.bodyTwo,c=t.bodyThree,i=t.name,u=t.nameTwo,m=t.nameThree,s=t.numberBoxColor,p=t.nameColor,b=t.bodyTextColor,d=t.numberBGColor,g=t.columns;return wp.element.createElement("div",{className:"ugb-number-box column-"+g},wp.element.createElement("div",{className:"ugb-number-box-column-one"},n&&!!n.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},n),i&&!!i.length&&wp.element.createElement("h4",{className:"ugb-number-box-name",style:{color:p}},i),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-number-box-body",style:{color:b}},r)),g>1&&wp.element.createElement("div",{className:"ugb-number-box-column-two"},l&&!!l.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},l),u&&!!u.length&&wp.element.createElement("h4",{className:"ugb-number-box-name-two",style:{color:p}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-number-box-body-two",style:{color:b}},a)),g>2&&wp.element.createElement("div",{className:"ugb-number-box-column-three"},o&&!!o.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},o),m&&!!m.length&&wp.element.createElement("h4",{className:"ugb-number-box-name-three",style:{color:p}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-number-box-body-three",style:{color:b}},c)))};p("ugb/number-box",{title:a("Number Box"),icon:r.h,category:"common",keywords:[a("Number Box"),a("Stackable")],attributes:{numberBox:{type:"array",source:"children",selector:".ugb-number-box-column-one span",default:a("01")},numberBoxTwo:{type:"array",source:"children",selector:".ugb-number-box-column-two span",default:a("02")},numberBoxThree:{type:"array",source:"children",selector:".ugb-number-box-column-three span",default:a("03")},name:{type:"array",source:"children",selector:".ugb-number-box-name",default:a("Registration")},nameTwo:{type:"array",source:"children",selector:".ugb-number-box-name-two",default:a("Waiting Period")},nameThree:{type:"array",source:"children",selector:".ugb-number-box-name-three",default:a("Delivery")},body:{type:"array",source:"children",selector:".ugb-number-box-body",default:a("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},bodyTwo:{type:"array",source:"children",selector:".ugb-number-box-body-two",default:a("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},bodyThree:{type:"array",source:"children",selector:".ugb-number-box-body-three",default:a("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},numberBoxColor:{type:"string"},nameColor:{type:"string"},bodyTextColor:{type:"string"},numberBGColor:{type:"string"},columns:{type:"select",default:"1"}},edit:u({editable:"content"})(w),save:f})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(43),o=(n.n(l),n(44)),r=(n.n(o),n(0)),a=wp.i18n.__,c=(wp.element.Component,wp.components),i=c.PanelColor,u=c.SelectControl,m=c.withState,s=c.Dashicon,p=c.IconButton,b=c.RangeControl,d=wp.blocks,g=d.registerBlockType,h=d.InspectorControls,w=d.RichText,f=d.ColorPalette,y=d.BlockControls,v=d.UrlInput;g("ugb/pricing-box",{title:a("Pricing Box"),icon:r.j,category:"common",keywords:[a("Pricing Box"),a("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-one a",attribute:"href"},url2:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-two a",attribute:"href"},url3:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-three a",attribute:"href"},pricingBoxTitle:{type:"array",source:"children",selector:".ugb-pricing-box-column-one h3",default:a("Basic")},pricingBoxTitle2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two h3",default:a("Basic")},pricingBoxTitle3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three h3",default:a("Basic")},price:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-pricing",default:a("$9")},price2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-pricing",default:a("$9")},price3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-pricing",default:a("$9")},perMonthLabel:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-per-month-label",default:a("per month")},perMonthLabel2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-per-month-label",default:a("per month")},perMonthLabel3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-per-month-label",default:a("per month")},buttonText:{type:"array",source:"children",selector:".ugb-pricing-box-column-one a",default:a("Buy Now")},buttonText2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two a",default:a("Buy Now")},buttonText3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three a",default:a("Buy Now")},featureList:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-feature-list",default:a("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},featureList2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-feature-list",default:a("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},featureList3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-feature-list",default:a("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},pricingBoxColor:{type:"string"},priceColor:{type:"string"},perMonthLabelColor:{type:"string"},buttonColor:{type:"string"},buttonTextColor:{type:"string"},featureListColor:{type:"string"},columns:{type:"select",default:"1"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4}},edit:m({editable:"content"})(function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.url,m=(r.url2,r.url3,r.pricingBoxTitle),d=r.pricingBoxTitle2,g=r.pricingBoxTitle3,C=r.price,E=r.price2,x=r.price3,T=r.perMonthLabel,k=r.perMonthLabel2,N=r.perMonthLabel3,S=r.buttonText,B=r.buttonText2,L=r.buttonText3,F=r.featureList,O=r.featureList2,I=r.featureList3,A=r.pricingBoxColor,P=r.priceColor,R=r.perMonthLabelColor,z=r.buttonColor,V=r.buttonTextColor,M=r.featureListColor,_=r.columns,U=r.size,D=r.cornerButtonRadius,q=[{value:"1",label:a("One Column")},{value:"2",label:a("Two Column")},{value:"3",label:a("Three Column")}],H=[{value:"small",label:a("Small")},{value:"normal",label:a("Normal")},{value:"medium",label:a("Medium")},{value:"large",label:a("Large")}],j=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(y,{key:"controls"}),t&&wp.element.createElement(h,{key:"inspector"},wp.element.createElement(u,{label:a("Column Number"),value:_,options:q.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(b,{label:a("Corner Radius"),value:D,min:"1",max:"50",onChange:function(e){return o({cornerButtonRadius:e})}}),wp.element.createElement(i,{title:a("Pricing Title Color"),colorValue:A,initialOpen:!1},wp.element.createElement(f,{value:A,onChange:function(e){return o({pricingBoxColor:e})}})),wp.element.createElement(i,{title:a("Price Color"),colorValue:P,initialOpen:!1},wp.element.createElement(f,{value:P,onChange:function(e){return o({priceColor:e})}})),wp.element.createElement(i,{title:a("Per Month Label Color"),colorValue:R,initialOpen:!1},wp.element.createElement(f,{value:R,onChange:function(e){return o({perMonthLabelColor:e})}})),wp.element.createElement(i,{title:a("Feature List Color"),colorValue:M,initialOpen:!1},wp.element.createElement(f,{value:M,onChange:function(e){return o({featureListColor:e})}})),wp.element.createElement(u,{label:a("Button Size"),value:U,options:H.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(i,{title:a("Button Color"),colorValue:z,initialOpen:!1},wp.element.createElement(f,{value:z,onChange:function(e){return o({buttonColor:e})}})),wp.element.createElement(i,{title:a("Button Text Color"),colorValue:V,initialOpen:!1},wp.element.createElement(f,{value:V,onChange:function(e){return o({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-pricing-box column-"+_},wp.element.createElement("div",{className:"ugb-pricing-box-column-one"},wp.element.createElement(w,{tagName:"h3",placeholder:m.default,value:m,onChange:function(e){return o({pricingBoxTitle:e})},isSelected:t&&"pricingBoxTitle"===n,onFocus:j("pricingBoxTitle"),style:{color:A},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:C.default,value:C,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price:e})},isSelected:t&&"price"===n,onFocus:j("price"),style:{color:P},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:T.default,value:T,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel:e})},focus:t&&"perMonthLabel"===n,onFocus:j("perMonthLabel"),style:{color:R},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(w,{tagName:"span",placeholder:S.default,value:S,onChange:function(e){return o({buttonText:e})},className:"wp-ugb-button ugb-button-"+U,isSelected:t&&"buttonText"===n,onFocus:j("buttonText"),style:{backgroundColor:z,color:V,borderRadius:D+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(w,{tagName:"p",placeholder:F.default,value:F,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList:e})},focus:t&&"featureList"===n,onFocus:j("featureList"),style:{color:M},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(s,{icon:"admin-links"}),wp.element.createElement(v,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(p,{icon:"editor-break",label:a("Apply"),type:"submit"}))),wp.element.createElement("div",{className:"ugb-pricing-box-column-two"},wp.element.createElement(w,{tagName:"h3",placeholder:d.default,value:d,onChange:function(e){return o({pricingBoxTitle2:e})},isSelected:t&&"pricingBoxTitle2"===n,onFocus:j("pricingBoxTitle2"),style:{color:A},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:E.default,value:E,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price2:e})},isSelected:t&&"price2"===n,onFocus:j("price2"),style:{color:P},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:k.default,value:k,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel2:e})},focus:t&&"perMonthLabel2"===n,onFocus:j("perMonthLabel2"),style:{color:R},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(w,{tagName:"span",placeholder:B.default,value:B,onChange:function(e){return o({buttonText2:e})},className:"wp-ugb-button ugb-button-"+U,isSelected:t&&"buttonText2"===n,onFocus:j("buttonText2"),style:{backgroundColor:z,color:V,borderRadius:D+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(w,{tagName:"p",placeholder:O.default,value:O,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList2:e})},focus:t&&"featureList2"===n,onFocus:j("featureList2"),style:{color:M},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(s,{icon:"admin-links"}),wp.element.createElement(v,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(p,{icon:"editor-break",label:a("Apply"),type:"submit"}))),wp.element.createElement("div",{className:"ugb-pricing-box-column-three"},wp.element.createElement(w,{tagName:"h3",placeholder:g.default,value:g,onChange:function(e){return o({pricingBoxTitle3:e})},isSelected:t&&"pricingBoxTitle3"===n,onFocus:j("pricingBoxTitle3"),style:{color:A},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:x.default,value:x,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price3:e})},isSelected:t&&"price3"===n,onFocus:j("price3"),style:{color:P},keepPlaceholderOnFocus:!0}),wp.element.createElement(w,{tagName:"p",placeholder:N.default,value:N,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel3:e})},focus:t&&"perMonthLabel3"===n,onFocus:j("perMonthLabel3"),style:{color:R},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(w,{tagName:"span",placeholder:L.default,value:L,onChange:function(e){return o({buttonText3:e})},className:"wp-ugb-button ugb-button-"+U,isSelected:t&&"buttonText3"===n,onFocus:j("buttonText3"),style:{backgroundColor:z,color:V,borderRadius:D+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(w,{tagName:"p",placeholder:I.default,value:I,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList3:e})},focus:t&&"featureList3"===n,onFocus:j("featureList3"),style:{color:M},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(s,{icon:"admin-links"}),wp.element.createElement(v,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(p,{icon:"editor-break",label:a("Apply"),type:"submit"}))))]}),save:function(e){var t=e.attributes,n=t.url,l=t.url2,o=t.url3,r=t.pricingBoxTitle,a=t.pricingBoxTitle2,c=t.pricingBoxTitle3,i=t.price,u=t.price2,m=t.price3,s=t.perMonthLabel,p=t.perMonthLabel2,b=t.perMonthLabel3,d=t.buttonText,g=t.buttonText2,h=t.buttonText3,w=t.featureList,f=t.featureList2,y=t.featureList3,v=t.pricingBoxColor,C=t.priceColor,E=t.perMonthLabelColor,x=t.buttonColor,T=t.buttonTextColor,k=t.featureListColor,N=t.columns,S=t.size,B=t.cornerButtonRadius,L={backgroundColor:x,color:T,borderRadius:B+"px"};return wp.element.createElement("div",{className:"ugb-pricing-box column-"+N},wp.element.createElement("div",{className:"ugb-pricing-box-column-one"},r&&!!r.length&&wp.element.createElement("h3",{style:{color:v}},r),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:C}},i),s&&!!s.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:E}},s),d&&!!d.length&&wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+S,style:L},d),w&&!!w.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},w)),N>1&&wp.element.createElement("div",{className:"ugb-pricing-box-column-two"},a&&!!a.length&&wp.element.createElement("h3",{style:{color:v}},a),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:C}},u),p&&!!p.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:E}},p),g&&!!g.length&&wp.element.createElement("a",{href:l,className:"wp-ugb-button ugb-button-"+S,style:L},g),f&&!!f.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},f)),N>2&&wp.element.createElement("div",{className:"ugb-pricing-box-column-three"},c&&!!c.length&&wp.element.createElement("h3",{style:{color:v}},c),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:C}},m),b&&!!b.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:E}},b),h&&!!h.length&&wp.element.createElement("a",{href:o,className:"wp-ugb-button ugb-button-"+S,style:L},h),y&&!!y.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},y)))}})},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(e){return 0===e?null:"overlay-opacity-"+1*Math.round(e/1)}var o=n(46),r=n.n(o),a=n(47),c=(n.n(a),n(48)),i=(n.n(c),n(0)),u=wp.i18n.__,m=wp.components,s=m.IconButton,p=m.PanelColor,b=m.Dashicon,d=m.RangeControl,g=m.SelectControl,h=m.Toolbar,w=m.Button,f=m.withState,y=wp.blocks,v=y.registerBlockType,C=y.RichText,E=y.AlignmentToolbar,x=y.MediaUpload,T=y.BlockControls,k=y.InspectorControls,N=y.ColorPalette,S=y.UrlInput,B=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,o=e.editable,a=e.setState,c=e.attributes,i=c.url,m=c.buttonURL,f=c.buttonText,y=c.buttonColor,v=c.buttonTextColor,B=c.cornerButtonRadius,L=c.size,F=c.title,O=c.titleColor,I=c.subtitle,A=c.subtitleColor,P=c.contentAlign,R=c.id,z=c.backgroundColor,V=c.opacity,M=i?{backgroundImage:"url("+i+")"}:void 0,_=i?"has-image":"",U=r()(l(V),{"overlay-opacity":0!==V}),D=function(e){return function(){a({editable:e})}},q=[{value:"small",label:u("Small")},{value:"normal",label:u("Normal")},{value:"medium",label:u("Medium")},{value:"large",label:u("Large")}];return[n&&wp.element.createElement(T,{key:"controls"},wp.element.createElement(E,{value:P,onChange:function(e){return t({contentAlign:e})}}),wp.element.createElement(h,null,wp.element.createElement(x,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:R,render:function(e){var t=e.open;return wp.element.createElement(s,{className:"components-toolbar__control",label:u("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(k,{key:"inspector"},wp.element.createElement(p,{title:u("Title Color"),colorValue:O,initialOpen:!1},wp.element.createElement(N,{value:O,onChange:function(e){return t({titleColor:e})}})),wp.element.createElement(p,{title:u("Subtitle Color"),colorValue:A,initialOpen:!1},wp.element.createElement(N,{value:A,onChange:function(e){return t({subtitleColor:e})}})),wp.element.createElement(p,{title:u("Heading Background Color"),colorValue:z,initialOpen:!1},wp.element.createElement(N,{value:z,onChange:function(e){return t({backgroundColor:e})}})),wp.element.createElement(d,{label:u("Background Opacity"),value:V,min:0,max:10,step:1,onChange:function(e){return t({opacity:e})}}),wp.element.createElement("h2",null,"Button Settings"),wp.element.createElement(g,{label:u("Button Size"),value:L,options:q.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({size:e})}}),wp.element.createElement(d,{label:u("Corner Radius"),value:B,min:"1",max:"50",onChange:function(e){return t({cornerButtonRadius:e})}}),wp.element.createElement(p,{title:u("Button Color"),colorValue:y,initialOpen:!1},wp.element.createElement(N,{value:y,onChange:function(e){return t({buttonColor:e})}})),wp.element.createElement(p,{title:u("Button Text Color"),colorValue:v,initialOpen:!1},wp.element.createElement(N,{value:v,onChange:function(e){return t({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-header "+_+" "},wp.element.createElement("div",{className:"ugb-header-overlay "+U,style:{backgroundColor:z}}),wp.element.createElement(x,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:R,render:function(e){return[!i&&wp.element.createElement(w,{className:R?"":"button button-large",onClick:e.open},u("Upload Image"))]}}),wp.element.createElement("section",{key:"preview","data-url":i,style:M,className:"ugb-header-section"},wp.element.createElement(C,{tagName:"h2",className:"ugb-header-title",placeholder:F.default,value:F,onChange:function(e){return t({title:e})},isSelected:n&&"title"===o,onFocus:D("title"),style:{textAlign:P,color:O}}),wp.element.createElement(C,{tagName:"p",className:"ugb-header-subtitle",placeholder:I.default,value:I,onChange:function(e){return t({subtitle:e})},isSelected:n&&"subtitle"===o,onFocus:D("subtitle"),style:{textAlign:P,color:A}}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+P},wp.element.createElement(C,{tagName:"span",placeholder:f.default,value:f,onChange:function(e){return t({buttonText:e})},className:"wp-ugb-button ugb-button-"+L,style:{backgroundColor:y,color:v,borderRadius:B+"px"},isSelected:n&&"buttonText"===o,onFocus:D("buttonText"),keepPlaceholderOnFocus:!0})))),n&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+P},wp.element.createElement(b,{icon:"admin-links"}),wp.element.createElement(S,{value:m,onChange:function(e){return t({buttonURL:e})}}),wp.element.createElement(s,{icon:"editor-break",label:u("Apply"),type:"submit"}))]},L=function(e){var t=e.attributes,n=t.url,o=t.buttonURL,a=t.buttonText,c=t.buttonColor,i=t.buttonTextColor,u=t.cornerButtonRadius,m=t.size,s=t.title,p=t.titleColor,b=t.subtitle,d=t.subtitleColor,g=(t.contentAlign,t.id,t.backgroundColor),h=t.opacity,w={backgroundColor:c,color:i,borderRadius:u+"px"},f=n?{backgroundImage:"url("+n+")"}:void 0,y=n?"has-image":"",v=r()(l(h),{"overlay-opacity":0!==h}),C=s.length||b.length||a.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-header "+y+" "+C},wp.element.createElement("div",{className:"ugb-header-overlay "+v,style:{backgroundColor:g}}),wp.element.createElement("section",{key:"preview","data-url":n,style:f,className:"ugb-header-section"},s&&!!s.length&&wp.element.createElement("h2",{className:"ugb-header-title",style:{color:p}},s),b&&!!b.length&&wp.element.createElement("p",{className:"ugb-header-subtitle",style:{color:d}},b),a&&!!a.length&&wp.element.createElement("a",{href:o,className:"wp-ugb-button ugb-button-"+m,style:w},a)))};v("ugb/header",{title:u("Header"),icon:i.f,category:"common",keywords:[u("Header"),u("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h2",default:u("Heading Title")},subtitle:{type:"array",source:"children",selector:"p",default:u("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus congue tincidunt nisit ut pretium. Duis blandit, tortor et suscipit tincidunt, dolor metus mattis neque, ac varius magna nibh ac tortor.")},url:{type:"string",source:"attribute",selector:".ugb-header .ugb-header-section",attribute:"data-url"},buttonURL:{type:"string",source:"attribute",selector:"a",attribute:"href"},titleColor:{type:"string",default:"#ffffff"},subtitleColor:{type:"string",default:"#ffffff"},buttonText:{type:"array",source:"children",selector:".ugb-header a.wp-ugb-button",default:u("Button")},buttonColor:{type:"string",default:"#2091e1"},buttonTextColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4},contentAlign:{type:"string",default:"center"},id:{type:"number"},backgroundColor:{type:"string",default:"#000000"},opacity:{type:"number",default:5}},edit:f({editable:"content"})(B),save:L})},function(e,t,n){var l,o;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var l=arguments[t];if(l){var o=typeof l;if("string"===o||"number"===o)e.push(l);else if(Array.isArray(l))e.push(n.apply(null,l));else if("object"===o)for(var a in l)r.call(l,a)&&l[a]&&e.push(a)}}return e.join(" ")}var r={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?e.exports=n:(l=[],void 0!==(o=function(){return n}.apply(t,l))&&(e.exports=o))}()},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(50),o=(n.n(l),n(51)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.IconButton,u=c.PanelColor,m=c.Toolbar,s=c.Button,p=c.withState,b=c.RangeControl,d=c.SelectControl,g=c.ToggleControl,h=wp.blocks,w=h.registerBlockType,f=h.RichText,y=h.MediaUpload,v=h.BlockControls,C=h.InspectorControls,E=h.ColorPalette,x=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.editable,o=e.setState,r=e.attributes,c=r.url,p=r.title,h=r.titleColor,w=r.subtitle,x=r.subtitleColor,T=r.overlayColor,k=r.id,N=r.height,S=r.width,B=r.verticalAlign,L=r.horizontalAlign,F=r.full,O=c?"has-image":"",I=F?"full-width":"",A=function(e){return function(){o({editable:e})}},P=[{value:"flex-start",label:a("Top")},{value:"center",label:a("Center")},{value:"flex-end",label:a("Bottom")}],R=[{value:"flex-start",label:a("Left")},{value:"center",label:a("Center")},{value:"flex-end",label:a("Right")}];return[n&&wp.element.createElement(v,{key:"controls"},c&&wp.element.createElement(m,null,wp.element.createElement(y,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:k,render:function(e){var t=e.open;return wp.element.createElement(i,{className:"components-toolbar__control",label:a("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(C,{key:"inspector"},wp.element.createElement(g,{label:"Full-Width",checked:!!F,onChange:function(){return t({full:!F})}}),wp.element.createElement(b,{label:a("Height"),value:N,min:"135",max:"700",onChange:function(e){return t({height:e})}}),wp.element.createElement(b,{label:a("Width"),value:S,min:"400",max:"999",onChange:function(e){return t({width:e})}}),wp.element.createElement(d,{label:a("Vertical Alignment"),value:B,options:P.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({verticalAlign:e})}}),wp.element.createElement(d,{label:a("Horizontal Alignment"),value:L,options:R.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({horizontalAlign:e})}}),wp.element.createElement(u,{title:a("Title Color"),colorValue:h,initialOpen:!1},wp.element.createElement(E,{value:h,onChange:function(e){return t({titleColor:e})}})),wp.element.createElement(u,{title:a("Subtitle Color"),colorValue:x,initialOpen:!1},wp.element.createElement(E,{value:x,onChange:function(e){return t({subtitleColor:e})}})),wp.element.createElement(u,{title:a("Overlay Color"),colorValue:T,initialOpen:!1},wp.element.createElement(E,{value:T,onChange:function(e){return t({overlayColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-image-box "+O+" "+I,"data-url":c,style:{width:S+"px",height:N+"px",backgroundImage:"url("+c+")",alignItems:L,justifyContent:B}},wp.element.createElement(y,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:k,render:function(e){return[!c&&wp.element.createElement(s,{className:k?"":"button button-large",onClick:e.open},a("Upload Image"))]}}),wp.element.createElement("a",{href:"#",style:{backgroundColor:T}}),wp.element.createElement(f,{tagName:"h4",placeholder:p.default,value:p,onChange:function(e){return t({title:e})},isSelected:n&&"title"===l,onFocus:A("title"),style:{color:h}}),wp.element.createElement(f,{tagName:"p",placeholder:w.default,value:w,onChange:function(e){return t({subtitle:e})},isSelected:n&&"subtitle"===l,onFocus:A("subtitle"),style:{color:x}}))]},T=function(e){var t=e.attributes,n=t.url,l=t.title,o=t.titleColor,r=t.subtitle,a=t.subtitleColor,c=t.overlayColor,i=(t.id,t.height),u=t.width,m=t.verticalAlign,s=t.horizontalAlign,p=t.full,b=n?"has-image":"",d=p?"full-width":"",g=l.length||r.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-image-box "+b+" "+g+" "+d,"data-url":n,style:{width:u+"px",height:i+"px",backgroundImage:"url("+n+")",alignItems:s,justifyContent:m}},wp.element.createElement("a",{href:"#",style:{backgroundColor:c}}),l&&!!l.length&&wp.element.createElement("h4",{style:{color:o}},l),r&&!!r.length&&wp.element.createElement("p",{style:{color:a}},r))};w("ugb/image-box",{title:a("Image Box"),icon:r.i,category:"common",keywords:[a("Image Box"),a("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h4",default:a("Title")},subtitle:{type:"array",source:"children",selector:"p",default:a("Subtitle goes here")},url:{type:"string",source:"attribute",selector:".ugb-image-box",attribute:"data-url"},titleColor:{type:"string",default:"#ffffff"},subtitleColor:{type:"string",default:"#ffffff"},overlayColor:{type:"string",default:"#42b078"},id:{type:"number"},width:{type:"number",default:"400"},height:{type:"number",default:"400"},verticalAlign:{type:"string",default:"center"},horizontalAlign:{type:"string",default:"center"},full:{type:"boolean",default:!1}},edit:p({editable:"content"})(x),save:T})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(53),o=(n.n(l),n(54)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.withState,m=c.RangeControl,s=wp.blocks,p=s.registerBlockType,b=s.InspectorControls,d=s.RichText,g=s.ColorPalette,h=function(e){var t=function(e){return function(){o({editable:e})}},n=e.isSelected,l=e.editable,o=e.setState,r=e.setAttributes,c=(e.className,e.attributes),u=c.color,s=c.headingColor,p=c.desColor,h=c.title,w=c.counter,f=c.des,y=c.fontSize;return[wp.element.createElement("div",{className:"ugb-countup"},wp.element.createElement(d,{tagName:"h4",value:h,onChange:function(e){return r({title:e})},isSelected:n&&"title"===l,onFocus:t("title"),style:{color:s}}),wp.element.createElement(d,{tagName:"div",className:"ugb-counter",placeholder:w.default,"data-duration":"1000","data-delay":"16",value:w,onChange:function(e){return r({counter:e})},isSelected:n&&"counter"===l,onFocus:t("counter"),style:{color:u,fontSize:y+"px"}}),wp.element.createElement(d,{tagName:"p",className:"ugb-counter-des",value:f,onChange:function(e){return r({des:e})},isSelected:n&&"des"===l,onFocus:t("des"),style:{color:p}})),n&&wp.element.createElement(b,{key:"inspector"},wp.element.createElement(i,{title:a("Heading Color"),colorValue:s,initialOpen:!1},wp.element.createElement(g,{value:s,onChange:function(e){return r({headingColor:e})}})),wp.element.createElement(i,{title:a("Count Up Text Color"),colorValue:u,initialOpen:!1},wp.element.createElement(g,{value:u,onChange:function(e){return r({color:e})}})),wp.element.createElement(i,{title:a("Description Color"),colorValue:p,initialOpen:!1},wp.element.createElement(g,{value:p,onChange:function(e){return r({desColor:e})}})),wp.element.createElement(m,{label:a("Counter Text Font Size"),max:"100",min:"10",value:y,onChange:function(e){return r({fontSize:e})}}))]},w=function(e){var t=e.attributes,n=t.color,l=t.headingColor,o=t.desColor,r=t.title,a=t.counter,c=t.des,i=t.fontSize;return wp.element.createElement("div",{className:"ugb-countup"},wp.element.createElement("h4",{style:{color:l}}," ",r," "),wp.element.createElement("div",{className:"ugb-counter",style:{color:n,fontSize:i+"px"},"data-duration":"1000","data-delay":"16"},a),wp.element.createElement("p",{style:{color:o}}," ",c," "))};p("ugb/count-up",{title:a("Count Up"),icon:r.h,category:"common",keywords:[a("Count Up"),a("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h4",default:a("Happy Customers")},counter:{type:"array",source:"children",selector:".ugb-counter",default:"12,345"},des:{type:"array",source:"children",selector:"p",default:a("and counting")},fontSize:{type:"number",default:"60"},headingColor:{type:"string"},desColor:{type:"string"},color:{type:"string"}},edit:u({editable:"content"})(h),save:w})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(56),o=(n.n(l),n(57)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.IconButton,u=c.PanelColor,m=c.Button,s=c.SelectControl,p=c.Dashicon,b=c.Toolbar,d=wp.blocks,g=d.registerBlockType,h=d.MediaUpload,w=d.InspectorControls,f=d.ColorPalette,y=d.BlockControls,v=d.UrlInput,C={normal:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",viewBox:"0 0 256 320"},wp.element.createElement("path",{d:"M0 0v320l256-160L0 0z"})),circle:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"50",height:"50",viewBox:"0 0 40 40"},wp.element.createElement("path",{d:"M16 29l12-9-12-9v18zm4-29C8.95 0 0 8.95 0 20s8.95 20 20 20 20-8.95 20-20S31.05 0 20 0zm0 36c-8.82 0-16-7.18-16-16S11.18 4 20 4s16 7.18 16 16-7.18 16-16 16z"})),outline:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"50",height:"50",viewBox:"0 0 34 34"},wp.element.createElement("path",{d:"M17 34C7.6 34 0 26.4 0 17S7.6 0 17 0s17 7.6 17 17-7.6 17-17 17zm0-32C8.7 2 2 8.7 2 17s6.7 15 15 15 15-6.7 15-15S25.3 2 17 2z"}),wp.element.createElement("path",{d:"M12 25.7V8.3L27 17l-15 8.7zm2-14v10.5l9-5.3-9-5.2z"}))},E=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.attributes,o=l.videoLink,r=l.mediaLink,c=l.overlayColor,d=l.playButtonType,g=l.mediaID,E=[{value:"normal",label:a("Normal Play Button")},{value:"circle",label:a("Play Button with Circle")},{value:"outline",label:a("Outline Play Button")}];return[n&&wp.element.createElement(y,{key:"controls"},r&&wp.element.createElement(b,null,wp.element.createElement(h,{onSelect:function(e){return t({mediaLink:e.url,mediaID:e.id})},type:"image",value:g,render:function(e){var t=e.open;return wp.element.createElement(i,{className:"components-toolbar__control",label:a("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(w,{key:"inspector"},wp.element.createElement(s,{label:a("Play Button Style"),value:d,options:E.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({playButtonType:e})}}),wp.element.createElement(u,{title:a("Background/Overlay Color"),colorValue:c,initialOpen:!1},wp.element.createElement(f,{value:c,onChange:function(e){return t({overlayColor:e})}}))),wp.element.createElement("div",{className:"ugb-video-popup","data-video":o,style:{backgroundColor:c}},wp.element.createElement("div",{className:"ugb-video-preview",style:{backgroundImage:"url("+r+")"}}),wp.element.createElement("div",{className:"ugb-video-wrapper"},wp.element.createElement(h,{onSelect:function(e){return t({mediaLink:e.url,mediaID:e.id})},type:"image",value:g,render:function(e){return[!r&&wp.element.createElement(m,{className:g?"":"button button-large",onClick:e.open},a("Upload Image"))]}}),wp.element.createElement("div",{className:"ugb-video-overlay",style:{backgroundColor:c}}),wp.element.createElement("span",{className:"ugb-play-button"},C[d]))),n&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"ugb-video-popup-link blocks-button__inline-link"},wp.element.createElement(p,{icon:"admin-links"}),wp.element.createElement(v,{value:o,onChange:function(e){return t({videoLink:e})}}),wp.element.createElement(i,{icon:"editor-break",label:a("Apply"),type:"submit"}),wp.element.createElement("p",null,wp.element.createElement("i",null,"Youtube/Vimeo ID only")))]},x=function(e){var t=e.attributes,n=t.videoLink,l=t.mediaLink,o=t.overlayColor,r=t.playButtonType;t.mediaID;return wp.element.createElement("div",{className:"ugb-video-popup","data-video":n,style:{backgroundColor:o}},wp.element.createElement("div",{className:"ugb-video-preview",style:{backgroundImage:"url("+l+")"},"data-url":l}),wp.element.createElement("div",{className:"ugb-video-wrapper"},wp.element.createElement("a",{href:"#",style:{backgroundColor:o}}),wp.element.createElement("span",{className:"ugb-play-button"},C[r])))};g("ugb/video-popup",{title:a("Video Popup"),icon:r.o,category:"common",keywords:[a("Video Popup"),a("Stackable")],attributes:{videoLink:{type:"string",source:"attribute",selector:".ugb-video-popup",attribute:"data-video"},mediaLink:{type:"string",source:"attribute",selector:".ugb-video-preview",attribute:"data-url"},mediaID:{type:"number"},overlayColor:{type:"string",default:"#000000"},playButtonType:{type:"string",default:"normal"}},edit:E,save:x})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(59),o=(n.n(l),n(60)),r=(n.n(o),n(0)),a=wp.i18n.__,c=wp.components,i=c.PanelColor,u=c.Button,m=c.IconButton,s=c.Dashicon,p=c.withState,b=c.SelectControl,d=c.RangeControl,g=c.Toolbar,h=wp.blocks,w=h.registerBlockType,f=h.InspectorControls,y=h.RichText,v=h.ColorPalette,C=h.MediaUpload,E=h.BlockControls,x=h.UrlInput,T=h.AlignmentToolbar,k=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.heading,p=r.tagline,h=r.des,w=r.mediaID,k=r.mediaURL,N=r.headingColor,S=r.taglineColor,B=r.desColor,L=r.buttonURL,F=r.buttonText,O=r.buttonColor,I=r.buttonTextColor,A=r.size,P=r.cornerButtonRadius,R=r.contentAlign,z=function(e){return function(){l({editable:e})}},V=k?"has-image":"",M=[{value:"small",label:a("Small")},{value:"normal",label:a("Normal")},{value:"medium",label:a("Medium")},{value:"large",label:a("Large")}];return[t&&wp.element.createElement(E,{key:"controls"},wp.element.createElement(T,{value:R,onChange:function(e){return o({contentAlign:e})}}),wp.element.createElement(g,null,wp.element.createElement(C,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:w,render:function(e){var t=e.open;return wp.element.createElement(m,{className:"components-toolbar__control",label:a("Edit image"),icon:"edit",onClick:t})}}))),t&&wp.element.createElement(f,{key:"inspector"},wp.element.createElement(i,{title:a("Heading Color"),colorValue:N,initialOpen:!1},wp.element.createElement(v,{value:N,onChange:function(e){return o({headingColor:e})}})),wp.element.createElement(i,{title:a("Tagline Color"),colorValue:S,initialOpen:!1},wp.element.createElement(v,{value:S,onChange:function(e){return o({taglineColor:e})}})),wp.element.createElement(i,{title:a("Description Color"),colorValue:B,initialOpen:!1},wp.element.createElement(v,{value:B,onChange:function(e){return o({desColor:e})}})),wp.element.createElement("h2",null,"Button Settings"),wp.element.createElement(b,{label:a("Button Size"),value:A,options:M.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(d,{label:a("Corner Radius"),value:P,min:"1",max:"50",onChange:function(e){return o({cornerButtonRadius:e})}}),wp.element.createElement(i,{title:a("Button Color"),colorValue:O,initialOpen:!1},wp.element.createElement(v,{value:O,onChange:function(e){return o({buttonColor:e})}})),wp.element.createElement(i,{title:a("Button Text Color"),colorValue:I,initialOpen:!1},wp.element.createElement(v,{value:I,onChange:function(e){return o({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-card "+V},wp.element.createElement("div",{className:"ugb-card-image-container",style:{backgroundImage:"url("+k+")",textAlign:R}},wp.element.createElement(C,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:w,render:function(e){return[!k&&wp.element.createElement(u,{className:w?"":"button button-large",onClick:e.open},a("Upload Image"))]}})),wp.element.createElement(y,{tagName:"h4",value:c,className:"ugb-card-heading",onChange:function(e){return o({heading:e})},isSelected:t&&"heading"===n,onFocus:z("heading"),style:{color:N,textAlign:R},keepPlaceholderOnFocus:!0}),wp.element.createElement(y,{tagName:"p",value:p,className:"ugb-tagline",onChange:function(e){return o({tagline:e})},isSelected:t&&"tagline"===n,onFocus:z("tagline"),style:{color:S,textAlign:R},keepPlaceholderOnFocus:!0}),wp.element.createElement(y,{tagName:"p",value:h,className:"ugb-card-des",onChange:function(e){return o({des:e})},isSelected:t&&"des"===n,onFocus:z("des"),style:{color:B,textAlign:R},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+R},wp.element.createElement(y,{tagName:"span",placeholder:F.default,value:F,onChange:function(e){return o({buttonText:e})},className:"wp-ugb-button ugb-button-"+A,style:{backgroundColor:O,color:I,borderRadius:P+"px"},isSelected:t&&"buttonText"===n,onFocus:z("buttonText"),keepPlaceholderOnFocus:!0}))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+R,style:{marginTop:10}},wp.element.createElement(s,{icon:"admin-links"}),wp.element.createElement(x,{value:L,onChange:function(e){return o({buttonURL:e})}}),wp.element.createElement(m,{icon:"editor-break",label:a("Apply"),type:"submit"}))]},N=function(e){var t=e.attributes,n=t.heading,l=t.tagline,o=t.des,r=t.mediaURL,a=(t.mediaID,t.headingColor),c=t.taglineColor,i=t.desColor,u=t.buttonURL,m=t.buttonText,s=t.buttonColor,p=t.buttonTextColor,b=t.size,d=t.cornerButtonRadius,g=t.contentAlign,h={backgroundColor:s,color:p,borderRadius:d+"px"},w=r?"has-image":"",f=n.length||l.length||o.length||m.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-card "+w+" "+f},r&&wp.element.createElement("div",{className:"ugb-card-image-container",style:{backgroundImage:"url("+r+")"},"data-src":r}),n&&!!n.length&&wp.element.createElement("h4",{style:{color:a,textAlign:g}},n),l&&!!l.length&&wp.element.createElement("p",{className:"ugb-tagline",style:{color:c,textAlign:g}},l),o&&!!o.length&&wp.element.createElement("p",{className:"ugb-card-des",style:{color:i,textAlign:g}},o),m&&!!m.length&&wp.element.createElement("a",{href:u,className:"wp-ugb-button wp-block-button ugb-button-"+b+" ugb-button-"+g,style:h},m))};w("ugb/card",{title:a("Card"),icon:r.m,category:"common",keywords:[a("Card"),a("Stackable")],attributes:{mediaID:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-card-image-container",attribute:"data-src"},heading:{type:"array",source:"children",selector:".ugb-card h4",default:a("Ben Adams")},tagline:{type:"array",source:"children",selector:".ugb-tagline",default:a("Ben is the head of our small team")},des:{type:"array",source:"children",selector:".ugb-card-des",default:a("Ben is the head of our small team. He loves walking his dog, Walter, when he has some free time.")},headingColor:{type:"string"},taglineColor:{type:"string"},desColor:{type:"string"},buttonURL:{type:"string",source:"attribute",selector:".wp-ugb-button",attribute:"href"},buttonText:{type:"array",source:"children",selector:".wp-block-button",default:a("Button")},buttonColor:{type:"string",default:"#2091e1"},buttonTextColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4},contentAlign:{type:"string",default:"left"}},edit:p({editable:"content"})(k),save:N})},function(e,t){},function(e,t){}]);
1
+ !function(e){function t(l){if(n[l])return n[l].exports;var o=n[l]={i:l,l:!1,exports:{}};return e[l].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,l){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:l})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){"use strict";n.d(t,"g",function(){return c}),n.d(t,"a",function(){return i}),n.d(t,"e",function(){return u}),n.d(t,"c",function(){return m}),n.d(t,"k",function(){return s}),n.d(t,"l",function(){return p}),n.d(t,"n",function(){return b}),n.d(t,"b",function(){return d}),n.d(t,"m",function(){return g}),n.d(t,"d",function(){return h}),n.d(t,"h",function(){return f}),n.d(t,"f",function(){return w}),n.d(t,"i",function(){return y}),n.d(t,"o",function(){return v}),n.d(t,"j",function(){return E});var l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},o=function(e){return wp.element.createElement("defs",null,wp.element.createElement("linearGradient",l({},e,{gradientTransform:"rotate(90)"}),wp.element.createElement("stop",{offset:"0%",stopColor:"#2FDDD1",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"20%",stopColor:"#30A2E3",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"50%",stopColor:"#F56FAE",stopOpacity:"1"}),wp.element.createElement("stop",{offset:"100%",stopColor:"#FFC58E",stopOpacity:"1"})))},r=1,a=function(){return"stk-icon-"+r++},c=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"20",height:"20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M512 96c-111.118 0-215.584 43.272-294.156 121.844S96 400.882 96 512s43.272 215.584 121.844 294.156S400.882 928 512 928s215.584-43.272 294.156-121.844S928 623.118 928 512s-43.272-215.584-121.843-294.156S623.118 96 512 96zm0-96c282.77 0 512 229.23 512 512s-229.23 512-512 512S0 794.77 0 512 229.23 0 512 0zm-64 704h128v128H448zm0-512h128v384H448z"}))},i=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M17 5H3c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm1 7c0 .6-.4 1-1 1H3c-.6 0-1-.4-1-1V7c0-.6.4-1 1-1h14c.6 0 1 .4 1 1v5z"}))},u=function(){return wp.element.createElement(i,null)},m=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M4 9h12v2H4V9z"}))},s=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M8.54 12.74c0-.87-.24-1.61-.72-2.22-.73-.92-2.14-1.03-2.96-.85-.34-1.93 1.3-4.39 3.42-5.45L6.65 1.94C3.45 3.46.31 6.96.85 11.37 1.19 14.16 2.8 16 5.08 16c1 0 1.83-.29 2.48-.88.66-.59.98-1.38.98-2.38zm9.43 0c0-.87-.24-1.61-.72-2.22-.73-.92-2.14-1.03-2.96-.85-.34-1.93 1.3-4.39 3.42-5.45l-1.63-2.28c-3.2 1.52-6.34 5.02-5.8 9.43.34 2.79 1.95 4.63 4.23 4.63 1 0 1.83-.29 2.48-.88.66-.59.98-1.38.98-2.38z"}))},p=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 14 32"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M0 29h5.833L0 23h5V9H0l5.833-6H0V0h14v3H8.167L14 9H9v14h5l-5.833 6H14v3H0v-3z"}))},b=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 13 12.916010856628418"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M5.68 12.916a.5.5 0 0 1-.397-.196L3.208 10H1.463C.656 10 0 9.428 0 8.621V1.463C0 .656.656 0 1.463 0h10.074C12.344 0 13 .656 13 1.463v7.158C13 9.428 12.344 10 11.537 10H8.151l-2.073 2.72a.504.504 0 0 1-.398.196zM1.463 1A.464.464 0 0 0 1 1.463v7.158c0 .255.208.463.463.463h1.993a.5.5 0 0 1 .397.196l1.827 2.312L7.507 9.28a.502.502 0 0 1 .397-.196h3.633A.464.464 0 0 0 12 8.621V1.463A.464.464 0 0 0 11.537 1H1.463zm1.193 2h7.828c.284.024.514.207.514.49a.498.498 0 0 1-.514.496H2.656a.499.499 0 0 1-.514-.496c.001-.283.231-.466.514-.49zm0 3h7.828c.284.024.514.207.514.49a.498.498 0 0 1-.514.496H2.656a.499.499 0 0 1-.514-.496c.001-.283.231-.466.514-.49z"}))},d=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 16 14"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M10 0c-.17 0-.36.05-.52.14C8.04 1.02 4.5 3.58 3 4c-1.38 0-3 .67-3 2.5S1.63 9 3 9c.3.08.64.23 1 .41V14h2v-3.45c1.34.86 2.69 1.83 3.48 2.31.16.09.34.14.52.14.52 0 1-.42 1-1V1c0-.58-.48-1-1-1zm0 12c-.38-.23-.89-.58-1.5-1-.16-.11-.33-.22-.5-.34V2.31c.16-.11.31-.2.47-.31.61-.41 1.16-.77 1.53-1v11zm2-6h4v1h-4V6zm0 2l4 2v1l-4-2V8zm4-6v1l-4 2V4l4-2z"}))},g=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 896 1023"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M821 491q-41-41-95-60 62-26 100-82t38-125q0-93-65.5-158.5T640 0q-71 0-128.5 41T430 147q-32-39-77-61t-97-22q-93 0-158.5 65.5T32 288q0 69 38 125t100 82q-54 19-95 60Q0 630 0 736v191q0 40 28 68t68 28h320q31 0 55.5-18t34.5-46h294q40 0 68-28t28-68V672q0-106-75-181zM527 111q47-47 113-47t113 47 47 113-47 113-113 47-113-47-47-113 47-113zM143 401q-47-47-47-113t47-113 113-47 113 47 47 113-47 113-113 47-113-47zm305 526q0 13-9.5 22.5T416 959H96q-13 0-22.5-9.5T64 927V736q0-79 56.5-135.5T256 544t136 56q1 2 2 3 54 55 54 133v191zm-27-387q-36-30-79-45 43-18 75.5-52t48.5-78q36 44 88 66-54 19-95 60-22 23-38 49zm411 323q0 13-9.5 22.5T800 895H512V736q0-80-46-146 15-30 38-53 57-57 136-57t135.5 56.5T832 672v191z"}))},h=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 32 8"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M4 0C1.79 0 0 1.79 0 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm24 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zM16 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"}))},f=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 21.027502059936523 10.284000396728516"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M3.028 10.284a1 1 0 0 1-1-1V2.902l-.553.276A1 1 0 1 1 .58 1.389l2-1a.998.998 0 0 1 1.447.895v8a1 1 0 0 1-1 1zm9 0h-5a1.002 1.002 0 0 1-.707-1.707l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001a1.33 1.33 0 0 0-.393.948 1 1 0 0 1-2 0c0-.894.348-1.733.98-2.364C8.273 0 10.472 0 11.735 1.264c.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.98 2.364L9.443 8.284h2.586a1 1 0 0 1 0 2zm7.955-5.623a2.725 2.725 0 0 0 .545-1.627 2.753 2.753 0 0 0-2.75-2.75 2.739 2.739 0 0 0-2.44 1.484 1 1 0 1 0 1.776.92.75.75 0 1 1 .664 1.096 1 1 0 0 0 0 2c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25a1 1 0 0 0-2 0c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25a3.23 3.23 0 0 0-1.045-2.373z"}))},w=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 32 38"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M0 0h32v38H0V0zm3 3v32h26V3H3zm2 2h22v7H5V5zm0 9h14v19H5V14zm16 19V14h6v19h-6zM6 6v5h20V6H6z"}))},y=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 1024 896"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M960 0H64Q38 0 19 19T0 64v768q0 26 19 45t45 19h896q26 0 45-19t19-45V64q0-26-19-45T960 0zM64 64h896v714L724 430q-7-12-21-14t-25 7L524 548 350 305q-10-14-28-13t-26 17L64 757V64zm855 768H97l231-447 184 255 179-145zM737 190q13 0 22.5 9.5T769 222t-9.5 22.5T737 254t-22.5-9.5T705 222t9.5-22.5T737 190zm0-64q-40 0-68 28t-28 68 28 68 68 28 68-28 28-68-28-68-68-28z"}))},v=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 38 26"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M2 0h34a2 2 0 0 1 2 2v22a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm5.77 4C6.24 4 5 5.511 5 7.375v11.25C5 20.489 6.24 22 7.77 22h15.46c1.53 0 2.77-1.511 2.77-3.375V16l6 5h1V5h-1l-6 5V7.375C26 5.511 24.76 4 23.23 4H7.77z"}))},E=function(){var e=a();return wp.element.createElement("svg",{className:"dashicon",role:"img",focusable:"false",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 448 448"},wp.element.createElement(o,{id:e}),wp.element.createElement("path",{fill:"url(#"+e+")",d:"M416 32V0H256L0 288l160 160 23.471-23.904L208 448l240-272V32h-32zM160 425.371L22.39 288 262.621 16H400v137.377l-216.555 247.99-11.34 11.363L160 425.371zm272-255.994L208 425.371l-13.182-12.65L416 160V48h16v121.377z"}),wp.element.createElement("path",{d:"M320 128c17.645 0 32-14.355 32-32s-14.355-32-32-32-32 14.355-32 32 14.355 32 32 32zm0-48c8.836 0 16 7.163 16 16s-7.164 16-16 16-16-7.163-16-16 7.164-16 16-16z"}))}},function(e,t,n){"use strict";n.d(t,"q",function(){return l}),n.d(t,"p",function(){return o}),n.d(t,"r",function(){return a}),n.d(t,"i",function(){return c}),n.d(t,"j",function(){return i}),n.d(t,"l",function(){return u}),n.d(t,"m",function(){return m}),n.d(t,"e",function(){return s}),n.d(t,"f",function(){return p}),n.d(t,"c",function(){return b}),n.d(t,"n",function(){return d}),n.d(t,"g",function(){return h}),n.d(t,"b",function(){return f}),n.d(t,"d",function(){return w}),n.d(t,"a",function(){return y}),n.d(t,"k",function(){return v}),n.d(t,"o",function(){return E}),n.d(t,"h",function(){return C});var l=wp.blocks.registerBlockType,o=wp.i18n.__,r=wp.components,a=r.withState,c=r.PanelColor,i=r.RangeControl,u=r.SelectControl,m=(r.TextControl,r.ToggleControl),s=r.Dashicon,p=r.IconButton,b=r.Button,d=r.Toolbar,g=wp.editor.InspectorControls?wp.editor:wp.blocks,h=g.InspectorControls,f=g.BlockControls,w=g.ColorPalette,y=g.AlignmentToolbar,v=g.RichText,E=g.UrlInput,C=g.MediaUpload},function(e,t){var n={utf8:{stringToBytes:function(e){return n.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(n.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(4),n(7),n(10),n(13),n(16),n(22),n(25),n(28),n(31),n(34),n(37),n(40),n(43),n(46),n(50),n(53),n(56),n(59)},function(e,t,n){"use strict";var l=n(5),o=(n.n(l),n(6)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.attributes.height;return wp.element.createElement("div",{style:{height:t+"px"}})},i=function(e){var t=e.isSelected,n=e.attributes.height;return[!!t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.j,{label:Object(a.p)("Height"),value:n,min:"30",max:"200",onChange:function(t){e.setAttributes({height:t})}})),wp.element.createElement("div",{className:e.className,style:{height:n+"px"}})]};Object(a.q)("ugb/spacer",{title:Object(a.p)("Spacer"),icon:r.l,category:"layout",keywords:[Object(a.p)("Spacer"),Object(a.p)("Stackable")],attributes:{height:{default:50,type:"number"}},edit:i,save:c})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(8),o=(n.n(l),n(9)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.attributes,n=t.height,l=t.width,o=t.color,r=t.alignment;return wp.element.createElement("div",{className:"ugb-divider"},wp.element.createElement("hr",{align:r,style:{backgroundColor:o,width:l+"%",height:n}}))},i=function(e){var t=e.isSelected,n=e.attributes,l=n.height,o=n.width,r=n.color,c=n.alignment;return[t&&wp.element.createElement(a.b,{key:"controls"},wp.element.createElement(a.a,{value:c,onChange:function(t){e.setAttributes({alignment:t})}})),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.j,{label:Object(a.p)("Height"),value:l,min:"1",max:"10",onChange:function(t){e.setAttributes({height:t})}}),wp.element.createElement(a.j,{label:Object(a.p)("Width"),value:o,min:"10",max:"100",step:"0.1",onChange:function(t){e.setAttributes({width:t})}}),wp.element.createElement(a.i,{title:Object(a.p)("Divider Color"),colorValue:r,initialOpen:!1},wp.element.createElement(a.d,{value:r,onChange:function(t){return e.setAttributes({color:t})}}))),wp.element.createElement("div",{className:"ugb-divider",style:{paddingTop:8,paddingBottom:8}},wp.element.createElement("hr",{align:c,style:{marginTop:0,marginBottom:0,backgroundColor:r,width:o+"%",height:l}}))]};Object(a.q)("ugb/divider",{title:Object(a.p)("Divider"),icon:r.c,category:"layout",keywords:[Object(a.p)("Divider"),Object(a.p)("Stackable")],attributes:{height:{default:1,type:"number"},width:{default:50,type:"number"},color:{type:"string",default:"#dddddd"},alignment:{type:"string",default:"center"}},edit:i,save:c})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(11),o=(n.n(l),n(12)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=(e.className,e.setAttributes),l=e.attributes,o=l.url,r=l.text,c=l.color,i=l.textColor,u=l.size,m=l.textAlignment,s=l.cornerButtonRadius,p=[{value:"small",label:Object(a.p)("Small")},{value:"normal",label:Object(a.p)("Normal")},{value:"medium",label:Object(a.p)("Medium")},{value:"large",label:Object(a.p)("Large")}];return[t&&wp.element.createElement(a.b,{key:"controls"},wp.element.createElement(a.a,{value:m,onChange:function(e){n({textAlignment:e})}})),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Size"),value:u,options:p.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){n({size:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Corner Radius"),value:s,min:"1",max:"50",onChange:function(e){return n({cornerButtonRadius:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Background Color"),colorValue:c},wp.element.createElement(a.d,{value:c,onChange:function(e){return n({color:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Text Color"),colorValue:i},wp.element.createElement(a.d,{value:i,onChange:function(e){return n({textColor:e})}}))),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+m},wp.element.createElement(a.k,{tagName:"span",placeholder:Object(a.p)("Enter Text"),value:r,onChange:function(e){return n({text:e})},formattingControls:["bold","italic","strikethrough"],className:"wp-ugb-button ugb-button-"+u,style:{backgroundColor:c,color:i,borderRadius:s+"px"},isSelected:t,keepPlaceholderOnFocus:!0})),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+m},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:o,onChange:function(e){return n({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))]},i=function(e){var t=e.attributes,n=t.url,l=t.text,o=t.textAlignment,r=t.color,a=t.textColor,c=t.size,i=t.cornerButtonRadius,u={backgroundColor:r,color:a,borderRadius:i+"px"};return wp.element.createElement("div",{className:"ugb-button-"+o},wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+c,style:u},l))};Object(a.q)("ugb/button",{title:Object(a.p)("Button"),icon:r.a,category:"layout",keywords:[Object(a.p)("Button"),Object(a.p)("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},text:{type:"array",source:"children",selector:"a"},textAlignment:{type:"string",default:"center"},color:{type:"string",default:"#2091e1"},textColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4}},edit:c,save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(14),o=(n.n(l),n(15)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.setAttributes,l=e.attributes,o=l.url,r=l.text,c=l.color,i=l.size,u=l.textAlignment,m=l.cornerButtonRadius,s=l.borderThickness,p=[{value:"small",label:Object(a.p)("Small")},{value:"normal",label:Object(a.p)("Normal ")},{value:"medium",label:Object(a.p)("Medium")},{value:"large",label:Object(a.p)("Large")}];return[t&&wp.element.createElement(a.b,{key:"controls"},wp.element.createElement(a.a,{value:u,onChange:function(e){n({textAlignment:e})}})),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+u},wp.element.createElement(a.k,{tagName:"span",placeholder:Object(a.p)("Enter Text"),value:r,onChange:function(e){return n({text:e})},formattingControls:["bold","italic","strikethrough"],className:"wp-ugb-button ugb-button-"+i+" ugb-ghost-button",style:{borderColor:c,color:c,borderRadius:m+"px",borderWidth:s+"px"},isSelected:t,keepPlaceholderOnFocus:!0}),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Size"),value:i,options:p.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){n({size:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Corner Radius"),value:m,min:"1",max:"50",onChange:function(e){return n({cornerButtonRadius:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Border Thickness"),value:s,min:"1",max:"10",onChange:function(e){return n({borderThickness:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Button Color"),colorValue:c,initialOpen:!1},wp.element.createElement(a.d,{value:c,onChange:function(e){return n({color:e})}})))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+u},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:o,onChange:function(e){return n({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))]},i=function(e){var t=e.attributes,n=t.url,l=t.text,o=t.textAlignment,r=t.color,a=t.size,c=t.cornerButtonRadius,i=t.borderThickness,u={borderColor:r,color:r,borderRadius:c+"px",borderWidth:i+"px"};return wp.element.createElement("div",{className:"ugb-button-"+o},wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+a+" ugb-ghost-button",style:u},l))};Object(a.q)("ugb/ghost-button",{title:Object(a.p)("Ghost Button"),icon:r.e,category:"layout",keywords:[Object(a.p)("Ghost Button"),Object(a.p)("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},text:{type:"array",source:"children",selector:"a"},textAlignment:{type:"string",default:"center"},color:{type:"string"},textColor:{type:"string"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:"4"},borderThickness:{type:"number",default:"1"}},edit:c,save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(17),o=(n.n(l),n(18)),r=(n.n(o),n(19)),a=n.n(r),c=n(0),i=n(1),u=function(e){var t=[{value:"success",label:Object(i.p)("Success")},{value:"error",label:Object(i.p)("Error")},{value:"warning",label:Object(i.p)("Warning")},{value:"info",label:Object(i.p)("Information")}],n=e.isSelected,l=e.editable,o=e.setState,r=e.setAttributes,a=(e.className,e.attributes),c=a.text,u=a.color,m=a.textColor,s=a.notifType,p=a.dismissible;return[n&&wp.element.createElement(i.b,{key:"controls"}),wp.element.createElement("div",{key:"editable",className:"ugb-notification type-"+s+" dismissible-"+p},p&&wp.element.createElement("span",{key:"button",className:"close-button"},wp.element.createElement("svg",{viewBox:"0 0 28.3 28.3",style:{fill:m}},wp.element.createElement("path",{d:"M52.4-166.2c3.2,0,3.2-5,0-5C49.2-171.2,49.2-166.2,52.4-166.2L52.4-166.2z"}),wp.element.createElement("path",{d:"M16.8,13.9L26.9,3.8c0.6-0.6,0.6-1.5,0-2.1s-1.5-0.6-2.1,0L14.7,11.8L4.6,1.7C4,1.1,3.1,1.1,2.5,1.7s-0.6,1.5,0,2.1l10.1,10.1L2.5,24c-0.6,0.6-0.6,1.5,0,2.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4L14.7,16l10.1,10.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4c0.6-0.6,0.6-1.5,0-2.1L16.8,13.9z"}))),wp.element.createElement(i.k,{tagName:"p",placeholder:e.attributes.text.default,value:c,isSelected:n&&"content"===l,onFocus:function(e){return function(){o({editable:e})}}("content"),onChange:function(e){return r({text:e})},className:"wp-ugb-notif notif-"+s,style:{backgroundColor:u,color:m}}),n&&wp.element.createElement(i.g,{key:"inspector"},wp.element.createElement(i.m,{label:Object(i.p)("Dismissible"),checked:p,onChange:function(){return r({dismissible:!p})}}),wp.element.createElement(i.l,{label:Object(i.p)("Notification Type"),value:s,options:t.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){r({notifType:e})}}),wp.element.createElement(i.i,{title:Object(i.p)("Background Color"),colorValue:u,initialOpen:!1},wp.element.createElement(i.d,{value:u,onChange:function(e){return r({color:e})}})),wp.element.createElement(i.i,{title:Object(i.p)("Text Color"),colorValue:m,initialOpen:!1},wp.element.createElement(i.d,{value:m,onChange:function(e){return r({textColor:e})}}))))]},m=function(e){var t=e.attributes,n=t.text,l=t.color,o=t.textColor,r=t.notifType,c=t.dismissible,i={backgroundColor:l,color:o},u=a()(n+r).substr(0,6);return wp.element.createElement("div",{className:"ugb-notification type-"+r+" dismissible-"+c,"data-uid":u},c&&wp.element.createElement("span",{key:"button",className:"close-button"},wp.element.createElement("svg",{viewBox:"0 0 28.3 28.3",style:{fill:o}},wp.element.createElement("path",{d:"M52.4-166.2c3.2,0,3.2-5,0-5C49.2-171.2,49.2-166.2,52.4-166.2L52.4-166.2z"}),wp.element.createElement("path",{d:"M16.8,13.9L26.9,3.8c0.6-0.6,0.6-1.5,0-2.1s-1.5-0.6-2.1,0L14.7,11.8L4.6,1.7C4,1.1,3.1,1.1,2.5,1.7s-0.6,1.5,0,2.1l10.1,10.1L2.5,24c-0.6,0.6-0.6,1.5,0,2.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4L14.7,16l10.1,10.1c0.3,0.3,0.7,0.4,1.1,0.4s0.8-0.1,1.1-0.4c0.6-0.6,0.6-1.5,0-2.1L16.8,13.9z"}))),wp.element.createElement("p",{className:"wp-ugb-notif notif-"+r,style:i},n))};Object(i.q)("ugb/notification",{title:Object(i.p)("Notification"),icon:c.g,category:"layout",keywords:[Object(i.p)("Notification"),Object(i.p)("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:Object(i.p)("This is an informational alert, usually used for successful subscriptions, promo announcements, and the like.")},color:{type:"string"},textColor:{type:"string"},notifType:{type:"string",default:"success"},dismissible:{type:"boolean",default:!1}},edit:Object(i.r)({editable:"content"})(u),save:m})},function(e,t){},function(e,t){},function(e,t,n){!function(){var t=n(20),l=n(2).utf8,o=n(21),r=n(2).bin,a=function(e,n){e.constructor==String?e=n&&"binary"===n.encoding?r.stringToBytes(e):l.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||(e=e.toString());for(var c=t.bytesToWords(e),i=8*e.length,u=1732584193,m=-271733879,s=-1732584194,p=271733878,b=0;b<c.length;b++)c[b]=16711935&(c[b]<<8|c[b]>>>24)|4278255360&(c[b]<<24|c[b]>>>8);c[i>>>5]|=128<<i%32,c[14+(i+64>>>9<<4)]=i;for(var d=a._ff,g=a._gg,h=a._hh,f=a._ii,b=0;b<c.length;b+=16){var w=u,y=m,v=s,E=p;u=d(u,m,s,p,c[b+0],7,-680876936),p=d(p,u,m,s,c[b+1],12,-389564586),s=d(s,p,u,m,c[b+2],17,606105819),m=d(m,s,p,u,c[b+3],22,-1044525330),u=d(u,m,s,p,c[b+4],7,-176418897),p=d(p,u,m,s,c[b+5],12,1200080426),s=d(s,p,u,m,c[b+6],17,-1473231341),m=d(m,s,p,u,c[b+7],22,-45705983),u=d(u,m,s,p,c[b+8],7,1770035416),p=d(p,u,m,s,c[b+9],12,-1958414417),s=d(s,p,u,m,c[b+10],17,-42063),m=d(m,s,p,u,c[b+11],22,-1990404162),u=d(u,m,s,p,c[b+12],7,1804603682),p=d(p,u,m,s,c[b+13],12,-40341101),s=d(s,p,u,m,c[b+14],17,-1502002290),m=d(m,s,p,u,c[b+15],22,1236535329),u=g(u,m,s,p,c[b+1],5,-165796510),p=g(p,u,m,s,c[b+6],9,-1069501632),s=g(s,p,u,m,c[b+11],14,643717713),m=g(m,s,p,u,c[b+0],20,-373897302),u=g(u,m,s,p,c[b+5],5,-701558691),p=g(p,u,m,s,c[b+10],9,38016083),s=g(s,p,u,m,c[b+15],14,-660478335),m=g(m,s,p,u,c[b+4],20,-405537848),u=g(u,m,s,p,c[b+9],5,568446438),p=g(p,u,m,s,c[b+14],9,-1019803690),s=g(s,p,u,m,c[b+3],14,-187363961),m=g(m,s,p,u,c[b+8],20,1163531501),u=g(u,m,s,p,c[b+13],5,-1444681467),p=g(p,u,m,s,c[b+2],9,-51403784),s=g(s,p,u,m,c[b+7],14,1735328473),m=g(m,s,p,u,c[b+12],20,-1926607734),u=h(u,m,s,p,c[b+5],4,-378558),p=h(p,u,m,s,c[b+8],11,-2022574463),s=h(s,p,u,m,c[b+11],16,1839030562),m=h(m,s,p,u,c[b+14],23,-35309556),u=h(u,m,s,p,c[b+1],4,-1530992060),p=h(p,u,m,s,c[b+4],11,1272893353),s=h(s,p,u,m,c[b+7],16,-155497632),m=h(m,s,p,u,c[b+10],23,-1094730640),u=h(u,m,s,p,c[b+13],4,681279174),p=h(p,u,m,s,c[b+0],11,-358537222),s=h(s,p,u,m,c[b+3],16,-722521979),m=h(m,s,p,u,c[b+6],23,76029189),u=h(u,m,s,p,c[b+9],4,-640364487),p=h(p,u,m,s,c[b+12],11,-421815835),s=h(s,p,u,m,c[b+15],16,530742520),m=h(m,s,p,u,c[b+2],23,-995338651),u=f(u,m,s,p,c[b+0],6,-198630844),p=f(p,u,m,s,c[b+7],10,1126891415),s=f(s,p,u,m,c[b+14],15,-1416354905),m=f(m,s,p,u,c[b+5],21,-57434055),u=f(u,m,s,p,c[b+12],6,1700485571),p=f(p,u,m,s,c[b+3],10,-1894986606),s=f(s,p,u,m,c[b+10],15,-1051523),m=f(m,s,p,u,c[b+1],21,-2054922799),u=f(u,m,s,p,c[b+8],6,1873313359),p=f(p,u,m,s,c[b+15],10,-30611744),s=f(s,p,u,m,c[b+6],15,-1560198380),m=f(m,s,p,u,c[b+13],21,1309151649),u=f(u,m,s,p,c[b+4],6,-145523070),p=f(p,u,m,s,c[b+11],10,-1120210379),s=f(s,p,u,m,c[b+2],15,718787259),m=f(m,s,p,u,c[b+9],21,-343485551),u=u+w>>>0,m=m+y>>>0,s=s+v>>>0,p=p+E>>>0}return t.endian([u,m,s,p])};a._ff=function(e,t,n,l,o,r,a){var c=e+(t&n|~t&l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._gg=function(e,t,n,l,o,r,a){var c=e+(t&l|n&~l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._hh=function(e,t,n,l,o,r,a){var c=e+(t^n^l)+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._ii=function(e,t,n,l,o,r,a){var c=e+(n^(t|~l))+(o>>>0)+a;return(c<<r|c>>>32-r)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,n){if(void 0===e||null===e)throw new Error("Illegal argument "+e);var l=t.wordsToBytes(a(e,n));return n&&n.asBytes?l:n&&n.asString?r.bytesToString(l):t.bytesToHex(l)}}()},function(e,t){!function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,l=0;n<e.length;n++,l+=8)t[l>>>5]|=e[n]<<24-l%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],l=0;l<e.length;l+=3)for(var o=e[l]<<16|e[l+1]<<8|e[l+2],r=0;r<4;r++)8*l+6*r<=8*e.length?n.push(t.charAt(o>>>6*(3-r)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],l=0,o=0;l<e.length;o=++l%4)0!=o&&n.push((t.indexOf(e.charAt(l-1))&Math.pow(2,-2*o+8)-1)<<2*o|t.indexOf(e.charAt(l))>>>6-2*o);return n}};e.exports=n}()},function(e,t){function n(e){return!!e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function l(e){return"function"===typeof e.readFloatLE&&"function"===typeof e.slice&&n(e.slice(0,0))}e.exports=function(e){return null!=e&&(n(e)||l(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var l=n(23),o=(n.n(l),n(24)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.setAttributes,l=(e.className,e.attributes),o=l.color,r=l.text,c=l.borderColor;return[wp.element.createElement("blockquote",{key:"quote",className:"ugb-blockquote",style:{borderLeftColor:c}},wp.element.createElement(a.k,{tagName:"p",className:"ugb-blockquote-text",value:r,onChange:function(e){return n({text:e})},isSelected:t,style:{color:o}})),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.i,{title:Object(a.p)("Text Color"),colorValue:o},wp.element.createElement(a.d,{value:o,onChange:function(e){return n({color:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Border Color"),colorValue:c},wp.element.createElement(a.d,{value:c,onChange:function(e){return n({borderColor:e})}})))]},i=function(e){var t=e.attributes,n=t.color,l=t.text,o=t.borderColor;return wp.element.createElement("blockquote",{className:"ugb-blockquote",style:{borderLeftColor:o}},wp.element.createElement("p",{style:{color:n}},l))};Object(a.q)("ugb/blockquote",{title:Object(a.p)("Blockquote"),icon:r.k,category:"common",keywords:[Object(a.p)("Blockquote"),Object(a.p)("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:Object(a.p)("It's okay to acknowledge that life can get complicated, but we musn't forget the beauty in its simplicity, too. From the multitude of stars above, to freshly mowed grass in the morning, life is simply wonderful.")},color:{type:"string",default:"#424242"},borderColor:{type:"string",default:"#2091e1"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(26),o=(n.n(l),n(27)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.setAttributes,l=(e.className,e.attributes),o=l.color,r=l.text,c=l.borderColor;return[wp.element.createElement("blockquote",{key:"quote",className:"ugb-pullquote",style:{borderTopColor:c,borderBottomColor:c}},wp.element.createElement(a.k,{tagName:"p",className:"ugb-pullquote-text",value:r,onChange:function(e){return n({text:e})},placeholder:Object(a.p)("Write quote\u2026"),formattingControls:["bold","italic","strikethrough","link"],isSelected:t,keepPlaceholderOnFocus:!0,style:{color:o}})),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.i,{title:Object(a.p)("Text Color"),colorValue:o,initialOpen:!1},wp.element.createElement(a.d,{value:o,onChange:function(e){return n({color:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Border Color"),colorValue:c,initialOpen:!1},wp.element.createElement(a.d,{value:c,onChange:function(e){return n({borderColor:e})}})))]},i=function(e){var t=e.attributes,n=t.color,l=t.text,o=t.borderColor;return wp.element.createElement("blockquote",{className:"ugb-pullquote",style:{borderTopColor:o,borderBottomColor:o}},wp.element.createElement("p",{style:{color:n}},l))};Object(a.q)("ugb/pullquote",{title:Object(a.p)("Pullquote"),icon:r.k,category:"formatting",keywords:[Object(a.p)("Pullquote"),Object(a.p)("Stackable")],attributes:{text:{type:"array",source:"children",selector:"p",default:Object(a.p)("It's okay to acknowledge that life can get complicated, but we musn't forget the beauty in its simplicity, too. From the multitude of stars above, to freshly mowed grass in the morning, life is simply wonderful.")},color:{type:"string",default:"#2091e1"},borderColor:{type:"string",default:"#2091e1"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(29),o=(n.n(l),n(30)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.url,i=r.buttonText,u=r.ctaTitle,m=r.bodyText,s=r.color,p=r.textColor,b=r.size,d=r.borderButtonRadius,g=r.bodyTextColor,h=r.titleColor,f=r.bgColor,w=[{value:"small",label:Object(a.p)("Small")},{value:"normal",label:Object(a.p)("Normal")},{value:"medium",label:Object(a.p)("Medium")},{value:"large",label:Object(a.p)("Large")}],y=function(e){return function(){l({editable:e})}};return[wp.element.createElement("div",{key:"editable",className:"ugb-cta",style:{backgroundColor:f}},wp.element.createElement(a.k,{className:"ugb-cta-title",tagName:"h3",placeholder:Object(a.p)("Add Title"),value:u,onChange:function(e){return o({ctaTitle:e})},isSelected:t&&"ctaTitle"===n,onFocus:y("ctaTitle"),keepPlaceholderOnFocus:!0,style:{color:h}}),wp.element.createElement(a.k,{tagName:"p",value:m,className:"ugb-cta-bodyText",onChange:function(e){return o({bodyText:e})},isSelected:t&&"bodyText"===n,onFocus:y("bodyText"),placeholder:Object(a.p)("Write body text\u2026"),style:{color:g}}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-cta-button"},wp.element.createElement(a.k,{tagName:"span",placeholder:Object(a.p)("Add Text"),value:i,onChange:function(e){return o({buttonText:e})},isSelected:t&&"buttonText"===n,onFocus:y("buttonText"),className:"wp-ugb-button ugb-button-"+b,style:{backgroundColor:s,color:p,borderRadius:d+"px"},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Button Size"),value:b,options:w.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Button Border Radius"),value:d,min:"1",max:"50",onChange:function(e){return o({borderButtonRadius:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Title Color"),colorValue:h,initialOpen:!1},wp.element.createElement(a.d,{value:s,onChange:function(e){return o({titleColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Body Text Color"),colorValue:g,initialOpen:!1},wp.element.createElement(a.d,{value:s,onChange:function(e){return o({bodyTextColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Button Background Color"),colorValue:s,initialOpen:!1},wp.element.createElement(a.d,{value:s,onChange:function(e){return o({color:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Button Text Color"),colorValue:p,initialOpen:!1},wp.element.createElement(a.d,{value:p,onChange:function(e){return o({textColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Background Color"),colorValue:f,initialOpen:!1},wp.element.createElement(a.d,{value:f,onChange:function(e){return o({bgColor:e})}})))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link"},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"})))]},i=function(e){var t=e.attributes,n=t.url,l=t.buttonText,o=t.ctaTitle,r=t.bodyText,a=t.color,c=t.textColor,i=t.size,u=t.borderButtonRadius,m=t.bodyTextColor,s=t.titleColor,p=t.bgColor,b={backgroundColor:a,color:c,borderRadius:u+"px"};return wp.element.createElement("div",{className:"ugb-cta",style:{backgroundColor:p}},o&&!!o.length&&wp.element.createElement("h3",{className:"ugb-cta-title",style:{color:s}},o),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-cta-bodyText",style:{color:m}},r),l&&!!l.length&&wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-cta-button ugb-button-"+i,style:b},l))};Object(a.q)("ugb/cta",{title:Object(a.p)("Call to Action"),icon:r.b,category:"layout",keywords:[Object(a.p)("Call to Action"),Object(a.p)("Stackable"),Object(a.p)("CTA")],attributes:{url:{type:"string",source:"attribute",selector:"a",attribute:"href"},ctaTitle:{type:"array",source:"children",selector:"h3",default:Object(a.p)("Get Started Today")},bodyText:{type:"array",source:"children",selector:"p",default:Object(a.p)("Get Stackable: Ultimate Gutenberg Blocks today.\xa0 Apart from adding new blocks, it gives Gutenberg users more options and settings to tinker with, expanding Gutenberg\u2019s functionality.")},buttonText:{type:"array",source:"children",selector:"a"},color:{type:"string",default:"#2091e1"},textColor:{type:"string",default:"#ffffff"},titleColor:{type:"string"},bodyTextColor:{type:"string"},bgColor:{type:"string"},size:{type:"string",default:"normal"},borderButtonRadius:{type:"number",default:4}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(32),o=(n.n(l),n(33)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.testimonialTitle,i=r.testimonialTitleTwo,u=r.testimonialTitleThree,m=r.body,s=r.bodyTwo,p=r.bodyThree,b=r.position,d=r.positionTwo,g=r.positionThree,h=(r.href,r.hrefTwo,r.hrefThree,r.mediaID),f=r.mediaIDTwo,w=r.mediaIDThree,y=r.mediaURL,v=r.mediaURLTwo,E=r.mediaURLThree,C=r.columns,O=r.titleColor,x=r.posColor,k=r.bodyTextColor,T=r.iconColor,j=[{value:"1",label:Object(a.p)("One Column")},{value:"2",label:Object(a.p)("Two Column")},{value:"3",label:Object(a.p)("Three Column")}],N=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(a.b,null),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Column Number"),value:C,options:j.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Title Color"),colorValue:O,initialOpen:!1},wp.element.createElement(a.d,{value:O,onChange:function(e){return o({titleColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Position Color"),colorValue:x,initialOpen:!1},wp.element.createElement(a.d,{value:x,onChange:function(e){return o({posColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Body Text Color"),colorValue:k,initialOpen:!1},wp.element.createElement(a.d,{value:k,onChange:function(e){return o({bodyTextColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Icon Color"),colorValue:T,initialOpen:!1},wp.element.createElement(a.d,{value:T,onChange:function(e){return o({iconColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-testimonial column-"+C},wp.element.createElement("div",{className:"ugb-testimonial-column-one"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:h,render:function(e){return wp.element.createElement(a.c,{className:h?"":"button button-large",onClick:e.open},h?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+y+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:c,onChange:function(e){return o({testimonialTitle:e})},isSelected:t&&"testimonialTitle"===n,onFocus:N("testimonialTitle"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:b,className:"ugb-testimonial-position",onChange:function(e){return o({position:e})},isSelected:t&&"position"===n,onFocus:N("position"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:m,className:"ugb-testimonial-body",onChange:function(e){return o({body:e})},isSelected:t&&"body"===n,onFocus:N("body"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-testimonial-column-two"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURLTwo:e.url,mediaIDTwo:e.id})},type:"image",value:f,render:function(e){return wp.element.createElement(a.c,{className:f?"":"button button-large",onClick:e.open},f?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+v+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:i,onChange:function(e){return o({testimonialTitleTwo:e})},isSelected:t&&"testimonialTitleTwo"===n,onFocus:N("testimonialTitleTwo"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:d,className:"ugb-testimonial-position-two",onChange:function(e){return o({positionTwo:e})},isSelected:t&&"positionTwo"===n,onFocus:N("positionTwo"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:s,className:"ugb-testimonial-body-two",onChange:function(e){return o({bodyTwo:e})},isSelected:t&&"bodyTwo"===n,onFocus:N("bodyTwo"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-testimonial-column-three"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURLThree:e.url,mediaIDThree:e.id})},type:"image",value:w,render:function(e){return wp.element.createElement(a.c,{className:w?"":"button button-large",onClick:e.open},w?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+E+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:u,onChange:function(e){return o({testimonialTitleThree:e})},isSelected:t&&"testimonialTitleThree"===n,onFocus:N("testimonialTitleThree"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:g,className:"ugb-testimonial-position-three",onChange:function(e){return o({positionThree:e})},isSelected:t&&"positionThree"===n,onFocus:N("positionThree"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:p,className:"ugb-testimonial-body-three",onChange:function(e){return o({bodyThree:e})},isSelected:t&&"bodyThree"===n,onFocus:N("bodyThree"),style:{color:k},keepPlaceholderOnFocus:!0})))]},i=function(e){var t=e.attributes,n=t.testimonialTitle,l=t.testimonialTitleTwo,o=t.testimonialTitleThree,r=t.body,a=t.bodyTwo,c=t.bodyThree,i=t.position,u=t.positionTwo,m=t.positionThree,s=t.mediaURL,p=t.mediaURLTwo,b=t.mediaURLThree,d=(t.mediaID,t.mediaIDTwo,t.mediaIDThree,t.titleColor),g=t.posColor,h=t.bodyTextColor,f=t.iconColor,w=t.columns,y=wp.element.createElement("div",{key:"button",className:"quote-icon"},wp.element.createElement("svg",{viewBox:"0 0 246 187.5",style:{fill:f}},wp.element.createElement("path",{d:"M98.5,0h-93C2.5,0,0,2.5,0,5.5v93c0,3,2.5,5.5,5.5,5.5h39c-1.7,15.5-8.8,50-39,50c-3,0-5.5,2.5-5.5,5.5V182c0,3,2.5,5.5,5.5,5.5c5.2,0,98.5-4.5,98.5-89v-93C104,2.5,101.5,0,98.5,0z"}),wp.element.createElement("path",{d:"M240.5,0h-93c-3,0-5.5,2.5-5.5,5.5v93c0,3,2.5,5.5,5.5,5.5h39c-1.7,15.5-8.8,50-39,50c-3,0-5.5,2.5-5.5,5.5V182c0,3,2.5,5.5,5.5,5.5c5.2,0,98.5-4.5,98.5-89v-93C246,2.5,243.5,0,240.5,0z"}),wp.element.createElement("path",{d:"M161.3-86.3c3.2,0,3.2-5,0-5C158.1-91.3,158.1-86.3,161.3-86.3L161.3-86.3z"})));return wp.element.createElement("div",{className:"ugb-testimonial column-"+w},wp.element.createElement("div",{className:"ugb-testimonial-column-one"},s?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+s+")"},"data-src":s}):y,n&&!!n.length&&wp.element.createElement("h4",{style:{color:d}},n),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-testimonial-position",style:{color:g}},i),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-testimonial-body",style:{color:h}},r)),w>1&&wp.element.createElement("div",{className:"ugb-testimonial-column-two"},p?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+p+")"},"data-src":p}):y,l&&!!l.length&&wp.element.createElement("h4",{style:{color:d}},l),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-testimonial-position-two",style:{color:g}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-testimonial-body-two",style:{color:h}},a)),w>2&&wp.element.createElement("div",{className:"ugb-testimonial-column-three"},b?wp.element.createElement("div",{className:"testimonial-image",style:{backgroundImage:"url("+b+")"},"data-src":b}):y,o&&!!o.length&&wp.element.createElement("h4",{style:{color:d}},o),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-testimonial-position-three",style:{color:g}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-testimonial-body-three",style:{color:h}},c)))};Object(a.q)("ugb/testimonial",{title:Object(a.p)("Testimonial"),icon:r.n,category:"common",keywords:[Object(a.p)("Testimonial"),Object(a.p)("Stackable")],attributes:{href:{type:"url"},hrefTwo:{type:"url"},hrefThree:{type:"url"},mediaID:{type:"number"},mediaIDTwo:{type:"number"},mediaIDThree:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-testimonial-column-one .testimonial-image",attribute:"data-src"},mediaURLTwo:{type:"string",source:"attribute",selector:".ugb-testimonial-column-two .testimonial-image",attribute:"data-src"},mediaURLThree:{type:"string",source:"attribute",selector:".ugb-testimonial-column-three .testimonial-image",attribute:"data-src"},testimonialTitle:{type:"array",source:"children",selector:".ugb-testimonial-column-one h4",default:Object(a.p)("Ben Adams")},testimonialTitleTwo:{type:"array",source:"children",selector:".ugb-testimonial-column-two h4",default:Object(a.p)("Alex Johnson")},testimonialTitleThree:{type:"array",source:"children",selector:".ugb-testimonial-column-three h4",default:Object(a.p)("Sammy Simpson")},position:{type:"array",source:"children",selector:".ugb-testimonial-position",default:Object(a.p)("Founder")},positionTwo:{type:"array",source:"children",selector:".ugb-testimonial-position-two",default:Object(a.p)("Editor")},positionThree:{type:"array",source:"children",selector:".ugb-testimonial-position-three",default:Object(a.p)("Programmer")},body:{type:"array",source:"children",selector:".ugb-testimonial-body",default:Object(a.p)("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},bodyTwo:{type:"array",source:"children",selector:".ugb-testimonial-body-two",default:Object(a.p)("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},bodyThree:{type:"array",source:"children",selector:".ugb-testimonial-body-three",default:Object(a.p)("Stackable: Ultimate Blocks from Gutenberg has all the blocks I need to make a great webpage.")},titleColor:{type:"string"},posColor:{type:"string"},bodyTextColor:{type:"string"},iconColor:{type:"string"},columns:{type:"select",default:"1"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(35),o=(n.n(l),n(36)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.name,i=r.nameTwo,u=r.nameThree,m=r.des,s=r.desTwo,p=r.desThree,b=r.position,d=r.positionTwo,g=r.positionThree,h=(r.href,r.hrefTwo,r.hrefThree,r.mediaID),f=r.mediaIDTwo,w=r.mediaIDThree,y=r.mediaURL,v=r.mediaURLTwo,E=r.mediaURLThree,C=r.columns,O=r.nameColor,x=r.posColor,k=r.desColor,T=r.iconColor,j=r.shapes,N=[{value:"1",label:Object(a.p)("One Column")},{value:"2",label:Object(a.p)("Two Column")},{value:"3",label:Object(a.p)("Three Column")}],S=[{value:"square",label:Object(a.p)("Square")},{value:"circle",label:Object(a.p)("Circle")}],B=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(a.b,{key:"controls"}),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Image Shape"),value:j,options:S.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({shapes:e})}}),wp.element.createElement(a.l,{label:Object(a.p)("Column Number"),value:C,options:N.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Name Color"),colorValue:O,initialOpen:!1},wp.element.createElement(a.d,{value:O,onChange:function(e){return o({nameColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Position Color"),colorValue:x,initialOpen:!1},wp.element.createElement(a.d,{value:x,onChange:function(e){return o({posColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Description Color"),colorValue:k,initialOpen:!1},wp.element.createElement(a.d,{value:k,onChange:function(e){return o({desColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Icon Color"),colorValue:T,initialOpen:!1},wp.element.createElement(a.d,{value:T,onChange:function(e){return o({iconColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-team-member column-"+C+" image-"+j},wp.element.createElement("div",{className:"ugb-team-member-column-one"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:h,render:function(e){return wp.element.createElement(a.c,{className:h?"":"button button-large",onClick:e.open},h?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+y+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:c,onChange:function(e){return o({name:e})},isSelected:t&&"name"===n,onFocus:B("name"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:b,className:"ugb-team-member-position",onChange:function(e){return o({position:e})},isSelected:t&&"position"===n,onFocus:B("position"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:m,className:"ugb-team-member-des",onChange:function(e){return o({des:e})},isSelected:t&&"des"===n,onFocus:B("des"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-team-member-column-two"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURLTwo:e.url,mediaIDTwo:e.id})},type:"image",value:f,render:function(e){return wp.element.createElement(a.c,{className:f?"":"button button-large",onClick:e.open},f?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+v+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:i,onChange:function(e){return o({nameTwo:e})},isSelected:t&&"nameTwo"===n,onFocus:B("nameTwo"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:d,className:"ugb-team-member-position",onChange:function(e){return o({positionTwo:e})},isSelected:t&&"positionTwo"===n,onFocus:B("positionTwo"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:s,className:"ugb-team-member-des-two",onChange:function(e){return o({desTwo:e})},isSelected:t&&"desTwo"===n,onFocus:B("desTwo"),style:{color:k},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-team-member-column-three"},wp.element.createElement("div",null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURLThree:e.url,mediaIDThree:e.id})},type:"image",value:w,render:function(e){return wp.element.createElement(a.c,{className:w?"":"button button-large",onClick:e.open},w?wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+E+")"}}):Object(a.p)("Upload Image"))}})),wp.element.createElement(a.k,{tagName:"h4",value:u,onChange:function(e){return o({nameThree:e})},isSelected:t&&"nameThree"===n,onFocus:B("nameThree"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:g,className:"ugb-team-member-position",onChange:function(e){return o({positionThree:e})},isSelected:t&&"positionThree"===n,onFocus:B("positionThree"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:p,className:"ugb-team-member-des-three",onChange:function(e){return o({desThree:e})},isSelected:t&&"desThree"===n,onFocus:B("desThree"),style:{color:k},keepPlaceholderOnFocus:!0})))]},i=function(e){var t=e.attributes,n=t.name,l=t.nameTwo,o=t.nameThree,r=t.shapes,a=t.des,c=t.desTwo,i=t.desThree,u=t.position,m=t.positionTwo,s=t.positionThree,p=t.mediaURL,b=t.mediaURLTwo,d=t.mediaURLThree,g=(t.mediaID,t.mediaIDTwo,t.mediaIDThree,t.nameColor),h=t.posColor,f=t.desColor,w=(t.iconColor,t.columns);return wp.element.createElement("div",{className:"ugb-team-member column-"+w+" image-"+r},wp.element.createElement("div",{className:"ugb-team-member-column-one"},p&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+p+")"},"data-src":p}),n&&!!n.length&&wp.element.createElement("h4",{style:{color:g}},n),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-team-member-des",style:{color:f}},a)),w>1&&wp.element.createElement("div",{className:"ugb-team-member-column-two"},b&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+b+")"},"data-src":b}),l&&!!l.length&&wp.element.createElement("h4",{style:{color:g}},l),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-team-member-des-two",style:{color:f}},c)),w>2&&wp.element.createElement("div",{className:"ugb-team-member-column-three"},d&&wp.element.createElement("div",{className:"team-member-image",style:{backgroundImage:"url("+d+")"},"data-src":d}),o&&!!o.length&&wp.element.createElement("h4",{style:{color:g}},o),s&&!!s.length&&wp.element.createElement("p",{className:"ugb-team-member-position",style:{color:h}},s),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-team-member-des-three",style:{color:f}},i)))};Object(a.q)("ugb/team-member",{title:Object(a.p)("Team Member"),icon:r.m,category:"common",keywords:[Object(a.p)("Team Member"),Object(a.p)("Stackable")],attributes:{href:{type:"url"},hrefTwo:{type:"url"},hrefThree:{type:"url"},mediaID:{type:"number"},mediaIDTwo:{type:"number"},mediaIDThree:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-team-member-column-one .team-member-image",attribute:"data-src"},mediaURLTwo:{type:"string",source:"attribute",selector:".ugb-team-member-column-two .team-member-image",attribute:"data-src"},mediaURLThree:{type:"string",source:"attribute",selector:".ugb-team-member-column-three .team-member-image",attribute:"data-src"},name:{type:"array",source:"children",selector:".ugb-team-member-column-one h4",default:Object(a.p)("Ben Adams")},nameTwo:{type:"array",source:"children",selector:".ugb-team-member-column-two h4",default:Object(a.p)("Alex Johnson")},nameThree:{type:"array",source:"children",selector:".ugb-team-member-column-three h4",default:Object(a.p)("Sammy Simpson")},position:{type:"array",source:"children",selector:".ugb-team-member-column-one .ugb-team-member-position",default:Object(a.p)("Founder")},positionTwo:{type:"array",source:"children",selector:".ugb-team-member-column-two .ugb-team-member-position",default:Object(a.p)("Editor")},positionThree:{type:"array",source:"children",selector:".ugb-team-member-column-three .ugb-team-member-position",default:Object(a.p)("Programmer")},des:{type:"array",source:"children",selector:".ugb-team-member-des",default:Object(a.p)("Ben is the head of our small team. He loves walking his dog, Walter, when he has some free time.")},desTwo:{type:"array",source:"children",selector:".ugb-team-member-des-two",default:Object(a.p)("Alex handles all written content. She enjoys painting and playing softball on the weekends.")},desThree:{type:"array",source:"children",selector:".ugb-team-member-des-three",default:Object(a.p)("Sammy is our programmer. You'll usually find her nose in a book. She has a cat named Skitty.")},nameColor:{type:"string"},posColor:{type:"string"},desColor:{type:"string"},iconColor:{type:"string"},columns:{type:"select",default:"1"},shapes:{type:"select",default:"square"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(38),r=(n.n(o),n(39)),a=(n.n(r),n(0)),c=n(1),i=function(e){return e.map?e.map(function(e){return e.children}):""},u=function(e){return e.map?e.map(function(e){return{children:e}}):""},m=function(e){var t=(e.focus,e.setFocus,e.editable),n=e.setAttributes,o=e.setState,r=e.className,a=e.isSelected,m=function(e){return function(){o({editable:e})}},s=e.attributes,p=s.text,b=s.moreLabel,d=s.moreText,g=s.lessLabel;return[a&&wp.element.createElement(c.b,{key:"controls"}),wp.element.createElement("div",{key:"expand",className:r},a&&wp.element.createElement("label",{className:"ugb-editor-label"},"Less text"),wp.element.createElement(c.k,l({multiline:"p",placeholder:e.attributes.text.default,value:i(p),onChange:function(e){return n({text:u(e)})},isSelected:a&&"text"===t,onFocus:m("text"),className:"ugb-expand-less-text"},"placeholder",Object(c.p)("Some short text that can be expanded to show more details."))),wp.element.createElement(c.k,l({tagName:"a",placeholder:e.attributes.moreLabel.default,value:b,isSelected:a&&"moreLabel"===t,onFocus:m("moreLabel"),onChange:function(e){return n({moreLabel:e})},formattingControls:["bold","italic","strikethrough"],className:"ugb-expand-more"},"placeholder",Object(c.p)("Show more"))),a&&wp.element.createElement("label",{className:"ugb-editor-label"},"More text"),a&&wp.element.createElement(c.k,l({multiline:"p",placeholder:e.attributes.moreText.default,value:i(d),isSelected:a&&"moreText"===t,onFocus:m("moreText"),onChange:function(e){return n({moreText:u(e)})},className:"ugb-expand-more-text"},"placeholder",Object(c.p)("Some short text that can be expanded to show more details. Some additional text that can only be seen when expanded."))),a&&wp.element.createElement(c.k,l({tagName:"a",placeholder:e.attributes.lessLabel.default,value:g,isSelected:a&&"lessLabel"===t,onFocus:m("lessLabel"),onChange:function(e){return n({lessLabel:e})},formattingControls:["bold","italic","strikethrough"],className:"ugb-expand-less"},"placeholder",Object(c.p)("Show less"))))]},s=function(e){var t=e.attributes,n=t.text,l=t.moreLabel,o=t.moreText,r=t.lessLabel;return wp.element.createElement("div",null,wp.element.createElement("div",{className:"ugb-expand-less-text"},n.map&&n.map(function(e,t){return wp.element.createElement("p",{key:t},e.children&&e.children.props.children)})),wp.element.createElement("div",{className:"ugb-expand-more-text",style:{display:"none"}},o.map&&o.map(function(e,t){return wp.element.createElement("p",{key:t},e.children&&e.children.props.children)})),wp.element.createElement("a",{className:"ugb-expand-button",href:"#"},wp.element.createElement("span",{className:"ugb-expand-more"},l),wp.element.createElement("span",{className:"ugb-expand-less",style:{display:"none"}},r)))};Object(c.q)("ugb/expand",{title:Object(c.p)("Expand / Show More"),icon:a.d,category:"formatting",keywords:[Object(c.p)("Expand"),Object(c.p)("Show more/less"),Object(c.p)("Stackable")],attributes:{text:{type:"array",source:"query",selector:".ugb-expand-less-text > p",query:{children:{source:"node"}},default:[]},moreText:{type:"array",source:"query",selector:".ugb-expand-more-text > p",query:{children:{source:"node"}},default:[]},moreLabel:{type:"array",source:"children",selector:".ugb-expand-more",default:Object(c.p)("Show more")},lessLabel:{type:"array",source:"children",selector:".ugb-expand-less",default:Object(c.p)("Show less")}},edit:Object(c.r)({editable:"text"})(m),save:s})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(41),o=(n.n(l),n(42)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.editable,o=e.setState,r=e.attributes,c=r.numberBox,i=r.numberBoxTwo,u=r.numberBoxThree,m=r.body,s=r.bodyTwo,p=r.bodyThree,b=r.name,d=r.nameTwo,g=r.nameThree,h=r.columns,f=r.numberBoxColor,w=r.nameColor,y=r.bodyTextColor,v=r.numberBGColor,E=[{value:"1",label:Object(a.p)("One Column")},{value:"2",label:Object(a.p)("Two Column")},{value:"3",label:Object(a.p)("Three Column")}],C=function(e){return function(){o({editable:e})}};return[n&&wp.element.createElement(a.b,{key:"controls"}),n&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Column Number"),value:h,options:E.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({columns:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Number Color"),colorValue:f,initialOpen:!1},wp.element.createElement(a.d,{value:f,onChange:function(e){return t({numberBoxColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Number Background Color"),colorValue:v,initialOpen:!1},wp.element.createElement(a.d,{value:v,onChange:function(e){return t({numberBGColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Name Color"),colorValue:w,initialOpen:!1},wp.element.createElement(a.d,{value:w,onChange:function(e){return t({nameColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Body Text Color"),colorValue:y,initialOpen:!1},wp.element.createElement(a.d,{value:y,onChange:function(e){return t({bodyTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-number-box column-"+h},wp.element.createElement("div",{className:"ugb-number-box-column-one"},wp.element.createElement(a.k,{tagName:"span",placeholder:c?c.default:"",value:c,onChange:function(e){return t({numberBox:e})},isSelected:n&&"numberBox"===l,onFocus:C("numberBox"),style:{color:f,backgroundColor:v},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"h4",value:b,className:"ugb-number-box-name",onChange:function(e){return t({name:e})},isSelected:n&&"name"===l,onFocus:C("name"),placeholder:Object(a.p)("Add name\u2026"),style:{color:w},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:m,className:"ugb-number-box-body",onChange:function(e){return t({body:e})},isSelected:n&&"body"===l,onFocus:C("body"),placeholder:Object(a.p)("Add body\u2026"),style:{color:y},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-number-box-column-two"},wp.element.createElement(a.k,{tagName:"span",placeholder:i?i.default:"",value:i,onChange:function(e){return t({numberBoxTwo:e})},isSelected:n&&"numberBoxTwo"===l,onFocus:C("numberBoxTwo"),style:{color:f,backgroundColor:v},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"h4",value:d,className:"ugb-number-box-name-two",onChange:function(e){return t({nameTwo:e})},isSelected:n&&"nameTwo"===l,onFocus:C("nameTwo"),placeholder:Object(a.p)("Add name\u2026"),style:{color:w},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:s,className:"ugb-number-box-body-two",onChange:function(e){return t({bodyTwo:e})},isSelected:n&&"bodyTwo"===l,onFocus:C("bodyTwo"),placeholder:Object(a.p)("Add body\u2026"),style:{color:y},keepPlaceholderOnFocus:!0})),wp.element.createElement("div",{className:"ugb-number-box-column-three"},wp.element.createElement(a.k,{tagName:"span",placeholder:u?u.default:"",value:u,onChange:function(e){return t({numberBoxThree:e})},isSelected:n&&"numberBoxThree"===l,onFocus:C("numberBoxThree"),style:{color:f,backgroundColor:v},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"h4",value:g,className:"ugb-number-box-name-three",onChange:function(e){return t({nameThree:e})},isSelected:n&&"nameThree"===l,onFocus:C("nameThree"),placeholder:Object(a.p)("Add name\u2026"),style:{color:w},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:p,className:"ugb-number-box-body-three",onChange:function(e){return t({bodyThree:e})},isSelected:n&&"bodyThree"===l,onFocus:C("bodyThree"),placeholder:Object(a.p)("Add body\u2026"),style:{color:y},keepPlaceholderOnFocus:!0})))]},i=function(e){var t=e.attributes,n=t.numberBox,l=t.numberBoxTwo,o=t.numberBoxThree,r=t.body,a=t.bodyTwo,c=t.bodyThree,i=t.name,u=t.nameTwo,m=t.nameThree,s=t.numberBoxColor,p=t.nameColor,b=t.bodyTextColor,d=t.numberBGColor,g=t.columns;return wp.element.createElement("div",{className:"ugb-number-box column-"+g},wp.element.createElement("div",{className:"ugb-number-box-column-one"},n&&!!n.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},n),i&&!!i.length&&wp.element.createElement("h4",{className:"ugb-number-box-name",style:{color:p}},i),r&&!!r.length&&wp.element.createElement("p",{className:"ugb-number-box-body",style:{color:b}},r)),g>1&&wp.element.createElement("div",{className:"ugb-number-box-column-two"},l&&!!l.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},l),u&&!!u.length&&wp.element.createElement("h4",{className:"ugb-number-box-name-two",style:{color:p}},u),a&&!!a.length&&wp.element.createElement("p",{className:"ugb-number-box-body-two",style:{color:b}},a)),g>2&&wp.element.createElement("div",{className:"ugb-number-box-column-three"},o&&!!o.length&&wp.element.createElement("span",{style:{color:s,backgroundColor:d}},o),m&&!!m.length&&wp.element.createElement("h4",{className:"ugb-number-box-name-three",style:{color:p}},m),c&&!!c.length&&wp.element.createElement("p",{className:"ugb-number-box-body-three",style:{color:b}},c)))};Object(a.q)("ugb/number-box",{title:Object(a.p)("Number Box"),icon:r.h,category:"common",keywords:[Object(a.p)("Number Box"),Object(a.p)("Stackable")],attributes:{numberBox:{type:"array",source:"children",selector:".ugb-number-box-column-one span",default:Object(a.p)("01")},numberBoxTwo:{type:"array",source:"children",selector:".ugb-number-box-column-two span",default:Object(a.p)("02")},numberBoxThree:{type:"array",source:"children",selector:".ugb-number-box-column-three span",default:Object(a.p)("03")},name:{type:"array",source:"children",selector:".ugb-number-box-name",default:Object(a.p)("Registration")},nameTwo:{type:"array",source:"children",selector:".ugb-number-box-name-two",default:Object(a.p)("Waiting Period")},nameThree:{type:"array",source:"children",selector:".ugb-number-box-name-three",default:Object(a.p)("Delivery")},body:{type:"array",source:"children",selector:".ugb-number-box-body",default:Object(a.p)("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},bodyTwo:{type:"array",source:"children",selector:".ugb-number-box-body-two",default:Object(a.p)("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},bodyThree:{type:"array",source:"children",selector:".ugb-number-box-body-three",default:Object(a.p)("This is just a sample write-up, but you can check out more info on Gutenberg on the WP repository.")},numberBoxColor:{type:"string"},nameColor:{type:"string"},bodyTextColor:{type:"string"},numberBGColor:{type:"string"},columns:{type:"select",default:"1"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(44),o=(n.n(l),n(45)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.url,i=(r.url2,r.url3,r.pricingBoxTitle),u=r.pricingBoxTitle2,m=r.pricingBoxTitle3,s=r.price,p=r.price2,b=r.price3,d=r.perMonthLabel,g=r.perMonthLabel2,h=r.perMonthLabel3,f=r.buttonText,w=r.buttonText2,y=r.buttonText3,v=r.featureList,E=r.featureList2,C=r.featureList3,O=r.pricingBoxColor,x=r.priceColor,k=r.perMonthLabelColor,T=r.buttonColor,j=r.buttonTextColor,N=r.featureListColor,S=r.columns,B=r.size,L=r.cornerButtonRadius,F=[{value:"1",label:Object(a.p)("One Column")},{value:"2",label:Object(a.p)("Two Column")},{value:"3",label:Object(a.p)("Three Column")}],z=[{value:"small",label:Object(a.p)("Small")},{value:"normal",label:Object(a.p)("Normal")},{value:"medium",label:Object(a.p)("Medium")},{value:"large",label:Object(a.p)("Large")}],A=function(e){return function(){l({editable:e})}};return[t&&wp.element.createElement(a.b,{key:"controls"}),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Column Number"),value:S,options:F.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({columns:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Corner Radius"),value:L,min:"1",max:"50",onChange:function(e){return o({cornerButtonRadius:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Pricing Title Color"),colorValue:O,initialOpen:!1},wp.element.createElement(a.d,{value:O,onChange:function(e){return o({pricingBoxColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Price Color"),colorValue:x,initialOpen:!1},wp.element.createElement(a.d,{value:x,onChange:function(e){return o({priceColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Per Month Label Color"),colorValue:k,initialOpen:!1},wp.element.createElement(a.d,{value:k,onChange:function(e){return o({perMonthLabelColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Feature List Color"),colorValue:N,initialOpen:!1},wp.element.createElement(a.d,{value:N,onChange:function(e){return o({featureListColor:e})}})),wp.element.createElement(a.l,{label:Object(a.p)("Button Size"),value:B,options:z.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Button Color"),colorValue:T,initialOpen:!1},wp.element.createElement(a.d,{value:T,onChange:function(e){return o({buttonColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Button Text Color"),colorValue:j,initialOpen:!1},wp.element.createElement(a.d,{value:j,onChange:function(e){return o({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-pricing-box column-"+S},wp.element.createElement("div",{className:"ugb-pricing-box-column-one"},wp.element.createElement(a.k,{tagName:"h3",value:i,onChange:function(e){return o({pricingBoxTitle:e})},isSelected:t&&"pricingBoxTitle"===n,onFocus:A("pricingBoxTitle"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:s,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price:e})},isSelected:t&&"price"===n,onFocus:A("price"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:d,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel:e})},focus:t&&"perMonthLabel"===n,onFocus:A("perMonthLabel"),style:{color:k},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(a.k,{tagName:"span",value:f,onChange:function(e){return o({buttonText:e})},className:"wp-ugb-button ugb-button-"+B,isSelected:t&&"buttonText"===n,onFocus:A("buttonText"),style:{backgroundColor:T,color:j,borderRadius:L+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(a.k,{tagName:"p",value:v,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList:e})},focus:t&&"featureList"===n,onFocus:A("featureList"),style:{color:N},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))),wp.element.createElement("div",{className:"ugb-pricing-box-column-two"},wp.element.createElement(a.k,{tagName:"h3",value:u,onChange:function(e){return o({pricingBoxTitle2:e})},isSelected:t&&"pricingBoxTitle2"===n,onFocus:A("pricingBoxTitle2"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:p,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price2:e})},isSelected:t&&"price2"===n,onFocus:A("price2"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:g,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel2:e})},focus:t&&"perMonthLabel2"===n,onFocus:A("perMonthLabel2"),style:{color:k},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(a.k,{tagName:"span",value:w,onChange:function(e){return o({buttonText2:e})},className:"wp-ugb-button ugb-button-"+B,isSelected:t&&"buttonText2"===n,onFocus:A("buttonText2"),style:{backgroundColor:T,color:j,borderRadius:L+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(a.k,{tagName:"p",value:E,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList2:e})},focus:t&&"featureList2"===n,onFocus:A("featureList2"),style:{color:N},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))),wp.element.createElement("div",{className:"ugb-pricing-box-column-three"},wp.element.createElement(a.k,{tagName:"h3",value:m,onChange:function(e){return o({pricingBoxTitle3:e})},isSelected:t&&"pricingBoxTitle3"===n,onFocus:A("pricingBoxTitle3"),style:{color:O},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:b,className:"ugb-pricing-box-pricing",onChange:function(e){return o({price3:e})},isSelected:t&&"price3"===n,onFocus:A("price3"),style:{color:x},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:h,className:"ugb-pricing-box-per-month-label",onChange:function(e){return o({perMonthLabel3:e})},focus:t&&"perMonthLabel3"===n,onFocus:A("perMonthLabel3"),style:{color:k},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button"},wp.element.createElement(a.k,{tagName:"span",value:y,onChange:function(e){return o({buttonText3:e})},className:"wp-ugb-button ugb-button-"+B,isSelected:t&&"buttonText3"===n,onFocus:A("buttonText3"),style:{backgroundColor:T,color:j,borderRadius:L+"px"},keepPlaceholderOnFocus:!0})),wp.element.createElement(a.k,{tagName:"p",value:C,className:"ugb-pricing-box-feature-list",onChange:function(e){return o({featureList3:e})},focus:t&&"featureList3"===n,onFocus:A("featureList3"),style:{color:N},keepPlaceholderOnFocus:!0}),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link pricing-box"},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:c,onChange:function(e){return o({url:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))))]},i=function(e){var t=e.attributes,n=t.url,l=t.url2,o=t.url3,r=t.pricingBoxTitle,a=t.pricingBoxTitle2,c=t.pricingBoxTitle3,i=t.price,u=t.price2,m=t.price3,s=t.perMonthLabel,p=t.perMonthLabel2,b=t.perMonthLabel3,d=t.buttonText,g=t.buttonText2,h=t.buttonText3,f=t.featureList,w=t.featureList2,y=t.featureList3,v=t.pricingBoxColor,E=t.priceColor,C=t.perMonthLabelColor,O=t.buttonColor,x=t.buttonTextColor,k=t.featureListColor,T=t.columns,j=t.size,N=t.cornerButtonRadius,S={backgroundColor:O,color:x,borderRadius:N+"px"};return wp.element.createElement("div",{className:"ugb-pricing-box column-"+T},wp.element.createElement("div",{className:"ugb-pricing-box-column-one"},r&&!!r.length&&wp.element.createElement("h3",{style:{color:v}},r),i&&!!i.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:E}},i),s&&!!s.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:C}},s),d&&!!d.length&&wp.element.createElement("a",{href:n,className:"wp-ugb-button ugb-button-"+j,style:S},d),f&&!!f.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},f)),T>1&&wp.element.createElement("div",{className:"ugb-pricing-box-column-two"},a&&!!a.length&&wp.element.createElement("h3",{style:{color:v}},a),u&&!!u.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:E}},u),p&&!!p.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:C}},p),g&&!!g.length&&wp.element.createElement("a",{href:l,className:"wp-ugb-button ugb-button-"+j,style:S},g),w&&!!w.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},w)),T>2&&wp.element.createElement("div",{className:"ugb-pricing-box-column-three"},c&&!!c.length&&wp.element.createElement("h3",{style:{color:v}},c),m&&!!m.length&&wp.element.createElement("p",{className:"ugb-pricing-box-pricing",style:{color:E}},m),b&&!!b.length&&wp.element.createElement("p",{className:"ugb-pricing-box-per-month-label",style:{color:C}},b),h&&!!h.length&&wp.element.createElement("a",{href:o,className:"wp-ugb-button ugb-button-"+j,style:S},h),y&&!!y.length&&wp.element.createElement("p",{className:"ugb-pricing-box-feature-list",style:{color:k}},y)))};Object(a.q)("ugb/pricing-box",{title:Object(a.p)("Pricing Box"),icon:r.j,category:"common",keywords:[Object(a.p)("Pricing Box"),Object(a.p)("Stackable")],attributes:{url:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-one a",attribute:"href"},url2:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-two a",attribute:"href"},url3:{type:"string",source:"attribute",selector:".ugb-pricing-box-column-three a",attribute:"href"},pricingBoxTitle:{type:"array",source:"children",selector:".ugb-pricing-box-column-one h3",default:Object(a.p)("Basic")},pricingBoxTitle2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two h3",default:Object(a.p)("Basic")},pricingBoxTitle3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three h3",default:Object(a.p)("Basic")},price:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-pricing",default:Object(a.p)("$9")},price2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-pricing",default:Object(a.p)("$9")},price3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-pricing",default:Object(a.p)("$9")},perMonthLabel:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-per-month-label",default:Object(a.p)("per month")},perMonthLabel2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-per-month-label",default:Object(a.p)("per month")},perMonthLabel3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-per-month-label",default:Object(a.p)("per month")},buttonText:{type:"array",source:"children",selector:".ugb-pricing-box-column-one a",default:Object(a.p)("Buy Now")},buttonText2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two a",default:Object(a.p)("Buy Now")},buttonText3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three a",default:Object(a.p)("Buy Now")},featureList:{type:"array",source:"children",selector:".ugb-pricing-box-column-one .ugb-pricing-box-feature-list",default:Object(a.p)("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},featureList2:{type:"array",source:"children",selector:".ugb-pricing-box-column-two .ugb-pricing-box-feature-list",default:Object(a.p)("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},featureList3:{type:"array",source:"children",selector:".ugb-pricing-box-column-three .ugb-pricing-box-feature-list",default:Object(a.p)("Consectetur adipiscing elit Suspendisse at pretium tortor Vestibulum ante ipsum primis In faucibus orci luctus et Ultrices posuere cubilia cura Aenean consectetur nec")},pricingBoxColor:{type:"string"},priceColor:{type:"string"},perMonthLabelColor:{type:"string"},buttonColor:{type:"string"},buttonTextColor:{type:"string"},featureListColor:{type:"string"},columns:{type:"select",default:"1"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(e){return 0===e?null:"overlay-opacity-"+1*Math.round(e/1)}var o=n(47),r=n.n(o),a=n(48),c=(n.n(a),n(49)),i=(n.n(c),n(0)),u=n(1),m=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,o=e.editable,a=e.setState,c=e.attributes,i=c.url,m=c.buttonURL,s=c.buttonText,p=c.buttonColor,b=c.buttonTextColor,d=c.cornerButtonRadius,g=c.size,h=c.title,f=c.titleColor,w=c.subtitle,y=c.subtitleColor,v=c.contentAlign,E=c.id,C=c.backgroundColor,O=c.opacity,x=i?{backgroundImage:"url("+i+")"}:void 0,k=i?"has-image":"",T=r()(l(O),{"overlay-opacity":0!==O}),j=function(e){return function(){a({editable:e})}},N=[{value:"small",label:Object(u.p)("Small")},{value:"normal",label:Object(u.p)("Normal")},{value:"medium",label:Object(u.p)("Medium")},{value:"large",label:Object(u.p)("Large")}];return[n&&wp.element.createElement(u.b,{key:"controls"},wp.element.createElement(u.a,{value:v,onChange:function(e){return t({contentAlign:e})}}),wp.element.createElement(u.n,null,wp.element.createElement(u.h,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:E,render:function(e){var t=e.open;return wp.element.createElement(u.f,{className:"components-toolbar__control",label:Object(u.p)("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(u.g,{key:"inspector"},wp.element.createElement(u.i,{title:Object(u.p)("Title Color"),colorValue:f,initialOpen:!1},wp.element.createElement(u.d,{value:f,onChange:function(e){return t({titleColor:e})}})),wp.element.createElement(u.i,{title:Object(u.p)("Subtitle Color"),colorValue:y,initialOpen:!1},wp.element.createElement(u.d,{value:y,onChange:function(e){return t({subtitleColor:e})}})),wp.element.createElement(u.i,{title:Object(u.p)("Heading Background Color"),colorValue:C,initialOpen:!1},wp.element.createElement(u.d,{value:C,onChange:function(e){return t({backgroundColor:e})}})),wp.element.createElement(u.j,{label:Object(u.p)("Background Opacity"),value:O,min:0,max:10,step:1,onChange:function(e){return t({opacity:e})}}),wp.element.createElement("h2",null,"Button Settings"),wp.element.createElement(u.l,{label:Object(u.p)("Button Size"),value:g,options:N.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({size:e})}}),wp.element.createElement(u.j,{label:Object(u.p)("Corner Radius"),value:d,min:"1",max:"50",onChange:function(e){return t({cornerButtonRadius:e})}}),wp.element.createElement(u.i,{title:Object(u.p)("Button Color"),colorValue:p,initialOpen:!1},wp.element.createElement(u.d,{value:p,onChange:function(e){return t({buttonColor:e})}})),wp.element.createElement(u.i,{title:Object(u.p)("Button Text Color"),colorValue:b,initialOpen:!1},wp.element.createElement(u.d,{value:b,onChange:function(e){return t({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-header "+k+" "},wp.element.createElement("div",{className:"ugb-header-overlay "+T,style:{backgroundColor:C}}),wp.element.createElement(u.h,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:E,render:function(e){return[!i&&wp.element.createElement(u.c,{className:E?"":"button button-large",onClick:e.open},Object(u.p)("Upload Image"))]}}),wp.element.createElement("section",{key:"preview","data-url":i,style:x,className:"ugb-header-section"},wp.element.createElement(u.k,{tagName:"h2",className:"ugb-header-title",placeholder:h.default,value:h,onChange:function(e){return t({title:e})},isSelected:n&&"title"===o,onFocus:j("title"),style:{textAlign:v,color:f}}),wp.element.createElement(u.k,{tagName:"p",className:"ugb-header-subtitle",placeholder:w.default,value:w,onChange:function(e){return t({subtitle:e})},isSelected:n&&"subtitle"===o,onFocus:j("subtitle"),style:{textAlign:v,color:y}}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+v},wp.element.createElement(u.k,{tagName:"span",placeholder:s.default,value:s,onChange:function(e){return t({buttonText:e})},className:"wp-ugb-button ugb-button-"+g,style:{backgroundColor:p,color:b,borderRadius:d+"px"},isSelected:n&&"buttonText"===o,onFocus:j("buttonText"),keepPlaceholderOnFocus:!0})))),n&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+v},wp.element.createElement(u.e,{icon:"admin-links"}),wp.element.createElement(u.o,{value:m,onChange:function(e){return t({buttonURL:e})}}),wp.element.createElement(u.f,{icon:"editor-break",label:Object(u.p)("Apply"),type:"submit"}))]},s=function(e){var t=e.attributes,n=t.url,o=t.buttonURL,a=t.buttonText,c=t.buttonColor,i=t.buttonTextColor,u=t.cornerButtonRadius,m=t.size,s=t.title,p=t.titleColor,b=t.subtitle,d=t.subtitleColor,g=(t.contentAlign,t.id,t.backgroundColor),h=t.opacity,f={backgroundColor:c,color:i,borderRadius:u+"px"},w=n?{backgroundImage:"url("+n+")"}:void 0,y=n?"has-image":"",v=r()(l(h),{"overlay-opacity":0!==h}),E=s.length||b.length||a.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-header "+y+" "+E},wp.element.createElement("div",{className:"ugb-header-overlay "+v,style:{backgroundColor:g}}),wp.element.createElement("section",{key:"preview","data-url":n,style:w,className:"ugb-header-section"},s&&!!s.length&&wp.element.createElement("h2",{className:"ugb-header-title",style:{color:p}},s),b&&!!b.length&&wp.element.createElement("p",{className:"ugb-header-subtitle",style:{color:d}},b),a&&!!a.length&&wp.element.createElement("a",{href:o,className:"wp-ugb-button ugb-button-"+m,style:f},a)))};Object(u.q)("ugb/header",{title:Object(u.p)("Header"),icon:i.f,category:"common",keywords:[Object(u.p)("Header"),Object(u.p)("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h2",default:Object(u.p)("Heading Title")},subtitle:{type:"array",source:"children",selector:"p",default:Object(u.p)("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus congue tincidunt nisit ut pretium. Duis blandit, tortor et suscipit tincidunt, dolor metus mattis neque, ac varius magna nibh ac tortor.")},url:{type:"string",source:"attribute",selector:".ugb-header .ugb-header-section",attribute:"data-url"},buttonURL:{type:"string",source:"attribute",selector:"a",attribute:"href"},titleColor:{type:"string",default:"#ffffff"},subtitleColor:{type:"string",default:"#ffffff"},buttonText:{type:"array",source:"children",selector:".ugb-header a.wp-ugb-button",default:Object(u.p)("Button")},buttonColor:{type:"string",default:"#2091e1"},buttonTextColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4},contentAlign:{type:"string",default:"center"},id:{type:"number"},backgroundColor:{type:"string",default:"#000000"},opacity:{type:"number",default:5}},edit:Object(u.r)({editable:"content"})(m),save:s})},function(e,t,n){var l,o;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var l=arguments[t];if(l){var o=typeof l;if("string"===o||"number"===o)e.push(l);else if(Array.isArray(l)&&l.length){var a=n.apply(null,l);a&&e.push(a)}else if("object"===o)for(var c in l)r.call(l,c)&&l[c]&&e.push(c)}}return e.join(" ")}var r={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?(n.default=n,e.exports=n):(l=[],void 0!==(o=function(){return n}.apply(t,l))&&(e.exports=o))}()},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(51),o=(n.n(l),n(52)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.editable,o=e.setState,r=e.attributes,c=r.url,i=r.title,u=r.titleColor,m=r.subtitle,s=r.subtitleColor,p=r.overlayColor,b=r.id,d=r.height,g=r.width,h=r.verticalAlign,f=r.horizontalAlign,w=r.full,y=c?"has-image":"",v=w?"full-width":"",E=function(e){return function(){o({editable:e})}},C=[{value:"flex-start",label:Object(a.p)("Top")},{value:"center",label:Object(a.p)("Center")},{value:"flex-end",label:Object(a.p)("Bottom")}],O=[{value:"flex-start",label:Object(a.p)("Left")},{value:"center",label:Object(a.p)("Center")},{value:"flex-end",label:Object(a.p)("Right")}];return[n&&wp.element.createElement(a.b,{key:"controls"},c&&wp.element.createElement(a.n,null,wp.element.createElement(a.h,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:b,render:function(e){var t=e.open;return wp.element.createElement(a.f,{className:"components-toolbar__control",label:Object(a.p)("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.m,{label:"Full-Width",checked:!!w,onChange:function(){return t({full:!w})}}),wp.element.createElement(a.j,{label:Object(a.p)("Height"),value:d,min:"135",max:"700",onChange:function(e){return t({height:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Width"),value:g,min:"400",max:"999",onChange:function(e){return t({width:e})}}),wp.element.createElement(a.l,{label:Object(a.p)("Vertical Alignment"),value:h,options:C.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({verticalAlign:e})}}),wp.element.createElement(a.l,{label:Object(a.p)("Horizontal Alignment"),value:f,options:O.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({horizontalAlign:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Title Color"),colorValue:u,initialOpen:!1},wp.element.createElement(a.d,{value:u,onChange:function(e){return t({titleColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Subtitle Color"),colorValue:s,initialOpen:!1},wp.element.createElement(a.d,{value:s,onChange:function(e){return t({subtitleColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Overlay Color"),colorValue:p,initialOpen:!1},wp.element.createElement(a.d,{value:p,onChange:function(e){return t({overlayColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-image-box "+y+" "+v,"data-url":c,style:{width:g+"px",height:d+"px",backgroundImage:"url("+c+")",alignItems:f,justifyContent:h}},wp.element.createElement(a.h,{onSelect:function(e){return t({url:e.url,id:e.id})},type:"image",value:b,render:function(e){return[!c&&wp.element.createElement(a.c,{className:b?"":"button button-large",onClick:e.open},Object(a.p)("Upload Image"))]}}),wp.element.createElement("a",{href:"#",style:{backgroundColor:p}}),wp.element.createElement(a.k,{tagName:"h4",placeholder:i.default,value:i,onChange:function(e){return t({title:e})},isSelected:n&&"title"===l,onFocus:E("title"),style:{color:u}}),wp.element.createElement(a.k,{tagName:"p",placeholder:m.default,value:m,onChange:function(e){return t({subtitle:e})},isSelected:n&&"subtitle"===l,onFocus:E("subtitle"),style:{color:s}}))]},i=function(e){var t=e.attributes,n=t.url,l=t.title,o=t.titleColor,r=t.subtitle,a=t.subtitleColor,c=t.overlayColor,i=(t.id,t.height),u=t.width,m=t.verticalAlign,s=t.horizontalAlign,p=t.full,b=n?"has-image":"",d=p?"full-width":"",g=l.length||r.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-image-box "+b+" "+g+" "+d,"data-url":n,style:{width:u+"px",height:i+"px",backgroundImage:"url("+n+")",alignItems:s,justifyContent:m}},wp.element.createElement("a",{href:"#",style:{backgroundColor:c}}),l&&!!l.length&&wp.element.createElement("h4",{style:{color:o}},l),r&&!!r.length&&wp.element.createElement("p",{style:{color:a}},r))};Object(a.q)("ugb/image-box",{title:Object(a.p)("Image Box"),icon:r.i,category:"common",keywords:[Object(a.p)("Image Box"),Object(a.p)("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h4",default:Object(a.p)("Title")},subtitle:{type:"array",source:"children",selector:"p",default:Object(a.p)("Subtitle goes here")},url:{type:"string",source:"attribute",selector:".ugb-image-box",attribute:"data-url"},titleColor:{type:"string",default:"#ffffff"},subtitleColor:{type:"string",default:"#ffffff"},overlayColor:{type:"string",default:"#42b078"},id:{type:"number"},width:{type:"number",default:"400"},height:{type:"number",default:"400"},verticalAlign:{type:"string",default:"center"},horizontalAlign:{type:"string",default:"center"},full:{type:"boolean",default:!1}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(54),o=(n.n(l),n(55)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=function(e){return function(){o({editable:e})}},n=e.isSelected,l=e.editable,o=e.setState,r=e.setAttributes,c=(e.className,e.attributes),i=c.color,u=c.headingColor,m=c.desColor,s=c.title,p=c.counter,b=c.des,d=c.fontSize;return[wp.element.createElement("div",{className:"ugb-countup"},wp.element.createElement(a.k,{tagName:"h4",value:s,onChange:function(e){return r({title:e})},isSelected:n&&"title"===l,onFocus:t("title"),style:{color:u}}),wp.element.createElement(a.k,{tagName:"div",className:"ugb-counter",placeholder:p.default,"data-duration":"1000","data-delay":"16",value:p,onChange:function(e){return r({counter:e})},isSelected:n&&"counter"===l,onFocus:t("counter"),style:{color:i,fontSize:d+"px"}}),wp.element.createElement(a.k,{tagName:"p",className:"ugb-counter-des",value:b,onChange:function(e){return r({des:e})},isSelected:n&&"des"===l,onFocus:t("des"),style:{color:m}})),n&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.i,{title:Object(a.p)("Heading Color"),colorValue:u,initialOpen:!1},wp.element.createElement(a.d,{value:u,onChange:function(e){return r({headingColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Count Up Text Color"),colorValue:i,initialOpen:!1},wp.element.createElement(a.d,{value:i,onChange:function(e){return r({color:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Description Color"),colorValue:m,initialOpen:!1},wp.element.createElement(a.d,{value:m,onChange:function(e){return r({desColor:e})}})),wp.element.createElement(a.j,{label:Object(a.p)("Counter Text Font Size"),max:"100",min:"10",value:d,onChange:function(e){return r({fontSize:e})}}))]},i=function(e){var t=e.attributes,n=t.color,l=t.headingColor,o=t.desColor,r=t.title,a=t.counter,c=t.des,i=t.fontSize;return wp.element.createElement("div",{className:"ugb-countup"},wp.element.createElement("h4",{style:{color:l}}," ",r," "),wp.element.createElement("div",{className:"ugb-counter",style:{color:n,fontSize:i+"px"},"data-duration":"1000","data-delay":"16"},a),wp.element.createElement("p",{style:{color:o}}," ",c," "))};Object(a.q)("ugb/count-up",{title:Object(a.p)("Count Up"),icon:r.h,category:"common",keywords:[Object(a.p)("Count Up"),Object(a.p)("Stackable")],attributes:{title:{type:"array",source:"children",selector:"h4",default:Object(a.p)("Happy Customers")},counter:{type:"array",source:"children",selector:".ugb-counter",default:"12,345"},des:{type:"array",source:"children",selector:"p",default:Object(a.p)("and counting")},fontSize:{type:"number",default:"60"},headingColor:{type:"string"},desColor:{type:"string"},color:{type:"string"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(57),o=(n.n(l),n(58)),r=(n.n(o),n(0)),a=n(1),c={normal:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"30",height:"30",viewBox:"0 0 256 320"},wp.element.createElement("path",{d:"M0 0v320l256-160L0 0z"})),circle:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"50",height:"50",viewBox:"0 0 40 40"},wp.element.createElement("path",{d:"M16 29l12-9-12-9v18zm4-29C8.95 0 0 8.95 0 20s8.95 20 20 20 20-8.95 20-20S31.05 0 20 0zm0 36c-8.82 0-16-7.18-16-16S11.18 4 20 4s16 7.18 16 16-7.18 16-16 16z"})),outline:wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"50",height:"50",viewBox:"0 0 34 34"},wp.element.createElement("path",{d:"M17 34C7.6 34 0 26.4 0 17S7.6 0 17 0s17 7.6 17 17-7.6 17-17 17zm0-32C8.7 2 2 8.7 2 17s6.7 15 15 15 15-6.7 15-15S25.3 2 17 2z"}),wp.element.createElement("path",{d:"M12 25.7V8.3L27 17l-15 8.7zm2-14v10.5l9-5.3-9-5.2z"}))},i=function(e){var t=(e.className,e.setAttributes),n=e.isSelected,l=e.attributes,o=l.videoLink,r=l.mediaLink,i=l.overlayColor,u=l.playButtonType,m=l.mediaID,s=[{value:"normal",label:Object(a.p)("Normal Play Button")},{value:"circle",label:Object(a.p)("Play Button with Circle")},{value:"outline",label:Object(a.p)("Outline Play Button")}];return[n&&wp.element.createElement(a.b,{key:"controls"},r&&wp.element.createElement(a.n,null,wp.element.createElement(a.h,{onSelect:function(e){return t({mediaLink:e.url,mediaID:e.id})},type:"image",value:m,render:function(e){var t=e.open;return wp.element.createElement(a.f,{className:"components-toolbar__control",label:Object(a.p)("Edit image"),icon:"edit",onClick:t})}}))),n&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.l,{label:Object(a.p)("Play Button Style"),value:u,options:s.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){t({playButtonType:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Background/Overlay Color"),colorValue:i,initialOpen:!1},wp.element.createElement(a.d,{value:i,onChange:function(e){return t({overlayColor:e})}}))),wp.element.createElement("div",{className:"ugb-video-popup","data-video":o,style:{backgroundColor:i}},wp.element.createElement("div",{className:"ugb-video-preview",style:{backgroundImage:"url("+r+")"}}),wp.element.createElement("div",{className:"ugb-video-wrapper"},wp.element.createElement(a.h,{onSelect:function(e){return t({mediaLink:e.url,mediaID:e.id})},type:"image",value:m,render:function(e){return[!r&&wp.element.createElement(a.c,{className:m?"":"button button-large",onClick:e.open},Object(a.p)("Upload Image"))]}}),wp.element.createElement("div",{className:"ugb-video-overlay",style:{backgroundColor:i}}),wp.element.createElement("span",{className:"ugb-play-button"},c[u]))),n&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"ugb-video-popup-link blocks-button__inline-link"},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:o,onChange:function(e){return t({videoLink:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}),wp.element.createElement("p",null,wp.element.createElement("i",null,"Youtube/Vimeo ID only")))]},u=function(e){var t=e.attributes,n=t.videoLink,l=t.mediaLink,o=t.overlayColor,r=t.playButtonType;t.mediaID;return wp.element.createElement("div",{className:"ugb-video-popup","data-video":n,style:{backgroundColor:o}},wp.element.createElement("div",{className:"ugb-video-preview",style:{backgroundImage:"url("+l+")"},"data-url":l}),wp.element.createElement("div",{className:"ugb-video-wrapper"},wp.element.createElement("a",{href:"#",style:{backgroundColor:o}}),wp.element.createElement("span",{className:"ugb-play-button"},c[r])))};Object(a.q)("ugb/video-popup",{title:Object(a.p)("Video Popup"),icon:r.o,category:"common",keywords:[Object(a.p)("Video Popup"),Object(a.p)("Stackable")],attributes:{videoLink:{type:"string",source:"attribute",selector:".ugb-video-popup",attribute:"data-video"},mediaLink:{type:"string",source:"attribute",selector:".ugb-video-preview",attribute:"data-url"},mediaID:{type:"number"},overlayColor:{type:"string",default:"#000000"},playButtonType:{type:"string",default:"normal"}},edit:i,save:u})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var l=n(60),o=(n.n(l),n(61)),r=(n.n(o),n(0)),a=n(1),c=function(e){var t=e.isSelected,n=e.editable,l=e.setState,o=(e.className,e.setAttributes),r=e.attributes,c=r.heading,i=r.tagline,u=r.des,m=r.mediaID,s=r.mediaURL,p=r.headingColor,b=r.taglineColor,d=r.desColor,g=r.buttonURL,h=r.buttonText,f=r.buttonColor,w=r.buttonTextColor,y=r.size,v=r.cornerButtonRadius,E=r.contentAlign,C=function(e){return function(){l({editable:e})}},O=s?"has-image":"",x=[{value:"small",label:Object(a.p)("Small")},{value:"normal",label:Object(a.p)("Normal")},{value:"medium",label:Object(a.p)("Medium")},{value:"large",label:Object(a.p)("Large")}];return[t&&wp.element.createElement(a.b,{key:"controls"},wp.element.createElement(a.a,{value:E,onChange:function(e){return o({contentAlign:e})}}),wp.element.createElement(a.n,null,wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:m,render:function(e){var t=e.open;return wp.element.createElement(a.f,{className:"components-toolbar__control",label:Object(a.p)("Edit image"),icon:"edit",onClick:t})}}))),t&&wp.element.createElement(a.g,{key:"inspector"},wp.element.createElement(a.i,{title:Object(a.p)("Heading Color"),colorValue:p,initialOpen:!1},wp.element.createElement(a.d,{value:p,onChange:function(e){return o({headingColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Tagline Color"),colorValue:b,initialOpen:!1},wp.element.createElement(a.d,{value:b,onChange:function(e){return o({taglineColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Description Color"),colorValue:d,initialOpen:!1},wp.element.createElement(a.d,{value:d,onChange:function(e){return o({desColor:e})}})),wp.element.createElement("h2",null,"Button Settings"),wp.element.createElement(a.l,{label:Object(a.p)("Button Size"),value:y,options:x.map(function(e){return{value:e.value,label:e.label}}),onChange:function(e){o({size:e})}}),wp.element.createElement(a.j,{label:Object(a.p)("Corner Radius"),value:v,min:"1",max:"50",onChange:function(e){return o({cornerButtonRadius:e})}}),wp.element.createElement(a.i,{title:Object(a.p)("Button Color"),colorValue:f,initialOpen:!1},wp.element.createElement(a.d,{value:f,onChange:function(e){return o({buttonColor:e})}})),wp.element.createElement(a.i,{title:Object(a.p)("Button Text Color"),colorValue:w,initialOpen:!1},wp.element.createElement(a.d,{value:w,onChange:function(e){return o({buttonTextColor:e})}}))),wp.element.createElement("div",{key:"editable",className:"ugb-card "+O},wp.element.createElement("div",{className:"ugb-card-image-container",style:{backgroundImage:"url("+s+")",textAlign:E}},wp.element.createElement(a.h,{onSelect:function(e){return o({mediaURL:e.url,mediaID:e.id})},type:"image",value:m,render:function(e){return[!s&&wp.element.createElement(a.c,{className:m?"":"button button-large",onClick:e.open},Object(a.p)("Upload Image"))]}})),wp.element.createElement(a.k,{tagName:"h4",value:c,className:"ugb-card-heading",onChange:function(e){return o({heading:e})},isSelected:t&&"heading"===n,onFocus:C("heading"),style:{color:p,textAlign:E},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:i,className:"ugb-tagline",onChange:function(e){return o({tagline:e})},isSelected:t&&"tagline"===n,onFocus:C("tagline"),style:{color:b,textAlign:E},keepPlaceholderOnFocus:!0}),wp.element.createElement(a.k,{tagName:"p",value:u,className:"ugb-card-des",onChange:function(e){return o({des:e})},isSelected:t&&"des"===n,onFocus:C("des"),style:{color:d,textAlign:E},keepPlaceholderOnFocus:!0}),wp.element.createElement("span",{key:"button",className:"wp-block-button ugb-button-"+E},wp.element.createElement(a.k,{tagName:"span",placeholder:h.default,value:h,onChange:function(e){return o({buttonText:e})},className:"wp-ugb-button ugb-button-"+y,style:{backgroundColor:f,color:w,borderRadius:v+"px"},isSelected:t&&"buttonText"===n,onFocus:C("buttonText"),keepPlaceholderOnFocus:!0}))),t&&wp.element.createElement("form",{key:"form-link",onSubmit:function(e){return e.preventDefault()},className:"blocks-button__inline-link ugb-button-"+E,style:{marginTop:10}},wp.element.createElement(a.e,{icon:"admin-links"}),wp.element.createElement(a.o,{value:g,onChange:function(e){return o({buttonURL:e})}}),wp.element.createElement(a.f,{icon:"editor-break",label:Object(a.p)("Apply"),type:"submit"}))]},i=function(e){var t=e.attributes,n=t.heading,l=t.tagline,o=t.des,r=t.mediaURL,a=(t.mediaID,t.headingColor),c=t.taglineColor,i=t.desColor,u=t.buttonURL,m=t.buttonText,s=t.buttonColor,p=t.buttonTextColor,b=t.size,d=t.cornerButtonRadius,g=t.contentAlign,h={backgroundColor:s,color:p,borderRadius:d+"px"},f=r?"has-image":"",w=n.length||l.length||o.length||m.length?"has-content":"has-no-content";return wp.element.createElement("div",{className:"ugb-card "+f+" "+w},r&&wp.element.createElement("div",{className:"ugb-card-image-container",style:{backgroundImage:"url("+r+")",textAlign:g},"data-src":r}),n&&!!n.length&&wp.element.createElement("h4",{style:{color:a,textAlign:g}},n),l&&!!l.length&&wp.element.createElement("p",{className:"ugb-tagline",style:{color:c,textAlign:g}},l),o&&!!o.length&&wp.element.createElement("p",{className:"ugb-card-des",style:{color:i,textAlign:g}},o),m&&!!m.length&&wp.element.createElement("a",{href:u,className:"wp-ugb-button wp-block-button ugb-button-"+b+" ugb-button-"+g,style:h},m))};Object(a.q)("ugb/card",{title:Object(a.p)("Card"),icon:r.m,category:"common",keywords:[Object(a.p)("Card"),Object(a.p)("Stackable")],attributes:{mediaID:{type:"number"},mediaURL:{type:"string",source:"attribute",selector:".ugb-card-image-container",attribute:"data-src"},heading:{type:"array",source:"children",selector:".ugb-card h4",default:Object(a.p)("Ben Adams")},tagline:{type:"array",source:"children",selector:".ugb-tagline",default:Object(a.p)("Ben is the head of our small team")},des:{type:"array",source:"children",selector:".ugb-card-des",default:Object(a.p)("Ben is the head of our small team. He loves walking his dog, Walter, when he has some free time.")},headingColor:{type:"string"},taglineColor:{type:"string"},desColor:{type:"string"},buttonURL:{type:"string",source:"attribute",selector:".wp-ugb-button",attribute:"href"},buttonText:{type:"array",source:"children",selector:".wp-block-button",default:Object(a.p)("Button")},buttonColor:{type:"string",default:"#2091e1"},buttonTextColor:{type:"string",default:"#ffffff"},size:{type:"string",default:"normal"},cornerButtonRadius:{type:"number",default:4},contentAlign:{type:"string",default:"left"}},edit:Object(a.r)({editable:"content"})(c),save:i})},function(e,t){},function(e,t){}]);
dist/blocks.editor.build.css CHANGED
@@ -1,18 +1,18 @@
1
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
2
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-divider hr{border:0 !important}
3
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-ugb-button__link{background:#fff;width:280px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;line-height:1.4}
4
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
5
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
6
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
7
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
8
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
9
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
10
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
11
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
12
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
13
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
14
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
15
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
16
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
17
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
18
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.edit-post-visual-editor .ugb-card{margin:0 !important}.edit-post-visual-editor .ugb-card .ugb-card-image-container{padding:0}.edit-post-visual-editor .ugb-card button{margin:0 30px}.edit-post-visual-editor .ugb-card.has-image button{width:100%;height:300px;padding:0}
1
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
2
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-divider hr{border:0 !important}
3
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-ugb-button__link{background:#fff;width:280px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;line-height:1.4}
4
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
5
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
6
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
7
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
8
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
9
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
10
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
11
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
12
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
13
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
14
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
15
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
16
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
17
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}form.ugb-video-popup-link{-ms-flex-wrap:wrap;flex-wrap:wrap;margin:5px auto}form.ugb-video-popup-link>svg,form.ugb-video-popup-link>button{-ms-flex-negative:0;flex-shrink:0}form.ugb-video-popup-link .editor-url-input{-ms-flex:1;flex:1}form.ugb-video-popup-link>p{width:100%;-ms-flex-positive:1;flex-grow:1;font-size:.8em;margin:0 0 0 30px}
18
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.edit-post-visual-editor .ugb-card{margin:0 !important}.edit-post-visual-editor .ugb-card .ugb-card-image-container{padding:0}.edit-post-visual-editor .ugb-card button{margin:0 30px}.edit-post-visual-editor .ugb-card.has-image button{width:100%;height:300px;padding:0}
dist/blocks.frontend.build.js CHANGED
@@ -1119,386 +1119,605 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
1119
 
1120
  // BigPicture.js | license MIT | henrygd.me/bigpicture
1121
  (function() {
1122
- var
1123
- // assign window object to variable
1124
- global = window,
1125
- // trigger element used to open popup
1126
- el,
1127
- // set to true after first interaction
1128
- initialized,
1129
- // container element holding html needed for script
1130
- container,
1131
- // currently active display element (image, video, youtube / vimeo iframe container)
1132
- displayElement,
1133
- // popup image element
1134
- displayImage,
1135
- // popup video element
1136
- displayVideo,
1137
- // container element to hold youtube / vimeo iframe
1138
- iframeContainer,
1139
- // iframe to hold youtube / vimeo player
1140
- iframeSiteVid,
1141
- // store requested image source
1142
- imgSrc,
1143
- // button that closes the container
1144
- closeButton,
1145
- // youtube / vimeo video id
1146
- siteVidID,
1147
- // keeps track of loading icon display state
1148
- isLoading,
1149
- // timeout to check video status while loading
1150
- checkVidTimeout,
1151
- // loading icon element
1152
- loadingIcon,
1153
- // caption element
1154
- caption,
1155
- // caption content element
1156
- captionText,
1157
- // store caption content
1158
- captionContent,
1159
- // hide caption button element
1160
- captionHideButton,
1161
- // open state for container element
1162
- isOpen,
1163
- // used during close animation to avoid triggering timeout twice
1164
- isClosing,
1165
- // array of prev viewed image urls to check if cached before showing loading icon
1166
- imgCache,
1167
- // store whether remote image is already cached on request
1168
- cached,
1169
- // store whether image requested is remote or local
1170
- remoteImage,
1171
- // store animation opening callbacks
1172
- animationStart,
1173
- animationEnd,
1174
- // set to true if user wants to hide loading icon
1175
- noLoader,
1176
- // Save bytes in the minified version
1177
- doc = document,
1178
- appendEl = 'appendChild',
1179
- createEl = 'createElement',
1180
- removeEl = 'removeChild',
1181
- htmlInner = 'innerHTML',
1182
- pointerEventsAuto = 'pointer-events:auto',
1183
- cHeight = 'clientHeight',
1184
- cWidth = 'clientWidth',
1185
- listenFor = 'addEventListener',
1186
- timeout = global.setTimeout,
1187
- clearTimeout = global.clearTimeout;
1188
-
1189
-
1190
- module.exports = function(options) {
1191
- // initialize called on initial open to create elements / style / event handlers
1192
- initialized || initialize();
1193
-
1194
- // clear currently loading stuff
1195
- if (isLoading) {
1196
- clearTimeout(checkVidTimeout);
1197
- removeContainer();
1198
- }
1199
-
1200
- // store video id if youtube / vimeo video is requested
1201
- siteVidID = options.ytSrc || options.vimeoSrc;
1202
-
1203
- // store optional callbacks
1204
- animationStart = options.animationStart;
1205
- animationEnd = options.animationEnd;
1206
-
1207
- // store whether user requests to hide loading icon
1208
- noLoader = options.noLoader;
1209
-
1210
- // set trigger element
1211
- el = options.el;
1212
-
1213
- // wipe existing remoteImage state
1214
- remoteImage = false;
1215
-
1216
- // set caption if provided
1217
- captionContent = el.getAttribute('caption');
1218
- if (captionContent) {
1219
- captionText[htmlInner] = captionContent;
1220
- container[appendEl](caption);
1221
- }
1222
-
1223
- // if vimeo or youtube video
1224
- if (siteVidID) {
1225
- toggleLoadingIcon(true);
1226
- displayElement = iframeContainer;
1227
- createIframe(!!options.ytSrc);
1228
- }
1229
- // if remote image
1230
- else if (options.imgSrc) {
1231
- remoteImage = true;
1232
- imgSrc = options.imgSrc;
1233
- cached = ~imgCache.indexOf(imgSrc);
1234
- !cached && toggleLoadingIcon(true);
1235
- displayElement = displayImage;
1236
- displayElement.src = imgSrc;
1237
- }
1238
- // if direct video link
1239
- else if (options.vidSrc) {
1240
- toggleLoadingIcon(true);
1241
- displayElement = displayVideo;
1242
- displayElement.src = options.vidSrc;
1243
- checkVid();
1244
- }
1245
- // local image / background image already loaded on page
1246
- else {
1247
- displayElement = displayImage;
1248
- // get img source or element background image
1249
- displayElement.src = el.tagName === 'IMG' ? el.src :
1250
- global.getComputedStyle(el).backgroundImage.replace(/^url|[(|)|'|"]/g, '');
1251
- }
1252
-
1253
- // add container to page
1254
- container[appendEl](displayElement);
1255
- doc.body[appendEl](container);
1256
- };
1257
-
1258
-
1259
- // create all needed methods / store dom elements on first use
1260
- function initialize() {
1261
-
1262
- // return close button elements
1263
- function createCloseButton() {
1264
- var el = doc[createEl]('button');
1265
- el.className = 'bp-x';
1266
- el[htmlInner] = '&#215;'
1267
- return el;
1268
- }
1269
 
1270
- // imgCache holds displayed image urls to prevent loader on cached images
1271
- imgCache = [];
1272
-
1273
- // add style
1274
- // if you want to tweak, grab from doc head & run through beautifier
1275
- var style = doc[createEl]('STYLE');
1276
- style[htmlInner] = '#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0}#bp_container>*,.bp-x,#bp_loader{position:absolute;right:0}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;pointer-events:none;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:-webkit-flex;display:flex;margin:0;cursor:wait;z-index:9}#bp_loader svg{width:40%;max-height:40%;margin:auto;' + webkitify('animation:', 'ldr .7s infinite linear;') + '}' + webkitifyKeyframes('keyframes ldr{to{' + webkitify('transform:', 'rotate(1turn);') + '}}') + '#bp_container img,#bp_sv,#bp_vid{max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{width:171vh}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}.bp-x{font-family:Arial;top:0;cursor:pointer;opacity:.8;font-size:3em;padding:0 .3em;color:#fff;background:transparent;border:0;text-shadow:0 0 2px #000}#bp_caption .bp-x{left:2%;top:auto;right:auto;bottom:100%;padding:0 .6em;background:#d74040;border-radius:2px 2px 0 0;font-size:2.3em;text-shadow:none}.bp-x:hover,.bp-x:focus{opacity:1}.bp-x:active{outline:0}@media (max-aspect-ratio:9/5){#bp_sv{height:53vw}}';
1277
- doc.head[appendEl](style);
1278
-
1279
- // create container element
1280
- container = doc[createEl]('DIV');
1281
- container.id = 'bp_container';
1282
- container.onclick = close;
1283
- closeButton = createCloseButton();
1284
- container[appendEl](closeButton);
1285
-
1286
- // create display image element
1287
- displayImage = doc[createEl]('IMG');
1288
-
1289
- // create display video element
1290
- displayVideo = doc[createEl]('VIDEO');
1291
- displayVideo.id = 'bp_vid';
1292
- displayVideo.autoplay = true;
1293
- displayVideo.setAttribute('playsinline', true);
1294
- displayVideo.controls = true;
1295
- displayVideo.loop = true;
1296
-
1297
- // create caption elements
1298
- caption = doc[createEl]('DIV');
1299
- caption.id = 'bp_caption';
1300
- captionHideButton = createCloseButton();
1301
- captionHideButton.onclick = function() {
1302
- changeCSS(caption, 'opacity:0');
1303
- timeout(function() {
1304
- captionContent = false;
1305
- container[removeEl](caption);
1306
- }, 300);
1307
- }
1308
- caption[appendEl](captionHideButton);
1309
- captionText = doc[createEl]('SPAN');
1310
- caption[appendEl](captionText);
1311
-
1312
- // create loading icon element
1313
- loadingIcon = doc[createEl]('DIV');
1314
- loadingIcon.id = 'bp_loader';
1315
- loadingIcon[htmlInner] = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 399 399"><path d="M341 58.5C303 20.8 253 0 199.6 0 146.4 0 96.2 20.8 58.5 58.5 20.8 96.2 0 146.5 0 199.7 0 253 20.8 303.2 58.5 341c37.7 37.6 88 58.4 141.2 58.4 53.3 0 103.5-20.8 141.2-58.5 37.6-37.8 58.4-88 58.4-141.3 0-53.3-20.8-103.5-58.5-141.2zm-13 12.8c34.3 34.3 53.2 80 53.2 128.4h-41c0-77.4-63-140.4-140.5-140.4-4.6 0-9 .2-13.6.7V18.7c4.6-.4 9-.5 13.7-.5 48.5 0 94 18.8 128.4 53zM199.8 322c-67.4 0-122.2-55-122.2-122.3S132.3 77.5 199.7 77.5 322 132.3 322 199.7 267 322 199.6 322z"/></svg>';
1316
-
1317
- // create youtube / vimeo container
1318
- iframeContainer = doc[createEl]('DIV');
1319
- iframeContainer.id = 'bp_sv';
1320
-
1321
- // create iframe to hold youtube / vimeo player
1322
- iframeSiteVid = doc[createEl]('IFRAME');
1323
- iframeSiteVid.allowFullscreen = true;
1324
- iframeSiteVid.onload = open;
1325
- changeCSS(iframeSiteVid, 'border:0px;height:100%;width:100%');
1326
- iframeContainer[appendEl](iframeSiteVid);
1327
-
1328
- // display image bindings for image load and error
1329
- displayImage.onload = open;
1330
- displayImage.onerror = open.bind(null, 'image');
1331
-
1332
- // adjust loader position on window resize
1333
- global[listenFor]('resize', function() {
1334
- isLoading && toggleLoadingIcon(true);
1335
- });
1336
-
1337
- // close container on escape key press
1338
- doc[listenFor]('keyup', function(e) {
1339
- e.keyCode === 27 && isOpen && close(container);
1340
- });
1341
-
1342
- // trap focus within conainer while open
1343
- doc[listenFor]('focus', function(e) {
1344
- if (isOpen && !container.contains(e.target)) {
1345
- e.stopPropagation();
1346
- closeButton.focus();
1347
- }
1348
- }, true);
1349
 
1350
- // all done
1351
- initialized = true;
1352
- }
 
1353
 
 
 
 
 
 
 
 
 
 
 
1354
 
1355
- // return transform style to make full size display el match trigger el size
1356
- function getRect() {
1357
- var rect = el.getBoundingClientRect();
1358
- var leftOffset = rect.left - (container[cWidth] - rect.width) / 2;
1359
- var centerTop = rect.top - (container[cHeight] - rect.height) / 2;
1360
- var scaleWidth = el[cWidth] / displayElement[cWidth];
1361
- var scaleHeight = el[cHeight] / displayElement[cHeight];
1362
- return webkitify('transform:', 'translate3D(' + leftOffset + 'px, ' +
1363
- centerTop + 'px, 0) scale3D(' + scaleWidth + ', ' + scaleHeight + ', 0);');
1364
- }
 
 
1365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1366
 
1367
- // create youtube / vimeo video iframe
1368
- function createIframe(isYoutube) {
1369
- // create appropriate url for youtube or vimeo
1370
- var url = isYoutube ?
1371
- 'www.youtube.com/embed/' + siteVidID + '?html5=1&rel=0&showinfo=0&playsinline=1&' :
1372
- 'player.vimeo.com/video/' + siteVidID + '?';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1373
 
1374
- // set iframe src to url
1375
- iframeSiteVid.src = 'https://' + url + 'autoplay=1';
1376
- }
1377
 
1378
- // timeout to check video status while loading
1379
- // onloadeddata event doesn't seem to fire in less up-to-date browsers like midori & epiphany
1380
- function checkVid() {
1381
- if (displayElement.readyState === 4)
1382
- open();
1383
- else if (displayVideo.error)
1384
- open('video');
1385
- else
1386
- checkVidTimeout = timeout(checkVid, 35);
1387
- }
 
 
 
 
 
 
 
 
 
 
1388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1389
 
1390
- // hide / show loading icon
1391
- function toggleLoadingIcon(bool) {
1392
- // don't show loading icon if noLoader is specified
1393
- if (noLoader) return;
1394
- // bool is true if we want to show icon, false if we want to remove
1395
- // change style to match trigger element dimensions if we want to show
1396
- bool && changeCSS(loadingIcon, 'top:' + el.offsetTop +
1397
- 'px;left:' + el.offsetLeft + 'px;height:' +
1398
- el[cHeight] + 'px;width:' + el[cWidth] + 'px');
1399
- // add or remove loader from DOM
1400
- el.parentElement[bool ? appendEl : removeEl](loadingIcon);
1401
- isLoading = bool;
1402
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1403
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1404
 
1405
- // animate open of image / video; display caption if needed
1406
- function open(err) {
1407
- // hide loading spinner
1408
- isLoading && toggleLoadingIcon();
 
 
 
 
 
 
 
 
1409
 
1410
- // execute animationStart callback
1411
- animationStart && animationStart();
 
 
 
 
 
1412
 
1413
- // check if we have an error string instead of normal event
1414
- if (typeof(err) === 'string') {
1415
- removeContainer();
1416
- return alert('Error: The requested ' + err + ' could not be displayed.');
1417
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1418
 
1419
- // if remote image is loaded, add url to imgCache array
1420
- (remoteImage && !cached) && imgCache.push(imgSrc);
 
 
 
 
 
 
 
 
1421
 
1422
- // transform displayEl to match trigger el
1423
- changeCSS(displayElement, getRect());
 
1424
 
1425
- // fade in container
1426
- changeCSS(container, 'opacity:1;' + pointerEventsAuto);
 
 
1427
 
1428
- // set animationEnd callback to run after animation ends (cleared if container closed)
1429
- animationEnd = timeout(animationEnd, 410);
1430
 
1431
- isOpen = true;
 
 
 
 
1432
 
1433
- // enlarge displayEl, fade in caption if hasCaption
1434
- timeout(function() {
1435
- changeCSS(displayElement, webkitify('transition:', 'transform .35s;') + webkitify('transform:', 'none;'));
1436
- captionContent && timeout(changeCSS.bind(null, caption, 'opacity:1'), 250);
1437
- }, 60);
1438
- }
1439
 
 
 
 
 
1440
 
1441
- // close active display element
1442
- function close(e) {
1443
- var target = e.target;
1444
- var clickEls = [caption, captionHideButton, displayVideo, captionText];
1445
 
1446
- // blur to hide close button focus style
1447
- target && target.blur();
1448
 
1449
- // don't close if one of the clickEls was clicked or container is already closing
1450
- if (isClosing || ~clickEls.indexOf(target)) {
1451
- return;
1452
- }
1453
 
1454
- // animate closing
1455
- displayElement.style.cssText += getRect();
1456
- changeCSS(container, pointerEventsAuto);
1457
 
1458
- // timeout to remove els from dom; use variable to avoid calling more than once
1459
- timeout(removeContainer, 350);
1460
 
1461
- // clear animationEnd timeout
1462
- clearTimeout(animationEnd);
 
 
 
 
 
 
 
 
1463
 
1464
- isOpen = false;
1465
- isClosing = true;
1466
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1467
 
 
 
 
1468
 
1469
- // remove container / display element from the DOM
1470
- function removeContainer() {
1471
- // remove container from DOM & clear inline style
1472
- doc.body[removeEl](container);
1473
- container[removeEl](displayElement);
1474
- changeCSS(container, '');
1475
 
1476
- // clear src of displayElement (or iframe if display el is iframe container)
1477
- (displayElement === iframeContainer ? iframeSiteVid : displayElement)
1478
- .removeAttribute('src');
1479
 
1480
- if (captionContent) {
1481
- changeCSS(caption, '');
1482
- container[removeEl](caption);
1483
- }
1484
- isClosing = false;
1485
- }
1486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1487
 
1488
- // style helper functions
1489
- function changeCSS(element, newStyle) {
1490
- element.style.cssText = newStyle;
1491
- }
1492
- function webkitify(prop, val) {
1493
- var webkit = '-webkit-';
1494
- var propVal = prop + val;
1495
- return webkit + propVal + prop + webkit + val + propVal;
1496
- }
1497
- function webkitifyKeyframes(css) {
1498
- return '@-webkit-' + css + '@' + css;
1499
- }
1500
 
1501
- })();
 
 
 
 
 
 
 
 
 
1502
 
1503
 
1504
  /***/ })
1119
 
1120
  // BigPicture.js | license MIT | henrygd.me/bigpicture
1121
  (function() {
1122
+ var // assign window object to variable
1123
+ global = window,
1124
+ // trigger element used to open popup
1125
+ el,
1126
+ // set to true after first interaction
1127
+ initialized,
1128
+ // container element holding html needed for script
1129
+ container,
1130
+ // currently active display element (image, video, youtube / vimeo iframe container)
1131
+ displayElement,
1132
+ // popup image element
1133
+ displayImage,
1134
+ // popup video element
1135
+ displayVideo,
1136
+ // container element to hold youtube / vimeo iframe
1137
+ iframeContainer,
1138
+ // iframe to hold youtube / vimeo player
1139
+ iframeSiteVid,
1140
+ // store requested image source
1141
+ imgSrc,
1142
+ // button that closes the container
1143
+ closeButton,
1144
+ // youtube / vimeo video id
1145
+ siteVidID,
1146
+ // keeps track of loading icon display state
1147
+ isLoading,
1148
+ // timeout to check video status while loading
1149
+ checkVidTimeout,
1150
+ // loading icon element
1151
+ loadingIcon,
1152
+ // caption element
1153
+ caption,
1154
+ // caption content element
1155
+ captionText,
1156
+ // store caption content
1157
+ captionContent,
1158
+ // hide caption button element
1159
+ captionHideButton,
1160
+ // open state for container element
1161
+ isOpen,
1162
+ // gallery open state
1163
+ galleryOpen,
1164
+ // used during close animation to avoid triggering timeout twice
1165
+ isClosing,
1166
+ // array of prev viewed image urls to check if cached before showing loading icon
1167
+ imgCache = [],
1168
+ // store whether image requested is remote or local
1169
+ remoteImage,
1170
+ // store animation opening callbacks
1171
+ animationStart,
1172
+ animationEnd,
1173
+ // gallery left / right icons
1174
+ rightArrowBtn,
1175
+ leftArrowBtn,
1176
+ // position of gallery
1177
+ galleryPosition,
1178
+ // hold active gallery els / image src
1179
+ galleryEls,
1180
+ // counter element
1181
+ galleryCounter,
1182
+ // store images in gallery that are being loaded
1183
+ preloadedImages = {},
1184
+ // whether device supports touch events
1185
+ supportsTouch,
1186
+ // set to true if user wants to hide loading icon
1187
+ noLoader,
1188
+ // Save bytes in the minified version
1189
+ doc = document,
1190
+ appendEl = 'appendChild',
1191
+ createEl = 'createElement',
1192
+ removeEl = 'removeChild',
1193
+ htmlInner = 'innerHTML',
1194
+ pointerEventsAuto = 'pointer-events:auto',
1195
+ cHeight = 'clientHeight',
1196
+ cWidth = 'clientWidth',
1197
+ listenFor = 'addEventListener',
1198
+ timeout = global.setTimeout,
1199
+ clearTimeout = global.clearTimeout
1200
+
1201
+ module.exports = function(options) {
1202
+ // initialize called on initial open to create elements / style / event handlers
1203
+ initialized || initialize()
1204
+
1205
+ // clear currently loading stuff
1206
+ if (isLoading) {
1207
+ clearTimeout(checkVidTimeout)
1208
+ removeContainer()
1209
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1210
 
1211
+ // store video id if youtube / vimeo video is requested
1212
+ siteVidID = options.ytSrc || options.vimeoSrc
1213
+
1214
+ // store optional callbacks
1215
+ animationStart = options.animationStart
1216
+ animationEnd = options.animationEnd
1217
+
1218
+ // store whether user requests to hide loading icon
1219
+ noLoader = options.noLoader
1220
+
1221
+ // set trigger element
1222
+ el = options.el
1223
+
1224
+ // wipe existing remoteImage state
1225
+ remoteImage = false
1226
+
1227
+ // set caption if provided
1228
+ captionContent = el.getAttribute('caption')
1229
+
1230
+ if (options.gallery) {
1231
+ makeGallery(options.gallery)
1232
+ } else if (siteVidID) {
1233
+ // if vimeo or youtube video
1234
+ toggleLoadingIcon(true)
1235
+ displayElement = iframeContainer
1236
+ createIframe(!!options.ytSrc)
1237
+ } else if (options.imgSrc) {
1238
+ // if remote image
1239
+ remoteImage = true
1240
+ imgSrc = options.imgSrc
1241
+ !~imgCache.indexOf(imgSrc) && toggleLoadingIcon(true)
1242
+ displayElement = displayImage
1243
+ displayElement.src = imgSrc
1244
+ } else if (options.vidSrc) {
1245
+ // if direct video link
1246
+ toggleLoadingIcon(true)
1247
+ displayElement = displayVideo
1248
+ displayElement.src = options.vidSrc
1249
+ checkVid()
1250
+ } else {
1251
+ // local image / background image already loaded on page
1252
+ displayElement = displayImage
1253
+ // get img source or element background image
1254
+ displayElement.src =
1255
+ el.tagName === 'IMG'
1256
+ ? el.src
1257
+ : global
1258
+ .getComputedStyle(el)
1259
+ .backgroundImage.replace(/^url|[(|)|'|"]/g, '')
1260
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1261
 
1262
+ // add container to page
1263
+ container[appendEl](displayElement)
1264
+ doc.body[appendEl](container)
1265
+ }
1266
 
1267
+ // create all needed methods / store dom elements on first use
1268
+ function initialize() {
1269
+ var startX
1270
+ // return close button elements
1271
+ function createCloseButton() {
1272
+ var el = doc[createEl]('button')
1273
+ el.className = 'bp-x'
1274
+ el[htmlInner] = '&#215;'
1275
+ return el
1276
+ }
1277
 
1278
+ function createArrowSymbol(direction, style) {
1279
+ var el = doc[createEl]('button')
1280
+ el.className = 'bp-lr'
1281
+ el[htmlInner] =
1282
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129" height="75" fill="#fff"><path d="M88.6 121.3c.8.8 1.8 1.2 2.9 1.2s2.1-.4 2.9-1.2a4.1 4.1 0 0 0 0-5.8l-51-51 51-51a4.1 4.1 0 0 0-5.8-5.8l-54 53.9a4.1 4.1 0 0 0 0 5.8l54 53.9z"/></svg>'
1283
+ changeCSS(el, style)
1284
+ el.onclick = function(e) {
1285
+ e.stopPropagation()
1286
+ updateGallery(direction)
1287
+ }
1288
+ return el
1289
+ }
1290
 
1291
+ // add style - if you want to tweak, run through beautifier
1292
+ var style = doc[createEl]('STYLE')
1293
+ style[htmlInner] =
1294
+ '.bp-lr,.bp-x:active{outline:0}#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0;backface-visibility:hidden}#bp_container>*,#bp_loader,.bp-x{position:absolute;right:0;z-index:10}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;pointer-events:none;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:-webkit-flex;display:flex;margin:0;cursor:wait;z-index:9}#bp_count,.bp-lr,.bp-x{cursor:pointer;color:#fff}#bp_loader svg{width:50%;max-height:50%;margin:auto}#bp_container img,#bp_sv,#bp_vid{user-select:none;max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{width:171vh}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}#bp_count,.bp-x{top:0;opacity:.8;font-size:3em;padding:0 .3em;background:0 0;border:0;text-shadow:0 0 2px rgba(0,0,0,.6)}#bp_caption .bp-x{left:2%;top:auto;right:auto;bottom:100%;padding:0 .6em;background:#d74040;border-radius:2px 2px 0 0;font-size:2.3em;text-shadow:none}.bp-x:focus,.bp-x:hover{opacity:1}@media (max-aspect-ratio:9/5){#bp_sv{height:53vw}}.bp-lr{top:50%;top:calc(50% - 138px);padding:99px 1vw;background:0 0;border:0;opacity:.4;transition:opacity .1s}.bp-lr:focus,.bp-lr:hover{opacity:.8}@media (max-width:600px){.bp-lr{font-size:15vw}}#bp_count{left:0;display:table;padding:14px;color:#fff;font-size:22px;opacity:.7;cursor:default;right:auto}'
1295
+ doc.head[appendEl](style)
1296
+
1297
+ // create container element
1298
+ container = doc[createEl]('DIV')
1299
+ container.id = 'bp_container'
1300
+ container.onclick = close
1301
+ closeButton = createCloseButton()
1302
+ container[appendEl](closeButton)
1303
+ // gallery swipe listeners
1304
+ if ('ontouchstart' in global) {
1305
+ supportsTouch = true
1306
+ container.ontouchstart = function(e) {
1307
+ startX = e.changedTouches[0].pageX
1308
+ }
1309
+ container.ontouchmove = function(e) {
1310
+ e.preventDefault()
1311
+ }
1312
+ container.ontouchend = function(e) {
1313
+ if (!galleryOpen) {
1314
+ return
1315
+ }
1316
+ var touchobj = e.changedTouches[0]
1317
+ var distX = touchobj.pageX - startX
1318
+ // swipe right
1319
+ distX < -30 && updateGallery(1)
1320
+ // swipe left
1321
+ distX > 30 && updateGallery(-1)
1322
+ }
1323
+ }
1324
 
1325
+ // create display image element
1326
+ displayImage = doc[createEl]('IMG')
1327
+
1328
+ // create display video element
1329
+ displayVideo = doc[createEl]('VIDEO')
1330
+ displayVideo.id = 'bp_vid'
1331
+ displayVideo.autoplay = true
1332
+ displayVideo.setAttribute('playsinline', true)
1333
+ displayVideo.controls = true
1334
+ displayVideo.loop = true
1335
+
1336
+ // create gallery counter
1337
+ galleryCounter = doc[createEl]('span')
1338
+ galleryCounter.id = 'bp_count'
1339
+
1340
+ // create caption elements
1341
+ caption = doc[createEl]('DIV')
1342
+ caption.id = 'bp_caption'
1343
+ captionHideButton = createCloseButton()
1344
+ captionHideButton.onclick = toggleCaption.bind(null, false)
1345
+ caption[appendEl](captionHideButton)
1346
+ captionText = doc[createEl]('SPAN')
1347
+ caption[appendEl](captionText)
1348
+ container[appendEl](caption)
1349
+
1350
+ // left / right arrow icons
1351
+ rightArrowBtn = createArrowSymbol(1, webkitify('transform:', 'scalex(-1);'))
1352
+ leftArrowBtn = createArrowSymbol(-1, 'left:0;right:auto')
1353
+
1354
+ // create loading icon element
1355
+ loadingIcon = doc[createEl]('DIV')
1356
+ loadingIcon.id = 'bp_loader'
1357
+ loadingIcon[htmlInner] =
1358
+ '<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 32 32" fill="#fff" opacity=".8"><path d="M16 0a16 16 0 0 0 0 32 16 16 0 0 0 0-32m0 4a12 12 0 0 1 0 24 12 12 0 0 1 0-24" fill="#000" opacity=".5"/><path d="M16 0a16 16 0 0 1 16 16h-4A12 12 0 0 0 16 4z"><animateTransform attributeName="transform" dur="1s" from="0 16 16" repeatCount="indefinite" to="360 16 16" type="rotate"/></path></svg>'
1359
+
1360
+ // create youtube / vimeo container
1361
+ iframeContainer = doc[createEl]('DIV')
1362
+ iframeContainer.id = 'bp_sv'
1363
+
1364
+ // create iframe to hold youtube / vimeo player
1365
+ iframeSiteVid = doc[createEl]('IFRAME')
1366
+ iframeSiteVid.allowFullscreen = true
1367
+ iframeSiteVid.onload = open
1368
+ changeCSS(iframeSiteVid, 'border:0px;height:100%;width:100%')
1369
+ iframeContainer[appendEl](iframeSiteVid)
1370
+
1371
+ // display image bindings for image load and error
1372
+ displayImage.onload = open
1373
+ displayImage.onerror = open.bind(null, 'image')
1374
+
1375
+ // adjust loader position on window resize
1376
+ global[listenFor]('resize', function() {
1377
+ galleryOpen || (isLoading && toggleLoadingIcon(true))
1378
+ })
1379
+
1380
+ // close container on escape key press and arrow buttons for gallery
1381
+ doc[listenFor]('keyup', function(e) {
1382
+ var key = e.keyCode
1383
+ key === 27 && isOpen && close(container)
1384
+ if (galleryOpen) {
1385
+ key === 39 && updateGallery(1)
1386
+ key === 37 && updateGallery(-1)
1387
+ key === 38 && updateGallery(10)
1388
+ key === 40 && updateGallery(-10)
1389
+ }
1390
+ })
1391
+ // prevent scrolling with arrow keys if gallery open
1392
+ doc[listenFor]('keydown', function(e) {
1393
+ var usedKeys = [37, 38, 39, 40]
1394
+ if (galleryOpen && ~usedKeys.indexOf(e.keyCode)) {
1395
+ e.preventDefault()
1396
+ }
1397
+ })
1398
+
1399
+ // trap focus within conainer while open
1400
+ doc[listenFor](
1401
+ 'focus',
1402
+ function(e) {
1403
+ if (isOpen && !container.contains(e.target)) {
1404
+ e.stopPropagation()
1405
+ closeButton.focus()
1406
+ }
1407
+ },
1408
+ true
1409
+ )
1410
 
1411
+ // all done
1412
+ initialized = true
1413
+ }
1414
 
1415
+ // return transform style to make full size display el match trigger el size
1416
+ function getRect() {
1417
+ var rect = el.getBoundingClientRect()
1418
+ var leftOffset = rect.left - (container[cWidth] - rect.width) / 2
1419
+ var centerTop = rect.top - (container[cHeight] - rect.height) / 2
1420
+ var scaleWidth = el[cWidth] / displayElement[cWidth]
1421
+ var scaleHeight = el[cHeight] / displayElement[cHeight]
1422
+ return webkitify(
1423
+ 'transform:',
1424
+ 'translate3D(' +
1425
+ leftOffset +
1426
+ 'px, ' +
1427
+ centerTop +
1428
+ 'px, 0) scale3D(' +
1429
+ scaleWidth +
1430
+ ', ' +
1431
+ scaleHeight +
1432
+ ', 0);'
1433
+ )
1434
+ }
1435
 
1436
+ function makeGallery(gallery) {
1437
+ if (Array.isArray(gallery)) {
1438
+ // is array of images
1439
+ galleryPosition = 0
1440
+ galleryEls = gallery
1441
+ captionContent = gallery[0].caption
1442
+ } else {
1443
+ // is element selector
1444
+ galleryEls = [].slice.call(doc.querySelectorAll(gallery + ' [data-bp]'))
1445
+ // find initial gallery position
1446
+ var elIndex = galleryEls.indexOf(el)
1447
+ galleryPosition = elIndex !== -1 ? elIndex : 0
1448
+ // make gallery object w/ els / src / caption
1449
+ galleryEls = galleryEls.map(function(el) {
1450
+ return {
1451
+ el: el,
1452
+ src: el.getAttribute('data-bp'),
1453
+ caption: el.getAttribute('caption')
1454
+ }
1455
+ })
1456
+ }
1457
+ // show loading icon if needed
1458
+ remoteImage = true
1459
+ // set initial src to imgSrc so it will be cached in open func
1460
+ imgSrc = galleryEls[galleryPosition].src
1461
+ !~imgCache.indexOf(imgSrc) && toggleLoadingIcon(true)
1462
+ if (galleryEls.length > 1) {
1463
+ // if length is greater than one, add gallery stuff
1464
+ container[appendEl](galleryCounter)
1465
+ galleryCounter[htmlInner] = galleryPosition + 1 + '/' + galleryEls.length
1466
+ if (!supportsTouch) {
1467
+ // add arrows if device doesn't support touch
1468
+ container[appendEl](rightArrowBtn)
1469
+ container[appendEl](leftArrowBtn)
1470
+ }
1471
+ } else {
1472
+ // gallery is one, just show without clutter
1473
+ galleryEls = false
1474
+ }
1475
+ displayElement = displayImage
1476
+ // set initial image src
1477
+ displayElement.src = imgSrc
1478
+ }
1479
 
1480
+ function updateGallery(movement) {
1481
+ var galleryLength = galleryEls.length - 1
1482
+ // normalize position
1483
+ galleryPosition = Math.max(
1484
+ 0,
1485
+ Math.min(galleryPosition + movement, galleryLength)
1486
+ )
1487
+
1488
+ // load images before and after for quicker scrolling through pictures
1489
+ ;[galleryPosition - 1, galleryPosition, galleryPosition + 1].forEach(
1490
+ function(position) {
1491
+ // normalize position
1492
+ position = Math.max(0, Math.min(position, galleryLength))
1493
+ // cancel if image has already been preloaded
1494
+ if (!!preloadedImages[position]) return
1495
+ var src = galleryEls[position].src
1496
+ // create image for preloadedImages
1497
+ var img = doc[createEl]('IMG')
1498
+ img[listenFor]('load', addToImgCache.bind(null, src))
1499
+ img.src = src
1500
+ preloadedImages[position] = img
1501
+ }
1502
+ )
1503
+ // if image is loaded, show it
1504
+ if (preloadedImages[galleryPosition].complete) {
1505
+ return changeGalleryImage()
1506
+ }
1507
+ // if not, show loading icon and change when loaded
1508
+ isLoading = true
1509
+ changeCSS(loadingIcon, 'opacity:.4;')
1510
+ container[appendEl](loadingIcon)
1511
+ preloadedImages[galleryPosition].onload = function() {
1512
+ galleryOpen && changeGalleryImage()
1513
+ }
1514
+ // if error, store error object in el array
1515
+ preloadedImages[galleryPosition].onerror = function() {
1516
+ galleryEls[galleryPosition] = {
1517
+ error: 'Error loading image'
1518
+ }
1519
+ galleryOpen && changeGalleryImage()
1520
+ }
1521
+ }
1522
 
1523
+ function changeGalleryImage() {
1524
+ if (isLoading) {
1525
+ container[removeEl](loadingIcon)
1526
+ isLoading = false
1527
+ }
1528
+ var activeEl = galleryEls[galleryPosition]
1529
+ if (activeEl.error) {
1530
+ // show alert if error
1531
+ alert(activeEl.error)
1532
+ } else {
1533
+ var newSrc = activeEl.src
1534
+ displayImage.src = newSrc
1535
+ if (activeEl.el) {
1536
+ el = activeEl.el
1537
+ }
1538
+ }
1539
+ galleryCounter[htmlInner] = galleryPosition + 1 + '/' + galleryEls.length
1540
+ }
1541
 
1542
+ // create youtube / vimeo video iframe
1543
+ function createIframe(isYoutube) {
1544
+ // create appropriate url for youtube or vimeo
1545
+ var url = isYoutube
1546
+ ? 'www.youtube.com/embed/' +
1547
+ siteVidID +
1548
+ '?html5=1&rel=0&showinfo=0&playsinline=1&'
1549
+ : 'player.vimeo.com/video/' + siteVidID + '?'
1550
+
1551
+ // set iframe src to url
1552
+ iframeSiteVid.src = 'https://' + url + 'autoplay=1'
1553
+ }
1554
 
1555
+ // timeout to check video status while loading
1556
+ // onloadeddata event doesn't seem to fire in less up-to-date browsers like midori & epiphany
1557
+ function checkVid() {
1558
+ if (displayElement.readyState === 4) open()
1559
+ else if (displayVideo.error) open('video')
1560
+ else checkVidTimeout = timeout(checkVid, 35)
1561
+ }
1562
 
1563
+ // hide / show loading icon
1564
+ function toggleLoadingIcon(bool) {
1565
+ // don't show loading icon if noLoader is specified
1566
+ if (noLoader) return
1567
+ // bool is true if we want to show icon, false if we want to remove
1568
+ // change style to match trigger element dimensions if we want to show
1569
+ bool &&
1570
+ changeCSS(
1571
+ loadingIcon,
1572
+ 'top:' +
1573
+ el.offsetTop +
1574
+ 'px;left:' +
1575
+ el.offsetLeft +
1576
+ 'px;height:' +
1577
+ el[cHeight] +
1578
+ 'px;width:' +
1579
+ el[cWidth] +
1580
+ 'px'
1581
+ )
1582
+ // add or remove loader from DOM
1583
+ el.parentElement[bool ? appendEl : removeEl](loadingIcon)
1584
+ isLoading = bool
1585
+ }
1586
 
1587
+ // hide & show caption
1588
+ function toggleCaption(captionContent) {
1589
+ if (captionContent) {
1590
+ captionText[htmlInner] = captionContent
1591
+ }
1592
+ changeCSS(
1593
+ caption,
1594
+ 'opacity:' + (captionContent ? '1;' + pointerEventsAuto : '0')
1595
+ )
1596
+ }
1597
 
1598
+ function addToImgCache(url) {
1599
+ !~imgCache.indexOf(url) && imgCache.push(url)
1600
+ }
1601
 
1602
+ // animate open of image / video; display caption if needed
1603
+ function open(err) {
1604
+ // hide loading spinner
1605
+ isLoading && toggleLoadingIcon()
1606
 
1607
+ // execute animationStart callback
1608
+ animationStart && animationStart()
1609
 
1610
+ // check if we have an error string instead of normal event
1611
+ if (typeof err === 'string') {
1612
+ removeContainer()
1613
+ return alert('Error: The requested ' + err + ' could not be loaded.')
1614
+ }
1615
 
1616
+ // if remote image is loaded, add url to imgCache array
1617
+ remoteImage && addToImgCache(imgSrc)
 
 
 
 
1618
 
1619
+ if (galleryOpen) {
1620
+ return toggleCaption(galleryEls[galleryPosition].caption)
1621
+ // return
1622
+ }
1623
 
1624
+ // transform displayEl to match trigger el
1625
+ changeCSS(displayElement, getRect())
 
 
1626
 
1627
+ // fade in container
1628
+ changeCSS(container, 'opacity:1;' + pointerEventsAuto)
1629
 
1630
+ // set animationEnd callback to run after animation ends (cleared if container closed)
1631
+ animationEnd = timeout(animationEnd, 410)
 
 
1632
 
1633
+ isOpen = true
 
 
1634
 
1635
+ galleryOpen = !!galleryEls
 
1636
 
1637
+ // enlarge displayEl, fade in caption if hasCaption
1638
+ timeout(function() {
1639
+ changeCSS(
1640
+ displayElement,
1641
+ webkitify('transition:', 'transform .35s;') +
1642
+ webkitify('transform:', 'none;')
1643
+ )
1644
+ captionContent && timeout(toggleCaption.bind(null, captionContent), 250)
1645
+ }, 60)
1646
+ }
1647
 
1648
+ // close active display element
1649
+ function close(e) {
1650
+ var target = e.target
1651
+ var clickEls = [
1652
+ caption,
1653
+ captionHideButton,
1654
+ displayVideo,
1655
+ captionText,
1656
+ leftArrowBtn,
1657
+ rightArrowBtn,
1658
+ loadingIcon
1659
+ ]
1660
+
1661
+ // blur to hide close button focus style
1662
+ target && target.blur()
1663
+
1664
+ // don't close if one of the clickEls was clicked or container is already closing
1665
+ if (isClosing || ~clickEls.indexOf(target)) {
1666
+ return
1667
+ }
1668
 
1669
+ // animate closing
1670
+ displayElement.style.cssText += getRect()
1671
+ changeCSS(container, pointerEventsAuto)
1672
 
1673
+ // timeout to remove els from dom; use variable to avoid calling more than once
1674
+ timeout(removeContainer, 350)
 
 
 
 
1675
 
1676
+ // clear animationEnd timeout
1677
+ clearTimeout(animationEnd)
 
1678
 
1679
+ isOpen = false
1680
+ isClosing = true
1681
+ }
 
 
 
1682
 
1683
+ // remove container / display element from the DOM
1684
+ function removeContainer() {
1685
+ // remove container from DOM & clear inline style
1686
+ doc.body[removeEl](container)
1687
+ container[removeEl](displayElement)
1688
+ changeCSS(container, '')
1689
+
1690
+ // clear src of displayElement (or iframe if display el is iframe container)
1691
+ ;(displayElement === iframeContainer
1692
+ ? iframeSiteVid
1693
+ : displayElement
1694
+ ).removeAttribute('src')
1695
+
1696
+ // remove caption
1697
+ toggleCaption(false)
1698
+
1699
+ if (galleryOpen) {
1700
+ isLoading && container[removeEl](loadingIcon)
1701
+ container[removeEl](galleryCounter)
1702
+ galleryOpen = galleryEls = false
1703
+ preloadedImages = {}
1704
+ supportsTouch || container[removeEl](rightArrowBtn)
1705
+ supportsTouch || container[removeEl](leftArrowBtn)
1706
+ }
1707
 
1708
+ isClosing = isLoading = false
1709
+ }
 
 
 
 
 
 
 
 
 
 
1710
 
1711
+ // style helper functions
1712
+ function changeCSS(element, newStyle) {
1713
+ element.style.cssText = newStyle
1714
+ }
1715
+ function webkitify(prop, val) {
1716
+ var webkit = '-webkit-'
1717
+ var propVal = prop + val
1718
+ return webkit + propVal + prop + webkit + val + propVal
1719
+ }
1720
+ })()
1721
 
1722
 
1723
  /***/ })
dist/blocks.frontend.build.min.js CHANGED
@@ -1 +1 @@
1
- var main=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(t){if("complete"===document.readyState)return t();document.addEventListener("DOMContentLoaded",t)}},function(t,e,n){n(2),n(4),n(5),t.exports=n(6)},function(t,e,n){"use strict";var i,o=n(0);(0,((i=o)&&i.__esModule?i:{default:i}).default)(function(){n(3),document.querySelectorAll(".ugb-countup .ugb-counter").forEach(function(t){t.classList.add("ugb-countup-hide"),new Waypoint({element:t,handler:function(){r(t),t.classList.remove("ugb-countup-hide"),this.destroy()},offset:"bottom-in-view"})})});var r=function(t){var e,n,i,o,r,s,a,l,u,c,p,d,h,f;if(function(t){clearTimeout(t.countUpTimeout),t._countUpOrigInnerHTML&&(t.innerHTML=t._countUpOrigInnerHTML,t._countUpOrigInnerHTML=void 0),t.style.visibility=""}(t),/[0-9]/.test(t.innerHTML)){for(t._countUpOrigInnerHTML=t.innerHTML,e=document.querySelector("html").getAttribute("lang")||void 0,i=t.getAttribute("data-duration")/(n=t.getAttribute("data-delay")),o=t.innerHTML.split(/(<[^>]+>|[0-9.][,.0-9]*[0-9]*)/),r=[],s=0;s<i;s++)r.push("");for(a=0;a<o.length;a++)if(/([0-9.][,.0-9]*[0-9]*)/.test(o[a])&&!/<[^>]+>/.test(o[a]))for(l=o[a],u=/[0-9]+,[0-9]+/.test(l),l=l.replace(/,/g,""),p=(c=/^[0-9]+\.[0-9]+$/.test(l))?(l.split(".")[1]||[]).length:0,s=r.length-1,d=i;d>=1;d--)h=parseInt(l/i*d,10),c&&(h=parseFloat(l/i*d).toFixed(p),h=parseFloat(h).toLocaleString(e)),u&&(h=h.toLocaleString(e)),r[s--]+=h;else for(s=0;s<i;s++)r[s]+=o[a];r[r.length]=t.innerHTML,t.innerHTML=r[0],t.style.visibility="visible",f=function(){t.innerHTML=r.shift(),r.length?(clearTimeout(t.countUpTimeout),t.countUpTimeout=setTimeout(f,n)):t._countUpOrigInnerHTML=void 0},t.countUpTimeout=setTimeout(f,n)}}},function(t,e){!function(){"use strict";var t=0,e={};function n(i){if(!i)throw new Error("No options passed to Waypoint constructor");if(!i.element)throw new Error("No element option passed to Waypoint constructor");if(!i.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+t,this.options=n.Adapter.extend({},n.defaults,i),this.element=this.options.element,this.adapter=new n.Adapter(this.element),this.callback=i.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=n.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=n.Context.findOrCreateByElement(this.options.context),n.offsetAliases[this.options.offset]&&(this.options.offset=n.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),e[this.key]=this,t+=1}n.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},n.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},n.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete e[this.key]},n.prototype.disable=function(){return this.enabled=!1,this},n.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},n.prototype.next=function(){return this.group.next(this)},n.prototype.previous=function(){return this.group.previous(this)},n.invokeAll=function(t){var n=[];for(var i in e)n.push(e[i]);for(var o=0,r=n.length;o<r;o++)n[o][t]()},n.destroyAll=function(){n.invokeAll("destroy")},n.disableAll=function(){n.invokeAll("disable")},n.enableAll=function(){for(var t in n.Context.refreshAll(),e)e[t].enabled=!0;return this},n.refreshAll=function(){n.Context.refreshAll()},n.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},n.viewportWidth=function(){return document.documentElement.clientWidth},n.adapters=[],n.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},n.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=n}(),function(){"use strict";function t(t){window.setTimeout(t,1e3/60)}var e=0,n={},i=window.Waypoint,o=window.onload;function r(t){this.element=t,this.Adapter=i.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+e,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,n[t.waypointContextKey]=this,e+=1,i.windowContext||(i.windowContext=!0,i.windowContext=new r(window)),this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}r.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},r.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical),i=this.element==this.element.window;t&&e&&!i&&(this.adapter.off(".waypoints"),delete n[this.key])},r.prototype.createThrottledResizeHandler=function(){var t=this;function e(){t.handleResize(),t.didResize=!1}this.adapter.on("resize.waypoints",function(){t.didResize||(t.didResize=!0,i.requestAnimationFrame(e))})},r.prototype.createThrottledScrollHandler=function(){var t=this;function e(){t.handleScroll(),t.didScroll=!1}this.adapter.on("scroll.waypoints",function(){t.didScroll&&!i.isTouch||(t.didScroll=!0,i.requestAnimationFrame(e))})},r.prototype.handleResize=function(){i.Context.refreshAll()},r.prototype.handleScroll=function(){var t={},e={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var n in e){var i=e[n],o=i.newScroll>i.oldScroll?i.forward:i.backward;for(var r in this.waypoints[n]){var s=this.waypoints[n][r];if(null!==s.triggerPoint){var a=i.oldScroll<s.triggerPoint,l=i.newScroll>=s.triggerPoint;(a&&l||!a&&!l)&&(s.queueTrigger(o),t[s.group.id]=s.group)}}}for(var u in t)t[u].flushTriggers();this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},r.prototype.innerHeight=function(){return this.element==this.element.window?i.viewportHeight():this.adapter.innerHeight()},r.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},r.prototype.innerWidth=function(){return this.element==this.element.window?i.viewportWidth():this.adapter.innerWidth()},r.prototype.destroy=function(){var t=[];for(var e in this.waypoints)for(var n in this.waypoints[e])t.push(this.waypoints[e][n]);for(var i=0,o=t.length;i<o;i++)t[i].destroy()},r.prototype.refresh=function(){var t,e=this.element==this.element.window,n=e?void 0:this.adapter.offset(),o={};for(var r in this.handleScroll(),t={horizontal:{contextOffset:e?0:n.left,contextScroll:e?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:e?0:n.top,contextScroll:e?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}}){var s=t[r];for(var a in this.waypoints[r]){var l,u,c,p,d=this.waypoints[r][a],h=d.options.offset,f=d.triggerPoint,g=0,m=null==f;d.element!==d.element.window&&(g=d.adapter.offset()[s.offsetProp]),"function"==typeof h?h=h.apply(d):"string"==typeof h&&(h=parseFloat(h),d.options.offset.indexOf("%")>-1&&(h=Math.ceil(s.contextDimension*h/100))),l=s.contextScroll-s.contextOffset,d.triggerPoint=Math.floor(g+l-h),u=f<s.oldScroll,c=d.triggerPoint>=s.oldScroll,p=!u&&!c,!m&&(u&&c)?(d.queueTrigger(s.backward),o[d.group.id]=d.group):!m&&p?(d.queueTrigger(s.forward),o[d.group.id]=d.group):m&&s.oldScroll>=d.triggerPoint&&(d.queueTrigger(s.forward),o[d.group.id]=d.group)}}return i.requestAnimationFrame(function(){for(var t in o)o[t].flushTriggers()}),this},r.findOrCreateByElement=function(t){return r.findByElement(t)||new r(t)},r.refreshAll=function(){for(var t in n)n[t].refresh()},r.findByElement=function(t){return n[t.waypointContextKey]},window.onload=function(){o&&o(),r.refreshAll()},i.requestAnimationFrame=function(e){(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||t).call(window,e)},i.Context=r}(),function(){"use strict";function t(t,e){return t.triggerPoint-e.triggerPoint}function e(t,e){return e.triggerPoint-t.triggerPoint}var n={vertical:{},horizontal:{}},i=window.Waypoint;function o(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),n[this.axis][this.name]=this}o.prototype.add=function(t){this.waypoints.push(t)},o.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},o.prototype.flushTriggers=function(){for(var n in this.triggerQueues){var i=this.triggerQueues[n],o="up"===n||"left"===n;i.sort(o?e:t);for(var r=0,s=i.length;r<s;r+=1){var a=i[r];(a.options.continuous||r===i.length-1)&&a.trigger([n])}}this.clearTriggerQueues()},o.prototype.next=function(e){this.waypoints.sort(t);var n=i.Adapter.inArray(e,this.waypoints);return n===this.waypoints.length-1?null:this.waypoints[n+1]},o.prototype.previous=function(e){this.waypoints.sort(t);var n=i.Adapter.inArray(e,this.waypoints);return n?this.waypoints[n-1]:null},o.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},o.prototype.remove=function(t){var e=i.Adapter.inArray(t,this.waypoints);e>-1&&this.waypoints.splice(e,1)},o.prototype.first=function(){return this.waypoints[0]},o.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},o.findOrCreate=function(t){return n[t.axis][t.name]||new o(t)},i.Group=o}(),function(){"use strict";var t=window.Waypoint;function e(t){return t===t.window}function n(t){return e(t)?t:t.defaultView}function i(t){this.element=t,this.handlers={}}i.prototype.innerHeight=function(){return e(this.element)?this.element.innerHeight:this.element.clientHeight},i.prototype.innerWidth=function(){return e(this.element)?this.element.innerWidth:this.element.clientWidth},i.prototype.off=function(t,e){function n(t,e,n){for(var i=0,o=e.length-1;i<o;i++){var r=e[i];n&&n!==r||t.removeEventListener(r)}}var i=t.split("."),o=i[0],r=i[1],s=this.element;if(r&&this.handlers[r]&&o)n(s,this.handlers[r][o],e),this.handlers[r][o]=[];else if(o)for(var a in this.handlers)n(s,this.handlers[a][o]||[],e),this.handlers[a][o]=[];else if(r&&this.handlers[r]){for(var l in this.handlers[r])n(s,this.handlers[r][l],e);this.handlers[r]={}}},i.prototype.offset=function(){if(!this.element.ownerDocument)return null;var t=this.element.ownerDocument.documentElement,e=n(this.element.ownerDocument),i={top:0,left:0};return this.element.getBoundingClientRect&&(i=this.element.getBoundingClientRect()),{top:i.top+e.pageYOffset-t.clientTop,left:i.left+e.pageXOffset-t.clientLeft}},i.prototype.on=function(t,e){var n=t.split("."),i=n[0],o=n[1]||"__default",r=this.handlers[o]=this.handlers[o]||{};(r[i]=r[i]||[]).push(e),this.element.addEventListener(i,e)},i.prototype.outerHeight=function(t){var n,i=this.innerHeight();return t&&!e(this.element)&&(n=window.getComputedStyle(this.element),i+=parseInt(n.marginTop,10),i+=parseInt(n.marginBottom,10)),i},i.prototype.outerWidth=function(t){var n,i=this.innerWidth();return t&&!e(this.element)&&(n=window.getComputedStyle(this.element),i+=parseInt(n.marginLeft,10),i+=parseInt(n.marginRight,10)),i},i.prototype.scrollLeft=function(){var t=n(this.element);return t?t.pageXOffset:this.element.scrollLeft},i.prototype.scrollTop=function(){var t=n(this.element);return t?t.pageYOffset:this.element.scrollTop},i.extend=function(){var t=Array.prototype.slice.call(arguments);function e(t,e){if("object"==typeof t&&"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}for(var n=1,i=t.length;n<i;n++)e(t[0],t[n]);return t[0]},i.inArray=function(t,e,n){return null==e?-1:e.indexOf(t,n)},i.isEmptyObject=function(t){for(var e in t)return!1;return!0},t.adapters.push({name:"noframework",Adapter:i}),t.Adapter=i}()},function(t,e,n){"use strict";var i,o=n(0);(0,((i=o)&&i.__esModule?i:{default:i}).default)(function(){document.querySelectorAll(".wp-block-ugb-expand").forEach(function(t){var e=t.querySelector(".ugb-expand-button"),n=function(e){t.classList.toggle("ugb-more"),e.preventDefault()};e&&(e.addEventListener("click",n),e.addEventListener("tapEnd",n))})})},function(t,e,n){"use strict";var i,o=n(0);(0,((i=o)&&i.__esModule?i:{default:i}).default)(function(){document.querySelectorAll(".ugb-notification.dismissible-true[data-uid]").forEach(function(t){var e=t.getAttribute("data-uid");localStorage.getItem("stckbl-notif-"+e)||(t.style.display="block"),t.querySelector(".close-button").addEventListener("click",function(){localStorage.setItem("stckbl-notif-"+e,1),t.style.display=""})})})},function(t,e,n){"use strict";var i=r(n(0)),o=r(n(7));function r(t){return t&&t.__esModule?t:{default:t}}(0,i.default)(function(){var t=document.querySelectorAll(".ugb-video-popup"),e=function(t){if(o.default){var e=t.getAttribute("data-video"),n={el:t,noLoader:!0};e.match(/^\d+$/g)?n.vimeoSrc=e:e.match(/^https?:\/\//g)?n.vidSrc=e:n.ytSrc=e,(0,o.default)(n)}};t.forEach(function(t){var n=t.querySelector("a");n.addEventListener("click",function(n){n.preventDefault(),e(t)}),n.addEventListener("touchend",function(n){n.preventDefault(),e(t)})})})},function(t,e){!function(){var e,n,i,o,r,s,a,l,u,c,p,d,h,f,g,m,y,w,v,b,x,S,A,T,k,L,_=window,E=document,H="appendChild",z="createElement",O="removeChild",M="innerHTML",C="pointer-events:auto",q="clientHeight",W="clientWidth",I="addEventListener",P=_.setTimeout,D=_.clearTimeout;function R(){var t=e.getBoundingClientRect();return N("transform:","translate3D("+(t.left-(i[W]-t.width)/2)+"px, "+(t.top-(i[q]-t.height)/2)+"px, 0) scale3D("+e[W]/o[W]+", "+e[q]/o[q]+", 0);")}function F(){4===o.readyState?U():s.error?U("video"):h=P(F,35)}function B(t){L||(t&&V(f,"top:"+e.offsetTop+"px;left:"+e.offsetLeft+"px;height:"+e[q]+"px;width:"+e[W]+"px"),e.parentElement[t?H:O](f),d=t)}function U(t){if(d&&B(),T&&T(),"string"==typeof t)return Q(),alert("Error: The requested "+t+" could not be displayed.");A&&!S&&x.push(u),V(o,R()),V(i,"opacity:1;"+C),k=P(k,410),v=!0,P(function(){V(o,N("transition:","transform .35s;")+N("transform:","none;")),y&&P(V.bind(null,g,"opacity:1"),250)},60)}function j(t){var e=t.target,n=[g,w,s,m];e&&e.blur(),b||~n.indexOf(e)||(o.style.cssText+=R(),V(i,C),P(Q,350),D(k),v=!1,b=!0)}function Q(){E.body[O](i),i[O](o),V(i,""),(o===a?l:o).removeAttribute("src"),y&&(V(g,""),i[O](g)),b=!1}function V(t,e){t.style.cssText=e}function N(t,e){var n=t+e;return"-webkit-"+n+t+"-webkit-"+e+n}t.exports=function(t){var b,C;n||function(){function t(){var t=E[z]("button");return t.className="bp-x",t[M]="&#215;",t}x=[];var e=E[z]("STYLE");e[M]="#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0}#bp_container>*,.bp-x,#bp_loader{position:absolute;right:0}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;pointer-events:none;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:-webkit-flex;display:flex;margin:0;cursor:wait;z-index:9}#bp_loader svg{width:40%;max-height:40%;margin:auto;"+N("animation:","ldr .7s infinite linear;")+"}"+(o="keyframes ldr{to{"+N("transform:","rotate(1turn);")+"}}","@-webkit-"+o+"@"+o)+"#bp_container img,#bp_sv,#bp_vid{max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{width:171vh}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}.bp-x{font-family:Arial;top:0;cursor:pointer;opacity:.8;font-size:3em;padding:0 .3em;color:#fff;background:transparent;border:0;text-shadow:0 0 2px #000}#bp_caption .bp-x{left:2%;top:auto;right:auto;bottom:100%;padding:0 .6em;background:#d74040;border-radius:2px 2px 0 0;font-size:2.3em;text-shadow:none}.bp-x:hover,.bp-x:focus{opacity:1}.bp-x:active{outline:0}@media (max-aspect-ratio:9/5){#bp_sv{height:53vw}}",E.head[H](e),(i=E[z]("DIV")).id="bp_container",i.onclick=j,c=t(),i[H](c),r=E[z]("IMG"),(s=E[z]("VIDEO")).id="bp_vid",s.autoplay=!0,s.setAttribute("playsinline",!0),s.controls=!0,s.loop=!0,(g=E[z]("DIV")).id="bp_caption",(w=t()).onclick=function(){V(g,"opacity:0"),P(function(){y=!1,i[O](g)},300)},g[H](w),m=E[z]("SPAN"),g[H](m),(f=E[z]("DIV")).id="bp_loader",f[M]='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 399 399"><path d="M341 58.5C303 20.8 253 0 199.6 0 146.4 0 96.2 20.8 58.5 58.5 20.8 96.2 0 146.5 0 199.7 0 253 20.8 303.2 58.5 341c37.7 37.6 88 58.4 141.2 58.4 53.3 0 103.5-20.8 141.2-58.5 37.6-37.8 58.4-88 58.4-141.3 0-53.3-20.8-103.5-58.5-141.2zm-13 12.8c34.3 34.3 53.2 80 53.2 128.4h-41c0-77.4-63-140.4-140.5-140.4-4.6 0-9 .2-13.6.7V18.7c4.6-.4 9-.5 13.7-.5 48.5 0 94 18.8 128.4 53zM199.8 322c-67.4 0-122.2-55-122.2-122.3S132.3 77.5 199.7 77.5 322 132.3 322 199.7 267 322 199.6 322z"/></svg>',(a=E[z]("DIV")).id="bp_sv",(l=E[z]("IFRAME")).allowFullscreen=!0,l.onload=U,V(l,"border:0px;height:100%;width:100%"),a[H](l),r.onload=U,r.onerror=U.bind(null,"image"),_[I]("resize",function(){d&&B(!0)}),E[I]("keyup",function(t){27===t.keyCode&&v&&j(i)}),E[I]("focus",function(t){v&&!i.contains(t.target)&&(t.stopPropagation(),c.focus())},!0),n=!0;var o}(),d&&(D(h),Q()),p=t.ytSrc||t.vimeoSrc,T=t.animationStart,k=t.animationEnd,L=t.noLoader,e=t.el,A=!1,(y=e.getAttribute("caption"))&&(m[M]=y,i[H](g)),p?(B(!0),o=a,b=!!t.ytSrc,C=b?"www.youtube.com/embed/"+p+"?html5=1&rel=0&showinfo=0&playsinline=1&":"player.vimeo.com/video/"+p+"?",l.src="https://"+C+"autoplay=1"):t.imgSrc?(A=!0,u=t.imgSrc,!(S=~x.indexOf(u))&&B(!0),(o=r).src=u):t.vidSrc?(B(!0),(o=s).src=t.vidSrc,F()):(o=r).src="IMG"===e.tagName?e.src:_.getComputedStyle(e).backgroundImage.replace(/^url|[(|)|'|"]/g,""),i[H](o),E.body[H](i)}}()}]);
1
+ var main=function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(t){if("complete"===document.readyState)return t();document.addEventListener("DOMContentLoaded",t)}},function(t,e,n){n(2),n(4),n(5),t.exports=n(6)},function(t,e,n){"use strict";var o,i=n(0);(0,((o=i)&&o.__esModule?o:{default:o}).default)(function(){n(3),document.querySelectorAll(".ugb-countup .ugb-counter").forEach(function(t){t.classList.add("ugb-countup-hide"),new Waypoint({element:t,handler:function(){r(t),t.classList.remove("ugb-countup-hide"),this.destroy()},offset:"bottom-in-view"})})});var r=function(t){var e,n,o,i,r,a,s,l,c,u,p,d,f,h;if(function(t){clearTimeout(t.countUpTimeout),t._countUpOrigInnerHTML&&(t.innerHTML=t._countUpOrigInnerHTML,t._countUpOrigInnerHTML=void 0),t.style.visibility=""}(t),/[0-9]/.test(t.innerHTML)){for(t._countUpOrigInnerHTML=t.innerHTML,e=document.querySelector("html").getAttribute("lang")||void 0,o=t.getAttribute("data-duration")/(n=t.getAttribute("data-delay")),i=t.innerHTML.split(/(<[^>]+>|[0-9.][,.0-9]*[0-9]*)/),r=[],a=0;a<o;a++)r.push("");for(s=0;s<i.length;s++)if(/([0-9.][,.0-9]*[0-9]*)/.test(i[s])&&!/<[^>]+>/.test(i[s]))for(l=i[s],c=/[0-9]+,[0-9]+/.test(l),l=l.replace(/,/g,""),p=(u=/^[0-9]+\.[0-9]+$/.test(l))?(l.split(".")[1]||[]).length:0,a=r.length-1,d=o;d>=1;d--)f=parseInt(l/o*d,10),u&&(f=parseFloat(l/o*d).toFixed(p),f=parseFloat(f).toLocaleString(e)),c&&(f=f.toLocaleString(e)),r[a--]+=f;else for(a=0;a<o;a++)r[a]+=i[s];r[r.length]=t.innerHTML,t.innerHTML=r[0],t.style.visibility="visible",h=function(){t.innerHTML=r.shift(),r.length?(clearTimeout(t.countUpTimeout),t.countUpTimeout=setTimeout(h,n)):t._countUpOrigInnerHTML=void 0},t.countUpTimeout=setTimeout(h,n)}}},function(t,e){!function(){"use strict";var t=0,e={};function n(o){if(!o)throw new Error("No options passed to Waypoint constructor");if(!o.element)throw new Error("No element option passed to Waypoint constructor");if(!o.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+t,this.options=n.Adapter.extend({},n.defaults,o),this.element=this.options.element,this.adapter=new n.Adapter(this.element),this.callback=o.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=n.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=n.Context.findOrCreateByElement(this.options.context),n.offsetAliases[this.options.offset]&&(this.options.offset=n.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),e[this.key]=this,t+=1}n.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},n.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},n.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete e[this.key]},n.prototype.disable=function(){return this.enabled=!1,this},n.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},n.prototype.next=function(){return this.group.next(this)},n.prototype.previous=function(){return this.group.previous(this)},n.invokeAll=function(t){var n=[];for(var o in e)n.push(e[o]);for(var i=0,r=n.length;i<r;i++)n[i][t]()},n.destroyAll=function(){n.invokeAll("destroy")},n.disableAll=function(){n.invokeAll("disable")},n.enableAll=function(){for(var t in n.Context.refreshAll(),e)e[t].enabled=!0;return this},n.refreshAll=function(){n.Context.refreshAll()},n.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},n.viewportWidth=function(){return document.documentElement.clientWidth},n.adapters=[],n.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},n.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=n}(),function(){"use strict";function t(t){window.setTimeout(t,1e3/60)}var e=0,n={},o=window.Waypoint,i=window.onload;function r(t){this.element=t,this.Adapter=o.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+e,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,n[t.waypointContextKey]=this,e+=1,o.windowContext||(o.windowContext=!0,o.windowContext=new r(window)),this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}r.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},r.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical),o=this.element==this.element.window;t&&e&&!o&&(this.adapter.off(".waypoints"),delete n[this.key])},r.prototype.createThrottledResizeHandler=function(){var t=this;function e(){t.handleResize(),t.didResize=!1}this.adapter.on("resize.waypoints",function(){t.didResize||(t.didResize=!0,o.requestAnimationFrame(e))})},r.prototype.createThrottledScrollHandler=function(){var t=this;function e(){t.handleScroll(),t.didScroll=!1}this.adapter.on("scroll.waypoints",function(){t.didScroll&&!o.isTouch||(t.didScroll=!0,o.requestAnimationFrame(e))})},r.prototype.handleResize=function(){o.Context.refreshAll()},r.prototype.handleScroll=function(){var t={},e={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var n in e){var o=e[n],i=o.newScroll>o.oldScroll?o.forward:o.backward;for(var r in this.waypoints[n]){var a=this.waypoints[n][r];if(null!==a.triggerPoint){var s=o.oldScroll<a.triggerPoint,l=o.newScroll>=a.triggerPoint;(s&&l||!s&&!l)&&(a.queueTrigger(i),t[a.group.id]=a.group)}}}for(var c in t)t[c].flushTriggers();this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},r.prototype.innerHeight=function(){return this.element==this.element.window?o.viewportHeight():this.adapter.innerHeight()},r.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},r.prototype.innerWidth=function(){return this.element==this.element.window?o.viewportWidth():this.adapter.innerWidth()},r.prototype.destroy=function(){var t=[];for(var e in this.waypoints)for(var n in this.waypoints[e])t.push(this.waypoints[e][n]);for(var o=0,i=t.length;o<i;o++)t[o].destroy()},r.prototype.refresh=function(){var t,e=this.element==this.element.window,n=e?void 0:this.adapter.offset(),i={};for(var r in this.handleScroll(),t={horizontal:{contextOffset:e?0:n.left,contextScroll:e?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:e?0:n.top,contextScroll:e?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}}){var a=t[r];for(var s in this.waypoints[r]){var l,c,u,p,d=this.waypoints[r][s],f=d.options.offset,h=d.triggerPoint,g=0,m=null==h;d.element!==d.element.window&&(g=d.adapter.offset()[a.offsetProp]),"function"==typeof f?f=f.apply(d):"string"==typeof f&&(f=parseFloat(f),d.options.offset.indexOf("%")>-1&&(f=Math.ceil(a.contextDimension*f/100))),l=a.contextScroll-a.contextOffset,d.triggerPoint=Math.floor(g+l-f),c=h<a.oldScroll,u=d.triggerPoint>=a.oldScroll,p=!c&&!u,!m&&(c&&u)?(d.queueTrigger(a.backward),i[d.group.id]=d.group):!m&&p?(d.queueTrigger(a.forward),i[d.group.id]=d.group):m&&a.oldScroll>=d.triggerPoint&&(d.queueTrigger(a.forward),i[d.group.id]=d.group)}}return o.requestAnimationFrame(function(){for(var t in i)i[t].flushTriggers()}),this},r.findOrCreateByElement=function(t){return r.findByElement(t)||new r(t)},r.refreshAll=function(){for(var t in n)n[t].refresh()},r.findByElement=function(t){return n[t.waypointContextKey]},window.onload=function(){i&&i(),r.refreshAll()},o.requestAnimationFrame=function(e){(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||t).call(window,e)},o.Context=r}(),function(){"use strict";function t(t,e){return t.triggerPoint-e.triggerPoint}function e(t,e){return e.triggerPoint-t.triggerPoint}var n={vertical:{},horizontal:{}},o=window.Waypoint;function i(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),n[this.axis][this.name]=this}i.prototype.add=function(t){this.waypoints.push(t)},i.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},i.prototype.flushTriggers=function(){for(var n in this.triggerQueues){var o=this.triggerQueues[n],i="up"===n||"left"===n;o.sort(i?e:t);for(var r=0,a=o.length;r<a;r+=1){var s=o[r];(s.options.continuous||r===o.length-1)&&s.trigger([n])}}this.clearTriggerQueues()},i.prototype.next=function(e){this.waypoints.sort(t);var n=o.Adapter.inArray(e,this.waypoints);return n===this.waypoints.length-1?null:this.waypoints[n+1]},i.prototype.previous=function(e){this.waypoints.sort(t);var n=o.Adapter.inArray(e,this.waypoints);return n?this.waypoints[n-1]:null},i.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},i.prototype.remove=function(t){var e=o.Adapter.inArray(t,this.waypoints);e>-1&&this.waypoints.splice(e,1)},i.prototype.first=function(){return this.waypoints[0]},i.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},i.findOrCreate=function(t){return n[t.axis][t.name]||new i(t)},o.Group=i}(),function(){"use strict";var t=window.Waypoint;function e(t){return t===t.window}function n(t){return e(t)?t:t.defaultView}function o(t){this.element=t,this.handlers={}}o.prototype.innerHeight=function(){return e(this.element)?this.element.innerHeight:this.element.clientHeight},o.prototype.innerWidth=function(){return e(this.element)?this.element.innerWidth:this.element.clientWidth},o.prototype.off=function(t,e){function n(t,e,n){for(var o=0,i=e.length-1;o<i;o++){var r=e[o];n&&n!==r||t.removeEventListener(r)}}var o=t.split("."),i=o[0],r=o[1],a=this.element;if(r&&this.handlers[r]&&i)n(a,this.handlers[r][i],e),this.handlers[r][i]=[];else if(i)for(var s in this.handlers)n(a,this.handlers[s][i]||[],e),this.handlers[s][i]=[];else if(r&&this.handlers[r]){for(var l in this.handlers[r])n(a,this.handlers[r][l],e);this.handlers[r]={}}},o.prototype.offset=function(){if(!this.element.ownerDocument)return null;var t=this.element.ownerDocument.documentElement,e=n(this.element.ownerDocument),o={top:0,left:0};return this.element.getBoundingClientRect&&(o=this.element.getBoundingClientRect()),{top:o.top+e.pageYOffset-t.clientTop,left:o.left+e.pageXOffset-t.clientLeft}},o.prototype.on=function(t,e){var n=t.split("."),o=n[0],i=n[1]||"__default",r=this.handlers[i]=this.handlers[i]||{};(r[o]=r[o]||[]).push(e),this.element.addEventListener(o,e)},o.prototype.outerHeight=function(t){var n,o=this.innerHeight();return t&&!e(this.element)&&(n=window.getComputedStyle(this.element),o+=parseInt(n.marginTop,10),o+=parseInt(n.marginBottom,10)),o},o.prototype.outerWidth=function(t){var n,o=this.innerWidth();return t&&!e(this.element)&&(n=window.getComputedStyle(this.element),o+=parseInt(n.marginLeft,10),o+=parseInt(n.marginRight,10)),o},o.prototype.scrollLeft=function(){var t=n(this.element);return t?t.pageXOffset:this.element.scrollLeft},o.prototype.scrollTop=function(){var t=n(this.element);return t?t.pageYOffset:this.element.scrollTop},o.extend=function(){var t=Array.prototype.slice.call(arguments);function e(t,e){if("object"==typeof t&&"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}for(var n=1,o=t.length;n<o;n++)e(t[0],t[n]);return t[0]},o.inArray=function(t,e,n){return null==e?-1:e.indexOf(t,n)},o.isEmptyObject=function(t){for(var e in t)return!1;return!0},t.adapters.push({name:"noframework",Adapter:o}),t.Adapter=o}()},function(t,e,n){"use strict";var o,i=n(0);(0,((o=i)&&o.__esModule?o:{default:o}).default)(function(){document.querySelectorAll(".wp-block-ugb-expand").forEach(function(t){var e=t.querySelector(".ugb-expand-button"),n=function(e){t.classList.toggle("ugb-more"),e.preventDefault()};e&&(e.addEventListener("click",n),e.addEventListener("tapEnd",n))})})},function(t,e,n){"use strict";var o,i=n(0);(0,((o=i)&&o.__esModule?o:{default:o}).default)(function(){document.querySelectorAll(".ugb-notification.dismissible-true[data-uid]").forEach(function(t){var e=t.getAttribute("data-uid");localStorage.getItem("stckbl-notif-"+e)||(t.style.display="block"),t.querySelector(".close-button").addEventListener("click",function(){localStorage.setItem("stckbl-notif-"+e,1),t.style.display=""})})})},function(t,e,n){"use strict";var o=r(n(0)),i=r(n(7));function r(t){return t&&t.__esModule?t:{default:t}}(0,o.default)(function(){var t=document.querySelectorAll(".ugb-video-popup"),e=function(t){if(i.default){var e=t.getAttribute("data-video"),n={el:t,noLoader:!0};e.match(/^\d+$/g)?n.vimeoSrc=e:e.match(/^https?:\/\//g)?n.vidSrc=e:n.ytSrc=e,(0,i.default)(n)}};t.forEach(function(t){var n=t.querySelector("a");n.addEventListener("click",function(n){n.preventDefault(),e(t)}),n.addEventListener("touchend",function(n){n.preventDefault(),e(t)})})})},function(t,e){!function(){var e,n,o,i,r,a,s,l,c,u,p,d,f,h,g,m,y,v,w,b,x,S,A,T,k,_,E,L,O,z,M,H=window,C=[],q={},I=document,P="appendChild",W="createElement",D="removeChild",R="innerHTML",F="pointer-events:auto",B="clientHeight",U="clientWidth",j="addEventListener",N=H.setTimeout,Q=H.clearTimeout;function V(){var t=e.getBoundingClientRect();return ot("transform:","translate3D("+(t.left-(o[U]-t.width)/2)+"px, "+(t.top-(o[B]-t.height)/2)+"px, 0) scale3D("+e[U]/i[U]+", "+e[B]/i[B]+", 0);")}function G(t){var e=L.length-1;if([(E=Math.max(0,Math.min(E+t,e)))-1,E,E+1].forEach(function(t){if(t=Math.max(0,Math.min(t,e)),!q[t]){var n=L[t].src,o=I[W]("IMG");o[j]("load",J.bind(null,n)),o.src=n,q[t]=o}}),q[E].complete)return X();d=!0,nt(h,"opacity:.4;"),o[P](h),q[E].onload=function(){b&&X()},q[E].onerror=function(){L[E]={error:"Error loading image"},b&&X()}}function X(){d&&(o[D](h),d=!1);var t=L[E];if(t.error)alert(t.error);else{var n=t.src;r.src=n,t.el&&(e=t.el)}O[R]=E+1+"/"+L.length}function K(){4===i.readyState?Z():a.error?Z("video"):f=N(K,35)}function Y(t){M||(t&&nt(h,"top:"+e.offsetTop+"px;left:"+e.offsetLeft+"px;height:"+e[B]+"px;width:"+e[U]+"px"),e.parentElement[t?P:D](h),d=t)}function $(t){t&&(m[R]=t),nt(g,"opacity:"+(t?"1;"+F:"0"))}function J(t){!~C.indexOf(t)&&C.push(t)}function Z(t){return d&&Y(),A&&A(),"string"==typeof t?(et(),alert("Error: The requested "+t+" could not be loaded.")):(S&&J(c),b?$(L[E].caption):(nt(i,V()),nt(o,"opacity:1;"+F),T=N(T,410),w=!0,b=!!L,void N(function(){nt(i,ot("transition:","transform .35s;")+ot("transform:","none;")),y&&N($.bind(null,y),250)},60)))}function tt(t){var e=t.target,n=[g,v,a,m,_,k,h];e&&e.blur(),x||~n.indexOf(e)||(i.style.cssText+=V(),nt(o,F),N(et,350),Q(T),w=!1,x=!0)}function et(){I.body[D](o),o[D](i),nt(o,""),(i===s?l:i).removeAttribute("src"),$(!1),b&&(d&&o[D](h),o[D](O),b=L=!1,q={},z||o[D](k),z||o[D](_)),x=d=!1}function nt(t,e){t.style.cssText=e}function ot(t,e){var n=t+e;return"-webkit-"+n+t+"-webkit-"+e+n}t.exports=function(t){var x,q;n||function(){var t;function e(){var t=I[W]("button");return t.className="bp-x",t[R]="&#215;",t}function i(t,e){var n=I[W]("button");return n.className="bp-lr",n[R]='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129 129" height="75" fill="#fff"><path d="M88.6 121.3c.8.8 1.8 1.2 2.9 1.2s2.1-.4 2.9-1.2a4.1 4.1 0 0 0 0-5.8l-51-51 51-51a4.1 4.1 0 0 0-5.8-5.8l-54 53.9a4.1 4.1 0 0 0 0 5.8l54 53.9z"/></svg>',nt(n,e),n.onclick=function(e){e.stopPropagation(),G(t)},n}var c=I[W]("STYLE");c[R]=".bp-lr,.bp-x:active{outline:0}#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0;backface-visibility:hidden}#bp_container>*,#bp_loader,.bp-x{position:absolute;right:0;z-index:10}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;pointer-events:none;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:-webkit-flex;display:flex;margin:0;cursor:wait;z-index:9}#bp_count,.bp-lr,.bp-x{cursor:pointer;color:#fff}#bp_loader svg{width:50%;max-height:50%;margin:auto}#bp_container img,#bp_sv,#bp_vid{user-select:none;max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{width:171vh}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}#bp_count,.bp-x{top:0;opacity:.8;font-size:3em;padding:0 .3em;background:0 0;border:0;text-shadow:0 0 2px rgba(0,0,0,.6)}#bp_caption .bp-x{left:2%;top:auto;right:auto;bottom:100%;padding:0 .6em;background:#d74040;border-radius:2px 2px 0 0;font-size:2.3em;text-shadow:none}.bp-x:focus,.bp-x:hover{opacity:1}@media (max-aspect-ratio:9/5){#bp_sv{height:53vw}}.bp-lr{top:50%;top:calc(50% - 138px);padding:99px 1vw;background:0 0;border:0;opacity:.4;transition:opacity .1s}.bp-lr:focus,.bp-lr:hover{opacity:.8}@media (max-width:600px){.bp-lr{font-size:15vw}}#bp_count{left:0;display:table;padding:14px;color:#fff;font-size:22px;opacity:.7;cursor:default;right:auto}",I.head[P](c),(o=I[W]("DIV")).id="bp_container",o.onclick=tt,u=e(),o[P](u),"ontouchstart"in H&&(z=!0,o.ontouchstart=function(e){t=e.changedTouches[0].pageX},o.ontouchmove=function(t){t.preventDefault()},o.ontouchend=function(e){if(b){var n=e.changedTouches[0],o=n.pageX-t;o<-30&&G(1),o>30&&G(-1)}});r=I[W]("IMG"),(a=I[W]("VIDEO")).id="bp_vid",a.autoplay=!0,a.setAttribute("playsinline",!0),a.controls=!0,a.loop=!0,(O=I[W]("span")).id="bp_count",(g=I[W]("DIV")).id="bp_caption",(v=e()).onclick=$.bind(null,!1),g[P](v),m=I[W]("SPAN"),g[P](m),o[P](g),k=i(1,ot("transform:","scalex(-1);")),_=i(-1,"left:0;right:auto"),(h=I[W]("DIV")).id="bp_loader",h[R]='<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 32 32" fill="#fff" opacity=".8"><path d="M16 0a16 16 0 0 0 0 32 16 16 0 0 0 0-32m0 4a12 12 0 0 1 0 24 12 12 0 0 1 0-24" fill="#000" opacity=".5"/><path d="M16 0a16 16 0 0 1 16 16h-4A12 12 0 0 0 16 4z"><animateTransform attributeName="transform" dur="1s" from="0 16 16" repeatCount="indefinite" to="360 16 16" type="rotate"/></path></svg>',(s=I[W]("DIV")).id="bp_sv",(l=I[W]("IFRAME")).allowFullscreen=!0,l.onload=Z,nt(l,"border:0px;height:100%;width:100%"),s[P](l),r.onload=Z,r.onerror=Z.bind(null,"image"),H[j]("resize",function(){b||d&&Y(!0)}),I[j]("keyup",function(t){var e=t.keyCode;27===e&&w&&tt(o),b&&(39===e&&G(1),37===e&&G(-1),38===e&&G(10),40===e&&G(-10))}),I[j]("keydown",function(t){b&&~[37,38,39,40].indexOf(t.keyCode)&&t.preventDefault()}),I[j]("focus",function(t){w&&!o.contains(t.target)&&(t.stopPropagation(),u.focus())},!0),n=!0}(),d&&(Q(f),et()),p=t.ytSrc||t.vimeoSrc,A=t.animationStart,T=t.animationEnd,M=t.noLoader,e=t.el,S=!1,y=e.getAttribute("caption"),t.gallery?function(t){if(Array.isArray(t))E=0,L=t,y=t[0].caption;else{var n=(L=[].slice.call(I.querySelectorAll(t+" [data-bp]"))).indexOf(e);E=-1!==n?n:0,L=L.map(function(t){return{el:t,src:t.getAttribute("data-bp"),caption:t.getAttribute("caption")}})}S=!0,c=L[E].src,!~C.indexOf(c)&&Y(!0),L.length>1?(o[P](O),O[R]=E+1+"/"+L.length,z||(o[P](k),o[P](_))):L=!1;(i=r).src=c}(t.gallery):p?(Y(!0),i=s,x=!!t.ytSrc,q=x?"www.youtube.com/embed/"+p+"?html5=1&rel=0&showinfo=0&playsinline=1&":"player.vimeo.com/video/"+p+"?",l.src="https://"+q+"autoplay=1"):t.imgSrc?(S=!0,c=t.imgSrc,!~C.indexOf(c)&&Y(!0),(i=r).src=c):t.vidSrc?(Y(!0),(i=a).src=t.vidSrc,K()):(i=r).src="IMG"===e.tagName?e.src:H.getComputedStyle(e).backgroundImage.replace(/^url|[(|)|'|"]/g,""),o[P](i),I.body[P](o)}}()}]);
dist/blocks.style.build.css CHANGED
@@ -1,18 +1,18 @@
1
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}
2
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-block-ugb-divider{border:0;height:1px;width:100%;background-color:transparent;margin-top:2rem;margin-bottom:2rem}.wp-block-ugb-divider hr{background-color:#dddddd;border:0 !important;padding:0 !important}
3
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-block-button.ugb-button-center{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);left:50%;position:relative}span.wp-block-button.ugb-button-right,form.blocks-button__inline-link.ugb-button-right{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);left:100%;position:relative}form.blocks-button__inline-link.ugb-button-center{margin:0 auto}.wp-ugb-button.wp-ugb-button{border:none;border-radius:4px;-webkit-box-shadow:none !important;box-shadow:none !important;cursor:pointer;display:inline-block;line-height:1em;margin:0;text-decoration:none !important;white-space:nowrap;display:inline-block;opacity:1;background:#2091e1;color:#fff;padding:0.75em 1em;-webkit-transition:opacity .2s ease-in-out;-o-transition:opacity .2s ease-in-out;transition:opacity .2s ease-in-out;box-shadow:none !important}.wp-ugb-button.wp-ugb-button:hover{opacity:.85;-webkit-box-shadow:none !important;box-shadow:none !important;border:0}.wp-block-ugb-button .wp-ugb-button:hover{color:white}.wp-block-ugb-button.ugb-button-right{margin:10px 0;text-align:right}.wp-block-ugb-button.ugb-button-center{margin:10px 0;text-align:center}.wp-block-ugb-button.ugb-button-left{margin:10px 0;text-align:left}.ugb-button-small{font-size:.75em}.ugb-button-normal{font-size:1em}.ugb-button-medium{font-size:1.25em}.ugb-button-large{font-size:1.5em}
4
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-block-ugb-ghost-button.ugb-button-right{margin:10px 0;text-align:right}.wp-block-ugb-ghost-button.ugb-button-center{margin:10px 0;text-align:center}.wp-block-ugb-ghost-button.ugb-button-left{margin:10px 0;text-align:left}.wp-block-button .wp-ugb-button.ugb-ghost-button,.wp-block-ugb-ghost-button .wp-ugb-button.ugb-ghost-button{background-color:transparent;border:2px solid #2091e1;color:#2091e1}.wp-block-button .wp-ugb-button.ugb-ghost-button:hover,.wp-block-ugb-ghost-button .wp-ugb-button.ugb-ghost-button:hover{opacity:.85;-webkit-box-shadow:none !important;box-shadow:none !important;color:#2091e1}
5
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-block-ugb-notification{position:relative}.wp-ugb-notif{border-radius:4px;padding:1.3em 1.5em;color:#ffffff}.notif-success{background-color:#40ba7b}.notif-error{background-color:#d9534f}.notif-warning{background-color:#ffdd57;color:#424242}.notif-info{background-color:#2091e1}.ugb-notification,.wp-block-ugb-notification{position:relative}.ugb-notification .close-button,.wp-block-ugb-notification .close-button{position:absolute;right:0;z-index:2;margin-right:1.5rem;margin-top:1.3rem;font-size:8px;padding-top:.3rem;cursor:pointer}.ugb-notification .close-button svg,.wp-block-ugb-notification .close-button svg{width:13px;height:auto}.ugb-notification.dismissible-true .wp-ugb-notif{padding-right:4rem}.ugb-notification.type-success svg,.ugb-notification.type-error svg,.ugb-notification.type-info svg{fill:#ffffff}.ugb-notification.type-warning svg{fill:#424242}.ugb-notification.dismissible-true[data-uid]{display:none}
6
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-blockquote{border:0;border-left:8px solid #2091e1;padding:1rem 2rem;margin:1rem 2rem;opacity:.5;font-style:italic;text-align:inherit;background:transparent}.ugb-blockquote p{margin:0}.ugb-blockquote:after,.ugb-blockquote:before,.ugb-blockquote p:after,.ugb-blockquote p:before{display:none}
7
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}blockquote.ugb-pullquote{border-top:8px solid #2091e1;border-bottom:8px solid #2091e1;border-left:none !important;border-right:none !important;text-align:center;padding:2rem;margin:1rem 0;opacity:.5;color:#2091e1;font-size:1.5em;font-style:normal}blockquote.ugb-pullquote p{margin:0;text-align:center}blockquote.ugb-pullquote:after,blockquote.ugb-pullquote:before,blockquote.ugb-pullquote p:after,blockquote.ugb-pullquote p:before{display:none}
8
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}div.ugb-cta{text-align:center;padding:4rem 2rem;background-color:#f4f4f4}div.ugb-cta .ugb-cta-title{margin:0 0 1rem !important}div.ugb-cta .ugb-cta-bodyText{opacity:.5;margin:0 0 1.5rem}div.ugb-cta .ugb-cta-button{margin:0}div.ugb-cta .blocks-button__inline-link{margin:0 auto}div.ugb-cta p{text-align:center}.wp-block-ugb-button .wp-ugb-button:hover{color:white}
9
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-testimonial{display:-ms-flexbox;display:flex}.ugb-testimonial .testimonial-image{height:75px;width:75px;background-size:cover;background-position:center;border-radius:100%;margin:0 auto 1.3rem}.ugb-testimonial .quote-icon{height:75px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-testimonial .quote-icon svg{height:50px;width:auto;fill:#e6e6e6}.ugb-testimonial>div{text-align:center;padding:1rem 0;margin:0 auto}.ugb-testimonial>div p{text-align:center}.ugb-testimonial h4{margin:0 0 .5rem !important}.ugb-testimonial .ugb-testimonial-position,.ugb-testimonial .ugb-testimonial-position-two,.ugb-testimonial .ugb-testimonial-position-three{opacity:.3;font-size:.75em;margin:0 0 1rem;text-transform:uppercase}.ugb-testimonial .ugb-testimonial-body,.ugb-testimonial .ugb-testimonial-body-two,.ugb-testimonial .ugb-testimonial-body-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-testimonial.column-1 .ugb-testimonial-column-two,.ugb-testimonial.column-1 .ugb-testimonial-column-three{display:none}.ugb-testimonial.column-2 .ugb-testimonial-column-one{margin-right:1rem}.ugb-testimonial.column-2 .ugb-testimonial-column-two{margin-left:1rem}.ugb-testimonial.column-2>div{width:50%}.ugb-testimonial.column-2 .ugb-testimonial-column-three{display:none}.ugb-testimonial.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-testimonial.column-3>div:first-child{margin-left:0}.ugb-testimonial.column-3>div:last-child{margin-right:0}@media screen and (max-width: 800px){.ugb-testimonial.column-3.column-3{display:block}.ugb-testimonial.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-testimonial.column-2.column-2{display:block}.ugb-testimonial.column-2.column-2>div{width:100%;margin:0}}
10
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-team-member .team-member-image{width:300px;height:300px;background-size:cover;background-position:center;margin:0 auto 1.3rem}.ugb-team-member.image-circle .team-member-image{border-radius:100%}.ugb-team-member.column-2 .team-member-image{width:220px;height:220px}.ugb-team-member.column-3 .team-member-image{width:150px;height:150px}.ugb-team-member>div{text-align:center;padding:1rem 0}.ugb-team-member>div p{text-align:center}.ugb-team-member h4{margin:0 0 .5rem !important}.ugb-team-member .ugb-team-member-position{margin:0 0 1rem}.ugb-team-member .ugb-team-member-position{opacity:.3;font-size:.75em;text-transform:uppercase}.ugb-team-member .ugb-team-member-des,.ugb-team-member .ugb-team-member-des-two,.ugb-team-member .ugb-team-member-des-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-team-member.column-1 .ugb-team-member-column-two,.ugb-team-member.column-1 .ugb-team-member-column-three{display:none}.ugb-team-member.column-2{display:-ms-flexbox;display:flex}.ugb-team-member.column-2 .ugb-team-member-column-one{padding-right:1rem}.ugb-team-member.column-2 .ugb-team-member-column-two{padding-left:1rem}.ugb-team-member.column-2 .ugb-team-member-column-one,.ugb-team-member.column-2 .ugb-team-member-column-two{width:50%}.ugb-team-member.column-2 .ugb-team-member-column-three{display:none}.ugb-team-member.column-2 .team-member-image img{height:200px;width:250px}.ugb-team-member.column-3{display:-ms-flexbox;display:flex}.ugb-team-member.column-3 .ugb-team-member-column-one,.ugb-team-member.column-3 .ugb-team-member-column-two,.ugb-team-member.column-3 .ugb-team-member-column-three{width:33.33%}.ugb-team-member.column-3 .ugb-team-member-column-one{padding-right:1rem}.ugb-team-member.column-3 .ugb-team-member-column-two{padding-left:1rem;padding-right:1rem}.ugb-team-member.column-3 .ugb-team-member-column-three{padding-left:1rem}.ugb-team-member.column-3 .team-member-image img{height:200px;width:200px}.team-member-social a{color:#000000;opacity:.30;padding:0 3px}
11
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.wp-block-ugb-expand p:last-child{margin-bottom:0}.wp-block-ugb-expand.ugb-more .ugb-expand-less-text,.wp-block-ugb-expand.ugb-more .ugb-expand-more{display:none}.wp-block-ugb-expand.ugb-more .ugb-expand-more-text,.wp-block-ugb-expand.ugb-more .ugb-expand-less{display:inline !important}
12
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-number-box{display:-ms-flexbox;display:flex;margin:1rem 0}.ugb-number-box span,.ugb-number-box .blocks-rich-text span{background-color:#ddd;border-radius:100%;font-size:3em;display:block;padding:0;text-align:center;overflow:hidden;margin:0 auto;height:2.5em;width:2.5em;line-height:2.5em}.ugb-number-box>div{text-align:center;margin:0 auto}.ugb-number-box>div p{text-align:center}.ugb-number-box .ugb-number-box-name,.ugb-number-box .ugb-number-box-name-two,.ugb-number-box .ugb-number-box-name-three{margin:1.3rem 0 1rem}.ugb-number-box .ugb-number-box-body,.ugb-number-box .ugb-number-box-body-two,.ugb-number-box .ugb-number-box-body-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-number-box.column-1 .ugb-number-box-column-two,.ugb-number-box.column-1 .ugb-number-box-column-three{display:none}.ugb-number-box.column-2 .ugb-number-box-column-one{margin-right:1rem}.ugb-number-box.column-2 .ugb-number-box-column-two{margin-left:1rem}.ugb-number-box.column-2>div{width:50%}.ugb-number-box.column-2 .ugb-number-box-column-three{display:none}.ugb-number-box.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-number-box.column-3>div:first-child{margin-left:0}.ugb-number-box.column-3>div:last-child{margin-right:0}@media screen and (max-width: 800px){.ugb-number-box.column-3.column-3{display:block}.ugb-number-box.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-number-box.column-2.column-2{display:block}.ugb-number-box.column-2.column-2>div{width:100%;margin:0}}
13
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-pricing-box{display:-ms-flexbox;display:flex;margin-top:2rem;margin-bottom:2rem}.ugb-pricing-box>div{text-align:center;margin:0 auto}.ugb-pricing-box>div p{text-align:center;padding-bottom:0}.ugb-pricing-box h3{margin:0 0 2rem !important;line-height:100% !important}.ugb-pricing-box .ugb-pricing-box-pricing{font-size:3.5em;margin:0 0 .5rem;line-height:100% !important}.ugb-pricing-box .ugb-pricing-box-per-month-label{font-size:.75em;opacity:.3;margin:0 0 2rem;text-transform:uppercase;line-height:100% !important}.ugb-pricing-box .wp-ugb-button{margin-bottom:2rem}.ugb-pricing-box .ugb-pricing-box-feature-list{opacity:.5;font-size:1em;line-height:1.8em !important;width:40%;margin:0 auto}.blocks-button__inline-link.pricing-box{margin:5px auto 0px auto}.ugb-pricing-box.column-1 .ugb-pricing-box-column-two,.ugb-pricing-box.column-1 .ugb-pricing-box-column-three{display:none}.ugb-pricing-box.column-2 .ugb-pricing-box-feature-list{width:85%;margin:0 auto}.ugb-pricing-box.column-2 .ugb-pricing-box-column-one{margin-right:2rem}.ugb-pricing-box.column-2 .ugb-pricing-box-column-two{border-left:1px solid #eee;margin-left:0;padding-left:2rem}.ugb-pricing-box.column-2>div{width:50%}.ugb-pricing-box.column-2 .ugb-pricing-box-column-three{display:none}.ugb-pricing-box.column-2 .blocks-button__inline-link{width:225px}.ugb-pricing-box.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-pricing-box.column-3>div:first-child{margin-left:0}.ugb-pricing-box.column-3>div:last-child{margin-right:0}.ugb-pricing-box.column-3 .ugb-pricing-box-column-two{border-left:1px solid #eee;border-right:1px solid #eee;margin-left:0;margin-right:0;padding-left:1rem;padding-right:1rem}.ugb-pricing-box.column-3 .ugb-pricing-box-feature-list{width:100%}.ugb-pricing-box.column-3 .blocks-button__inline-link{width:181px}.ugb-pricing-box.column-3 .blocks-button__inline-link .blocks-url-input{width:50%}@media screen and (max-width: 800px){.ugb-pricing-box.column-3.column-3{display:block}.ugb-pricing-box.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-pricing-box.column-2.column-2{display:block}.ugb-pricing-box.column-2.column-2>div{width:100%;margin:0}}
14
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-header.has-image{padding:0}.ugb-header.has-image .ugb-header-section{padding:9.5rem 4rem;background-size:cover;background-repeat:no-repeat;background-position:center}.ugb-header{text-align:center;padding:9.5rem 4rem;position:relative}.ugb-header .ugb-header-overlay{position:absolute;top:0;left:0;right:0;bottom:0}.ugb-header .header-image{height:400px;width:600px;background-size:cover;background-repeat:no-repeat;background-position:center}.ugb-header .wp-block-button.ugb-button-center{left:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);margin-bottom:1.5em}.ugb-header .wp-block-button.ugb-button-right{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);left:50%;margin-bottom:1.5em}.ugb-header .wp-block-button.ugb-button-left{-webkit-transform:translateX(50%);-ms-transform:translateX(50%);transform:translateX(50%);left:-50%;margin-bottom:1.5em}.ugb-header .ugb-header-title{margin-bottom:1rem;padding-bottom:0;margin-top:0;position:relative}.ugb-header .ugb-header-subtitle{margin-bottom:2rem;padding-bottom:0;position:relative}.ugb-header button.components-button{margin-bottom:.5em;position:relative}.ugb-header .wp-ugb-button{position:relative}.ugb-header-overlay.overlay-opacity.overlay-opacity-1{opacity:.1}.ugb-header-overlay.overlay-opacity.overlay-opacity-2{opacity:.2}.ugb-header-overlay.overlay-opacity.overlay-opacity-3{opacity:.3}.ugb-header-overlay.overlay-opacity.overlay-opacity-4{opacity:.4}.ugb-header-overlay.overlay-opacity.overlay-opacity-5{opacity:.5}.ugb-header-overlay.overlay-opacity.overlay-opacity-6{opacity:.6}.ugb-header-overlay.overlay-opacity.overlay-opacity-7{opacity:.7}.ugb-header-overlay.overlay-opacity.overlay-opacity-8{opacity:.8}.ugb-header-overlay.overlay-opacity.overlay-opacity-9{opacity:.9}.ugb-header-overlay.overlay-opacity.overlay-opacity-10{opacity:1}.wp-block-ugb-header.has-no-content{display:none}
15
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-image-box{background-size:cover;background-position:center;padding:2rem;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;margin:0 auto;position:relative;background-color:#999}.ugb-image-box *{-webkit-transition:all .4s ease-in-out !important;-o-transition:all .4s ease-in-out !important;transition:all .4s ease-in-out !important;border:0 !important;-webkit-box-shadow:none !important;box-shadow:none !important}.ugb-image-box button.components-button{z-index:3;margin-bottom:1em}.ugb-image-box a{position:absolute;z-index:2;top:0;left:0;right:0;bottom:0;opacity:0;pointer-events:none}.ugb-image-box h4,.ugb-image-box p{z-index:3}.ugb-image-box h4{margin:0 0 0.5em !important}.ugb-image-box p{margin:0 !important;opacity:0;-webkit-transform:translateY(-15px);-ms-transform:translateY(-15px);transform:translateY(-15px)}.ugb-image-box:hover a{opacity:.7}.ugb-image-box:hover p{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ugb-image-box.full-width{width:100% !important}.wp-block-ugb-image-box.has-no-content{display:none}
16
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-countup{text-align:center;margin-bottom:1em}.ugb-countup h4,.ugb-countup div,.ugb-countup p{margin:0 !important;line-height:1em}.ugb-countup h4{margin-bottom:1em !important}.ugb-countup p{margin-top:1em !important}.ugb-countup .ugb-countup-hide{visibility:hidden}
17
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.video-popup-image{height:220px;width:220px;background-position:center;background-size:cover;margin-bottom:10px}.ugb-video-popup{position:relative;margin:0 auto;width:100%;max-width:600px}.ugb-video-popup .ugb-video-preview,.ugb-video-popup a,.ugb-video-popup .ugb-video-overlay,.ugb-video-popup .ugb-play-button{position:absolute;top:0;left:0;right:0;bottom:0}.ugb-video-popup .ugb-video-preview{background-size:cover;background-position:center;opacity:.4;-webkit-transition:all .3s ease-in-out;-o-transition:all .3s ease-in-out;transition:all .3s ease-in-out;z-index:1}.ugb-video-popup:hover .ugb-video-preview{opacity:.5}.ugb-video-popup .ugb-video-wrapper{position:relative;width:100%;padding-bottom:56.25%;border:0 !important;-webkit-box-shadow:none !important;box-shadow:none !important}.ugb-video-popup a,.ugb-video-popup .ugb-video-overlay{z-index:3;-webkit-box-shadow:none !important;box-shadow:none !important;background:transparent !important;display:block !important}.ugb-video-popup .ugb-play-button{z-index:2;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}.ugb-video-popup svg{fill:#fff !important}.ugb-video-popup button.components-button.button{position:absolute;z-index:4;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);top:30%}.ugb-video-popup button.components-button.button:active{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.ugb-video-popup-link.blocks-button__inline-link{margin:5px auto}.ugb-video-popup-link.blocks-button__inline-link>p{font-size:.8em;margin-left:30px}
18
- .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}.ugb-card{border-radius:4px;-webkit-box-shadow:0 0 5px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.1);margin:30px 0;padding-bottom:30px}.ugb-card:not(.has-image){padding-top:30px}.ugb-card.has-image .ugb-card-image-container{height:300px;width:100%;margin:0 auto 20px;background-size:cover;background-position:center;border-top-right-radius:4px;border-top-left-radius:4px;padding-top:0px}.ugb-card>*:first-child{margin-top:0 !important}.ugb-card>*:last-child{margin-bottom:0 !important}.ugb-card>h4,.ugb-card>*{margin:0 30px .5rem !important}.ugb-card .wp-ugb-button{margin-top:1rem !important}.ugb-card .ugb-card-image-container{margin:0 0 20px !important}.ugb-card .ugb-tagline{opacity:.7}.ugb-card .wp-block-button.ugb-button-center{margin-left:0 !important;margin-right:0 !important}.ugb-card .wp-block-button.ugb-button-right{-webkit-transform:translateX(-100%) translateX(-60px);-ms-transform:translateX(-100%) translateX(-60px);transform:translateX(-100%) translateX(-60px)}
1
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}
2
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-block-ugb-divider{border:0;height:1px;width:100%;background-color:transparent;margin-top:2rem;margin-bottom:2rem}.wp-block-ugb-divider hr{background-color:#dddddd;border:0 !important;padding:0 !important}
3
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-block-button.ugb-button-center{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);left:50%;position:relative}span.wp-block-button.ugb-button-right,form.blocks-button__inline-link.ugb-button-right{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%);left:100%;position:relative}form.blocks-button__inline-link.ugb-button-center{margin:0 auto}.wp-ugb-button.wp-ugb-button{border:none;border-radius:4px;-webkit-box-shadow:none !important;box-shadow:none !important;cursor:pointer;display:inline-block;line-height:1em !important;margin:0;text-decoration:none !important;white-space:nowrap;display:inline-block;opacity:1;background:#2091e1;color:#fff;padding:0.75em 1em;-webkit-transition:opacity .2s ease-in-out;-o-transition:opacity .2s ease-in-out;transition:opacity .2s ease-in-out;box-shadow:none !important}.wp-ugb-button.wp-ugb-button:hover{opacity:.85;-webkit-box-shadow:none !important;box-shadow:none !important;border:0}.wp-block-ugb-button .wp-ugb-button:hover{color:white}.wp-block-ugb-button.ugb-button-right{margin:10px 0;text-align:right}.wp-block-ugb-button.ugb-button-center{margin:10px 0;text-align:center}.wp-block-ugb-button.ugb-button-left{margin:10px 0;text-align:left}.ugb-button-small{font-size:.75em}.ugb-button-normal{font-size:1em}.ugb-button-medium{font-size:1.25em}.ugb-button-large{font-size:1.5em}
4
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-block-ugb-ghost-button.ugb-button-right{margin:10px 0;text-align:right}.wp-block-ugb-ghost-button.ugb-button-center{margin:10px 0;text-align:center}.wp-block-ugb-ghost-button.ugb-button-left{margin:10px 0;text-align:left}.wp-block-button .wp-ugb-button.ugb-ghost-button,.wp-block-ugb-ghost-button .wp-ugb-button.ugb-ghost-button{background-color:transparent;border:2px solid #2091e1;color:#2091e1}.wp-block-button .wp-ugb-button.ugb-ghost-button:hover,.wp-block-ugb-ghost-button .wp-ugb-button.ugb-ghost-button:hover{opacity:.85;-webkit-box-shadow:none !important;box-shadow:none !important;color:#2091e1}
5
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-block-ugb-notification{position:relative}.wp-ugb-notif{border-radius:4px;padding:1.3em 1.5em;color:#ffffff}.notif-success{background-color:#40ba7b}.notif-error{background-color:#d9534f}.notif-warning{background-color:#ffdd57;color:#424242}.notif-info{background-color:#2091e1}.ugb-notification,.wp-block-ugb-notification{position:relative}.ugb-notification .close-button,.wp-block-ugb-notification .close-button{position:absolute;right:0;z-index:2;margin-right:1.5rem;margin-top:1.3rem;font-size:8px;padding-top:.3rem;cursor:pointer}.ugb-notification .close-button svg,.wp-block-ugb-notification .close-button svg{width:13px;height:auto}.ugb-notification.dismissible-true .wp-ugb-notif{padding-right:4rem}.ugb-notification.type-success svg,.ugb-notification.type-error svg,.ugb-notification.type-info svg{fill:#ffffff}.ugb-notification.type-warning svg{fill:#424242}.ugb-notification.dismissible-true[data-uid]{display:none}
6
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-blockquote{border:0;border-left:8px solid #2091e1;padding:1rem 2rem;margin:1rem 2rem;opacity:.5;font-style:italic;text-align:inherit;background:transparent}.ugb-blockquote p{margin:0}.ugb-blockquote:after,.ugb-blockquote:before,.ugb-blockquote p:after,.ugb-blockquote p:before{display:none}
7
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}blockquote.ugb-pullquote{border-top:8px solid #2091e1;border-bottom:8px solid #2091e1;border-left:none !important;border-right:none !important;text-align:center;padding:2rem;margin:1rem 0;opacity:.5;color:#2091e1;font-size:1.5em;font-style:normal}blockquote.ugb-pullquote p{margin:0;text-align:center}blockquote.ugb-pullquote:after,blockquote.ugb-pullquote:before,blockquote.ugb-pullquote p:after,blockquote.ugb-pullquote p:before{display:none}
8
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}div.ugb-cta{text-align:center;padding:4rem 2rem;background-color:#f4f4f4}div.ugb-cta .ugb-cta-title{margin:0 0 1rem !important}div.ugb-cta .ugb-cta-bodyText{opacity:.5;margin:0 0 1.5rem}div.ugb-cta .ugb-cta-button{margin:0}div.ugb-cta .blocks-button__inline-link{margin:0 auto}div.ugb-cta p{text-align:center}.wp-block-ugb-button .wp-ugb-button:hover{color:white}
9
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-testimonial{display:-ms-flexbox;display:flex}.ugb-testimonial .testimonial-image{height:75px;width:75px;background-size:cover;background-position:center;border-radius:100%;margin:0 auto 1.3rem}.ugb-testimonial .quote-icon{height:75px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-testimonial .quote-icon svg{height:50px;width:auto;fill:#e6e6e6}.ugb-testimonial>div{text-align:center;padding:1rem 0;margin:0 auto}.ugb-testimonial>div p{text-align:center}.ugb-testimonial h4{margin:0 0 .5rem !important}.ugb-testimonial .ugb-testimonial-position,.ugb-testimonial .ugb-testimonial-position-two,.ugb-testimonial .ugb-testimonial-position-three{opacity:.3;font-size:.75em;margin:0 0 1rem;text-transform:uppercase}.ugb-testimonial .ugb-testimonial-body,.ugb-testimonial .ugb-testimonial-body-two,.ugb-testimonial .ugb-testimonial-body-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-testimonial.column-1 .ugb-testimonial-column-two,.ugb-testimonial.column-1 .ugb-testimonial-column-three{display:none}.ugb-testimonial.column-2 .ugb-testimonial-column-one{margin-right:1rem}.ugb-testimonial.column-2 .ugb-testimonial-column-two{margin-left:1rem}.ugb-testimonial.column-2>div{width:50%}.ugb-testimonial.column-2 .ugb-testimonial-column-three{display:none}.ugb-testimonial.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-testimonial.column-3>div:first-child{margin-left:0}.ugb-testimonial.column-3>div:last-child{margin-right:0}@media screen and (max-width: 800px){.ugb-testimonial.column-3.column-3{display:block}.ugb-testimonial.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-testimonial.column-2.column-2{display:block}.ugb-testimonial.column-2.column-2>div{width:100%;margin:0}}
10
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-team-member .team-member-image{width:300px;height:300px;background-size:cover;background-position:center;margin:0 auto 1.3rem}.ugb-team-member.image-circle .team-member-image{border-radius:100%}.ugb-team-member.column-2 .team-member-image{width:220px;height:220px}.ugb-team-member.column-3 .team-member-image{width:150px;height:150px}.ugb-team-member>div{text-align:center;padding:1rem 0}.ugb-team-member>div p{text-align:center}.ugb-team-member h4{margin:0 0 .5rem !important}.ugb-team-member .ugb-team-member-position{margin:0 0 1rem}.ugb-team-member .ugb-team-member-position{opacity:.3;font-size:.75em;text-transform:uppercase}.ugb-team-member .ugb-team-member-des,.ugb-team-member .ugb-team-member-des-two,.ugb-team-member .ugb-team-member-des-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-team-member.column-1 .ugb-team-member-column-two,.ugb-team-member.column-1 .ugb-team-member-column-three{display:none}.ugb-team-member.column-2{display:-ms-flexbox;display:flex}.ugb-team-member.column-2 .ugb-team-member-column-one{padding-right:1rem}.ugb-team-member.column-2 .ugb-team-member-column-two{padding-left:1rem}.ugb-team-member.column-2 .ugb-team-member-column-one,.ugb-team-member.column-2 .ugb-team-member-column-two{width:50%}.ugb-team-member.column-2 .ugb-team-member-column-three{display:none}.ugb-team-member.column-2 .team-member-image img{height:200px;width:250px}.ugb-team-member.column-3{display:-ms-flexbox;display:flex}.ugb-team-member.column-3 .ugb-team-member-column-one,.ugb-team-member.column-3 .ugb-team-member-column-two,.ugb-team-member.column-3 .ugb-team-member-column-three{width:33.33%}.ugb-team-member.column-3 .ugb-team-member-column-one{padding-right:1rem}.ugb-team-member.column-3 .ugb-team-member-column-two{padding-left:1rem;padding-right:1rem}.ugb-team-member.column-3 .ugb-team-member-column-three{padding-left:1rem}.ugb-team-member.column-3 .team-member-image img{height:200px;width:200px}.team-member-social a{color:#000000;opacity:.30;padding:0 3px}
11
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.wp-block-ugb-expand p:last-child{margin-bottom:0}.wp-block-ugb-expand.ugb-more .ugb-expand-less-text,.wp-block-ugb-expand.ugb-more .ugb-expand-more{display:none}.wp-block-ugb-expand.ugb-more .ugb-expand-more-text,.wp-block-ugb-expand.ugb-more .ugb-expand-less{display:inline !important}
12
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-number-box{display:-ms-flexbox;display:flex;margin:1rem 0}.ugb-number-box span,.ugb-number-box .blocks-rich-text span{background-color:#ddd;border-radius:100%;font-size:3em;display:block;padding:0;text-align:center;overflow:hidden;margin:0 auto;height:2.5em;width:2.5em;line-height:2.5em !important}.ugb-number-box>div{text-align:center;margin:0 auto}.ugb-number-box>div p{text-align:center}.ugb-number-box .ugb-number-box-name,.ugb-number-box .ugb-number-box-name-two,.ugb-number-box .ugb-number-box-name-three{margin:1.3rem 0 1rem}.ugb-number-box .ugb-number-box-body,.ugb-number-box .ugb-number-box-body-two,.ugb-number-box .ugb-number-box-body-three{opacity:.5;margin:0 0 1rem;left:0}.ugb-number-box.column-1 .ugb-number-box-column-two,.ugb-number-box.column-1 .ugb-number-box-column-three{display:none}.ugb-number-box.column-2 .ugb-number-box-column-one{margin-right:1rem}.ugb-number-box.column-2 .ugb-number-box-column-two{margin-left:1rem}.ugb-number-box.column-2>div{width:50%}.ugb-number-box.column-2 .ugb-number-box-column-three{display:none}.ugb-number-box.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-number-box.column-3>div:first-child{margin-left:0}.ugb-number-box.column-3>div:last-child{margin-right:0}@media screen and (max-width: 800px){.ugb-number-box.column-3.column-3{display:block}.ugb-number-box.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-number-box.column-2.column-2{display:block}.ugb-number-box.column-2.column-2>div{width:100%;margin:0}}
13
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-pricing-box{display:-ms-flexbox;display:flex;margin-top:2rem;margin-bottom:2rem}.ugb-pricing-box>div{text-align:center;margin:0 auto}.ugb-pricing-box>div p{text-align:center;padding-bottom:0}.ugb-pricing-box h3{margin:0 0 2rem !important;line-height:100% !important}.ugb-pricing-box .ugb-pricing-box-pricing{font-size:3.5em;margin:0 0 .5rem;line-height:100% !important}.ugb-pricing-box .ugb-pricing-box-per-month-label{font-size:.75em;opacity:.3;margin:0 0 2rem;text-transform:uppercase;line-height:100% !important}.ugb-pricing-box .wp-ugb-button{margin-bottom:2rem}.ugb-pricing-box .ugb-pricing-box-feature-list{opacity:.5;font-size:1em;line-height:1.8em !important;width:40%;margin:0 auto}.blocks-button__inline-link.pricing-box{margin:5px auto 0px auto}.ugb-pricing-box.column-1 .ugb-pricing-box-column-two,.ugb-pricing-box.column-1 .ugb-pricing-box-column-three{display:none}.ugb-pricing-box.column-2 .ugb-pricing-box-feature-list{width:85%;margin:0 auto}.ugb-pricing-box.column-2 .ugb-pricing-box-column-one{margin-right:2rem}.ugb-pricing-box.column-2 .ugb-pricing-box-column-two{border-left:1px solid #eee;margin-left:0;padding-left:2rem}.ugb-pricing-box.column-2>div{width:50%}.ugb-pricing-box.column-2 .ugb-pricing-box-column-three{display:none}.ugb-pricing-box.column-2 .blocks-button__inline-link{width:225px}.ugb-pricing-box.column-3>div{width:33.2%;margin-left:1rem;margin-right:1rem}.ugb-pricing-box.column-3>div:first-child{margin-left:0}.ugb-pricing-box.column-3>div:last-child{margin-right:0}.ugb-pricing-box.column-3 .ugb-pricing-box-column-two{border-left:1px solid #eee;border-right:1px solid #eee;margin-left:0;margin-right:0;padding-left:1rem;padding-right:1rem}.ugb-pricing-box.column-3 .ugb-pricing-box-feature-list{width:100%}.ugb-pricing-box.column-3 .blocks-button__inline-link{width:181px}.ugb-pricing-box.column-3 .blocks-button__inline-link .blocks-url-input{width:50%}@media screen and (max-width: 800px){.ugb-pricing-box.column-3.column-3{display:block}.ugb-pricing-box.column-3.column-3>div{width:100%;margin:0}}@media screen and (max-width: 600px){.ugb-pricing-box.column-2.column-2{display:block}.ugb-pricing-box.column-2.column-2>div{width:100%;margin:0}}
14
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-header.has-image{padding:0}.ugb-header.has-image .ugb-header-section{padding:9.5rem 4rem;background-size:cover;background-repeat:no-repeat;background-position:center}.ugb-header{text-align:center;padding:9.5rem 4rem;position:relative}.ugb-header .ugb-header-overlay{position:absolute;top:0;left:0;right:0;bottom:0}.ugb-header .header-image{height:400px;width:600px;background-size:cover;background-repeat:no-repeat;background-position:center}.ugb-header .wp-block-button.ugb-button-center{left:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);margin-bottom:1.5em}.ugb-header .wp-block-button.ugb-button-right{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);left:50%;margin-bottom:1.5em}.ugb-header .wp-block-button.ugb-button-left{-webkit-transform:translateX(50%);-ms-transform:translateX(50%);transform:translateX(50%);left:-50%;margin-bottom:1.5em}.ugb-header .ugb-header-title{margin-bottom:1rem;padding-bottom:0;margin-top:0;position:relative}.ugb-header .ugb-header-subtitle{margin-bottom:2rem;padding-bottom:0;position:relative}.ugb-header button.components-button{margin-bottom:.5em;position:relative}.ugb-header .wp-ugb-button{position:relative}.ugb-header-overlay.overlay-opacity.overlay-opacity-1{opacity:.1}.ugb-header-overlay.overlay-opacity.overlay-opacity-2{opacity:.2}.ugb-header-overlay.overlay-opacity.overlay-opacity-3{opacity:.3}.ugb-header-overlay.overlay-opacity.overlay-opacity-4{opacity:.4}.ugb-header-overlay.overlay-opacity.overlay-opacity-5{opacity:.5}.ugb-header-overlay.overlay-opacity.overlay-opacity-6{opacity:.6}.ugb-header-overlay.overlay-opacity.overlay-opacity-7{opacity:.7}.ugb-header-overlay.overlay-opacity.overlay-opacity-8{opacity:.8}.ugb-header-overlay.overlay-opacity.overlay-opacity-9{opacity:.9}.ugb-header-overlay.overlay-opacity.overlay-opacity-10{opacity:1}.wp-block-ugb-header.has-no-content{display:none}
15
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-image-box{background-size:cover;background-position:center;padding:2rem;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;margin:0 auto;position:relative;background-color:#999}.ugb-image-box *{-webkit-transition:all .4s ease-in-out !important;-o-transition:all .4s ease-in-out !important;transition:all .4s ease-in-out !important;border:0 !important;-webkit-box-shadow:none !important;box-shadow:none !important}.ugb-image-box button.components-button{z-index:3;margin-bottom:1em}.ugb-image-box a{position:absolute;z-index:2;top:0;left:0;right:0;bottom:0;opacity:0;pointer-events:none}.ugb-image-box h4,.ugb-image-box p{z-index:3}.ugb-image-box h4{margin:0 0 0.5em !important}.ugb-image-box p{margin:0 !important;opacity:0;-webkit-transform:translateY(-15px);-ms-transform:translateY(-15px);transform:translateY(-15px)}.ugb-image-box:hover a{opacity:.7}.ugb-image-box:hover p{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ugb-image-box.full-width{width:100% !important}.wp-block-ugb-image-box.has-no-content{display:none}
16
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-countup{text-align:center;margin-bottom:1em}.ugb-countup h4,.ugb-countup div,.ugb-countup p{margin:0 !important;line-height:1em}.ugb-countup h4{margin-bottom:1em !important}.ugb-countup p{margin-top:1em !important}.ugb-countup .ugb-countup-hide{visibility:hidden}
17
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.video-popup-image{height:220px;width:220px;background-position:center;background-size:cover;margin-bottom:10px}.ugb-video-popup{position:relative;margin:0 auto;width:100%;max-width:600px}.ugb-video-popup .ugb-video-preview,.ugb-video-popup a,.ugb-video-popup .ugb-video-overlay,.ugb-video-popup .ugb-play-button{position:absolute;top:0;left:0;right:0;bottom:0}.ugb-video-popup .ugb-video-preview{background-size:cover;background-position:center;opacity:.4;-webkit-transition:all .3s ease-in-out;-o-transition:all .3s ease-in-out;transition:all .3s ease-in-out;z-index:1}.ugb-video-popup:hover .ugb-video-preview{opacity:.5}.ugb-video-popup .ugb-video-wrapper{position:relative;width:100%;padding-bottom:56.25%;border:0 !important;-webkit-box-shadow:none !important;box-shadow:none !important}.ugb-video-popup a,.ugb-video-popup .ugb-video-overlay{z-index:3;-webkit-box-shadow:none !important;box-shadow:none !important;background:transparent !important;display:block !important}.ugb-video-popup .ugb-play-button{z-index:2;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column}.ugb-video-popup svg{fill:#fff !important}.ugb-video-popup button.components-button.button{position:absolute;z-index:4;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);top:30%}.ugb-video-popup button.components-button.button:active{-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}
18
+ .gutenberg .ugb-editor-label{font-size:12px;text-transform:uppercase;font-weight:600;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;color:#8e979e;padding:2em 0 0;background:#fff;border:none;-webkit-box-shadow:none;box-shadow:none;white-space:nowrap;display:block}.gutenberg .ugb-editor-label:first-child{padding-top:0}[class*="ugb-"] form[class*="-link"],form[class*="ugb-"][class*="-link"],[class*="ugb-"]+form[class*="-link"]{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.ugb-card{border-radius:4px;-webkit-box-shadow:0 0 5px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.1);margin:30px 0;padding-bottom:30px}.ugb-card:not(.has-image){padding-top:30px}.ugb-card.has-image .ugb-card-image-container{height:300px;width:100%;margin:0 auto 20px;background-size:cover;background-position:center;border-top-right-radius:4px;border-top-left-radius:4px;padding-top:0px}.ugb-card>*:first-child{margin-top:0 !important}.ugb-card>*:last-child{margin-bottom:0 !important}.ugb-card>h4,.ugb-card>*{margin:0 30px .5rem !important}.ugb-card .wp-ugb-button{margin-top:1rem !important}.ugb-card .ugb-card-image-container{margin:0 0 20px !important}.ugb-card .ugb-tagline{opacity:.7}.ugb-card .wp-block-button.ugb-button-center{margin-left:0 !important;margin-right:0 !important}.ugb-card .wp-block-button.ugb-button-right{-webkit-transform:translateX(-100%) translateX(-60px);-ms-transform:translateX(-100%) translateX(-60px);transform:translateX(-100%) translateX(-60px)}
freemius/assets/css/admin/account.css CHANGED
@@ -1 +1 @@
1
- #fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .button i.dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
1
+ #fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:grey;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
freemius/assets/css/admin/affiliation.css CHANGED
@@ -1 +1 @@
1
- @charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
1
+ @charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
freemius/assets/css/admin/connect.css CHANGED
@@ -1 +1 @@
1
- #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
1
+ #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect.require-license-key #sites_list_container td{cursor:pointer}#fs_connect #delegate_to_site_admins{margin-right:15px;float:right;height:26px;vertical-align:middle;line-height:37px;font-weight:bold;border-bottom:1px dashed;text-decoration:none}#fs_connect #delegate_to_site_admins.rtl{margin-left:15px;margin-right:0}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}#multisite_options_container{margin-top:10px;border:1px solid #ccc;padding:5px}#multisite_options_container a{text-decoration:none}#multisite_options_container a:focus{box-shadow:none}#multisite_options_container a.selected{font-weight:bold}#multisite_options_container.apply-on-all-sites{border:0 none;padding:0}#multisite_options_container.apply-on-all-sites #all_sites_options{border-spacing:0}#multisite_options_container.apply-on-all-sites #all_sites_options td:not(:first-child){display:none}#multisite_options_container #sites_list_container{display:none;overflow:auto}#multisite_options_container #sites_list_container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:rgba(0,0,0,0.8);color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right}.fs-tooltip-trigger .fs-tooltip::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:rgba(0,0,0,0.8) transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl .fs-tooltip-trigger .fs-tooltip::after{right:21px;left:auto}.fs-tooltip-trigger:hover .fs-tooltip{visibility:visible;opacity:1}#fs_marketing_optin{display:none;margin-top:10px;border:1px solid #ccc;padding:10px;line-height:1.5em}#fs_marketing_optin .fs-message{display:block;margin-bottom:5px;font-size:1.05em;font-weight:600}#fs_marketing_optin.error{border:1px solid #d3135a;background:#fee}#fs_marketing_optin.error .fs-message{color:#d3135a}#fs_marketing_optin .fs-input-container{margin-top:5px}#fs_marketing_optin .fs-input-container label{margin-top:5px;display:block}#fs_marketing_optin .fs-input-container label input{float:left;margin:1px 0 0 0}#fs_marketing_optin .fs-input-container label:first-child{display:block;margin-bottom:2px}#fs_marketing_optin .fs-input-label{display:block;margin-left:20px}#fs_marketing_optin .fs-input-label .underlined{text-decoration:underline}.rtl #fs_marketing_optin .fs-input-container label input{float:right}.rtl #fs_marketing_optin .fs-input-label{margin-left:0;margin-right:20px}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
freemius/assets/css/admin/dialog-boxes.css CHANGED
@@ -1,2 +1,2 @@
1
- .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label{float:left}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-license-activation .fs-modal-body input.license_key{width:100%}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}
2
  .rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}
1
+ .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-header .fs-close .dashicons,.fs-modal .fs-modal-header .fs-close:hover .dashicons{text-decoration:none}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label{float:left}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-license-activation .fs-modal-body input.license_key{width:100%}#license_options_container table,#license_options_container table select,#license_options_container table #available_license_key{width:100%}#license_options_container table td:first-child{width:1%}#license_options_container table #other_license_key_container label{position:relative;top:6px;float:left;margin-right:5px}#license_options_container table #other_license_key_container div{overflow:hidden;width:auto;height:30px;display:block;top:2px;position:relative}#license_options_container table #other_license_key_container div input{margin:0}#sites_list_container td{cursor:pointer}#multisite_options_container{margin-top:10px;border:1px solid #ccc;padding:5px}#multisite_options_container a{text-decoration:none}#multisite_options_container a:focus{box-shadow:none}#multisite_options_container a.selected{font-weight:bold}#multisite_options_container.apply-on-all-sites{border:0 none;padding:0}#multisite_options_container.apply-on-all-sites #all_sites_options{border-spacing:0}#multisite_options_container.apply-on-all-sites #all_sites_options td:not(:first-child){display:none}#multisite_options_container #sites_list_container{display:none;overflow:auto}#multisite_options_container #sites_list_container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}
2
  .rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}
freemius/assets/css/admin/gdpr-optin-notice.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice[data-id^="gdpr_optin_actions"] .underlined{text-decoration:underline}.fs-notice[data-id^="gdpr_optin_actions"] ul .button,.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{vertical-align:middle}.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{display:inline-block;margin-left:3px}
freemius/assets/scss/_colors.scss CHANGED
@@ -63,3 +63,6 @@ $linkedin_color: #4875b4;
63
  $youtube_color: #ff3333;
64
  $gplus_color: #c63d2d;
65
 
 
 
 
63
  $youtube_color: #ff3333;
64
  $gplus_color: #c63d2d;
65
 
66
+ // Tooltip
67
+ $tooltip-color: #fff;
68
+ $tooltip-bkg-color: rgba(0,0,0,0.8);
freemius/assets/scss/admin/_gdpr-consent.scss ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #fs_marketing_optin
2
+ {
3
+ display: none;
4
+ margin-top: 10px;
5
+ border: 1px solid #ccc;
6
+ padding: 10px;
7
+ line-height: 1.5em;
8
+
9
+ .fs-message
10
+ {
11
+ display: block;
12
+ margin-bottom: 5px;
13
+ font-size: 1.05em;
14
+ font-weight: 600;
15
+ }
16
+
17
+ &.error
18
+ {
19
+ border: 1px solid $fs-logo-magenta-color;
20
+ background: #fee;
21
+
22
+ .fs-message
23
+ {
24
+ color: $fs-logo-magenta-color;
25
+ }
26
+ }
27
+
28
+ .fs-input-container
29
+ {
30
+ margin-top: 5px;
31
+
32
+ label
33
+ {
34
+ margin-top: 5px;
35
+ display: block;
36
+
37
+ input
38
+ {
39
+ float: left;
40
+ margin: 1px 0 0 0;
41
+ }
42
+
43
+ &:first-child
44
+ {
45
+ display: block;
46
+ margin-bottom: 2px;
47
+ }
48
+ }
49
+ }
50
+
51
+ .fs-input-label
52
+ {
53
+ display: block;
54
+ margin-left: 20px;
55
+
56
+ .underlined
57
+ {
58
+ text-decoration: underline;
59
+ }
60
+ }
61
+ }
62
+
63
+ .rtl
64
+ {
65
+ #fs_marketing_optin
66
+ {
67
+ .fs-input-container
68
+ {
69
+ label input
70
+ {
71
+ float: right;
72
+ }
73
+ }
74
+
75
+ .fs-input-label
76
+ {
77
+ margin-left: 0;
78
+ margin-right: 20px;
79
+ }
80
+ }
81
+ }
freemius/assets/scss/admin/_license-activation.scss CHANGED
@@ -4,4 +4,44 @@
4
  width: 100%;
5
  }
6
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
4
  width: 100%;
5
  }
6
  }
7
+ }
8
+
9
+ #license_options_container {
10
+ table {
11
+ &, select, #available_license_key {
12
+ width: 100%;
13
+ }
14
+
15
+ td:first-child {
16
+ width: 1%;
17
+ }
18
+
19
+ #other_license_key_container {
20
+ label {
21
+ position: relative;
22
+ top: 6px;
23
+ float: left;
24
+ margin-right: 5px;
25
+ }
26
+
27
+ div {
28
+ overflow: hidden;
29
+ width: auto;
30
+ height: 30px;
31
+ display: block;
32
+ top: 2px;
33
+ position: relative;
34
+
35
+ input {
36
+ margin: 0;
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ #sites_list_container {
44
+ td {
45
+ cursor: pointer;
46
+ }
47
  }
freemius/assets/scss/admin/_modal-common.scss CHANGED
@@ -118,6 +118,14 @@
118
  color: #fff;
119
  background: #aaa;
120
  }
 
 
 
 
 
 
 
 
121
  }
122
  }
123
 
118
  color: #fff;
119
  background: #aaa;
120
  }
121
+
122
+ &, &:hover
123
+ {
124
+ .dashicons
125
+ {
126
+ text-decoration: none;
127
+ }
128
+ }
129
  }
130
  }
131
 
freemius/assets/scss/admin/_multisite-options.scss ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #multisite_options_container {
2
+ margin-top: 10px;
3
+ border: 1px solid #ccc;
4
+ padding: 5px;
5
+
6
+ a {
7
+ text-decoration: none;
8
+
9
+ &:focus {
10
+ box-shadow: none;
11
+ }
12
+
13
+ &.selected {
14
+ font-weight: bold;
15
+ }
16
+ }
17
+
18
+ &.apply-on-all-sites {
19
+ border: 0 none;
20
+ padding: 0;
21
+
22
+ #all_sites_options {
23
+ border-spacing: 0;
24
+
25
+ td:not(:first-child) {
26
+ display: none;
27
+ }
28
+ }
29
+ }
30
+
31
+ #sites_list_container {
32
+ display: none;
33
+ overflow: auto;
34
+
35
+ table td {
36
+ border-top: 1px solid #ccc;
37
+ padding: 4px 2px;
38
+ }
39
+ }
40
+ }
freemius/assets/scss/admin/_tooltip.scss ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-tooltip-trigger
2
+ {
3
+ &:not(a)
4
+ {
5
+ cursor: help;
6
+ }
7
+
8
+ position: relative;
9
+
10
+ .fs-tooltip
11
+ {
12
+ opacity: 0;
13
+ visibility: hidden;
14
+ @include transition(opacity 0.3s ease-in-out);
15
+ position: absolute;
16
+ background: $tooltip-bkg-color;
17
+ color: $tooltip-color;
18
+ font-family: 'arial', serif;
19
+ font-size: 12px;
20
+ padding: 10px;
21
+ z-index: 999999;
22
+ bottom: 100%;
23
+ margin-bottom: 5px;
24
+ left: 0;
25
+ right: 0;
26
+ @include border-radius(5px);
27
+ @include box-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));
28
+ line-height: 1.3em;
29
+ font-weight: bold;
30
+ text-align: left;
31
+
32
+ .rtl &
33
+ {
34
+ text-align: right;
35
+ }
36
+
37
+ &::after
38
+ {
39
+ content: ' ';
40
+ display: block;
41
+ width: 0;
42
+ height: 0;
43
+ border-style: solid;
44
+ border-width: 5px 5px 0 5px;
45
+ border-color: $tooltip-bkg-color transparent transparent transparent;
46
+ position: absolute;
47
+ top: 100%;
48
+ left: 21px;
49
+
50
+ .rtl &
51
+ {
52
+ right: 21px;
53
+ left: auto;
54
+ }
55
+ }
56
+ }
57
+
58
+ &:hover
59
+ {
60
+ .fs-tooltip
61
+ {
62
+ visibility: visible;
63
+ opacity: 1;
64
+ }
65
+ }
66
+ }
freemius/assets/scss/admin/account.scss CHANGED
@@ -30,12 +30,9 @@
30
  width: 1.2em;
31
  }
32
 
33
- .button
34
  {
35
- i.dashicons
36
- {
37
- vertical-align: middle;
38
- }
39
  }
40
 
41
  .fs-header-actions
@@ -160,6 +157,55 @@ label.fs-tag
160
  }
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  #fs_addons
164
  {
165
  h3
30
  width: 1.2em;
31
  }
32
 
33
+ .dashicons
34
  {
35
+ vertical-align: middle;
 
 
 
36
  }
37
 
38
  .fs-header-actions
157
  }
158
  }
159
 
160
+ #fs_sites
161
+ {
162
+ .fs-scrollable-table
163
+ {
164
+ .fs-table-body {
165
+ max-height: 200px;
166
+ overflow: auto;
167
+ border: 1px solid #e5e5e5;
168
+
169
+ & > table.widefat {
170
+ border: none !important;
171
+ }
172
+ }
173
+
174
+ .fs-main-column {
175
+ width: 100%;
176
+ }
177
+
178
+ .fs-site-details
179
+ {
180
+ td:first-of-type
181
+ {
182
+ text-align: right;
183
+ color: grey;
184
+ width: 1px;
185
+ }
186
+
187
+ td:last-of-type
188
+ {
189
+ text-align: right;
190
+ }
191
+ }
192
+
193
+ .fs-install-details table
194
+ {
195
+ tr td
196
+ {
197
+ width: 1px;
198
+ white-space: nowrap;
199
+
200
+ &:last-of-type
201
+ {
202
+ width: auto;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
  #fs_addons
210
  {
211
  h3
freemius/assets/scss/admin/connect.scss CHANGED
@@ -53,6 +53,30 @@ $form_width: 480px;
53
  }
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  .fs-actions
57
  {
58
  padding: 10px 20px;
@@ -326,6 +350,10 @@ $form_width: 480px;
326
  }
327
  }
328
 
 
 
 
 
329
  .rtl
330
  {
331
  #fs_connect
53
  }
54
  }
55
 
56
+ &.require-license-key {
57
+ #sites_list_container {
58
+ td {
59
+ cursor: pointer;
60
+ }
61
+ }
62
+ }
63
+
64
+ #delegate_to_site_admins {
65
+ margin-right: 15px;
66
+ float: right;
67
+ height: 26px;
68
+ vertical-align: middle;
69
+ line-height: 37px;
70
+ font-weight: bold;
71
+ border-bottom: 1px dashed;
72
+ text-decoration: none;
73
+
74
+ &.rtl {
75
+ margin-left: 15px;
76
+ margin-right: 0;
77
+ }
78
+ }
79
+
80
  .fs-actions
81
  {
82
  padding: 10px 20px;
350
  }
351
  }
352
 
353
+ @import "multisite-options";
354
+ @import "tooltip";
355
+ @import "gdpr-consent";
356
+
357
  .rtl
358
  {
359
  #fs_connect
freemius/assets/scss/admin/dialog-boxes.scss CHANGED
@@ -2,6 +2,7 @@
2
  @import "modal-common";
3
  @import "deactivation-feedback";
4
  @import "license-activation";
 
5
  @import "license-key-resend";
6
  @import "ajax-loader";
7
  @import "auto-install";
2
  @import "modal-common";
3
  @import "deactivation-feedback";
4
  @import "license-activation";
5
+ @import "multisite-options";
6
  @import "license-key-resend";
7
  @import "ajax-loader";
8
  @import "auto-install";
freemius/assets/scss/admin/gdpr-optin-notice.scss ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-notice[data-id^="gdpr_optin_actions"]
2
+ {
3
+ .underlined {
4
+ text-decoration: underline;
5
+ }
6
+
7
+ ul {
8
+ .button, .action-description {
9
+ vertical-align: middle;
10
+ }
11
+
12
+ .action-description {
13
+ display: inline-block;
14
+ margin-left: 3px;
15
+ }
16
+ }
17
+ }
freemius/composer.json CHANGED
@@ -3,7 +3,7 @@
3
  "description": "Freemius WordPress SDK",
4
  "keywords": ["freemius", "wordpress", "plugin", "sdk"],
5
  "homepage": "https://freemius.com",
6
- "license": "GPL-3.0",
7
  "require": {
8
  "php": ">=5.2"
9
  }
3
  "description": "Freemius WordPress SDK",
4
  "keywords": ["freemius", "wordpress", "plugin", "sdk"],
5
  "homepage": "https://freemius.com",
6
+ "license": "GPL-3.0-only",
7
  "require": {
8
  "php": ">=5.2"
9
  }
freemius/config.php CHANGED
@@ -1,331 +1,388 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.4
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- if ( ! defined( 'WP_FS__SLUG' ) ) {
14
- define( 'WP_FS__SLUG', 'freemius' );
15
- }
16
- if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
17
- define( 'WP_FS__DEV_MODE', false );
18
- }
19
-
20
- #--------------------------------------------------------------------------------
21
- #region API Connectivity Issues Simulation
22
- #--------------------------------------------------------------------------------
23
-
24
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
25
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
26
- }
27
- if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
28
- define( 'WP_FS__SIMULATE_NO_CURL', false );
29
- }
30
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
31
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
32
- }
33
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
34
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
35
- }
36
- if ( WP_FS__SIMULATE_NO_CURL ) {
37
- define( 'FS_SDK__SIMULATE_NO_CURL', true );
38
- }
39
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
40
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
41
- }
42
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
43
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
44
- }
45
-
46
- #endregion
47
-
48
- if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
49
- define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
50
- }
51
-
52
- if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
53
- /**
54
- * @since 1.1.7.3
55
- * @author Vova Feldman (@svovaf)
56
- *
57
- * I'm not sure if shared servers periodically change IP, or the subdomain of the
58
- * admin dashboard. Also, I've seen sites that have strange loop of switching
59
- * between domains on a daily basis. Therefore, to eliminate the risk of
60
- * multiple unwanted connectivity test pings, temporary ignore domain or
61
- * server IP changes.
62
- */
63
- define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
64
- }
65
-
66
- /**
67
- * If your dev environment supports custom public network IP setup
68
- * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
69
- * and uncomment it during dev.
70
- */
71
- if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
72
- // VVV default public network IP.
73
- define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
74
 
75
  // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
76
- }
77
-
78
- /**
79
- * If true and running with secret key, the opt-in process
80
- * will skip the email activation process which is invoked
81
- * when the email of the context user already exist in Freemius
82
- * database (as a security precaution, to prevent sharing user
83
- * secret with unauthorized entity).
84
- *
85
- * IMPORTANT:
86
- * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
87
- * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
88
- * CLOCK IS SYNCED.
89
- */
90
- if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
91
- define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
92
- }
93
-
94
-
95
- #--------------------------------------------------------------------------------
96
- #region Directories
97
- #--------------------------------------------------------------------------------
98
-
99
- if ( ! defined( 'WP_FS__DIR' ) ) {
100
- define( 'WP_FS__DIR', dirname( __FILE__ ) );
101
- }
102
- if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
103
- define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
104
- }
105
- if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
106
- define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
107
- }
108
- if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
109
- define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
110
- }
111
- if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
112
- define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
113
- }
114
- if ( ! defined( 'WP_FS__DIR_JS' ) ) {
115
- define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
116
- }
117
- if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
118
- define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
119
- }
120
- if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
121
- define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
122
- }
123
-
124
- #endregion
125
-
126
- /**
127
- * Domain / URL / Address
128
- */
129
- define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
130
- define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
131
- define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
132
-
133
- if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
134
- define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
135
- }
136
- if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
137
- define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
138
- }
139
-
140
- if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
141
- define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  #--------------------------------------------------------------------------------
145
- #region HTTP
146
- #--------------------------------------------------------------------------------
147
-
148
- if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
149
- define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
150
- }
151
-
152
- if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
153
- define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
154
- // Checks if CloudFlare's HTTPS (Flexible SSL support).
155
- isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
156
- 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
157
- ) ||
158
- // Check if HTTPS request.
159
- ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
160
- ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
161
- );
162
- }
163
-
164
- if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
165
- define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
166
- strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
167
- }
168
-
169
- if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
170
- define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
171
- }
172
-
173
- if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
174
- if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
175
- define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
176
- } else {
177
- define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
178
- is_string( WP_FS__REMOTE_ADDR ) &&
179
- ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
180
- WP_FS__REMOTE_ADDR === '::1' )
181
- );
182
- }
183
- }
184
-
185
- if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
186
- define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
187
- false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
188
- }
189
-
190
- #endregion
191
-
192
- if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
193
- // By default, run with Freemius production servers.
194
- define( 'WP_FS__IS_PRODUCTION_MODE', true );
195
- }
196
-
197
- if ( ! defined( 'WP_FS__ADDRESS' ) ) {
198
- define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
199
- }
200
-
201
-
202
- #--------------------------------------------------------------------------------
203
- #region API
204
- #--------------------------------------------------------------------------------
205
-
206
- if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
207
- define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' );
208
- }
209
- if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
210
- define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
211
- }
212
-
213
- // Set API address for local testing.
214
- if ( ! WP_FS__IS_PRODUCTION_MODE ) {
215
- if ( ! defined( 'FS_API__ADDRESS' ) ) {
216
- define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
217
- }
218
- if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
219
- define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
220
- }
221
- }
222
-
223
- #endregion
224
-
225
- #--------------------------------------------------------------------------------
226
- #region Checkout
227
- #--------------------------------------------------------------------------------
228
-
229
- if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
230
- define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
231
- }
232
-
233
- if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
234
- define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
235
- }
236
-
237
- if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
238
- define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
239
- }
240
-
241
- #endregion
242
-
243
- define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
244
-
245
- if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
246
- define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
247
- }
248
- if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
249
- define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
250
- }
251
- define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
252
-
253
- /**
254
- * Module types
255
- *
256
- * @since 1.2.2
257
- */
258
- define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
259
- define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
260
-
261
- /**
262
- * Billing Frequencies
263
- */
264
- define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
265
- define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
266
- define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
267
-
268
- /**
269
- * Plans
270
- */
271
- define( 'WP_FS__PLAN_DEFAULT_PAID', false );
272
- define( 'WP_FS__PLAN_FREE', 'free' );
273
- define( 'WP_FS__PLAN_TRIAL', 'trial' );
274
-
275
- /**
276
- * Times in seconds
277
- */
278
- if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
279
- define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
280
- }
281
- if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
282
- define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
283
- }
284
  // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
285
- if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
286
- define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 );
287
- }
288
- if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
289
- define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
290
- }
291
-
292
- #--------------------------------------------------------------------------------
293
- #region Debugging
294
- #--------------------------------------------------------------------------------
295
-
296
- if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
297
- $debug_mode = get_option( 'fs_debug_mode', null );
298
-
299
- if ( $debug_mode === null ) {
300
- $debug_mode = false;
301
- add_option( 'fs_debug_mode', $debug_mode );
302
- }
303
-
304
- define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
305
- }
306
-
307
- if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
308
- define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
309
- }
310
- if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
311
- define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
312
- }
313
- if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
314
- define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
315
- }
316
-
317
- if ( WP_FS__ECHO_DEBUG_SDK ) {
318
- error_reporting( E_ALL );
319
- }
320
-
321
- #endregion
322
-
323
- if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
324
- define( 'WP_FS__SCRIPT_START_TIME', time() );
325
- }
326
- if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
327
- define( 'WP_FS__DEFAULT_PRIORITY', 10 );
328
- }
329
- if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
330
- define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! defined( 'WP_FS__SLUG' ) ) {
14
+ define( 'WP_FS__SLUG', 'freemius' );
15
+ }
16
+ if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
17
+ define( 'WP_FS__DEV_MODE', false );
18
+ }
19
+
20
+ #--------------------------------------------------------------------------------
21
+ #region API Connectivity Issues Simulation
22
+ #--------------------------------------------------------------------------------
23
+
24
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
25
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
26
+ }
27
+ if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
28
+ define( 'WP_FS__SIMULATE_NO_CURL', false );
29
+ }
30
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
31
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
32
+ }
33
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
34
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
35
+ }
36
+ if ( WP_FS__SIMULATE_NO_CURL ) {
37
+ define( 'FS_SDK__SIMULATE_NO_CURL', true );
38
+ }
39
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
40
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
41
+ }
42
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
43
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
44
+ }
45
+
46
+ #endregion
47
+
48
+ if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
49
+ define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
50
+ }
51
+
52
+ if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
53
+ /**
54
+ * @since 1.1.7.3
55
+ * @author Vova Feldman (@svovaf)
56
+ *
57
+ * I'm not sure if shared servers periodically change IP, or the subdomain of the
58
+ * admin dashboard. Also, I've seen sites that have strange loop of switching
59
+ * between domains on a daily basis. Therefore, to eliminate the risk of
60
+ * multiple unwanted connectivity test pings, temporary ignore domain or
61
+ * server IP changes.
62
+ */
63
+ define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
64
+ }
65
+
66
+ /**
67
+ * If your dev environment supports custom public network IP setup
68
+ * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
69
+ * and uncomment it during dev.
70
+ */
71
+ if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
72
+ // VVV default public network IP.
73
+ define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
74
 
75
  // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
76
+ }
77
+
78
+ /**
79
+ * If true and running with secret key, the opt-in process
80
+ * will skip the email activation process which is invoked
81
+ * when the email of the context user already exist in Freemius
82
+ * database (as a security precaution, to prevent sharing user
83
+ * secret with unauthorized entity).
84
+ *
85
+ * IMPORTANT:
86
+ * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
87
+ * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
88
+ * CLOCK IS SYNCED.
89
+ */
90
+ if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
91
+ define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
92
+ }
93
+
94
+
95
+ #--------------------------------------------------------------------------------
96
+ #region Directories
97
+ #--------------------------------------------------------------------------------
98
+
99
+ if ( ! defined( 'WP_FS__DIR' ) ) {
100
+ define( 'WP_FS__DIR', dirname( __FILE__ ) );
101
+ }
102
+ if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
103
+ define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
104
+ }
105
+ if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
106
+ define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
107
+ }
108
+ if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
109
+ define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
110
+ }
111
+ if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
112
+ define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
113
+ }
114
+ if ( ! defined( 'WP_FS__DIR_JS' ) ) {
115
+ define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
116
+ }
117
+ if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
118
+ define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
119
+ }
120
+ if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
121
+ define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
122
+ }
123
+
124
+ #endregion
125
+
126
+ /**
127
+ * Domain / URL / Address
128
+ */
129
+ define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
130
+ define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
131
+ define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
132
+
133
+ if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
134
+ define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
135
+ }
136
+ if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
137
+ define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
138
+ }
139
+
140
+ if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
141
+ define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
142
+ }
143
+
144
+ #--------------------------------------------------------------------------------
145
+ #region HTTP
146
+ #--------------------------------------------------------------------------------
147
+
148
+ if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
149
+ define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
150
+ }
151
+
152
+ if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
153
+ define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
154
+ // Checks if CloudFlare's HTTPS (Flexible SSL support).
155
+ isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
156
+ 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
157
+ ) ||
158
+ // Check if HTTPS request.
159
+ ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
160
+ ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
161
+ );
162
+ }
163
+
164
+ if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
165
+ define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
166
+ strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
167
+ }
168
+
169
+ if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
170
+ define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
171
+ }
172
+
173
+ if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
174
+ if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
175
+ define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
176
+ } else {
177
+ define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
178
+ is_string( WP_FS__REMOTE_ADDR ) &&
179
+ ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
180
+ WP_FS__REMOTE_ADDR === '::1' )
181
+ );
182
+ }
183
+ }
184
+
185
+ if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
186
+ define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
187
+ false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
188
+ }
189
+
190
+ #endregion
191
+
192
+ if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
193
+ // By default, run with Freemius production servers.
194
+ define( 'WP_FS__IS_PRODUCTION_MODE', true );
195
+ }
196
+
197
+ if ( ! defined( 'WP_FS__ADDRESS' ) ) {
198
+ define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
199
+ }
200
+
201
 
202
  #--------------------------------------------------------------------------------
203
+ #region API
204
+ #--------------------------------------------------------------------------------
205
+
206
+ if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
207
+ define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' );
208
+ }
209
+ if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
210
+ define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
211
+ }
212
+
213
+ // Set API address for local testing.
214
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
215
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
216
+ define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
217
+ }
218
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
219
+ define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
220
+ }
221
+ }
222
+
223
+ #endregion
224
+
225
+ #--------------------------------------------------------------------------------
226
+ #region Checkout
227
+ #--------------------------------------------------------------------------------
228
+
229
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
230
+ define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
231
+ }
232
+
233
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
234
+ define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
235
+ }
236
+
237
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
238
+ define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
239
+ }
240
+
241
+ #endregion
242
+
243
+ define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
244
+
245
+ if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
246
+ define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
247
+ }
248
+ if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
249
+ define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
250
+ }
251
+ if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
252
+ define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
253
+ }
254
+ define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
255
+
256
+ /**
257
+ * Module types
258
+ *
259
+ * @since 1.2.2
260
+ */
261
+ define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
262
+ define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
263
+
264
+ /**
265
+ * Billing Frequencies
266
+ */
267
+ define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
268
+ define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
269
+ define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
270
+
271
+ /**
272
+ * Plans
273
+ */
274
+ define( 'WP_FS__PLAN_DEFAULT_PAID', false );
275
+ define( 'WP_FS__PLAN_FREE', 'free' );
276
+ define( 'WP_FS__PLAN_TRIAL', 'trial' );
277
+
278
+ /**
279
+ * Times in seconds
280
+ */
281
+ if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
282
+ define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
283
+ }
284
+ if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
285
+ define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
286
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
288
+ if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
289
+ define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
290
+ }
291
+ if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
292
+ define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
293
+ }
294
+ if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
295
+ define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
296
+ }
297
+
298
+ #--------------------------------------------------------------------------------
299
+ #region Debugging
300
+ #--------------------------------------------------------------------------------
301
+
302
+ if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
303
+ $debug_mode = get_option( 'fs_debug_mode', null );
304
+
305
+ if ( $debug_mode === null ) {
306
+ $debug_mode = false;
307
+ add_option( 'fs_debug_mode', $debug_mode );
308
+ }
309
+
310
+ define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
311
+ }
312
+
313
+ if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
314
+ define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
315
+ }
316
+ if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
317
+ define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
318
+ }
319
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
320
+ define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
321
+ }
322
+
323
+ if ( WP_FS__ECHO_DEBUG_SDK ) {
324
+ error_reporting( E_ALL );
325
+ }
326
+
327
+ #endregion
328
+
329
+ if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
330
+ define( 'WP_FS__SCRIPT_START_TIME', time() );
331
+ }
332
+ if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
333
+ define( 'WP_FS__DEFAULT_PRIORITY', 10 );
334
+ }
335
+ if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
336
+ define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
337
+ }
338
+
339
+ #--------------------------------------------------------------------------------
340
+ #region Multisite Network
341
+ #--------------------------------------------------------------------------------
342
+
343
+ /**
344
+ * Do not use this define directly, it will have the wrong value
345
+ * during plugin uninstall/deletion when the inclusion of the plugin
346
+ * is triggered due to registration with register_uninstall_hook().
347
+ *
348
+ * Instead, use fs_is_network_admin().
349
+ *
350
+ * @author Vova Feldman (@svovaf)
351
+ */
352
+ if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
353
+ define( 'WP_FS__IS_NETWORK_ADMIN',
354
+ is_network_admin() ||
355
+ ( is_multisite() &&
356
+ ( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
357
+ ( isset( $_REQUEST['_fs_network_admin'] ) /*||
358
+ ( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
359
+ ) ||
360
+ // Plugin uninstall.
361
+ defined( 'WP_UNINSTALL_PLUGIN' ) )
362
+ )
363
+ );
364
+ }
365
+
366
+ /**
367
+ * Do not use this define directly, it will have the wrong value
368
+ * during plugin uninstall/deletion when the inclusion of the plugin
369
+ * is triggered due to registration with register_uninstall_hook().
370
+ *
371
+ * Instead, use fs_is_blog_admin().
372
+ *
373
+ * @author Vova Feldman (@svovaf)
374
+ */
375
+ if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
376
+ define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
377
+ }
378
+
379
+ if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
380
+ // Set to true to show network level settings even if delegated to site admins.
381
+ define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
382
+ }
383
+
384
+ #endregion
385
+
386
+ if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
387
+ define( 'WP_FS__DEMO_MODE', false );
388
+ }
freemius/includes/class-freemius-abstract.php CHANGED
@@ -359,7 +359,7 @@
359
  #----------------------------------------------------------------------------------
360
 
361
  /**
362
- * Check if plugin using the free plan.
363
  *
364
  * @since 1.0.4
365
  *
359
  #----------------------------------------------------------------------------------
360
 
361
  /**
362
+ * Check if the user is on the free plan of the product.
363
  *
364
  * @since 1.0.4
365
  *
freemius/includes/class-freemius.php CHANGED
@@ -1,14323 +1,20822 @@
1
  <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
- * @since 1.0.3
7
- */
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit;
10
- }
11
-
12
- // "final class"
13
- class Freemius extends Freemius_Abstract {
14
- /**
15
- * SDK Version
16
- *
17
- * @var string
18
- */
19
- public $version = WP_FS__SDK_VERSION;
20
-
21
- #region Plugin Info
22
-
23
- /**
24
- * @since 1.0.1
25
- *
26
- * @var string
27
- */
28
- private $_slug;
29
-
30
- /**
31
- * @since 1.0.0
32
- *
33
- * @var string
34
- */
35
- private $_plugin_basename;
36
- /**
37
- * @since 1.0.0
38
- *
39
- * @var string
40
- */
41
- private $_free_plugin_basename;
42
- /**
43
- * @since 1.0.0
44
- *
45
- * @var string
46
- */
47
- private $_plugin_dir_path;
48
- /**
49
- * @since 1.0.0
50
- *
51
- * @var string
52
- */
53
- private $_plugin_dir_name;
54
- /**
55
- * @since 1.0.0
56
- *
57
- * @var string
58
- */
59
- private $_plugin_main_file_path;
60
- /**
61
- * @var string[]
62
- */
63
- private $_plugin_data;
64
- /**
65
- * @since 1.0.9
66
- *
67
- * @var string
68
- */
69
- private $_plugin_name;
70
- /**
71
- * @since 1.2.2
72
- *
73
- * @var string
74
- */
75
- private $_module_type;
76
-
77
- #endregion Plugin Info
78
-
79
- /**
80
- * @since 1.0.9
81
- *
82
- * @var bool If false, don't turn Freemius on.
83
- */
84
- private $_is_on;
85
-
86
- /**
87
- * @since 1.1.3
88
- *
89
- * @var bool If false, don't turn Freemius on.
90
- */
91
- private $_is_anonymous;
92
-
93
- /**
94
- * @since 1.0.9
95
- * @var bool If false, issues with connectivity to Freemius API.
96
- */
97
- private $_has_api_connection;
98
-
99
- /**
100
- * @since 1.0.9
101
- * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
102
- */
103
- private $_enable_anonymous;
104
-
105
- /**
106
- * @since 1.1.7.5
107
- * @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
108
- */
109
- private $_anonymous_mode;
110
-
111
- /**
112
- * @since 1.1.9
113
- * @var bool Hints the SDK if plugin have any free plans.
114
- */
115
- private $_is_premium_only;
116
-
117
- /**
118
- * @since 1.2.1.6
119
- * @var bool Hints the SDK if plugin have premium code version at all.
120
- */
121
- private $_has_premium_version;
122
-
123
- /**
124
- * @since 1.2.1.6
125
- * @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
126
- */
127
- private $_ignore_pending_mode;
128
-
129
- /**
130
- * @since 1.0.8
131
- * @var bool Hints the SDK if the plugin has any paid plans.
132
- */
133
- private $_has_paid_plans;
134
-
135
- /**
136
- * @since 1.2.1.5
137
- * @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
138
- * without a specified period, if positive - the number of trial days.
139
- */
140
- private $_trial_days = - 1;
141
-
142
- /**
143
- * @since 1.2.1.5
144
- * @var bool Hints the SDK if the trial requires a payment method or not.
145
- */
146
- private $_is_trial_require_payment = false;
147
-
148
- /**
149
- * @since 1.0.7
150
- * @var bool Hints the SDK if the plugin is WordPress.org compliant.
151
- */
152
- private $_is_org_compliant;
153
-
154
- /**
155
- * @since 1.0.7
156
- * @var bool Hints the SDK if the plugin is has add-ons.
157
- */
158
- private $_has_addons;
159
-
160
- /**
161
- * @since 1.1.6
162
- * @var string[]bool.
163
- */
164
- private $_permissions;
165
-
166
- /**
167
- * @var FS_Key_Value_Storage
168
- */
169
- private $_storage;
170
-
171
- /**
172
- * @since 1.2.2.7
173
- * @var FS_Cache_Manager
174
- */
175
- private $_cache;
176
-
177
- /**
178
- * @since 1.0.0
179
- *
180
- * @var FS_Logger
181
- */
182
- private $_logger;
183
- /**
184
- * @since 1.0.4
185
- *
186
- * @var FS_Plugin
187
- */
188
- private $_plugin = false;
189
- /**
190
- * @since 1.0.4
191
- *
192
- * @var FS_Plugin|false
193
- */
194
- private $_parent_plugin = false;
195
- /**
196
- * @since 1.1.1
197
- *
198
- * @var Freemius
199
- */
200
- private $_parent = false;
201
- /**
202
- * @since 1.0.1
203
- *
204
- * @var FS_User
205
- */
206
- private $_user = false;
207
- /**
208
- * @since 1.0.1
209
- *
210
- * @var FS_Site
211
- */
212
- private $_site = false;
213
- /**
214
- * @since 1.0.1
215
- *
216
- * @var FS_Plugin_License
217
- */
218
- private $_license;
219
- /**
220
- * @since 1.0.2
221
- *
222
- * @var FS_Plugin_Plan[]
223
- */
224
- private $_plans = false;
225
- /**
226
- * @var FS_Plugin_License[]
227
- * @since 1.0.5
228
- */
229
- private $_licenses = false;
230
-
231
- /**
232
- * @since 1.0.1
233
- *
234
- * @var FS_Admin_Menu_Manager
235
- */
236
- private $_menu;
237
-
238
- /**
239
- * @var FS_Admin_Notice_Manager
240
- */
241
- private $_admin_notices;
242
-
243
- /**
244
- * @since 1.1.6
245
- *
246
- * @var FS_Admin_Notice_Manager
247
- */
248
- private static $_global_admin_notices;
249
-
250
- /**
251
- * @var FS_Logger
252
- * @since 1.0.0
253
- */
254
- private static $_static_logger;
255
-
256
- /**
257
- * @var FS_Option_Manager
258
- * @since 1.0.2
259
- */
260
- private static $_accounts;
261
-
262
- /**
263
- * @since 1.2.2
264
- *
265
- * @var number
266
- */
267
- private $_module_id;
268
-
269
- /**
270
- * @var Freemius[]
271
- */
272
- private static $_instances = array();
273
-
274
  /**
275
- * @author Leo Fajardo (@leorw)
276
  *
277
- * @since 1.2.3
 
 
 
 
 
 
 
278
  *
279
- * @var FS_Affiliate
280
  */
281
- private $affiliate = null;
282
 
283
  /**
284
- * @author Leo Fajardo (@leorw)
285
  *
286
- * @since 1.2.3
 
 
 
 
287
  *
288
- * @var FS_AffiliateTerms
289
  */
290
- private $plugin_affiliate_terms = null;
291
-
292
  /**
293
- * @author Leo Fajardo (@leorw)
 
 
 
 
 
 
294
  *
295
- * @since 1.2.3
 
 
 
 
296
  *
297
- * @var FS_AffiliateTerms
298
  */
299
- private $custom_affiliate_terms = null;
300
-
301
- #region Uninstall Reasons IDs
302
-
303
- const REASON_NO_LONGER_NEEDED = 1;
304
- const REASON_FOUND_A_BETTER_PLUGIN = 2;
305
- const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
306
- const REASON_BROKE_MY_SITE = 4;
307
- const REASON_SUDDENLY_STOPPED_WORKING = 5;
308
- const REASON_CANT_PAY_ANYMORE = 6;
309
- const REASON_OTHER = 7;
310
- const REASON_DIDNT_WORK = 8;
311
- const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
312
- const REASON_COULDNT_MAKE_IT_WORK = 10;
313
- const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
314
- const REASON_NOT_WORKING = 12;
315
- const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
316
- const REASON_DIDNT_WORK_AS_EXPECTED = 14;
317
- const REASON_TEMPORARY_DEACTIVATION = 15;
318
-
319
- #endregion
320
-
321
- /* Ctor
322
- ------------------------------------------------------------------------------------------------------------------*/
323
 
324
- /**
325
- * Main singleton instance.
326
- *
327
- * @author Vova Feldman (@svovaf)
328
- * @since 1.0.0
329
- *
330
- * @param number $module_id
331
- * @param string|bool $slug
332
- * @param bool $is_init Since 1.2.1 Is initiation sequence.
333
- */
334
- private function __construct( $module_id, $slug = false, $is_init = false ) {
335
- if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
336
- $this->store_id_slug_type_path_map( $module_id, $slug );
337
- }
338
-
339
- $this->_module_id = $module_id;
340
- $this->_slug = $this->get_slug();
341
- $this->_module_type = $this->get_module_type();
342
-
343
- $this->_storage = FS_Key_Value_Storage::instance( $this->_module_type . '_data', $this->_slug );
344
- $this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
345
-
346
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
347
-
348
- $this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
349
- $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
350
- $this->_plugin_basename = $this->get_plugin_basename();
351
- $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
352
-
353
- $base_name_split = explode( '/', $this->_plugin_basename );
354
- $this->_plugin_dir_name = $base_name_split[0];
355
-
356
- if ( $this->_logger->is_on() ) {
357
- $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
358
- $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
359
- $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
360
- $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
361
- $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
362
- }
363
-
364
- // Remember link between file to slug.
365
- $this->store_file_slug_map();
366
-
367
- // Store plugin's initial install timestamp.
368
- if ( ! isset( $this->_storage->install_timestamp ) ) {
369
- $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
370
- }
371
-
372
- if ( ! is_object( $this->_plugin ) ) {
373
- $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
374
- }
375
-
376
- $this->_admin_notices = FS_Admin_Notice_Manager::instance(
377
- $this->_slug . ( $this->is_theme() ? ':theme' : '' ),
378
- /**
379
- * Ensure that the admin notice will always have a title by using the stored plugin title if available and
380
- * retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
381
- *
382
- * @author Leo Fajardo (@leorw)
383
- * @since 1.2.2
384
- */
385
- ( is_object( $this->_plugin ) ? $this->_plugin->title : $this->get_plugin_name() ),
386
- $this->get_unique_affix()
387
- );
388
-
389
- if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
390
- 'true' === fs_request_is_action( 'restart_freemius' )
391
- ) {
392
- FS_Api::clear_cache();
393
- $this->_cache->clear();
394
- }
395
-
396
- $this->_register_hooks();
397
-
398
- $this->_load_account();
399
-
400
- $this->_version_updates_handler();
401
- }
402
-
403
- /**
404
- * Checks whether this module has a settings menu.
405
- *
406
- * @author Leo Fajardo (@leorw)
407
- * @since 1.2.2
408
- *
409
- * @return bool
410
- */
411
- function has_settings_menu() {
412
- return $this->_menu->has_menu();
413
- }
414
-
415
- /**
416
- * Check if the context module is free wp.org theme.
417
- *
418
- * This method is helpful because:
419
- * 1. wp.org themes are limited to a single submenu item,
420
- * and sub-submenu items are most likely not allowed (never verified).
421
- * 2. wp.org themes are not allowed to redirect the user
422
- * after the theme activation, therefore, the agreed UX
423
- * is showing the opt-in as a modal dialog box after
424
- * activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
425
- *
426
- * @author Vova Feldman (@svovaf)
427
- * @since 1.2.2.7
428
- *
429
- * @return bool
430
- */
431
- function is_free_wp_org_theme() {
432
- return (
433
- $this->is_theme() &&
434
- $this->is_org_repo_compliant() &&
435
- ! $this->is_premium()
436
- );
437
- }
438
-
439
- /**
440
- * Checks whether this a submenu item is visible.
441
- *
442
- * @author Vova Feldman (@svovaf)
443
- * @since 1.2.2.6
444
- * @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page.
445
- *
446
- * @param string $slug
447
- *
448
- * @return bool
449
- */
450
- function is_submenu_item_visible( $slug ) {
451
- if ( $this->is_admin_page( $slug ) ) {
452
- /**
453
- * It is the current context page, so show the submenu item
454
- * so the user will have the right context page, even if it
455
- * was set to hidden.
456
- */
457
- return true;
458
- }
459
-
460
- if ( ! $this->has_settings_menu() ) {
461
- // No menu settings at all.
462
- return false;
463
- }
464
-
465
- if ( $this->is_free_wp_org_theme() ) {
466
- /**
467
- * wp.org themes are limited to a single submenu item, and
468
- * sub-submenu items are most likely not allowed (never verified).
469
- */
470
- return false;
471
- }
472
-
473
- return $this->_menu->is_submenu_item_visible( $slug );
474
- }
475
-
476
- /**
477
- * Check if a Freemius page should be accessible via the UI.
478
- *
479
- * @author Vova Feldman (@svovaf)
480
- * @since 1.2.2.7
481
- *
482
- * @param string $slug
483
- *
484
- * @return bool
485
- */
486
- function is_page_visible( $slug ) {
487
- if ( $this->is_admin_page( $slug ) ) {
488
- return true;
489
- }
490
-
491
- return $this->_menu->is_submenu_item_visible( $slug, true, true );
492
- }
493
-
494
- /**
495
- * @author Vova Feldman (@svovaf)
496
- * @since 1.0.9
497
- */
498
- private function _version_updates_handler() {
499
- if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
500
- // Freemius version upgrade mode.
501
- $this->_storage->sdk_last_version = $this->_storage->sdk_version;
502
- $this->_storage->sdk_version = $this->version;
503
-
504
- if ( empty( $this->_storage->sdk_last_version ) ||
505
- version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
506
- ) {
507
- $this->_storage->sdk_upgrade_mode = true;
508
- $this->_storage->sdk_downgrade_mode = false;
509
- } else {
510
- $this->_storage->sdk_downgrade_mode = true;
511
- $this->_storage->sdk_upgrade_mode = false;
512
-
513
- }
514
-
515
- $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
516
- }
517
-
518
- $plugin_version = $this->get_plugin_version();
519
- if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
520
- // Plugin version upgrade mode.
521
- $this->_storage->plugin_last_version = $this->_storage->plugin_version;
522
- $this->_storage->plugin_version = $plugin_version;
523
-
524
- if ( empty( $this->_storage->plugin_last_version ) ||
525
- version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
526
- ) {
527
- $this->_storage->plugin_upgrade_mode = true;
528
- $this->_storage->plugin_downgrade_mode = false;
529
- } else {
530
- $this->_storage->plugin_downgrade_mode = true;
531
- $this->_storage->plugin_upgrade_mode = false;
532
- }
533
-
534
- if ( ! empty( $this->_storage->plugin_last_version ) ) {
535
- // Different version of the plugin was installed before, therefore it's an update.
536
- $this->_storage->is_plugin_new_install = false;
537
- }
538
-
539
- $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
540
- }
541
- }
542
-
543
- /**
544
- * @author Vova Feldman (@svovaf)
545
- * @since 1.1.5
546
- *
547
- * @param string $sdk_prev_version
548
- * @param string $sdk_version
549
- */
550
- function _data_migration( $sdk_prev_version, $sdk_version ) {
551
- /**
552
- * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
553
- */
554
- if ( empty( $sdk_prev_version ) ) {
555
- return;
556
- }
557
 
558
- if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
559
- version_compare( $sdk_version, '1.2.3', '>=' )
560
- ) {
561
- /**
562
- * Starting from version 1.2.3, paths are stored as relative paths and not absolute paths; so when
563
- * upgrading to 1.2.3, make paths relative.
564
- *
565
- * @author Leo Fajardo (@leorw)
566
- */
567
- $this->make_paths_relative();
568
- }
569
 
570
- if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
571
- version_compare( $sdk_version, '1.1.5', '>=' )
572
- ) {
573
- // On version 1.1.5 merged connectivity and is_on data.
574
- if ( isset( $this->_storage->connectivity_test ) ) {
575
- if ( ! isset( $this->_storage->is_on ) ) {
576
- unset( $this->_storage->connectivity_test );
577
- } else {
578
- $connectivity_data = $this->_storage->connectivity_test;
579
- $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
580
- $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
581
 
582
- // Override.
583
- $this->_storage->connectivity_test = $connectivity_data;
 
 
 
584
 
585
- // Remove previous structure.
586
- unset( $this->_storage->is_on );
587
- }
 
 
 
588
 
589
- }
590
- }
591
- }
 
 
592
 
593
  /**
594
- * Makes paths relative.
595
- *
596
- * @author Leo Fajardo
597
- * @since 1.2.3
598
  */
599
- private function make_paths_relative() {
600
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
601
 
602
- if ( isset( $id_slug_type_path_map[ $this->_module_id ]['path'] ) ) {
603
- $id_slug_type_path_map[ $this->_module_id ]['path'] = $this->get_relative_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
 
 
 
604
 
605
- self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
606
- }
 
 
 
607
 
608
- if ( isset( $this->_storage->plugin_main_file ) ) {
609
- $plugin_main_file = $this->_storage->plugin_main_file;
 
 
 
610
 
611
- if ( isset( $plugin_main_file->path ) ) {
612
- $this->_storage->plugin_main_file->path = $this->get_relative_path( $this->_storage->plugin_main_file->path );
613
- } else if ( isset( $plugin_main_file->prev_path ) ) {
614
- $this->_storage->plugin_main_file->prev_path = $this->get_relative_path( $this->_storage->plugin_main_file->prev_path );
615
- }
616
- }
617
 
618
- // Remove invalid path that is still associated with the current slug if there's any.
619
- $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
620
- foreach ( $file_slug_map as $plugin_basename => $slug ) {
621
- if ( $slug === $this->_slug &&
622
- $plugin_basename !== $this->_plugin_basename &&
623
- ! file_exists( $this->get_absolute_path( $plugin_basename ) )
624
- ) {
625
- unset( $file_slug_map[ $plugin_basename ] );
626
- self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
627
 
628
- break;
629
- }
630
- }
631
- }
 
632
 
633
- /**
634
- * @author Vova Feldman (@svovaf)
635
- * @since 1.2.2.7
636
- *
637
- * @param string $plugin_prev_version
638
- * @param string $plugin_version
639
- */
640
- function _after_version_update( $plugin_prev_version, $plugin_version ) {
641
- if ( $this->is_theme() ) {
642
- // Expire the cache of the previous tabs since the theme may
643
- // have setting updates.
644
- $this->_cache->expire( 'tabs' );
645
- $this->_cache->expire( 'tabs_stylesheets' );
646
- }
647
- }
648
-
649
- /**
650
- * This action is connected to the 'plugins_loaded' hook and helps to determine
651
- * if this is a new plugin installation or a plugin update.
652
- *
653
- * There are 3 different use-cases:
654
- * 1) New plugin installation right with Freemius:
655
- * 1.1 _activate_plugin_event_hook() will be executed first
656
- * 1.2 Since $this->_storage->is_plugin_new_install is not set,
657
- * and $this->_storage->plugin_last_version is not set,
658
- * $this->_storage->is_plugin_new_install will be set to TRUE.
659
- * 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
660
- * be already set to TRUE.
661
- *
662
- * 2) Plugin update, didn't have Freemius before, and now have the SDK:
663
- * 2.1 _activate_plugin_event_hook() will not be executed, because
664
- * the activation hook do NOT fires on updates since WP 3.1.
665
- * 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
666
- * be empty, therefore, it will be set to FALSE.
667
- *
668
- * 3) Plugin update, had Freemius in prev version as well:
669
- * 3.1 _version_updates_handler() will be executed 1st, since FS was installed
670
- * before, $this->_storage->plugin_last_version will NOT be empty,
671
- * therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
672
- * 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
673
- * already set, therefore, it will not be modified.
674
- *
675
- * Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
676
- *
677
- * NOTE:
678
- * The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
679
- * and then, the next immediate PageView is the plugin's main settings page, it will not
680
- * show the opt-in right away. The reason it will happen is because Freemius execution
681
- * will be turned off till the plugin is fully loaded at least once
682
- * (till $this->_storage->was_plugin_loaded is TRUE).
683
- *
684
- * @author Vova Feldman (@svovaf)
685
- * @since 1.1.9
686
- *
687
- */
688
- function _plugins_loaded() {
689
- // Update flag that plugin was loaded with Freemius at least once.
690
- $this->_storage->was_plugin_loaded = true;
691
-
692
- /**
693
- * Bug fix - only set to false when it's a plugin, due to the
694
- * execution sequence of the theme hooks and our methods, if
695
- * this will be set for themes, Freemius will always assume
696
- * it's a theme update.
697
- *
698
- * @author Vova Feldman (@svovaf)
699
- * @since 1.2.2.2
700
- */
701
- if ( $this->is_plugin() &&
702
- ! isset( $this->_storage->is_plugin_new_install )
703
- ) {
704
- $this->_storage->is_plugin_new_install = false;
705
- }
706
- }
707
-
708
- /**
709
- * @author Vova Feldman (@svovaf)
710
- * @since 1.0.9
711
- */
712
- private function _register_hooks() {
713
- $this->_logger->entrance();
714
-
715
- if ( is_admin() ) {
716
- if ( $this->is_plugin() ) {
717
- $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
718
-
719
- /**
720
- * @since 1.2.2
721
- *
722
- * Hook to both free and premium version activations to support
723
- * auto deactivation on the other version activation.
724
- */
725
- register_activation_hook(
726
- $plugin_dir . $this->_free_plugin_basename,
727
- array( &$this, '_activate_plugin_event_hook' )
728
- );
729
-
730
- register_activation_hook(
731
- $plugin_dir . $this->premium_plugin_basename(),
732
- array( &$this, '_activate_plugin_event_hook' )
733
- );
734
- } else {
735
- add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
736
-
737
- /**
738
- * Include the required hooks to capture the theme settings' page tabs
739
- * and cache them.
740
- *
741
- * @author Vova Feldman (@svovaf)
742
- * @since 1.2.2.7
743
- */
744
- if ( ! $this->_cache->has_valid( 'tabs' ) ) {
745
- add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
746
- // Add license activation AJAX callback.
747
- $this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
748
-
749
- add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
750
- }
751
-
752
- add_action(
753
- 'admin_footer',
754
- array( &$this, '_add_freemius_tabs' ),
755
- /**
756
- * The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
757
- * That's why the priority is 11 while the tabs capture logic is added
758
- * with priority 10.
759
- *
760
- * @author Vova Feldman (@svovaf)
761
- */
762
- 11
763
- );
764
-
765
- add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
766
- }
767
-
768
- /**
769
- * Part of the mechanism to identify new plugin install vs. plugin update.
770
- *
771
- * @author Vova Feldman (@svovaf)
772
- * @since 1.1.9
773
- */
774
- if ( empty( $this->_storage->was_plugin_loaded ) ) {
775
- if ( $this->is_plugin() &&
776
- $this->is_activation_mode( false ) &&
777
- 0 == did_action( 'plugins_loaded' )
778
- ) {
779
- add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
780
- } else {
781
- // If was activated before, then it was already loaded before.
782
- $this->_plugins_loaded();
783
- }
784
- }
785
-
786
- if ( ! self::is_ajax() ) {
787
- if ( ! $this->is_addon() ) {
788
- add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
789
- }
790
- }
791
- }
792
-
793
- if ( $this->is_plugin() ) {
794
- register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
795
- }
796
-
797
- if ( $this->is_theme() && self::is_customizer() ) {
798
- // Register customizer upsell.
799
- add_action( 'customize_register', array( &$this, '_customizer_register' ) );
800
- }
801
-
802
- add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
803
-
804
- add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
805
- add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
806
- $this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
807
- $this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
808
-
809
- $this->add_ajax_action( 'install_premium_version', array(
810
- &$this,
811
- '_install_premium_version_ajax_action'
812
- ) );
813
 
814
- $this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
 
 
 
 
815
 
816
- $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
 
 
 
817
 
818
- $this->add_action( 'sdk_version_update', array( &$this, '_data_migration' ), WP_FS__DEFAULT_PRIORITY, 2 );
819
- $this->add_action( 'plugin_version_update', array( &$this, '_after_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
820
- $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
 
 
821
 
822
- add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
823
- add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
824
- add_action( 'admin_init', array( &$this, '_enqueue_common_css' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
825
 
826
- /**
827
- * Handle request to reset anonymous mode for `get_reconnect_url()`.
828
- *
829
- * @author Vova Feldman (@svovaf)
830
- * @since 1.2.1.5
831
- */
832
- if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
833
- $this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
834
- ) {
835
- add_action( 'admin_init', array( &$this, 'connect_again' ) );
836
- }
837
- }
838
-
839
- /**
840
- * Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
841
- * could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
842
- * plugin will trigger inclusion of the free or premium version and if one of them is active during the
843
- * uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
844
- *
845
- * @author Leo Fajardo (leorw)
846
- *
847
- * @since 1.2.0
848
- */
849
- private function unregister_uninstall_hook() {
850
- $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
851
- unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
852
- unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
853
-
854
- update_option( 'uninstall_plugins', $uninstallable_plugins );
855
- }
856
-
857
- /**
858
- * @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
859
- */
860
- private function clear_module_main_file_cache() {
861
- if ( ! isset( $this->_storage->plugin_main_file ) ||
862
- empty( $this->_storage->plugin_main_file->path )
863
- ) {
864
- return;
865
- }
866
-
867
- $plugin_main_file = clone $this->_storage->plugin_main_file;
868
-
869
- // Store cached path (2nd layer cache).
870
- $plugin_main_file->prev_path = $plugin_main_file->path;
871
-
872
- // Clear cached path.
873
- unset( $plugin_main_file->path );
874
-
875
- $this->_storage->plugin_main_file = $plugin_main_file;
876
-
877
- /**
878
- * Clear global cached path.
879
- *
880
- * @author Leo Fajardo (@leorw)
881
- * @since 1.2.2
882
- */
883
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
884
- unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
885
- self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
886
- }
887
-
888
- /**
889
- * @author Vova Feldman (@svovaf)
890
- * @since 1.0.9
891
- */
892
- private function _register_account_hooks() {
893
- if ( ! is_admin() ) {
894
- return;
895
- }
896
-
897
- /**
898
- * Always show the deactivation feedback form since we added
899
- * automatic free version deactivation upon premium code activation.
900
- *
901
- * @since 1.2.1.6
902
- */
903
- $this->add_ajax_action(
904
- 'submit_uninstall_reason',
905
- array( &$this, '_submit_uninstall_reason_action' )
906
- );
907
-
908
- if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
909
- ( $this->is_theme() && self::is_themes_page() )
910
- ) {
911
- add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
912
- }
913
- }
914
-
915
- /**
916
- * Leverage backtrace to find caller plugin file path.
917
- *
918
- * @author Vova Feldman (@svovaf)
919
- * @since 1.0.6
920
- *
921
- * @param bool $is_init Is initiation sequence.
922
- *
923
- * @return string
924
- */
925
- private function _find_caller_plugin_file( $is_init = false ) {
926
- // Try to load the cached value of the file path.
927
- if ( isset( $this->_storage->plugin_main_file ) ) {
928
- $plugin_main_file = $this->_storage->plugin_main_file;
929
- if ( isset( $plugin_main_file->path ) ) {
930
- $absolute_path = $this->get_absolute_path( $plugin_main_file->path );
931
- if ( file_exists( $absolute_path ) ) {
932
- return $absolute_path;
933
- }
934
- }
935
- }
936
-
937
- /**
938
- * @since 1.2.1
939
- *
940
- * `clear_module_main_file_cache()` is clearing the plugin's cached path on
941
- * deactivation. Therefore, if any plugin/theme was initiating `Freemius`
942
- * with that plugin's slug, it was overriding the empty plugin path with a wrong path.
943
- *
944
- * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
945
- * when the class instantiator isn't the module.
946
- */
947
- if ( ! $is_init ) {
948
- // Fetch prev path cache.
949
- if ( isset( $this->_storage->plugin_main_file ) &&
950
- isset( $this->_storage->plugin_main_file->prev_path )
951
- ) {
952
- $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
953
- if ( file_exists( $absolute_path ) ) {
954
- return $absolute_path;
955
- }
956
- }
957
-
958
- wp_die(
959
- $this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) .
960
- " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
961
- $this->get_text_inline( 'Error', 'error' ),
962
- array( 'back_link' => true )
963
- );
964
- }
965
-
966
- /**
967
- * @since 1.2.1
968
- *
969
- * Only the original instantiator that calls dynamic_init can modify the module's path.
970
- */
971
- // Find caller module.
972
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
973
- $this->_storage->plugin_main_file = (object) array(
974
- 'path' => $id_slug_type_path_map[ $this->_module_id ]['path'],
975
- );
976
 
977
- return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
978
- }
 
 
979
 
980
  /**
981
- * @author Leo Fajardo (@leorw)
982
- * @since 1.2.3
983
  *
984
- * @param string $path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
  *
986
- * @return string
987
  */
988
- private function get_relative_path( $path ) {
989
- $module_root_dir = $this->get_module_root_dir_path();
990
- if ( 0 === strpos( $path, $module_root_dir ) ) {
991
- $path = substr( $path, strlen( $module_root_dir ) );
992
- }
993
 
994
- return $path;
995
- }
 
 
996
 
997
  /**
998
- * @author Leo Fajardo (@leorw)
999
- * @since 1.2.3
1000
  *
1001
- * @param string $path
1002
- * @param string|bool $module_type
 
 
 
 
1003
  *
1004
- * @return string
1005
  */
1006
- private function get_absolute_path( $path, $module_type = false ) {
1007
- $module_root_dir = $this->get_module_root_dir_path( $module_type );
1008
- if ( 0 !== strpos( $path, $module_root_dir ) ) {
1009
- $path = fs_normalize_path( $module_root_dir . $path );
1010
- }
1011
 
1012
- return $path;
1013
- }
 
 
 
 
1014
 
1015
  /**
1016
- * @author Leo Fajardo (@leorw)
1017
- * @since 1.2.3
1018
  *
1019
- * @param string|bool $module_type
 
 
 
 
 
1020
  *
1021
- * @return string
1022
  */
1023
- private function get_module_root_dir_path( $module_type = false ) {
1024
- $is_plugin = empty( $module_type ) ?
1025
- $this->is_plugin() :
1026
- ( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
1027
 
1028
- return fs_normalize_path( trailingslashit( $is_plugin ?
1029
- WP_PLUGIN_DIR :
1030
- get_theme_root() ) );
1031
- }
 
 
1032
 
1033
- /**
1034
- * @author Leo Fajardo (@leorw)
1035
- *
1036
- * @param number $module_id
1037
- * @param string $slug
1038
- *
1039
- * @since 1.2.2
1040
- */
1041
- private function store_id_slug_type_path_map( $module_id, $slug ) {
1042
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
1043
-
1044
- $store_option = false;
1045
-
1046
- if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
1047
- $id_slug_type_path_map[ $module_id ] = array(
1048
- 'slug' => $slug
1049
- );
1050
-
1051
- $store_option = true;
1052
- }
1053
-
1054
- if ( ! isset( $id_slug_type_path_map[ $module_id ]['path'] ) ||
1055
- /**
1056
- * This verification is for cases when suddenly the same module
1057
- * is installed but with a different folder name.
1058
- *
1059
- * @author Vova Feldman (@svovaf)
1060
- * @since 1.2.3
1061
- */
1062
- ! file_exists( $this->get_absolute_path(
1063
- $id_slug_type_path_map[ $module_id ]['path'],
1064
- $id_slug_type_path_map[ $module_id ]['type']
1065
- ) )
1066
- ) {
1067
- $caller_main_file_and_type = $this->get_caller_main_file_and_type();
1068
-
1069
- $id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
1070
- $id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
1071
-
1072
- $store_option = true;
1073
- }
1074
-
1075
- if ( $store_option ) {
1076
- self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
1077
- }
1078
- }
1079
-
1080
- /**
1081
- * Identifies the caller type: plugin or theme.
1082
- *
1083
- * @author Leo Fajardo (@leorw)
1084
- * @since 1.2.2
1085
- *
1086
- * @author Vova Feldman (@svovaf)
1087
- * @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
1088
- * add-ons are relying on loading the SDK from the parent module, and also allows themes including the
1089
- * SDK an internal file instead of directly from functions.php.
1090
- * @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
1091
- */
1092
- private function get_caller_main_file_and_type() {
1093
- self::require_plugin_essentials();
1094
-
1095
- $all_plugins = get_plugins();
1096
- $all_plugins_paths = array();
1097
-
1098
- // Get active plugin's main files real full names (might be symlinks).
1099
- foreach ( $all_plugins as $relative_path => &$data ) {
1100
- if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
1101
- /**
1102
- * Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
1103
- * can't really include the SDK.
1104
- *
1105
- * @author Vova Feldman
1106
- * @since 1.2.1.7
1107
- */
1108
- continue;
1109
- }
1110
-
1111
- $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
1112
- }
1113
-
1114
- $caller_file_candidate = false;
1115
- $caller_map = array();
1116
- $module_type = WP_FS__MODULE_TYPE_PLUGIN;
1117
- $themes_dir = fs_normalize_path( get_theme_root() );
1118
-
1119
- for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
1120
- if ( empty( $bt[ $i ]['file'] ) ) {
1121
- continue;
1122
- }
1123
-
1124
- if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
1125
- // If file same as the prev file in the stack, skip it.
1126
- continue;
1127
- }
1128
-
1129
- if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
1130
- 'do_action',
1131
- 'apply_filter',
1132
- // The string split is stupid, but otherwise, theme check
1133
- // throws info notices.
1134
- 'requir' . 'e_once',
1135
- 'requir' . 'e',
1136
- 'includ' . 'e_once',
1137
- 'includ' . 'e'
1138
- ) )
1139
- ) {
1140
- // Ignore call stack hooks and files inclusion.
1141
- continue;
1142
- }
1143
-
1144
- $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
1145
-
1146
- if ( 'functions.php' === basename( $caller_file_path ) ) {
1147
- /**
1148
- * 1. Assumes that theme's starting execution file is functions.php.
1149
- * 2. This complex logic fixes symlink issues (e.g. with Vargant).
1150
- *
1151
- * @author Vova Feldman (@svovaf)
1152
- * @since 1.2.2.5
1153
- */
1154
-
1155
- if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
1156
- $module_type = WP_FS__MODULE_TYPE_THEME;
1157
 
1158
- /**
1159
- * Relative path of the theme, e.g.:
1160
- * `my-theme/functions.php`
1161
- *
1162
- * @author Leo Fajardo (@leorw)
1163
- */
1164
- $caller_file_candidate = basename( dirname( $caller_file_path ) ) .
1165
- '/' .
1166
- basename( $caller_file_path );
1167
-
1168
- continue;
1169
- }
1170
- }
1171
-
1172
- $caller_file_hash = md5( $caller_file_path );
1173
-
1174
- if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
1175
- foreach ( $all_plugins_paths as $plugin_path ) {
1176
- if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
1177
- $caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
1178
- break;
1179
- }
1180
- }
1181
- }
1182
-
1183
- if ( isset( $caller_map[ $caller_file_hash ] ) ) {
1184
- $module_type = WP_FS__MODULE_TYPE_PLUGIN;
1185
- $caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
1186
- }
1187
- }
1188
-
1189
- return (object) array(
1190
- 'module_type' => $module_type,
1191
- 'path' => $caller_file_candidate
1192
- );
1193
- }
1194
-
1195
- #----------------------------------------------------------------------------------
1196
- #region Deactivation Feedback Form
1197
- #----------------------------------------------------------------------------------
1198
-
1199
- /**
1200
- * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
1201
- * page.
1202
- *
1203
- * @author Vova Feldman (@svovaf)
1204
- * @author Leo Fajardo (@leorw)
1205
- * @since 1.1.2
1206
- */
1207
- function _add_deactivation_feedback_dialog_box() {
1208
- /* Check the type of user:
1209
- * 1. Long-term (long-term)
1210
- * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
1211
- * 3. Short-term (short-term)
1212
- */
1213
- $is_long_term_user = true;
1214
 
1215
- // Check if the site is at least 2 days old.
1216
- $time_installed = $this->_storage->install_timestamp;
 
 
 
 
 
 
 
 
 
 
 
 
1217
 
1218
- // Difference in seconds.
1219
- $date_diff = time() - $time_installed;
 
1220
 
1221
- // Convert seconds to days.
1222
- $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
1223
 
1224
- if ( $date_diff_days < 2 ) {
1225
- $is_long_term_user = false;
1226
- }
1227
 
1228
- $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
1229
 
1230
- if ( $is_long_term_user ) {
1231
- $user_type = 'long-term';
1232
- } else {
1233
- if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
1234
- $user_type = 'non-registered-and-non-anonymous-short-term';
1235
- } else {
1236
- $user_type = 'short-term';
1237
- }
1238
- }
1239
 
1240
- $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
 
 
 
1241
 
1242
- // Load the HTML template for the deactivation feedback dialog box.
1243
- $vars = array(
1244
- 'reasons' => $uninstall_reasons,
1245
- 'id' => $this->_module_id
1246
- );
1247
 
1248
- /**
1249
- * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
1250
- */
1251
- fs_require_template( 'forms/deactivation/form.php', $vars );
1252
- }
1253
-
1254
- /**
1255
- * @author Leo Fajardo (leorw)
1256
- * @since 1.1.2
1257
- *
1258
- * @param string $user_type
1259
- *
1260
- * @return array The uninstall reasons for the specified user type.
1261
- */
1262
- function _get_uninstall_reasons( $user_type = 'long-term' ) {
1263
- $module_type = $this->_module_type;
1264
-
1265
- $internal_message_template_var = array(
1266
- 'id' => $this->_module_id
1267
- );
1268
-
1269
- if ( $this->is_registered() && false !== $this->get_plan() && $this->get_plan()->has_technical_support() ) {
1270
- $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
1271
- } else {
1272
- $contact_support_template = '';
1273
- }
1274
-
1275
- $reason_found_better_plugin = array(
1276
- 'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
1277
- 'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
1278
- 'input_type' => 'textfield',
1279
- 'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
1280
- );
1281
-
1282
- $reason_temporary_deactivation = array(
1283
- 'id' => self::REASON_TEMPORARY_DEACTIVATION,
1284
- 'text' => sprintf(
1285
- $this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
1286
- strtolower( $this->is_plugin() ?
1287
- $this->get_text_inline( 'Deactivation', 'deactivation' ) :
1288
- $this->get_text_inline( 'Theme Switch', 'theme-switch' )
1289
- )
1290
- ),
1291
- 'input_type' => '',
1292
- 'input_placeholder' => ''
1293
- );
1294
-
1295
- $reason_other = array(
1296
- 'id' => self::REASON_OTHER,
1297
- 'text' => $this->get_text_inline( 'Other', 'reason-other' ),
1298
- 'input_type' => 'textfield',
1299
- 'input_placeholder' => ''
1300
- );
1301
-
1302
- $long_term_user_reasons = array(
1303
- array(
1304
- 'id' => self::REASON_NO_LONGER_NEEDED,
1305
- 'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
1306
- 'input_type' => '',
1307
- 'input_placeholder' => ''
1308
- ),
1309
- $reason_found_better_plugin,
1310
- array(
1311
- 'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
1312
- 'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
1313
- 'input_type' => '',
1314
- 'input_placeholder' => ''
1315
- ),
1316
- array(
1317
- 'id' => self::REASON_BROKE_MY_SITE,
1318
- 'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
1319
- 'input_type' => '',
1320
- 'input_placeholder' => '',
1321
- 'internal_message' => $contact_support_template
1322
- ),
1323
- array(
1324
- 'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
1325
- 'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
1326
- 'input_type' => '',
1327
- 'input_placeholder' => '',
1328
- 'internal_message' => $contact_support_template
1329
- )
1330
- );
1331
-
1332
- if ( $this->is_paying() ) {
1333
- $long_term_user_reasons[] = array(
1334
- 'id' => self::REASON_CANT_PAY_ANYMORE,
1335
- 'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
1336
- 'input_type' => 'textfield',
1337
- 'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
1338
- );
1339
- }
1340
-
1341
- $reason_dont_share_info = array(
1342
- 'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
1343
- 'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
1344
- 'input_type' => '',
1345
- 'input_placeholder' => ''
1346
- );
1347
-
1348
- /**
1349
- * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
1350
- * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
1351
- * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
1352
- * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
1353
- * button in the opt-in form is shown/hidden).
1354
- */
1355
- if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
1356
- $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
1357
- }
1358
-
1359
- $uninstall_reasons = array(
1360
- 'long-term' => $long_term_user_reasons,
1361
- 'non-registered-and-non-anonymous-short-term' => array(
1362
- array(
1363
- 'id' => self::REASON_DIDNT_WORK,
1364
- 'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
1365
- 'input_type' => '',
1366
- 'input_placeholder' => ''
1367
- ),
1368
- $reason_dont_share_info,
1369
- $reason_found_better_plugin
1370
- ),
1371
- 'short-term' => array(
1372
- array(
1373
- 'id' => self::REASON_COULDNT_MAKE_IT_WORK,
1374
- 'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
1375
- 'input_type' => '',
1376
- 'input_placeholder' => '',
1377
- 'internal_message' => $contact_support_template
1378
- ),
1379
- $reason_found_better_plugin,
1380
- array(
1381
- 'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
1382
- 'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
1383
- 'input_type' => 'textarea',
1384
- 'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
1385
- ),
1386
- array(
1387
- 'id' => self::REASON_NOT_WORKING,
1388
- 'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
1389
- 'input_type' => 'textarea',
1390
- 'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
1391
- ),
1392
- array(
1393
- 'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
1394
- 'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
1395
- 'input_type' => 'textarea',
1396
- 'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
1397
- ),
1398
- array(
1399
- 'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
1400
- 'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
1401
- 'input_type' => 'textarea',
1402
- 'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
1403
- )
1404
- )
1405
- );
1406
-
1407
- // Randomize the reasons for the current user type.
1408
- shuffle( $uninstall_reasons[ $user_type ] );
1409
-
1410
- // Keep the following reasons as the last items in the list.
1411
- $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
1412
- $uninstall_reasons[ $user_type ][] = $reason_other;
1413
-
1414
- $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
1415
-
1416
- return $uninstall_reasons[ $user_type ];
1417
- }
1418
-
1419
- /**
1420
- * Called after the user has submitted his reason for deactivating the plugin.
1421
- *
1422
- * @author Leo Fajardo (@leorw)
1423
- * @since 1.1.2
1424
- */
1425
- function _submit_uninstall_reason_action() {
1426
- $this->_logger->entrance();
1427
-
1428
- $this->check_ajax_referer( 'submit_uninstall_reason' );
1429
-
1430
- $reason_id = fs_request_get( 'reason_id' );
1431
-
1432
- // Check if the given reason ID is an unsigned integer.
1433
- if ( ! ctype_digit( $reason_id ) ) {
1434
- exit;
1435
- }
1436
-
1437
- $reason_info = trim( fs_request_get( 'reason_info', '' ) );
1438
- if ( ! empty( $reason_info ) ) {
1439
- $reason_info = substr( $reason_info, 0, 128 );
1440
- }
1441
-
1442
- $reason = (object) array(
1443
- 'id' => $reason_id,
1444
- 'info' => $reason_info,
1445
- 'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
1446
- );
1447
-
1448
- $this->_storage->store( 'uninstall_reason', $reason );
1449
-
1450
- /**
1451
- * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
1452
- * not support uninstall hook.
1453
- *
1454
- * @author Leo Fajardo (@leorw)
1455
- * @since 1.2.2
1456
- */
1457
- if ( $this->is_theme() ) {
1458
- $this->_uninstall_plugin_event( false );
1459
- $this->remove_sdk_reference();
1460
- }
1461
-
1462
- // Print '1' for successful operation.
1463
- echo 1;
1464
- exit;
1465
- }
1466
-
1467
- #endregion
1468
-
1469
- #----------------------------------------------------------------------------------
1470
- #region Instance
1471
- #----------------------------------------------------------------------------------
1472
-
1473
- /**
1474
- * Main singleton instance.
1475
- *
1476
- * @author Vova Feldman (@svovaf)
1477
- * @since 1.0.0
1478
- *
1479
- * @param number $module_id
1480
- * @param string|bool $slug
1481
- * @param bool $is_init Is initiation sequence.
1482
- *
1483
- * @return Freemius|false
1484
- */
1485
- static function instance( $module_id, $slug = false, $is_init = false ) {
1486
- if ( empty( $module_id ) ) {
1487
- return false;
1488
- }
1489
-
1490
- if ( ! is_numeric( $module_id ) ) {
1491
- if ( ! $is_init && true === $slug ) {
1492
- $is_init = true;
1493
- }
1494
-
1495
- $slug = $module_id;
1496
-
1497
- $module = FS_Plugin_Manager::instance( $slug )->get();
1498
-
1499
- if ( is_object( $module ) ) {
1500
- $module_id = $module->id;
1501
- }
1502
- }
1503
-
1504
- $key = 'm_' . $module_id;
1505
-
1506
- if ( ! isset( self::$_instances[ $key ] ) ) {
1507
- if ( 0 === count( self::$_instances ) ) {
1508
- self::_load_required_static();
1509
- }
1510
-
1511
- self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
1512
- }
1513
-
1514
- return self::$_instances[ $key ];
1515
- }
1516
-
1517
- /**
1518
- * @author Vova Feldman (@svovaf)
1519
- * @since 1.0.6
1520
- *
1521
- * @param number $addon_id
1522
- *
1523
- * @return bool
1524
- */
1525
- private static function has_instance( $addon_id ) {
1526
- return isset( self::$_instances[ 'm_' . $addon_id ] );
1527
- }
1528
-
1529
- /**
1530
- * @author Leo Fajardo (@leorw)
1531
- * @since 1.2.2
1532
- *
1533
- * @param string|number $id_or_slug
1534
- *
1535
- * @return number|false
1536
- */
1537
- private static function get_module_id( $id_or_slug ) {
1538
- if ( is_numeric( $id_or_slug ) ) {
1539
- return $id_or_slug;
1540
- }
1541
-
1542
- foreach ( self::$_instances as $instance ) {
1543
- if ( $instance->is_plugin() && ( $id_or_slug === $instance->get_slug() ) ) {
1544
- return $instance->get_id();
1545
- }
1546
- }
1547
-
1548
- return false;
1549
- }
1550
-
1551
- /**
1552
- * @author Vova Feldman (@svovaf)
1553
- * @since 1.0.6
1554
- *
1555
- * @param number $id
1556
- *
1557
- * @return false|Freemius
1558
- */
1559
- static function get_instance_by_id( $id ) {
1560
- return isset ( self::$_instances[ 'm_' . $id ] ) ?
1561
- self::$_instances[ 'm_' . $id ] :
1562
- false;
1563
- }
1564
-
1565
- /**
1566
- *
1567
- * @author Vova Feldman (@svovaf)
1568
- * @since 1.0.1
1569
- *
1570
- * @param $plugin_file
1571
- *
1572
- * @return false|Freemius
1573
- */
1574
- static function get_instance_by_file( $plugin_file ) {
1575
- $slug = self::find_slug_by_basename( $plugin_file );
1576
-
1577
- return ( false !== $slug ) ?
1578
- self::instance( self::get_module_id( $slug ) ) :
1579
- false;
1580
- }
1581
-
1582
- /**
1583
- * @author Vova Feldman (@svovaf)
1584
- * @since 1.0.6
1585
- *
1586
- * @return false|Freemius
1587
- */
1588
- function get_parent_instance() {
1589
- return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
1590
- }
1591
-
1592
- /**
1593
- * @author Vova Feldman (@svovaf)
1594
- * @since 1.0.6
1595
- *
1596
- * @param string|number $id_or_slug
1597
- *
1598
- * @return false|Freemius
1599
- */
1600
- function get_addon_instance( $id_or_slug ) {
1601
- $addon_id = self::get_module_id( $id_or_slug );
1602
-
1603
- return self::instance( $addon_id );
1604
- }
1605
-
1606
- #endregion ------------------------------------------------------------------
1607
-
1608
- /**
1609
- * @author Vova Feldman (@svovaf)
1610
- * @since 1.0.6
1611
- *
1612
- * @return bool
1613
- */
1614
- function is_parent_plugin_installed() {
1615
- $is_active = self::has_instance( $this->_plugin->parent_plugin_id );
1616
-
1617
- if ( $is_active ) {
1618
- return true;
1619
- }
1620
-
1621
- /**
1622
- * Parent module might be a theme. If that's the case, the add-on's FS
1623
- * instance will be loaded prior to the theme's FS instance, therefore,
1624
- * we need to check if it's active with a "look ahead".
1625
- *
1626
- * @author Vova Feldman
1627
- * @since 1.2.2.3
1628
- */
1629
- global $fs_active_plugins;
1630
- if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
1631
- $active_theme = wp_get_theme();
1632
-
1633
- foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
1634
- if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
1635
- if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
1636
- // Parent module is a theme and it's currently active.
1637
- return true;
1638
- }
1639
- }
1640
- }
1641
- }
1642
-
1643
- return false;
1644
- }
1645
-
1646
- /**
1647
- * Check if add-on parent plugin in activation mode.
1648
- *
1649
- * @author Vova Feldman (@svovaf)
1650
- * @since 1.0.7
1651
- *
1652
- * @return bool
1653
- */
1654
- function is_parent_in_activation() {
1655
- $parent_fs = $this->get_parent_instance();
1656
- if ( ! is_object( $parent_fs ) ) {
1657
- return false;
1658
- }
1659
-
1660
- return ( $parent_fs->is_activation_mode() );
1661
- }
1662
-
1663
- /**
1664
- * Is plugin in activation mode.
1665
- *
1666
- * @author Vova Feldman (@svovaf)
1667
- * @since 1.0.7
1668
- *
1669
- * @param bool $and_on
1670
- *
1671
- * @return bool
1672
- */
1673
- function is_activation_mode( $and_on = true ) {
1674
- return (
1675
- ( $this->is_on() || ! $and_on ) &&
1676
- ( ! $this->is_registered() || ( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
1677
- ( ! $this->is_enable_anonymous() ||
1678
- ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
1679
- );
1680
- }
1681
-
1682
- /**
1683
- * Check if current page is the opt-in/pending-activation page.
1684
- *
1685
- * @author Vova Feldman (@svovaf)
1686
- * @since 1.2.1.7
1687
- *
1688
- * @return bool
1689
- */
1690
- function is_activation_page() {
1691
- if ( $this->_menu->is_main_settings_page() ) {
1692
- return true;
1693
- }
1694
-
1695
- if ( ! $this->is_activation_mode() ) {
1696
- return false;
1697
- }
1698
-
1699
- // Check if current page is matching the activation page.
1700
- return $this->is_matching_url( $this->get_activation_url() );
1701
- }
1702
-
1703
- /**
1704
- * Check if URL path's are matching and that all querystring
1705
- * arguments of the $sub_url exist in the $url with the same values.
1706
- *
1707
- * WARNING:
1708
- * 1. This method doesn't check if the sub/domain are matching.
1709
- * 2. Ignore case sensitivity.
1710
- *
1711
- * @author Vova Feldman (@svovaf)
1712
- * @since 1.2.1.7
1713
- *
1714
- * @param string $sub_url
1715
- * @param string $url If argument is not set, check if the sub_url matching the current's page URL.
1716
- *
1717
- * @return bool
1718
- */
1719
- private function is_matching_url( $sub_url, $url = '' ) {
1720
- if ( empty( $url ) ) {
1721
- $url = $_SERVER['REQUEST_URI'];
1722
- }
1723
-
1724
- $url = strtolower( $url );
1725
- $sub_url = strtolower( $sub_url );
1726
-
1727
- if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
1728
- // Different path - DO NOT OVERRIDE PAGE.
1729
- return false;
1730
- }
1731
-
1732
- $url_params = array();
1733
- parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
1734
-
1735
- $sub_url_params = array();
1736
- parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
1737
-
1738
- foreach ( $sub_url_params as $key => $val ) {
1739
- if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
1740
- // Not matching query string - DO NOT OVERRIDE PAGE.
1741
- return false;
1742
- }
1743
- }
1744
-
1745
- return true;
1746
- }
1747
-
1748
- /**
1749
- * Get collection of all active plugins.
1750
- *
1751
- * @author Vova Feldman (@svovaf)
1752
- * @since 1.0.9
1753
- *
1754
- * @return array[string]array
1755
- */
1756
- private static function get_active_plugins() {
1757
- self::require_plugin_essentials();
1758
-
1759
- $active_plugin = array();
1760
- $all_plugins = get_plugins();
1761
- $active_plugins_basenames = get_option( 'active_plugins' );
1762
-
1763
- foreach ( $active_plugins_basenames as $plugin_basename ) {
1764
- $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
1765
- }
1766
-
1767
- return $active_plugin;
1768
- }
1769
-
1770
- /**
1771
- * Get collection of all plugins.
1772
- *
1773
- * @author Vova Feldman (@svovaf)
1774
- * @since 1.1.8
1775
- *
1776
- * @return array Key is the plugin file path and the value is an array of the plugin data.
1777
- */
1778
- private static function get_all_plugins() {
1779
- self::require_plugin_essentials();
1780
-
1781
- $all_plugins = get_plugins();
1782
- $active_plugins_basenames = get_option( 'active_plugins' );
1783
-
1784
- foreach ( $all_plugins as $basename => &$data ) {
1785
- // By default set to inactive (next foreach update the active plugins).
1786
- $data['is_active'] = false;
1787
- // Enrich with plugin slug.
1788
- $data['slug'] = self::get_plugin_slug( $basename );
1789
- }
1790
-
1791
- // Flag active plugins.
1792
- foreach ( $active_plugins_basenames as $basename ) {
1793
- if ( isset( $all_plugins[ $basename ] ) ) {
1794
- $all_plugins[ $basename ]['is_active'] = true;
1795
- }
1796
- }
1797
-
1798
- return $all_plugins;
1799
- }
1800
-
1801
-
1802
- /**
1803
- * Cached result of get_site_transient( 'update_plugins' )
1804
- *
1805
- * @author Vova Feldman (@svovaf)
1806
- * @since 1.1.8
1807
- *
1808
- * @var object
1809
- */
1810
- private static $_plugins_info;
1811
-
1812
- /**
1813
- * Helper function to get specified plugin's slug.
1814
- *
1815
- * @author Vova Feldman (@svovaf)
1816
- * @since 1.1.8
1817
- *
1818
- * @param $basename
1819
- *
1820
- * @return string
1821
- */
1822
- private static function get_plugin_slug( $basename ) {
1823
- if ( ! isset( self::$_plugins_info ) ) {
1824
- self::$_plugins_info = get_site_transient( 'update_plugins' );
1825
- }
1826
-
1827
- $slug = '';
1828
-
1829
- if ( is_object( self::$_plugins_info ) ) {
1830
- if ( isset( self::$_plugins_info->no_update ) &&
1831
- isset( self::$_plugins_info->no_update[ $basename ] ) &&
1832
- ! empty( self::$_plugins_info->no_update[ $basename ]->slug )
1833
- ) {
1834
- $slug = self::$_plugins_info->no_update[ $basename ]->slug;
1835
- } else if ( isset( self::$_plugins_info->response ) &&
1836
- isset( self::$_plugins_info->response[ $basename ] ) &&
1837
- ! empty( self::$_plugins_info->response[ $basename ]->slug )
1838
- ) {
1839
- $slug = self::$_plugins_info->response[ $basename ]->slug;
1840
- }
1841
- }
1842
-
1843
- if ( empty( $slug ) ) {
1844
- // Try to find slug from FS data.
1845
- $slug = self::find_slug_by_basename( $basename );
1846
- }
1847
-
1848
- if ( empty( $slug ) ) {
1849
- // Fallback to plugin's folder name.
1850
- $slug = dirname( $basename );
1851
- }
1852
-
1853
- return $slug;
1854
- }
1855
-
1856
- private static $_statics_loaded = false;
1857
-
1858
- /**
1859
- * Load static resources.
1860
- *
1861
- * @author Vova Feldman (@svovaf)
1862
- * @since 1.0.1
1863
- */
1864
- private static function _load_required_static() {
1865
- if ( self::$_statics_loaded ) {
1866
- return;
1867
- }
1868
-
1869
- self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
1870
-
1871
- self::$_static_logger->entrance();
1872
-
1873
- self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
1874
-
1875
- self::$_global_admin_notices = FS_Admin_Notice_Manager::instance( 'global' );
1876
-
1877
- add_action( 'admin_menu', array( 'Freemius', '_add_debug_section' ) );
1878
-
1879
- add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
1880
-
1881
- self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
1882
-
1883
- self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
1884
-
1885
- self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
1886
-
1887
- if ( 0 == did_action( 'plugins_loaded' ) ) {
1888
- add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
1889
- }
1890
-
1891
- self::$_statics_loaded = true;
1892
- }
1893
-
1894
- #----------------------------------------------------------------------------------
1895
- #region Localization
1896
- #----------------------------------------------------------------------------------
1897
-
1898
- /**
1899
- * Load framework's text domain.
1900
- *
1901
- * @author Vova Feldman (@svovaf)
1902
- * @since 1.2.1
1903
- */
1904
- static function _load_textdomain() {
1905
- if ( ! is_admin() ) {
1906
- return;
1907
- }
1908
-
1909
- global $fs_active_plugins;
1910
-
1911
- // Works both for plugins and themes.
1912
- load_plugin_textdomain(
1913
- 'freemius',
1914
- false,
1915
- $fs_active_plugins->newest->sdk_path . '/languages/'
1916
- );
1917
- }
1918
-
1919
- #endregion
1920
-
1921
- #----------------------------------------------------------------------------------
1922
- #region Debugging
1923
- #----------------------------------------------------------------------------------
1924
-
1925
- /**
1926
- * @author Vova Feldman (@svovaf)
1927
- * @since 1.0.8
1928
- */
1929
- static function _add_debug_section() {
1930
- if ( ! current_user_can( 'activate_plugins' )
1931
- && ! current_user_can( 'switch_themes' )
1932
- ) {
1933
- return;
1934
- }
1935
-
1936
- self::$_static_logger->entrance();
1937
-
1938
- $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
1939
-
1940
- if ( WP_FS__DEV_MODE ) {
1941
- // Add top-level debug menu item.
1942
- $hook = FS_Admin_Menu_Manager::add_page(
1943
- $title,
1944
- $title,
1945
- 'manage_options',
1946
- 'freemius',
1947
- array( 'Freemius', '_debug_page_render' )
1948
- );
1949
- } else {
1950
- // Add hidden debug page.
1951
- $hook = FS_Admin_Menu_Manager::add_subpage(
1952
- null,
1953
- $title,
1954
- $title,
1955
- 'manage_options',
1956
- 'freemius',
1957
- array( 'Freemius', '_debug_page_render' )
1958
- );
1959
- }
1960
-
1961
- if ( ! empty( $hook ) ) {
1962
- add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
1963
- }
1964
- }
1965
-
1966
- /**
1967
- * @author Vova Feldman (@svovaf)
1968
- * @since 1.1.7.3
1969
- */
1970
- static function _toggle_debug_mode() {
1971
- $is_on = fs_request_get( 'is_on', false, 'post' );
1972
-
1973
- if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
1974
- update_option( 'fs_debug_mode', $is_on );
1975
-
1976
- // Turn on/off storage logging.
1977
- FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
1978
- }
1979
-
1980
- exit;
1981
- }
1982
-
1983
- /**
1984
- * @author Vova Feldman (@svovaf)
1985
- * @since 1.2.1.6
1986
- */
1987
- static function _get_debug_log() {
1988
- $logs = FS_Logger::load_db_logs(
1989
- fs_request_get( 'filters', false, 'post' ),
1990
- ! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
1991
- ! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
1992
- );
1993
-
1994
- self::shoot_ajax_success( $logs );
1995
- }
1996
-
1997
- /**
1998
- * @author Vova Feldman (@svovaf)
1999
- * @since 1.2.1.7
2000
- */
2001
- static function _get_db_option() {
2002
- $option_name = fs_request_get( 'option_name' );
2003
-
2004
- $value = get_option( $option_name );
2005
-
2006
- $result = array(
2007
- 'name' => $option_name,
2008
- );
2009
-
2010
- if ( false !== $value ) {
2011
- if ( ! is_string( $value ) ) {
2012
- $value = json_encode( $value );
2013
- }
2014
-
2015
- $result['value'] = $value;
2016
- }
2017
-
2018
- self::shoot_ajax_success( $result );
2019
- }
2020
-
2021
- /**
2022
- * @author Vova Feldman (@svovaf)
2023
- * @since 1.2.1.7
2024
- */
2025
- static function _set_db_option() {
2026
- $option_name = fs_request_get( 'option_name' );
2027
- $option_value = fs_request_get( 'option_value' );
2028
-
2029
- if ( ! empty( $option_value ) ) {
2030
- update_option( $option_name, $option_value );
2031
- }
2032
-
2033
- self::shoot_ajax_success();
2034
- }
2035
-
2036
- /**
2037
- * @author Vova Feldman (@svovaf)
2038
- * @since 1.0.8
2039
- */
2040
- static function _debug_page_actions() {
2041
- self::_clean_admin_content_section();
2042
-
2043
- if ( fs_request_is_action( 'restart_freemius' ) ) {
2044
- check_admin_referer( 'restart_freemius' );
2045
-
2046
- // Clear accounts data.
2047
- self::$_accounts->clear( true );
2048
-
2049
- // Clear SDK reference cache.
2050
- delete_option( 'fs_active_plugins' );
2051
- } else if ( fs_request_is_action( 'simulate_trial' ) ) {
2052
- check_admin_referer( 'simulate_trial' );
2053
-
2054
- $fs = freemius( fs_request_get( 'module_id' ) );
2055
-
2056
- // Update SDK install to at least 24 hours before.
2057
- $fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
2058
- // Unset the trial shown timestamp.
2059
- unset( $fs->_storage->trial_promotion_shown );
2060
- } else if ( fs_request_is_action( 'delete_install' ) ) {
2061
- check_admin_referer( 'delete_install' );
2062
-
2063
- self::_delete_site_by_slug(
2064
- fs_request_get( 'slug' ),
2065
- fs_request_get( 'module_type' )
2066
- );
2067
- } else if ( fs_request_is_action( 'download_logs' ) ) {
2068
- check_admin_referer( 'download_logs' );
2069
-
2070
- $download_url = FS_Logger::download_db_logs(
2071
- fs_request_get( 'filters', false, 'post' )
2072
- );
2073
-
2074
- if ( false === $download_url ) {
2075
- wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
2076
- }
2077
-
2078
- fs_redirect( $download_url );
2079
- }
2080
- }
2081
-
2082
- /**
2083
- * @author Vova Feldman (@svovaf)
2084
- * @since 1.0.8
2085
- */
2086
- static function _debug_page_render() {
2087
- self::$_static_logger->entrance();
2088
-
2089
- $vars = array(
2090
- 'plugin_sites' => self::get_all_sites(),
2091
- 'theme_sites' => self::get_all_sites( WP_FS__MODULE_TYPE_THEME ),
2092
- 'users' => self::get_all_users(),
2093
- 'addons' => self::get_all_addons(),
2094
- 'account_addons' => self::get_all_account_addons(),
2095
- 'plugin_licenses' => self::get_all_licenses(),
2096
- 'theme_licenses' => self::get_all_licenses( WP_FS__MODULE_TYPE_THEME )
2097
- );
2098
-
2099
- fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
2100
- fs_require_once_template( 'debug.php', $vars );
2101
- }
2102
-
2103
- #endregion
2104
-
2105
- #----------------------------------------------------------------------------------
2106
- #region Connectivity Issues
2107
- #----------------------------------------------------------------------------------
2108
-
2109
- /**
2110
- * Check if Freemius should be turned on for the current plugin install.
2111
- *
2112
- * Note:
2113
- * $this->_is_on is updated in has_api_connectivity()
2114
- *
2115
- * @author Vova Feldman (@svovaf)
2116
- * @since 1.0.9
2117
- *
2118
- * @return bool
2119
- */
2120
- function is_on() {
2121
- self::$_static_logger->entrance();
2122
-
2123
- if ( isset( $this->_is_on ) ) {
2124
- return $this->_is_on;
2125
- }
2126
-
2127
- // If already installed or pending then sure it's on :)
2128
- if ( $this->is_registered() || $this->is_pending_activation() ) {
2129
- $this->_is_on = true;
2130
-
2131
- return true;
2132
- }
2133
-
2134
- return false;
2135
- }
2136
-
2137
- /**
2138
- * @author Vova Feldman (@svovaf)
2139
- * @since 1.1.7.3
2140
- *
2141
- * @param bool $flush_if_no_connectivity
2142
- *
2143
- * @return bool
2144
- */
2145
- private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
2146
- if ( ! isset( $this->_storage->connectivity_test ) ) {
2147
- // Connectivity test was never executed, or cache was cleared.
2148
- return true;
2149
- }
2150
-
2151
- if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
2152
- if ( WP_FS__IS_HTTP_REQUEST ) {
2153
- if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
2154
- // Domain changed.
2155
- return true;
2156
- }
2157
-
2158
- if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
2159
- // Server IP changed.
2160
- return true;
2161
- }
2162
- }
2163
- }
2164
-
2165
- if ( $this->_storage->connectivity_test['is_connected'] &&
2166
- $this->_storage->connectivity_test['is_active']
2167
- ) {
2168
- // API connected and Freemius is active - no need to run connectivity check.
2169
- return false;
2170
- }
2171
-
2172
- if ( $flush_if_no_connectivity ) {
2173
- /**
2174
- * If explicitly asked to flush when no connectivity - do it only
2175
- * if at least 10 sec passed from the last API connectivity test.
2176
- */
2177
- return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
2178
- ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
2179
- }
2180
-
2181
- /**
2182
- * @since 1.1.7 Don't check for connectivity on plugin downgrade.
2183
- */
2184
- $version = $this->get_plugin_version();
2185
- if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
2186
- // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
2187
- return true;
2188
- }
2189
-
2190
- return false;
2191
- }
2192
-
2193
- /**
2194
- * @author Vova Feldman (@svovaf)
2195
- * @since 1.1.7.4
2196
- *
2197
- * @return object|false
2198
- */
2199
- private function ping() {
2200
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
2201
- return false;
2202
- }
2203
-
2204
- $version = $this->get_plugin_version();
2205
-
2206
- $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
2207
-
2208
- return $this->get_api_plugin_scope()->ping(
2209
- $this->get_anonymous_id(),
2210
- array(
2211
- 'is_update' => json_encode( $is_update ),
2212
- 'version' => $version,
2213
- 'sdk' => $this->version,
2214
- 'is_admin' => json_encode( is_admin() ),
2215
- 'is_ajax' => json_encode( self::is_ajax() ),
2216
- 'is_cron' => json_encode( self::is_cron() ),
2217
- 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
2218
- )
2219
- );
2220
- }
2221
-
2222
- /**
2223
- * Check if there's any connectivity issue to Freemius API.
2224
- *
2225
- * @author Vova Feldman (@svovaf)
2226
- * @since 1.0.9
2227
- *
2228
- * @param bool $flush_if_no_connectivity
2229
- *
2230
- * @return bool
2231
- */
2232
- function has_api_connectivity( $flush_if_no_connectivity = false ) {
2233
- $this->_logger->entrance();
2234
-
2235
- if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
2236
- return $this->_has_api_connection;
2237
- }
2238
-
2239
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
2240
- isset( $this->_storage->connectivity_test ) &&
2241
- true === $this->_storage->connectivity_test['is_connected']
2242
- ) {
2243
- unset( $this->_storage->connectivity_test );
2244
- }
2245
-
2246
- if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
2247
- $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
2248
- /**
2249
- * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
2250
- *
2251
- * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
2252
- */
2253
- $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
2254
- $this->is_premium() ||
2255
- ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
2256
-
2257
- return $this->_has_api_connection;
2258
- }
2259
-
2260
- $pong = $this->ping();
2261
- $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
2262
-
2263
- if ( ! $is_connected ) {
2264
- // API failure.
2265
- $this->_add_connectivity_issue_message( $pong );
2266
- }
2267
-
2268
- $this->store_connectivity_info( $pong, $is_connected );
2269
-
2270
- return $this->_has_api_connection;
2271
- }
2272
-
2273
- /**
2274
- * @author Vova Feldman (@svovaf)
2275
- * @since 1.1.7.4
2276
- *
2277
- * @param object $pong
2278
- * @param bool $is_connected
2279
- */
2280
- private function store_connectivity_info( $pong, $is_connected ) {
2281
- $this->_logger->entrance();
2282
-
2283
- $version = $this->get_plugin_version();
2284
-
2285
- if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
2286
- $is_active = false;
2287
- } else {
2288
- $is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
2289
- }
2290
-
2291
- $is_active = $this->apply_filters(
2292
- 'is_on',
2293
- $is_active,
2294
- $this->is_plugin_update(),
2295
- $version
2296
- );
2297
-
2298
- $this->_storage->connectivity_test = array(
2299
- 'is_connected' => $is_connected,
2300
- 'host' => $_SERVER['HTTP_HOST'],
2301
- 'server_ip' => WP_FS__REMOTE_ADDR,
2302
- 'is_active' => $is_active,
2303
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
2304
- // Last version with connectivity attempt.
2305
- 'version' => $version,
2306
- );
2307
-
2308
- $this->_has_api_connection = $is_connected;
2309
- $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
2310
- }
2311
-
2312
- /**
2313
- * Force turning Freemius on.
2314
- *
2315
- * @author Vova Feldman (@svovaf)
2316
- * @since 1.1.8.1
2317
- *
2318
- * @return bool TRUE if successfully turned on.
2319
- */
2320
- private function turn_on() {
2321
- $this->_logger->entrance();
2322
-
2323
- if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
2324
- return false;
2325
- }
2326
-
2327
- $updated_connectivity = $this->_storage->connectivity_test;
2328
- $updated_connectivity['is_active'] = true;
2329
- $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
2330
- $this->_storage->connectivity_test = $updated_connectivity;
2331
-
2332
- $this->_is_on = true;
2333
-
2334
- return true;
2335
- }
2336
-
2337
- /**
2338
- * Anonymous and unique site identifier (Hash).
2339
- *
2340
- * @author Vova Feldman (@svovaf)
2341
- * @since 1.1.0
2342
- *
2343
- * @return string
2344
- */
2345
- function get_anonymous_id() {
2346
- $unique_id = self::$_accounts->get_option( 'unique_id' );
2347
 
2348
- if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
2349
- $key = get_site_url();
 
 
2350
 
2351
- // If localhost, assign microtime instead of domain.
2352
- if ( WP_FS__IS_LOCALHOST ||
2353
- false !== strpos( $key, 'localhost' ) ||
2354
- false === strpos( $key, '.' )
2355
- ) {
2356
- $key = microtime();
2357
- }
2358
 
 
2359
  /**
2360
- * Base the unique identifier on the WP secure authentication key. Which
2361
- * turns the key into a secret anonymous identifier.
 
 
2362
  *
2363
  * @author Vova Feldman (@svovaf)
2364
- * @since 1.2.3
2365
  */
2366
- $unique_id = md5( $key . SECURE_AUTH_KEY );
 
 
 
 
2367
 
2368
- self::$_accounts->set_option( 'unique_id', $unique_id, true );
 
 
2369
  }
2370
 
2371
- $this->_logger->departure( $unique_id );
2372
 
2373
- return $unique_id;
2374
- }
2375
 
2376
- /**
2377
- * @author Vova Feldman (@svovaf)
2378
- * @since 1.1.7.4
2379
- *
2380
- * @return \WP_User
2381
- */
2382
- static function _get_current_wp_user() {
2383
- self::require_pluggable_essentials();
2384
-
2385
- return wp_get_current_user();
2386
- }
2387
-
2388
- /**
2389
- * @author Vova Feldman (@svovaf)
2390
- * @since 1.2.1.7
2391
- *
2392
- * @param string $email
2393
- *
2394
- * @return bool
2395
- */
2396
- static function is_valid_email( $email ) {
2397
- if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
2398
- return false;
2399
- }
2400
-
2401
- $parts = explode( '@', $email );
2402
-
2403
- if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
2404
- return false;
2405
- }
2406
-
2407
- $blacklist = array(
2408
- 'admin.',
2409
- 'webmaster.',
2410
- 'localhost.',
2411
- 'dev.',
2412
- 'development.',
2413
- 'test.',
2414
- 'stage.',
2415
- 'staging.',
2416
- );
2417
-
2418
- // Make sure domain is not one of the blacklisted.
2419
- foreach ( $blacklist as $invalid ) {
2420
- if ( 0 === strpos( $parts[1], $invalid ) ) {
2421
- return false;
2422
- }
2423
- }
2424
-
2425
- // Get the UTF encoded domain name.
2426
- $domain = idn_to_ascii( $parts[1] ) . '.';
2427
-
2428
- return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
2429
- }
2430
-
2431
- /**
2432
- * Generate API connectivity issue message.
2433
- *
2434
- * @author Vova Feldman (@svovaf)
2435
- * @since 1.0.9
2436
- *
2437
- * @param mixed $api_result
2438
- * @param bool $is_first_failure
2439
- */
2440
- function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
2441
- if ( ! $this->is_premium() && $this->_enable_anonymous ) {
2442
- // Don't add message if it's the free version and can run anonymously.
2443
- return;
2444
- }
2445
-
2446
- if ( ! function_exists( 'wp_nonce_url' ) ) {
2447
- require_once ABSPATH . 'wp-includes/functions.php';
2448
- }
2449
-
2450
- $current_user = self::_get_current_wp_user();
2451
- // $admin_email = get_option( 'admin_email' );
2452
- $admin_email = $current_user->user_email;
2453
-
2454
- // Aliases.
2455
- $deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
2456
- $deactivate_plugin_desc = $this->esc_html_inline( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'deactivate-plugin-desc' );
2457
- $install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
2458
- $install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
2459
- $fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
2460
- $fix_issue_desc = $this->esc_html_inline( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'fix-issue-desc' );
2461
- /* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
2462
- $x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
2463
- $sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
2464
- $happy_to_resolve_issue_asap = $this->esc_html_inline( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'happy-to-resolve-issue-asap' );
2465
 
2466
- $message = false;
2467
- if ( is_object( $api_result ) &&
2468
- isset( $api_result->error ) &&
2469
- isset( $api_result->error->code )
2470
- ) {
2471
- switch ( $api_result->error->code ) {
2472
- case 'curl_missing':
2473
- $missing_methods = '';
2474
- if ( is_array( $api_result->missing_methods ) &&
2475
- ! empty( $api_result->missing_methods )
2476
- ) {
2477
- foreach ( $api_result->missing_methods as $m ) {
2478
- if ( 'curl_version' === $m ) {
2479
- continue;
2480
- }
2481
-
2482
- if ( ! empty( $missing_methods ) ) {
2483
- $missing_methods .= ', ';
2484
- }
2485
-
2486
- $missing_methods .= sprintf( '<code>%s</code>', $m );
2487
- }
2488
-
2489
- if ( ! empty( $missing_methods ) ) {
2490
- $missing_methods = sprintf(
2491
- '<br><br><b>%s</b> %s',
2492
- $this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
2493
- $missing_methods
2494
- );
2495
- }
2496
- }
2497
-
2498
- $message = sprintf(
2499
- $x_requires_access_to_api . ' ' .
2500
- $this->esc_html_inline( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.', 'curl-missing-message' ) . ' ' .
2501
- $missing_methods .
2502
- ' %s',
2503
- '<b>' . $this->get_plugin_name() . '</b>',
2504
- sprintf(
2505
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2506
- sprintf(
2507
- '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
2508
- $this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
2509
- ' - ' . sprintf(
2510
- $this->get_text_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'curl-missing-no-clue-desc' ),
2511
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2512
- )
2513
- ),
2514
- sprintf(
2515
- '<b>%s</b> - %s',
2516
- $sysadmin_title,
2517
- esc_html( sprintf( $this->get_text_inline( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.', 'curl-missing-sysadmin-desc' ), $this->get_module_label( true ) ) )
2518
- ),
2519
- sprintf(
2520
- '<a href="%s"><b>%s</b></a> - %s',
2521
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
2522
- $deactivate_plugin_title,
2523
- $deactivate_plugin_desc
2524
- )
2525
- )
2526
- );
2527
- break;
2528
- case 'cloudflare_ddos_protection':
2529
- $message = sprintf(
2530
- $x_requires_access_to_api . ' ' .
2531
- $this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
2532
- $happy_to_resolve_issue_asap .
2533
- ' %s',
2534
- '<b>' . $this->get_plugin_name() . '</b>',
2535
- sprintf(
2536
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2537
- sprintf(
2538
- '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
2539
- $fix_issue_title,
2540
- ' - ' . sprintf(
2541
- $fix_issue_desc,
2542
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2543
- )
2544
- ),
2545
- sprintf(
2546
- '<a href="%s" target="_blank"><b>%s</b></a> - %s',
2547
- sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
2548
- $install_previous_title,
2549
- $install_previous_desc
2550
- ),
2551
- sprintf(
2552
- '<a href="%s"><b>%s</b></a> - %s',
2553
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
2554
- $deactivate_plugin_title,
2555
- $deactivate_plugin_desc
2556
- )
2557
- )
2558
- );
2559
- break;
2560
- case 'squid_cache_block':
2561
- $message = sprintf(
2562
- $x_requires_access_to_api . ' ' .
2563
- $this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
2564
- ' %s',
2565
- '<b>' . $this->get_plugin_name() . '</b>',
2566
- sprintf(
2567
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2568
- sprintf(
2569
- '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
2570
- $this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
2571
- sprintf(
2572
- $this->esc_html_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'squid-no-clue-desc' ),
2573
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2574
- )
2575
- ),
2576
- sprintf(
2577
- '<b>%s</b> - %s',
2578
- $sysadmin_title,
2579
- sprintf(
2580
- $this->esc_html_inline( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.', 'squid-sysadmin-desc' ),
2581
- // We use a filter since the plugin might require additional API connectivity.
2582
- '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com', 'wp.freemius.com' ) ) ) . '</b>',
2583
- $this->_module_type
2584
- )
2585
- ),
2586
- sprintf(
2587
- '<a href="%s"><b>%s</b></a> - %s',
2588
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
2589
- $deactivate_plugin_title,
2590
- $deactivate_plugin_desc
2591
- )
2592
- )
2593
- );
2594
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2595
  // default:
2596
  // $message = $this->get_text_inline( 'connectivity-test-fails-message' );
2597
  // break;
2598
- }
2599
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.3
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ // "final class"
13
+ class Freemius extends Freemius_Abstract {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
+ * SDK Version
16
  *
17
+ * @var string
18
+ */
19
+ public $version = WP_FS__SDK_VERSION;
20
+
21
+ #region Plugin Info
22
+
23
+ /**
24
+ * @since 1.0.1
25
  *
26
+ * @var string
27
  */
28
+ private $_slug;
29
 
30
  /**
31
+ * @since 1.0.0
32
  *
33
+ * @var string
34
+ */
35
+ private $_plugin_basename;
36
+ /**
37
+ * @since 1.0.0
38
  *
39
+ * @var string
40
  */
41
+ private $_free_plugin_basename;
 
42
  /**
43
+ * @since 1.0.0
44
+ *
45
+ * @var string
46
+ */
47
+ private $_plugin_dir_path;
48
+ /**
49
+ * @since 1.0.0
50
  *
51
+ * @var string
52
+ */
53
+ private $_plugin_dir_name;
54
+ /**
55
+ * @since 1.0.0
56
  *
57
+ * @var string
58
  */
59
+ private $_plugin_main_file_path;
60
+ /**
61
+ * @var string[]
62
+ */
63
+ private $_plugin_data;
64
+ /**
65
+ * @since 1.0.9
66
+ *
67
+ * @var string
68
+ */
69
+ private $_plugin_name;
70
+ /**
71
+ * @since 1.2.2
72
+ *
73
+ * @var string
74
+ */
75
+ private $_module_type;
 
 
 
 
 
 
 
76
 
77
+ #endregion Plugin Info
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
+ /**
80
+ * @since 1.0.9
81
+ *
82
+ * @var bool If false, don't turn Freemius on.
83
+ */
84
+ private $_is_on;
 
 
 
 
 
85
 
86
+ /**
87
+ * @since 1.1.3
88
+ *
89
+ * @var bool If false, don't turn Freemius on.
90
+ */
91
+ private $_is_anonymous;
 
 
 
 
 
92
 
93
+ /**
94
+ * @since 1.0.9
95
+ * @var bool If false, issues with connectivity to Freemius API.
96
+ */
97
+ private $_has_api_connection;
98
 
99
+ /**
100
+ * @since 1.0.9
101
+ * @since 2.0.0 Default to true since we need the property during the instance construction, prior to the dynamic_init() execution.
102
+ * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
103
+ */
104
+ private $_enable_anonymous = true;
105
 
106
+ /**
107
+ * @since 1.1.7.5
108
+ * @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
109
+ */
110
+ private $_anonymous_mode;
111
 
112
  /**
113
+ * @since 1.1.9
114
+ * @var bool Hints the SDK if plugin have any free plans.
 
 
115
  */
116
+ private $_is_premium_only;
 
117
 
118
+ /**
119
+ * @since 1.2.1.6
120
+ * @var bool Hints the SDK if plugin have premium code version at all.
121
+ */
122
+ private $_has_premium_version;
123
 
124
+ /**
125
+ * @since 1.2.1.6
126
+ * @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
127
+ */
128
+ private $_ignore_pending_mode;
129
 
130
+ /**
131
+ * @since 1.0.8
132
+ * @var bool Hints the SDK if the plugin has any paid plans.
133
+ */
134
+ private $_has_paid_plans;
135
 
136
+ /**
137
+ * @since 1.2.1.5
138
+ * @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
139
+ * without a specified period, if positive - the number of trial days.
140
+ */
141
+ private $_trial_days = - 1;
142
 
143
+ /**
144
+ * @since 1.2.1.5
145
+ * @var bool Hints the SDK if the trial requires a payment method or not.
146
+ */
147
+ private $_is_trial_require_payment = false;
 
 
 
 
148
 
149
+ /**
150
+ * @since 1.0.7
151
+ * @var bool Hints the SDK if the plugin is WordPress.org compliant.
152
+ */
153
+ private $_is_org_compliant;
154
 
155
+ /**
156
+ * @since 1.0.7
157
+ * @var bool Hints the SDK if the plugin is has add-ons.
158
+ */
159
+ private $_has_addons;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
+ /**
162
+ * @since 1.1.6
163
+ * @var string[]bool.
164
+ */
165
+ private $_permissions;
166
 
167
+ /**
168
+ * @var FS_Storage
169
+ */
170
+ private $_storage;
171
 
172
+ /**
173
+ * @since 1.2.2.7
174
+ * @var FS_Cache_Manager
175
+ */
176
+ private $_cache;
177
 
178
+ /**
179
+ * @since 1.0.0
180
+ *
181
+ * @var FS_Logger
182
+ */
183
+ private $_logger;
184
+ /**
185
+ * @since 1.0.4
186
+ *
187
+ * @var FS_Plugin
188
+ */
189
+ private $_plugin = false;
190
+ /**
191
+ * @since 1.0.4
192
+ *
193
+ * @var FS_Plugin|false
194
+ */
195
+ private $_parent_plugin = false;
196
+ /**
197
+ * @since 1.1.1
198
+ *
199
+ * @var Freemius
200
+ */
201
+ private $_parent = false;
202
+ /**
203
+ * @since 1.0.1
204
+ *
205
+ * @var FS_User
206
+ */
207
+ private $_user = false;
208
+ /**
209
+ * @since 1.0.1
210
+ *
211
+ * @var FS_Site
212
+ */
213
+ private $_site = false;
214
+ /**
215
+ * @since 1.0.1
216
+ *
217
+ * @var FS_Plugin_License
218
+ */
219
+ private $_license;
220
+ /**
221
+ * @since 1.0.2
222
+ *
223
+ * @var FS_Plugin_Plan[]
224
+ */
225
+ private $_plans = false;
226
+ /**
227
+ * @var FS_Plugin_License[]
228
+ * @since 1.0.5
229
+ */
230
+ private $_licenses = false;
231
 
232
+ /**
233
+ * @since 1.0.1
234
+ *
235
+ * @var FS_Admin_Menu_Manager
236
+ */
237
+ private $_menu;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
+ /**
240
+ * @var FS_Admin_Notices
241
+ */
242
+ private $_admin_notices;
243
 
244
  /**
245
+ * @since 1.1.6
 
246
  *
247
+ * @var FS_Admin_Notices
248
+ */
249
+ private static $_global_admin_notices;
250
+
251
+ /**
252
+ * @var FS_Logger
253
+ * @since 1.0.0
254
+ */
255
+ private static $_static_logger;
256
+
257
+ /**
258
+ * @var FS_Options
259
+ * @since 1.0.2
260
+ */
261
+ private static $_accounts;
262
+
263
+ /**
264
+ * @since 1.2.2
265
  *
266
+ * @var number
267
  */
268
+ private $_module_id;
 
 
 
 
269
 
270
+ /**
271
+ * @var Freemius[]
272
+ */
273
+ private static $_instances = array();
274
 
275
  /**
276
+ * @since 1.2.3
 
277
  *
278
+ * @var FS_Affiliate
279
+ */
280
+ private $affiliate = null;
281
+
282
+ /**
283
+ * @since 1.2.3
284
  *
285
+ * @var FS_AffiliateTerms
286
  */
287
+ private $plugin_affiliate_terms = null;
 
 
 
 
288
 
289
+ /**
290
+ * @since 1.2.3
291
+ *
292
+ * @var FS_AffiliateTerms
293
+ */
294
+ private $custom_affiliate_terms = null;
295
 
296
  /**
297
+ * @since 2.0.0
 
298
  *
299
+ * @var bool
300
+ */
301
+ private $_is_multisite_integrated;
302
+
303
+ /**
304
+ * @since 2.0.0
305
  *
306
+ * @var bool True if the current request is for a network admin screen and the plugin is network active.
307
  */
308
+ private $_is_network_active;
 
 
 
309
 
310
+ /**
311
+ * @since 2.0.0
312
+ *
313
+ * @var int|null The original blog ID the plugin was loaded with.
314
+ */
315
+ private $_blog_id = null;
316
 
317
+ /**
318
+ * @since 2.0.0
319
+ *
320
+ * @var int|null The current execution context. When true, run on network context. When int, run on the specified blog context.
321
+ */
322
+ private $_context_is_network_or_blog_id = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
 
324
+ /**
325
+ * @since 2.0.0
326
+ *
327
+ * @var string
328
+ */
329
+ private $_dynamically_added_top_level_page_hook_name = '';
330
+
331
+ #region Uninstall Reasons IDs
332
+
333
+ const REASON_NO_LONGER_NEEDED = 1;
334
+ const REASON_FOUND_A_BETTER_PLUGIN = 2;
335
+ const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
336
+ const REASON_BROKE_MY_SITE = 4;
337
+ const REASON_SUDDENLY_STOPPED_WORKING = 5;
338
+ const REASON_CANT_PAY_ANYMORE = 6;
339
+ const REASON_OTHER = 7;
340
+ const REASON_DIDNT_WORK = 8;
341
+ const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
342
+ const REASON_COULDNT_MAKE_IT_WORK = 10;
343
+ const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
344
+ const REASON_NOT_WORKING = 12;
345
+ const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
346
+ const REASON_DIDNT_WORK_AS_EXPECTED = 14;
347
+ const REASON_TEMPORARY_DEACTIVATION = 15;
348
+
349
+ #endregion
350
+
351
+ /* Ctor
352
+ ------------------------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
+ /**
355
+ * Main singleton instance.
356
+ *
357
+ * @author Vova Feldman (@svovaf)
358
+ * @since 1.0.0
359
+ *
360
+ * @param number $module_id
361
+ * @param string|bool $slug
362
+ * @param bool $is_init Since 1.2.1 Is initiation sequence.
363
+ */
364
+ private function __construct( $module_id, $slug = false, $is_init = false ) {
365
+ if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
366
+ $this->store_id_slug_type_path_map( $module_id, $slug );
367
+ }
368
 
369
+ $this->_module_id = $module_id;
370
+ $this->_slug = $this->get_slug();
371
+ $this->_module_type = $this->get_module_type();
372
 
373
+ $this->_blog_id = is_multisite() ? get_current_blog_id() : null;
 
374
 
375
+ $this->_storage = FS_Storage::instance( $this->_module_type, $this->_slug );
 
 
376
 
377
+ $this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
378
 
379
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
 
 
 
 
 
 
 
 
380
 
381
+ $this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
382
+ $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
383
+ $this->_plugin_basename = $this->get_plugin_basename();
384
+ $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
385
 
386
+ $this->_is_multisite_integrated = (
387
+ defined( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) &&
388
+ ( true === constant( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) )
389
+ );
 
390
 
391
+ $this->_is_network_active = (
392
+ is_multisite() &&
393
+ $this->_is_multisite_integrated &&
394
+ // Themes are always network activated, but the ACTUAL activation is per site.
395
+ $this->is_plugin() &&
396
+ ( is_plugin_active_for_network( $this->_plugin_basename ) ||
397
+ // Plugin network level activation or uninstall.
398
+ is_plugin_inactive( $this->_plugin_basename ) )
399
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
 
401
+ $this->_storage->set_network_active(
402
+ $this->_is_network_active,
403
+ $this->is_delegated_connection()
404
+ );
405
 
406
+ #region Migration
 
 
 
 
 
 
407
 
408
+ if ( is_multisite() ) {
409
  /**
410
+ * If the install_timestamp exists on the site level but doesn't exist on the
411
+ * network level storage, it means that we need to process the storage with migration.
412
+ *
413
+ * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, install_timestamp will be already set in the network level storage.
414
  *
415
  * @author Vova Feldman (@svovaf)
416
+ * @since 2.0.0
417
  */
418
+ if ( false === $this->_storage->get( 'install_timestamp', false, true ) &&
419
+ false !== $this->_storage->get( 'install_timestamp', false, false )
420
+ ) {
421
+ // Initiate storage migration.
422
+ $this->_storage->migrate_to_network();
423
 
424
+ // Migrate module cache to network level storage.
425
+ $this->_cache->migrate_to_network();
426
+ }
427
  }
428
 
429
+ #endregion
430
 
431
+ $base_name_split = explode( '/', $this->_plugin_basename );
432
+ $this->_plugin_dir_name = $base_name_split[0];
433
 
434
+ if ( $this->_logger->is_on() ) {
435
+ $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
436
+ $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
437
+ $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
438
+ $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
439
+ $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
440
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
 
442
+ // Remember link between file to slug.
443
+ $this->store_file_slug_map();
444
+
445
+ // Store plugin's initial install timestamp.
446
+ if ( ! isset( $this->_storage->install_timestamp ) ) {
447
+ $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
448
+ }
449
+
450
+ if ( ! is_object( $this->_plugin ) ) {
451
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
452
+ }
453
+
454
+ $this->_admin_notices = FS_Admin_Notices::instance(
455
+ $this->_slug . ( $this->is_theme() ? ':theme' : '' ),
456
+ /**
457
+ * Ensure that the admin notice will always have a title by using the stored plugin title if available and
458
+ * retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
459
+ *
460
+ * @author Leo Fajardo (@leorw)
461
+ * @since 1.2.2
462
+ */
463
+ ( is_object( $this->_plugin ) ? $this->_plugin->title : $this->get_plugin_name() ),
464
+ $this->get_unique_affix()
465
+ );
466
+
467
+ if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
468
+ 'true' === fs_request_is_action( 'restart_freemius' )
469
+ ) {
470
+ FS_Api::clear_cache();
471
+ $this->_cache->clear();
472
+ }
473
+
474
+ $this->_register_hooks();
475
+
476
+ /**
477
+ * Starting from version 2.0.0, `FS_Site` entities no longer have the `plan` property and have `plan_id`
478
+ * instead. This should be called before calling `_load_account()`, otherwise, `$this->_site` will not be
479
+ * loaded in `_load_account` for versions of SDK starting from 2.0.0.
480
+ *
481
+ * @author Leo Fajardo (@leorw)
482
+ */
483
+ self::migrate_install_plan_to_plan_id( $this->_storage );
484
+
485
+ $this->_load_account();
486
+
487
+ $this->_version_updates_handler();
488
+ }
489
+
490
+ /**
491
+ * Checks whether this module has a settings menu.
492
+ *
493
+ * @author Leo Fajardo (@leorw)
494
+ * @since 1.2.2
495
+ *
496
+ * @return bool
497
+ */
498
+ function has_settings_menu() {
499
+ return ( $this->_is_network_active && fs_is_network_admin() ) ?
500
+ $this->_menu->has_network_menu() :
501
+ $this->_menu->has_menu();
502
+ }
503
+
504
+ /**
505
+ * Check if the context module is free wp.org theme.
506
+ *
507
+ * This method is helpful because:
508
+ * 1. wp.org themes are limited to a single submenu item,
509
+ * and sub-submenu items are most likely not allowed (never verified).
510
+ * 2. wp.org themes are not allowed to redirect the user
511
+ * after the theme activation, therefore, the agreed UX
512
+ * is showing the opt-in as a modal dialog box after
513
+ * activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
514
+ *
515
+ * @author Vova Feldman (@svovaf)
516
+ * @since 1.2.2.7
517
+ *
518
+ * @return bool
519
+ */
520
+ function is_free_wp_org_theme() {
521
+ return (
522
+ $this->is_theme() &&
523
+ $this->is_org_repo_compliant() &&
524
+ ! $this->is_premium()
525
+ );
526
+ }
527
+
528
+ /**
529
+ * Checks whether this a submenu item is visible.
530
+ *
531
+ * @author Vova Feldman (@svovaf)
532
+ * @since 1.2.2.6
533
+ * @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page.
534
+ *
535
+ * @param string $slug
536
+ * @param bool $ignore_free_wp_org_theme_context This is used to decide if the associated tab should be shown
537
+ * or hidden.
538
+ *
539
+ * @return bool
540
+ */
541
+ function is_submenu_item_visible( $slug, $ignore_free_wp_org_theme_context = false ) {
542
+ if ( $this->is_admin_page( $slug ) ) {
543
+ /**
544
+ * It is the current context page, so show the submenu item
545
+ * so the user will have the right context page, even if it
546
+ * was set to hidden.
547
+ */
548
+ return true;
549
+ }
550
+
551
+ if ( ! $this->has_settings_menu() ) {
552
+ // No menu settings at all.
553
+ return false;
554
+ }
555
+
556
+ if ( ! $ignore_free_wp_org_theme_context && $this->is_free_wp_org_theme() ) {
557
+ /**
558
+ * wp.org themes are limited to a single submenu item, and
559
+ * sub-submenu items are most likely not allowed (never verified).
560
+ */
561
+ return false;
562
+ }
563
+
564
+ return $this->_menu->is_submenu_item_visible( $slug );
565
+ }
566
+
567
+ /**
568
+ * Check if a Freemius page should be accessible via the UI.
569
+ *
570
+ * @author Vova Feldman (@svovaf)
571
+ * @since 1.2.2.7
572
+ *
573
+ * @param string $slug
574
+ *
575
+ * @return bool
576
+ */
577
+ function is_page_visible( $slug ) {
578
+ if ( $this->is_admin_page( $slug ) ) {
579
+ return true;
580
+ }
581
+
582
+ return $this->_menu->is_submenu_item_visible( $slug, true, true );
583
+ }
584
+
585
+ /**
586
+ * @author Vova Feldman (@svovaf)
587
+ * @since 1.0.9
588
+ */
589
+ private function _version_updates_handler() {
590
+ if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
591
+ // Freemius version upgrade mode.
592
+ $this->_storage->sdk_last_version = $this->_storage->sdk_version;
593
+ $this->_storage->sdk_version = $this->version;
594
+
595
+ if ( empty( $this->_storage->sdk_last_version ) ||
596
+ version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
597
+ ) {
598
+ $this->_storage->sdk_upgrade_mode = true;
599
+ $this->_storage->sdk_downgrade_mode = false;
600
+ } else {
601
+ $this->_storage->sdk_downgrade_mode = true;
602
+ $this->_storage->sdk_upgrade_mode = false;
603
+
604
+ }
605
+
606
+ $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
607
+ }
608
+
609
+ $plugin_version = $this->get_plugin_version();
610
+ if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
611
+ // Plugin version upgrade mode.
612
+ $this->_storage->plugin_last_version = $this->_storage->plugin_version;
613
+ $this->_storage->plugin_version = $plugin_version;
614
+
615
+ if ( empty( $this->_storage->plugin_last_version ) ||
616
+ version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
617
+ ) {
618
+ $this->_storage->plugin_upgrade_mode = true;
619
+ $this->_storage->plugin_downgrade_mode = false;
620
+ } else {
621
+ $this->_storage->plugin_downgrade_mode = true;
622
+ $this->_storage->plugin_upgrade_mode = false;
623
+ }
624
+
625
+ if ( ! empty( $this->_storage->plugin_last_version ) ) {
626
+ // Different version of the plugin was installed before, therefore it's an update.
627
+ $this->_storage->is_plugin_new_install = false;
628
+ }
629
+
630
+ $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
631
+ }
632
+ }
633
+
634
+ #--------------------------------------------------------------------------------
635
+ #region Data Migration on SDK Update
636
+ #--------------------------------------------------------------------------------
637
+
638
+ /**
639
+ * @author Vova Feldman (@svovaf)
640
+ * @since 1.1.5
641
+ *
642
+ * @param string $sdk_prev_version
643
+ * @param string $sdk_version
644
+ */
645
+ function _sdk_version_update( $sdk_prev_version, $sdk_version ) {
646
+ /**
647
+ * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
648
+ */
649
+ if ( empty( $sdk_prev_version ) ) {
650
+ return;
651
+ }
652
+
653
+ if ( version_compare( $sdk_prev_version, '2.1.0', '<' ) &&
654
+ version_compare( $sdk_version, '2.1.0', '>=' )
655
+ ) {
656
+ $this->_storage->handle_gdpr_admin_notice = true;
657
+ }
658
+
659
+ if ( version_compare( $sdk_prev_version, '2.0.0', '<' ) &&
660
+ version_compare( $sdk_version, '2.0.0', '>=' )
661
+ ) {
662
+ $this->migrate_to_subscriptions_collection();
663
+
664
+ $this->consolidate_licenses();
665
+
666
+ // Clear trial_plan since it's now loaded from the plans collection when needed.
667
+ $this->_storage->remove( 'trial_plan', true, false );
668
+ }
669
+
670
+ if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
671
+ version_compare( $sdk_version, '1.2.3', '>=' )
672
+ ) {
673
+ /**
674
+ * Starting from version 1.2.3, paths are stored as relative paths and not absolute paths; so when upgrading to 1.2.3, make paths relative.
675
+ *
676
+ * @author Leo Fajardo (@leorw)
677
+ */
678
+ $this->make_paths_relative();
679
+ }
680
+
681
+ if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
682
+ version_compare( $sdk_version, '1.1.5', '>=' )
683
+ ) {
684
+ // On version 1.1.5 merged connectivity and is_on data.
685
+ if ( isset( $this->_storage->connectivity_test ) ) {
686
+ if ( ! isset( $this->_storage->is_on ) ) {
687
+ unset( $this->_storage->connectivity_test );
688
+ } else {
689
+ $connectivity_data = $this->_storage->connectivity_test;
690
+ $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
691
+ $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
692
+
693
+ // Override.
694
+ $this->_storage->connectivity_test = $connectivity_data;
695
+
696
+ // Remove previous structure.
697
+ unset( $this->_storage->is_on );
698
+ }
699
+
700
+ }
701
+ }
702
+ }
703
+
704
+ /**
705
+ * @author Leo Fajardo (@leorw)
706
+ * @since 2.0.0
707
+ *
708
+ * @param \FS_Storage $storage
709
+ * @param bool|int|null $blog_id
710
+ */
711
+ private static function migrate_install_plan_to_plan_id( FS_Storage $storage, $blog_id = null ) {
712
+ if ( empty( $storage->sdk_version ) ) {
713
+ // New installation of the plugin, no need to upgrade.
714
+ return;
715
+ }
716
+
717
+ if ( ! version_compare( $storage->sdk_version, '2.0.0', '<' ) ) {
718
+ // Previous version is >= 2.0.0, so no need to migrate.
719
+ return;
720
+ }
721
+
722
+ // Alias.
723
+ $module_type = $storage->get_module_type();
724
+ $module_slug = $storage->get_module_slug();
725
+
726
+ $installs = self::get_all_sites( $module_type, $blog_id );
727
+ $install = isset( $installs[ $module_slug ] ) ? $installs[ $module_slug ] : null;
728
+
729
+ if ( ! is_object( $install ) ) {
730
+ return;
731
+ }
732
+
733
+ if ( isset( $install->plan ) && is_object( $install->plan ) ) {
734
+ if ( isset( $install->plan->id ) && ! empty( $install->plan->id ) ) {
735
+ $install->plan_id = self::_decrypt( $install->plan->id );
736
+ }
737
+
738
+ unset( $install->plan );
739
+
740
+ $installs[ $module_slug ] = clone $install;
741
+
742
+ self::set_account_option_by_module(
743
+ $module_type,
744
+ 'sites',
745
+ $installs,
746
+ true,
747
+ $blog_id
748
+ );
749
+ }
750
+ }
751
+
752
+ /**
753
+ * @author Leo Fajardo (@leorw)
754
+ * @since 2.0.0
755
+ */
756
+ private function migrate_to_subscriptions_collection() {
757
+ if ( ! is_object( $this->_site ) ) {
758
+ return;
759
+ }
760
+
761
+ if ( isset( $this->_storage->subscription ) && is_object( $this->_storage->subscription ) ) {
762
+ $this->_storage->subscriptions = array( $this->_storage->subscription );
763
+ }
764
+ }
765
+
766
+ /**
767
+ * @author Leo Fajardo (@leorw)
768
+ * @since 2.0.0
769
+ */
770
+ private function consolidate_licenses() {
771
+ $plugin_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_PLUGIN );
772
+ if ( isset( $plugin_licenses[ $this->_slug ] ) ) {
773
+ $plugin_licenses = $plugin_licenses[ $this->_slug ];
774
+ } else {
775
+ $plugin_licenses = array();
776
+ }
777
+
778
+ $theme_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_THEME );
779
+ if ( isset( $theme_licenses[ $this->_slug ] ) ) {
780
+ $theme_licenses = $theme_licenses[ $this->_slug ];
781
+ } else {
782
+ $theme_licenses = array();
783
+ }
784
+
785
+ if ( empty( $plugin_licenses ) && empty( $theme_licenses ) ) {
786
+ return;
787
+ }
788
+
789
+ $all_licenses = array();
790
+ $user_id_license_ids_map = array();
791
+
792
+ foreach ( $plugin_licenses as $user_id => $user_licenses ) {
793
+ if ( is_array( $user_licenses ) ) {
794
+ if ( ! isset( $user_license_ids[ $user_id ] ) ) {
795
+ $user_id_license_ids_map[ $user_id ] = array();
796
+ }
797
+
798
+ foreach ( $user_licenses as $user_license ) {
799
+ $all_licenses[] = $user_license;
800
+ $user_id_license_ids_map[ $user_id ][] = $user_license->id;
801
+ }
802
+ }
803
+ }
804
+
805
+ foreach ( $theme_licenses as $user_id => $user_licenses ) {
806
+ if ( is_array( $user_licenses ) ) {
807
+ if ( ! isset( $user_license_ids[ $user_id ] ) ) {
808
+ $user_id_license_ids_map[ $user_id ] = array();
809
+ }
810
+
811
+ foreach ( $user_licenses as $user_license ) {
812
+ $all_licenses[] = $user_license;
813
+ $user_id_license_ids_map[ $user_id ][] = $user_license->id;
814
+ }
815
+ }
816
+ }
817
+
818
+ self::store_user_id_license_ids_map(
819
+ $user_id_license_ids_map,
820
+ $this->_module_id
821
+ );
822
+
823
+ $this->_store_licenses( true, $this->_module_id, $all_licenses );
824
+ }
825
+
826
+ /**
827
+ * Makes paths relative.
828
+ *
829
+ * @author Leo Fajardo (@leorw)
830
+ * @since 1.2.3
831
+ */
832
+ private function make_paths_relative() {
833
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
834
+
835
+ if ( isset( $id_slug_type_path_map[ $this->_module_id ]['path'] ) ) {
836
+ $id_slug_type_path_map[ $this->_module_id ]['path'] = $this->get_relative_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
837
+
838
+ self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
839
+ }
840
+
841
+ if ( isset( $this->_storage->plugin_main_file ) ) {
842
+ $plugin_main_file = $this->_storage->plugin_main_file;
843
+
844
+ if ( isset( $plugin_main_file->path ) ) {
845
+ $this->_storage->plugin_main_file->path = $this->get_relative_path( $this->_storage->plugin_main_file->path );
846
+ } else if ( isset( $plugin_main_file->prev_path ) ) {
847
+ $this->_storage->plugin_main_file->prev_path = $this->get_relative_path( $this->_storage->plugin_main_file->prev_path );
848
+ }
849
+ }
850
+
851
+ // Remove invalid path that is still associated with the current slug if there's any.
852
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
853
+ foreach ( $file_slug_map as $plugin_basename => $slug ) {
854
+ if ( $slug === $this->_slug &&
855
+ $plugin_basename !== $this->_plugin_basename &&
856
+ ! file_exists( $this->get_absolute_path( $plugin_basename ) )
857
+ ) {
858
+ unset( $file_slug_map[ $plugin_basename ] );
859
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
860
+
861
+ break;
862
+ }
863
+ }
864
+ }
865
+
866
+ /**
867
+ * @author Vova Feldman (@svovaf)
868
+ * @since 1.2.2.7
869
+ *
870
+ * @param string $plugin_prev_version
871
+ * @param string $plugin_version
872
+ */
873
+ function _after_version_update( $plugin_prev_version, $plugin_version ) {
874
+ if ( $this->is_theme() ) {
875
+ // Expire the cache of the previous tabs since the theme may
876
+ // have setting updates.
877
+ $this->_cache->expire( 'tabs' );
878
+ $this->_cache->expire( 'tabs_stylesheets' );
879
+ }
880
+ }
881
+
882
+ /**
883
+ * A special migration logic for the $_accounts, executed for all the plugins in the system:
884
+ * - Moves some data to the network level storage.
885
+ * - If the plugin's connection was skipped for all sites, set the plugin as if it was network skipped.
886
+ * - If the plugin's connection was ignored for all sites, don't do anything in terms of the network connection.
887
+ * - If the plugin was connected to all sites by the same super-admin, set the plugin as if was network opted-in for all sites.
888
+ * - If there's at least one site that was connected by a super-admin, find the "main super-admin" (the one that installed the majority of the plugin installs) and set the plugin as if was network activated with the main super-admin, set all the sites that were skipped or opted-in with a different user to delegated mode. Then, prompt the currently logged super-admin to choose what to do with the ignored sites.
889
+ * - If there are any sites in the network which the connection decision was not yet taken for, set this plugin into network activation mode so a super-admin can choose what to do with the rest of the sites.
890
+ *
891
+ * @author Vova Feldman (@svovaf)
892
+ * @since 2.0.0
893
+ */
894
+ private static function migrate_accounts_to_network() {
895
+ $sites = self::get_sites();
896
+ $sites_count = count( $sites );
897
+ $connection_status = array();
898
+ $plugin_slugs = array();
899
+ foreach ( $sites as $site ) {
900
+ $blog_id = self::get_site_blog_id( $site );
901
+
902
+ self::$_accounts->migrate_to_network( $blog_id );
903
+
904
+ /**
905
+ * Build a list of all Freemius powered plugins slugs.
906
+ */
907
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array(), $blog_id );
908
+ foreach ( $id_slug_type_path_map as $module_id => $data ) {
909
+ if ( WP_FS__MODULE_TYPE_PLUGIN === $data['type'] ) {
910
+ $plugin_slugs[ $data['slug'] ] = true;
911
+ }
912
+ }
913
+
914
+ $installs = self::get_account_option( 'sites', WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
915
+
916
+ if ( is_array( $installs ) ) {
917
+ foreach ( $installs as $slug => $install ) {
918
+ if ( ! isset( $connection_status[ $slug ] ) ) {
919
+ $connection_status[ $slug ] = array();
920
+ }
921
+
922
+ if ( is_object( $install ) &&
923
+ FS_Site::is_valid_id( $install->id ) &&
924
+ FS_User::is_valid_id( $install->user_id )
925
+ ) {
926
+ $connection_status[ $slug ][ $blog_id ] = $install->user_id;
927
+ }
928
+ }
929
+ }
930
+ }
931
+
932
+ foreach ( $plugin_slugs as $slug => $true ) {
933
+ if ( ! isset( $connection_status[ $slug ] ) ) {
934
+ $connection_status[ $slug ] = array();
935
+ }
936
+
937
+ foreach ( $sites as $site ) {
938
+ $blog_id = self::get_site_blog_id( $site );
939
+
940
+ if ( isset( $connection_status[ $slug ][ $blog_id ] ) ) {
941
+ continue;
942
+ }
943
+
944
+ $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
945
+
946
+ $is_anonymous = $storage->get( 'is_anonymous', null, $blog_id );
947
+
948
+ if ( ! is_null( $is_anonymous ) ) {
949
+ // Since 1.1.3 is_anonymous is an array.
950
+ if ( is_array( $is_anonymous ) && isset( $is_anonymous['is'] ) ) {
951
+ $is_anonymous = $is_anonymous['is'];
952
+ }
953
+
954
+ if ( is_bool( $is_anonymous ) && true === $is_anonymous ) {
955
+ $connection_status[ $slug ][ $blog_id ] = 'skipped';
956
+ }
957
+ }
958
+
959
+ if ( ! isset( $connection_status[ $slug ][ $blog_id ] ) ) {
960
+ $connection_status[ $slug ][ $blog_id ] = 'ignored';
961
+ }
962
+ }
963
+ }
964
+
965
+ $super_admins = array();
966
+
967
+ foreach ( $connection_status as $slug => $blogs_status ) {
968
+ $skips = 0;
969
+ $ignores = 0;
970
+ $connections = 0;
971
+ $opted_in_users = array();
972
+ $opted_in_super_admins = array();
973
+
974
+ $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
975
+
976
+ foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
977
+ if ( 'skipped' === $status_or_user_id ) {
978
+ $skips ++;
979
+ } else if ( 'ignored' === $status_or_user_id ) {
980
+ $ignores ++;
981
+ } else if ( FS_User::is_valid_id( $status_or_user_id ) ) {
982
+ $connections ++;
983
+
984
+ if ( ! isset( $opted_in_users[ $status_or_user_id ] ) ) {
985
+ $opted_in_users[ $status_or_user_id ] = array();
986
+ }
987
+
988
+ $opted_in_users[ $status_or_user_id ][] = $blog_id;
989
+
990
+ if ( isset( $super_admins[ $status_or_user_id ] ) ||
991
+ self::is_super_admin( $status_or_user_id )
992
+ ) {
993
+ // Cache super-admin data.
994
+ $super_admins[ $status_or_user_id ] = true;
995
+
996
+ // Remember opted-in super-admins for the plugin.
997
+ $opted_in_super_admins[ $status_or_user_id ] = true;
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ $main_super_admin_user_id = null;
1003
+ $all_migrated = false;
1004
+ if ( $sites_count == $skips ) {
1005
+ // All sites were skipped -> network skip by copying the anonymous mode from any of the sites.
1006
+ $storage->is_anonymous_ms = $storage->is_anonymous;
1007
+
1008
+ $all_migrated = true;
1009
+ } else if ( $sites_count == $ignores ) {
1010
+ // Don't do anything, still in activation mode.
1011
+
1012
+ $all_migrated = true;
1013
+ } else if ( 0 < count( $opted_in_super_admins ) ) {
1014
+ // Find the super-admin with the majority of installs.
1015
+ $max_installs_by_super_admin = 0;
1016
+ foreach ( $opted_in_super_admins as $user_id => $true ) {
1017
+ $installs_count = count( $opted_in_users[ $user_id ] );
1018
+
1019
+ if ( $installs_count > $max_installs_by_super_admin ) {
1020
+ $max_installs_by_super_admin = $installs_count;
1021
+ $main_super_admin_user_id = $user_id;
1022
+ }
1023
+ }
1024
+
1025
+ if ( $sites_count == $connections && 1 == count( $opted_in_super_admins ) ) {
1026
+ // Super-admin opted-in for all sites in the network.
1027
+ $storage->is_network_connected = true;
1028
+
1029
+ $all_migrated = true;
1030
+ }
1031
+
1032
+ // Store network user.
1033
+ $storage->network_user_id = $main_super_admin_user_id;
1034
+
1035
+ $storage->network_install_blog_id = ( $sites_count == $connections ) ?
1036
+ // Since all sites are opted-in, associating with the main site.
1037
+ get_current_blog_id() :
1038
+ // Associating with the 1st found opted-in site.
1039
+ $opted_in_users[ $main_super_admin_user_id ][0];
1040
+
1041
+ /**
1042
+ * Make sure we migrate the plan ID of the network install, otherwise, if after the migration
1043
+ * the 1st page that will be loaded is the network level WP Admin and $storage->network_install_blog_id
1044
+ * is different than the main site of the network, the $this->_site will not be set since the plan_id
1045
+ * will be empty.
1046
+ */
1047
+ $storage->migrate_to_network();
1048
+ self::migrate_install_plan_to_plan_id( $storage, $storage->network_install_blog_id );
1049
+ } else {
1050
+ // At least one opt-in. All the opt-in were created by a non-super-admin.
1051
+ if ( 0 == $ignores ) {
1052
+ // All sites were opted-in or skipped, all by non-super-admin. So delegate all.
1053
+ $storage->store( 'is_delegated_connection', true, true );
1054
+
1055
+ $all_migrated = true;
1056
+ }
1057
+ }
1058
+
1059
+ if ( ! $all_migrated ) {
1060
+ /**
1061
+ * Delegate all sites that were:
1062
+ * 1) Opted-in by a user that is NOT the main-super-admin.
1063
+ * 2) Skipped and non of the sites was opted-in by a super-admin. If any site was opted-in by a super-admin, there will be a main-super-admin, and we consider the skip as if it was done by that user.
1064
+ */
1065
+ foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
1066
+ if ( $status_or_user_id == $main_super_admin_user_id ) {
1067
+ continue;
1068
+ }
1069
+
1070
+ if ( FS_User::is_valid_id( $status_or_user_id ) ||
1071
+ ( 'skipped' === $status_or_user_id && is_null( $main_super_admin_user_id ) )
1072
+ ) {
1073
+ $storage->store( 'is_delegated_connection', true, $blog_id );
1074
+ }
1075
+ }
1076
+ }
1077
+
1078
+
1079
+ if ( ( $connections + $skips > 0 ) ) {
1080
+ if ( $ignores > 0 ) {
1081
+ /**
1082
+ * If admin already opted-in or skipped in any of the network sites, and also
1083
+ * have sites which the connection decision was not yet taken, set this plugin
1084
+ * into network activation mode so the super-admin can choose what to do with
1085
+ * the rest of the sites.
1086
+ */
1087
+ self::set_network_upgrade_mode( $storage );
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+
1093
+ /**
1094
+ * Set a module into network upgrade mode.
1095
+ *
1096
+ * @author Vova Feldman (@svovaf)
1097
+ * @since 2.0.0
1098
+ *
1099
+ * @param \FS_Storage $storage
1100
+ *
1101
+ * @return bool
1102
+ */
1103
+ private static function set_network_upgrade_mode( FS_Storage $storage ) {
1104
+ return $storage->is_network_activation = true;
1105
+ }
1106
+
1107
+ /**
1108
+ * Will return true after upgrading to the SDK with the network level integration,
1109
+ * when the super-admin involvement is required regarding the rest of the sites.
1110
+ *
1111
+ * @author Vova Feldman (@svovaf)
1112
+ * @since 2.0.0
1113
+ *
1114
+ * @return bool
1115
+ */
1116
+ function is_network_upgrade_mode() {
1117
+ return $this->_storage->get( 'is_network_activation' );
1118
+ }
1119
+
1120
+ /**
1121
+ * Clear flag after the upgrade mode completion.
1122
+ *
1123
+ * @author Vova Feldman (@svovaf)
1124
+ * @since 2.0.0
1125
+ *
1126
+ * @return bool True if network activation was on and now completed.
1127
+ */
1128
+ private function network_upgrade_mode_completed() {
1129
+ if ( fs_is_network_admin() && $this->is_network_upgrade_mode() ) {
1130
+ $this->_storage->remove( 'is_network_activation' );
1131
+
1132
+ return true;
1133
+ }
1134
+
1135
+ return false;
1136
+ }
1137
+
1138
+ #endregion
1139
+
1140
+ /**
1141
+ * This action is connected to the 'plugins_loaded' hook and helps to determine
1142
+ * if this is a new plugin installation or a plugin update.
1143
+ *
1144
+ * There are 3 different use-cases:
1145
+ * 1) New plugin installation right with Freemius:
1146
+ * 1.1 _activate_plugin_event_hook() will be executed first
1147
+ * 1.2 Since $this->_storage->is_plugin_new_install is not set,
1148
+ * and $this->_storage->plugin_last_version is not set,
1149
+ * $this->_storage->is_plugin_new_install will be set to TRUE.
1150
+ * 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1151
+ * be already set to TRUE.
1152
+ *
1153
+ * 2) Plugin update, didn't have Freemius before, and now have the SDK:
1154
+ * 2.1 _activate_plugin_event_hook() will not be executed, because
1155
+ * the activation hook do NOT fires on updates since WP 3.1.
1156
+ * 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1157
+ * be empty, therefore, it will be set to FALSE.
1158
+ *
1159
+ * 3) Plugin update, had Freemius in prev version as well:
1160
+ * 3.1 _version_updates_handler() will be executed 1st, since FS was installed
1161
+ * before, $this->_storage->plugin_last_version will NOT be empty,
1162
+ * therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
1163
+ * 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
1164
+ * already set, therefore, it will not be modified.
1165
+ *
1166
+ * Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
1167
+ *
1168
+ * NOTE:
1169
+ * The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
1170
+ * and then, the next immediate PageView is the plugin's main settings page, it will not
1171
+ * show the opt-in right away. The reason it will happen is because Freemius execution
1172
+ * will be turned off till the plugin is fully loaded at least once
1173
+ * (till $this->_storage->was_plugin_loaded is TRUE).
1174
+ *
1175
+ * @author Vova Feldman (@svovaf)
1176
+ * @since 1.1.9
1177
+ *
1178
+ */
1179
+ function _plugins_loaded() {
1180
+ // Update flag that plugin was loaded with Freemius at least once.
1181
+ $this->_storage->was_plugin_loaded = true;
1182
+
1183
+ /**
1184
+ * Bug fix - only set to false when it's a plugin, due to the
1185
+ * execution sequence of the theme hooks and our methods, if
1186
+ * this will be set for themes, Freemius will always assume
1187
+ * it's a theme update.
1188
+ *
1189
+ * @author Vova Feldman (@svovaf)
1190
+ * @since 1.2.2.2
1191
+ */
1192
+ if ( $this->is_plugin() &&
1193
+ ! isset( $this->_storage->is_plugin_new_install )
1194
+ ) {
1195
+ $this->_storage->is_plugin_new_install = false;
1196
+ }
1197
+ }
1198
+
1199
+ /**
1200
+ * Add special parameter to WP admin AJAX calls so when we
1201
+ * process AJAX calls we can identify its source properly.
1202
+ *
1203
+ * @author Leo Fajardo (@leorw)
1204
+ * @since 2.0.0
1205
+ */
1206
+ static function _enrich_ajax_url() {
1207
+ $admin_param = is_network_admin() ?
1208
+ '_fs_network_admin' :
1209
+ '_fs_blog_admin';
1210
+ ?>
1211
+ <script type="text/javascript">
1212
+ (function ($) {
1213
+ $(document).ajaxSend(function (event, jqxhr, settings) {
1214
+ if (settings.url &&
1215
+ -1 < settings.url.indexOf('admin-ajax.php') &&
1216
+ ! ( settings.url.indexOf( '<?php echo $admin_param ?>' ) > 0 )
1217
+ ) {
1218
+ if (settings.url.indexOf('?') > 0) {
1219
+ settings.url += '&';
1220
+ } else {
1221
+ settings.url += '?';
1222
+ }
1223
+
1224
+ settings.url += '<?php echo $admin_param ?>=true';
1225
+
1226
+ }
1227
+ });
1228
+ })(jQuery);
1229
+ </script>
1230
+ <?php
1231
+ }
1232
+
1233
+ /**
1234
+ * @author Vova Feldman (@svovaf)
1235
+ * @since 1.0.9
1236
+ */
1237
+ private function _register_hooks() {
1238
+ $this->_logger->entrance();
1239
+
1240
+ if ( is_admin() ) {
1241
+ add_action( 'plugins_loaded', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
1242
+
1243
+ if ( $this->is_plugin() ) {
1244
+ $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
1245
+
1246
+ /**
1247
+ * @since 1.2.2
1248
+ *
1249
+ * Hook to both free and premium version activations to support
1250
+ * auto deactivation on the other version activation.
1251
+ */
1252
+ register_activation_hook(
1253
+ $plugin_dir . $this->_free_plugin_basename,
1254
+ array( &$this, '_activate_plugin_event_hook' )
1255
+ );
1256
+
1257
+ register_activation_hook(
1258
+ $plugin_dir . $this->premium_plugin_basename(),
1259
+ array( &$this, '_activate_plugin_event_hook' )
1260
+ );
1261
+ } else {
1262
+ add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
1263
+
1264
+ /**
1265
+ * Include the required hooks to capture the theme settings' page tabs
1266
+ * and cache them.
1267
+ *
1268
+ * @author Vova Feldman (@svovaf)
1269
+ * @since 1.2.2.7
1270
+ */
1271
+ if ( ! $this->_cache->has_valid( 'tabs' ) ) {
1272
+ add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
1273
+ // Add license activation AJAX callback.
1274
+ $this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
1275
+
1276
+ add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
1277
+ }
1278
+
1279
+ add_action(
1280
+ 'admin_footer',
1281
+ array( &$this, '_add_freemius_tabs' ),
1282
+ /**
1283
+ * The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
1284
+ * That's why the priority is 11 while the tabs capture logic is added
1285
+ * with priority 10.
1286
+ *
1287
+ * @author Vova Feldman (@svovaf)
1288
+ */
1289
+ 11
1290
+ );
1291
+
1292
+ add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
1293
+ }
1294
+
1295
+ /**
1296
+ * Part of the mechanism to identify new plugin install vs. plugin update.
1297
+ *
1298
+ * @author Vova Feldman (@svovaf)
1299
+ * @since 1.1.9
1300
+ */
1301
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
1302
+ /**
1303
+ * During the plugin activation (not theme), 'plugins_loaded' will be already executed
1304
+ * when the logic gets here since the activation logic first add the activate plugins,
1305
+ * then triggers 'plugins_loaded', and only then include the code of the plugin that
1306
+ * is activated. Which means that _plugins_loaded() will NOT be executed during the
1307
+ * plugin activation, and that IS intentional.
1308
+ *
1309
+ * @author Vova Feldman (@svovaf)
1310
+ */
1311
+ if ( $this->is_plugin() && $this->is_activation_mode( false ) ) {
1312
+ add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
1313
+ } else {
1314
+ // If was activated before, then it was already loaded before.
1315
+ $this->_plugins_loaded();
1316
+ }
1317
+ }
1318
+
1319
+ if ( ! self::is_ajax() ) {
1320
+ if ( ! $this->is_addon() ) {
1321
+ add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
1322
+ }
1323
+ }
1324
+
1325
+ if ( $this->_storage->handle_gdpr_admin_notice ) {
1326
+ add_action( 'init', array( &$this, '_maybe_show_gdpr_admin_notice' ) );
1327
+ }
1328
+
1329
+ add_action( 'init', array( &$this, '_maybe_add_gdpr_optin_ajax_handler') );
1330
+ }
1331
+
1332
+ if ( $this->is_plugin() ) {
1333
+ if ( $this->_is_network_active ) {
1334
+ add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
1335
+ }
1336
+
1337
+ register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
1338
+ }
1339
+
1340
+ if ( is_multisite() ) {
1341
+ add_action( 'deactivate_blog', array( &$this, '_after_site_deactivated_callback' ) );
1342
+ add_action( 'archive_blog', array( &$this, '_after_site_deactivated_callback' ) );
1343
+ add_action( 'make_spam_blog', array( &$this, '_after_site_deactivated_callback' ) );
1344
+ add_action( 'deleted_blog', array( &$this, '_after_site_deleted_callback' ), 10, 2 );
1345
+
1346
+ add_action( 'activate_blog', array( &$this, '_after_site_reactivated_callback' ) );
1347
+ add_action( 'unarchive_blog', array( &$this, '_after_site_reactivated_callback' ) );
1348
+ add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
1349
+ }
1350
+
1351
+ if ( $this->is_theme() && self::is_customizer() ) {
1352
+ // Register customizer upsell.
1353
+ add_action( 'customize_register', array( &$this, '_customizer_register' ) );
1354
+ }
1355
+
1356
+ add_action( 'admin_init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
1357
+
1358
+ if ( $this->is_theme() ) {
1359
+ add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
1360
+ }
1361
+
1362
+ add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
1363
+ add_action( 'admin_init', array( &$this, '_add_premium_version_upgrade_selection' ) );
1364
+
1365
+ $this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
1366
+ $this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
1367
+
1368
+ if ( $this->_is_network_active && fs_is_network_admin() ) {
1369
+ $this->add_ajax_action( 'network_activate', array( &$this, '_network_activate_ajax_action' ) );
1370
+ }
1371
+
1372
+ $this->add_ajax_action( 'install_premium_version', array(
1373
+ &$this,
1374
+ '_install_premium_version_ajax_action'
1375
+ ) );
1376
+
1377
+ $this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
1378
+
1379
+ $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
1380
+
1381
+ $this->add_action( 'sdk_version_update', array( &$this, '_sdk_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
1382
+
1383
+ $this->add_action(
1384
+ 'plugin_version_update',
1385
+ array( &$this, '_after_version_update' ),
1386
+ WP_FS__DEFAULT_PRIORITY,
1387
+ 2
1388
+ );
1389
+ $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
1390
+
1391
+ add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
1392
+ add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
1393
+ add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_common_css' ) );
1394
+
1395
+ /**
1396
+ * Handle request to reset anonymous mode for `get_reconnect_url()`.
1397
+ *
1398
+ * @author Vova Feldman (@svovaf)
1399
+ * @since 1.2.1.5
1400
+ */
1401
+ if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
1402
+ $this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
1403
+ ) {
1404
+ add_action( 'admin_init', array( &$this, 'connect_again' ) );
1405
+ }
1406
+ }
1407
+
1408
+ /**
1409
+ * Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
1410
+ * could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
1411
+ * plugin will trigger inclusion of the free or premium version and if one of them is active during the
1412
+ * uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
1413
+ *
1414
+ * @author Leo Fajardo (@leorw)
1415
+ *
1416
+ * @since 1.2.0
1417
+ */
1418
+ private function unregister_uninstall_hook() {
1419
+ $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1420
+ unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
1421
+ unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
1422
+
1423
+ update_option( 'uninstall_plugins', $uninstallable_plugins );
1424
+ }
1425
+
1426
+ /**
1427
+ * @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
1428
+ */
1429
+ private function clear_module_main_file_cache() {
1430
+ if ( ! isset( $this->_storage->plugin_main_file ) ||
1431
+ empty( $this->_storage->plugin_main_file->path )
1432
+ ) {
1433
+ return;
1434
+ }
1435
+
1436
+ $plugin_main_file = clone $this->_storage->plugin_main_file;
1437
+
1438
+ // Store cached path (2nd layer cache).
1439
+ $plugin_main_file->prev_path = $plugin_main_file->path;
1440
+
1441
+ // Clear cached path.
1442
+ unset( $plugin_main_file->path );
1443
+
1444
+ $this->_storage->plugin_main_file = $plugin_main_file;
1445
+
1446
+ /**
1447
+ * Clear global cached path.
1448
+ *
1449
+ * @author Leo Fajardo (@leorw)
1450
+ * @since 1.2.2
1451
+ */
1452
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
1453
+ unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
1454
+ self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
1455
+ }
1456
+
1457
+ /**
1458
+ * @author Leo Fajardo (@leorw)
1459
+ * @since 2.0.0
1460
+ */
1461
+ function _hook_action_links_and_register_account_hooks() {
1462
+ add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
1463
+
1464
+ if ( self::is_plugins_page() && $this->is_plugin() ) {
1465
+ $this->hook_plugin_action_links();
1466
+ }
1467
+
1468
+ $this->_register_account_hooks();
1469
+ }
1470
+
1471
+ /**
1472
+ * @author Vova Feldman (@svovaf)
1473
+ * @since 1.0.9
1474
+ */
1475
+ private function _register_account_hooks() {
1476
+ if ( ! is_admin() ) {
1477
+ return;
1478
+ }
1479
+
1480
+ /**
1481
+ * Always show the deactivation feedback form since we added
1482
+ * automatic free version deactivation upon premium code activation.
1483
+ *
1484
+ * @since 1.2.1.6
1485
+ */
1486
+ $this->add_ajax_action(
1487
+ 'submit_uninstall_reason',
1488
+ array( &$this, '_submit_uninstall_reason_action' )
1489
+ );
1490
+
1491
+ if ( $this->is_theme() && $this->is_premium() && ! $this->has_active_valid_license() ) {
1492
+ $this->add_ajax_action(
1493
+ 'delete_theme_update_data',
1494
+ array( &$this, '_delete_theme_update_data_action' )
1495
+ );
1496
+ }
1497
+
1498
+ if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
1499
+ if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
1500
+ ( $this->is_theme() && self::is_themes_page() )
1501
+ ) {
1502
+ add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
1503
+ }
1504
+ }
1505
+ }
1506
+
1507
+ /**
1508
+ * Leverage backtrace to find caller plugin file path.
1509
+ *
1510
+ * @author Vova Feldman (@svovaf)
1511
+ * @since 1.0.6
1512
+ *
1513
+ * @param bool $is_init Is initiation sequence.
1514
+ *
1515
+ * @return string
1516
+ */
1517
+ private function _find_caller_plugin_file( $is_init = false ) {
1518
+ // Try to load the cached value of the file path.
1519
+ if ( isset( $this->_storage->plugin_main_file ) ) {
1520
+ $plugin_main_file = $this->_storage->plugin_main_file;
1521
+ if ( isset( $plugin_main_file->path ) ) {
1522
+ $absolute_path = $this->get_absolute_path( $plugin_main_file->path );
1523
+ if ( file_exists( $absolute_path ) ) {
1524
+ return $absolute_path;
1525
+ }
1526
+ }
1527
+ }
1528
+
1529
+ /**
1530
+ * @since 1.2.1
1531
+ *
1532
+ * `clear_module_main_file_cache()` is clearing the plugin's cached path on
1533
+ * deactivation. Therefore, if any plugin/theme was initiating `Freemius`
1534
+ * with that plugin's slug, it was overriding the empty plugin path with a wrong path.
1535
+ *
1536
+ * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
1537
+ * when the class instantiator isn't the module.
1538
+ */
1539
+ if ( ! $is_init ) {
1540
+ // Fetch prev path cache.
1541
+ if ( isset( $this->_storage->plugin_main_file ) &&
1542
+ isset( $this->_storage->plugin_main_file->prev_path )
1543
+ ) {
1544
+ $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
1545
+ if ( file_exists( $absolute_path ) ) {
1546
+ return $absolute_path;
1547
+ }
1548
+ }
1549
+
1550
+ wp_die(
1551
+ $this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) .
1552
+ " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
1553
+ $this->get_text_inline( 'Error', 'error' ),
1554
+ array( 'back_link' => true )
1555
+ );
1556
+ }
1557
+
1558
+ /**
1559
+ * @since 1.2.1
1560
+ *
1561
+ * Only the original instantiator that calls dynamic_init can modify the module's path.
1562
+ */
1563
+ // Find caller module.
1564
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
1565
+ $this->_storage->plugin_main_file = (object) array(
1566
+ 'path' => $id_slug_type_path_map[ $this->_module_id ]['path'],
1567
+ );
1568
+
1569
+ return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
1570
+ }
1571
+
1572
+ /**
1573
+ * @author Leo Fajardo (@leorw)
1574
+ * @since 1.2.3
1575
+ *
1576
+ * @param string $path
1577
+ *
1578
+ * @return string
1579
+ */
1580
+ private function get_relative_path( $path ) {
1581
+ $module_root_dir = $this->get_module_root_dir_path();
1582
+ if ( 0 === strpos( $path, $module_root_dir ) ) {
1583
+ $path = substr( $path, strlen( $module_root_dir ) );
1584
+ }
1585
+
1586
+ return $path;
1587
+ }
1588
+
1589
+ /**
1590
+ * @author Leo Fajardo (@leorw)
1591
+ * @since 1.2.3
1592
+ *
1593
+ * @param string $path
1594
+ * @param string|bool $module_type
1595
+ *
1596
+ * @return string
1597
+ */
1598
+ private function get_absolute_path( $path, $module_type = false ) {
1599
+ $module_root_dir = $this->get_module_root_dir_path( $module_type );
1600
+ if ( 0 !== strpos( $path, $module_root_dir ) ) {
1601
+ $path = fs_normalize_path( $module_root_dir . $path );
1602
+ }
1603
+
1604
+ return $path;
1605
+ }
1606
+
1607
+ /**
1608
+ * @author Leo Fajardo (@leorw)
1609
+ * @since 1.2.3
1610
+ *
1611
+ * @param string|bool $module_type
1612
+ *
1613
+ * @return string
1614
+ */
1615
+ private function get_module_root_dir_path( $module_type = false ) {
1616
+ $is_plugin = empty( $module_type ) ?
1617
+ $this->is_plugin() :
1618
+ ( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
1619
+
1620
+ return fs_normalize_path( trailingslashit( $is_plugin ?
1621
+ WP_PLUGIN_DIR :
1622
+ get_theme_root() ) );
1623
+ }
1624
+
1625
+ /**
1626
+ * @author Leo Fajardo (@leorw)
1627
+ *
1628
+ * @param number $module_id
1629
+ * @param string $slug
1630
+ *
1631
+ * @since 1.2.2
1632
+ */
1633
+ private function store_id_slug_type_path_map( $module_id, $slug ) {
1634
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
1635
+
1636
+ $store_option = false;
1637
+
1638
+ if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
1639
+ $id_slug_type_path_map[ $module_id ] = array(
1640
+ 'slug' => $slug
1641
+ );
1642
+
1643
+ $store_option = true;
1644
+ }
1645
+
1646
+ if ( ! isset( $id_slug_type_path_map[ $module_id ]['path'] ) ||
1647
+ /**
1648
+ * This verification is for cases when suddenly the same module
1649
+ * is installed but with a different folder name.
1650
+ *
1651
+ * @author Vova Feldman (@svovaf)
1652
+ * @since 1.2.3
1653
+ */
1654
+ ! file_exists( $this->get_absolute_path(
1655
+ $id_slug_type_path_map[ $module_id ]['path'],
1656
+ $id_slug_type_path_map[ $module_id ]['type']
1657
+ ) )
1658
+ ) {
1659
+ $caller_main_file_and_type = $this->get_caller_main_file_and_type();
1660
+
1661
+ $id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
1662
+ $id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
1663
+
1664
+ $store_option = true;
1665
+ }
1666
+
1667
+ if ( $store_option ) {
1668
+ self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
1669
+ }
1670
+ }
1671
+
1672
+ /**
1673
+ * Identifies the caller type: plugin or theme.
1674
+ *
1675
+ * @author Leo Fajardo (@leorw)
1676
+ * @since 1.2.2
1677
+ *
1678
+ * @author Vova Feldman (@svovaf)
1679
+ * @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
1680
+ * add-ons are relying on loading the SDK from the parent module, and also allows themes including the
1681
+ * SDK an internal file instead of directly from functions.php.
1682
+ * @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
1683
+ */
1684
+ private function get_caller_main_file_and_type() {
1685
+ self::require_plugin_essentials();
1686
+
1687
+ $all_plugins = get_plugins();
1688
+ $all_plugins_paths = array();
1689
+
1690
+ // Get active plugin's main files real full names (might be symlinks).
1691
+ foreach ( $all_plugins as $relative_path => &$data ) {
1692
+ if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
1693
+ /**
1694
+ * Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
1695
+ * can't really include the SDK.
1696
+ *
1697
+ * @author Vova Feldman
1698
+ * @since 1.2.1.7
1699
+ */
1700
+ continue;
1701
+ }
1702
+
1703
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
1704
+ }
1705
+
1706
+ $caller_file_candidate = false;
1707
+ $caller_map = array();
1708
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
1709
+ $themes_dir = fs_normalize_path( get_theme_root() );
1710
+
1711
+ for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
1712
+ if ( empty( $bt[ $i ]['file'] ) ) {
1713
+ continue;
1714
+ }
1715
+
1716
+ if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
1717
+ // If file same as the prev file in the stack, skip it.
1718
+ continue;
1719
+ }
1720
+
1721
+ if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
1722
+ 'do_action',
1723
+ 'apply_filter',
1724
+ // The string split is stupid, but otherwise, theme check
1725
+ // throws info notices.
1726
+ 'requir' . 'e_once',
1727
+ 'requir' . 'e',
1728
+ 'includ' . 'e_once',
1729
+ 'includ' . 'e'
1730
+ ) )
1731
+ ) {
1732
+ // Ignore call stack hooks and files inclusion.
1733
+ continue;
1734
+ }
1735
+
1736
+ $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
1737
+
1738
+ if ( 'functions.php' === basename( $caller_file_path ) ) {
1739
+ /**
1740
+ * 1. Assumes that theme's starting execution file is functions.php.
1741
+ * 2. This complex logic fixes symlink issues (e.g. with Vargant).
1742
+ *
1743
+ * @author Vova Feldman (@svovaf)
1744
+ * @since 1.2.2.5
1745
+ */
1746
+
1747
+ if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
1748
+ $module_type = WP_FS__MODULE_TYPE_THEME;
1749
+
1750
+ /**
1751
+ * Relative path of the theme, e.g.:
1752
+ * `my-theme/functions.php`
1753
+ *
1754
+ * @author Leo Fajardo (@leorw)
1755
+ */
1756
+ $caller_file_candidate = basename( dirname( $caller_file_path ) ) .
1757
+ '/' .
1758
+ basename( $caller_file_path );
1759
+
1760
+ continue;
1761
+ }
1762
+ }
1763
+
1764
+ $caller_file_hash = md5( $caller_file_path );
1765
+
1766
+ if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
1767
+ foreach ( $all_plugins_paths as $plugin_path ) {
1768
+ if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
1769
+ $caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
1770
+ break;
1771
+ }
1772
+ }
1773
+ }
1774
+
1775
+ if ( isset( $caller_map[ $caller_file_hash ] ) ) {
1776
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
1777
+ $caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
1778
+ }
1779
+ }
1780
+
1781
+ return (object) array(
1782
+ 'module_type' => $module_type,
1783
+ 'path' => $caller_file_candidate
1784
+ );
1785
+ }
1786
+
1787
+ #----------------------------------------------------------------------------------
1788
+ #region Deactivation Feedback Form
1789
+ #----------------------------------------------------------------------------------
1790
+
1791
+ /**
1792
+ * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
1793
+ * page.
1794
+ *
1795
+ * @author Vova Feldman (@svovaf)
1796
+ * @author Leo Fajardo (@leorw)
1797
+ * @since 1.1.2
1798
+ */
1799
+ function _add_deactivation_feedback_dialog_box() {
1800
+ /* Check the type of user:
1801
+ * 1. Long-term (long-term)
1802
+ * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
1803
+ * 3. Short-term (short-term)
1804
+ */
1805
+ $is_long_term_user = true;
1806
+
1807
+ // Check if the site is at least 2 days old.
1808
+ $time_installed = $this->_storage->install_timestamp;
1809
+
1810
+ // Difference in seconds.
1811
+ $date_diff = time() - $time_installed;
1812
+
1813
+ // Convert seconds to days.
1814
+ $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
1815
+
1816
+ if ( $date_diff_days < 2 ) {
1817
+ $is_long_term_user = false;
1818
+ }
1819
+
1820
+ $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
1821
+
1822
+ if ( $is_long_term_user ) {
1823
+ $user_type = 'long-term';
1824
+ } else {
1825
+ if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
1826
+ $user_type = 'non-registered-and-non-anonymous-short-term';
1827
+ } else {
1828
+ $user_type = 'short-term';
1829
+ }
1830
+ }
1831
+
1832
+ $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
1833
+
1834
+ // Load the HTML template for the deactivation feedback dialog box.
1835
+ $vars = array(
1836
+ 'reasons' => $uninstall_reasons,
1837
+ 'id' => $this->_module_id
1838
+ );
1839
+
1840
+ /**
1841
+ * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
1842
+ */
1843
+ fs_require_template( 'forms/deactivation/form.php', $vars );
1844
+ }
1845
+
1846
+ /**
1847
+ * @author Leo Fajardo (@leorw)
1848
+ * @since 1.1.2
1849
+ *
1850
+ * @param string $user_type
1851
+ *
1852
+ * @return array The uninstall reasons for the specified user type.
1853
+ */
1854
+ function _get_uninstall_reasons( $user_type = 'long-term' ) {
1855
+ $module_type = $this->_module_type;
1856
+
1857
+ $internal_message_template_var = array(
1858
+ 'id' => $this->_module_id
1859
+ );
1860
+
1861
+ $plan = $this->get_plan();
1862
+
1863
+ if ( $this->is_registered() && is_object( $plan ) && $plan->has_technical_support() ) {
1864
+ $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
1865
+ } else {
1866
+ $contact_support_template = '';
1867
+ }
1868
+
1869
+ $reason_found_better_plugin = array(
1870
+ 'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
1871
+ 'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
1872
+ 'input_type' => 'textfield',
1873
+ 'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
1874
+ );
1875
+
1876
+ $reason_temporary_deactivation = array(
1877
+ 'id' => self::REASON_TEMPORARY_DEACTIVATION,
1878
+ 'text' => sprintf(
1879
+ $this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
1880
+ strtolower( $this->is_plugin() ?
1881
+ $this->get_text_inline( 'Deactivation', 'deactivation' ) :
1882
+ $this->get_text_inline( 'Theme Switch', 'theme-switch' )
1883
+ )
1884
+ ),
1885
+ 'input_type' => '',
1886
+ 'input_placeholder' => ''
1887
+ );
1888
+
1889
+ $reason_other = array(
1890
+ 'id' => self::REASON_OTHER,
1891
+ 'text' => $this->get_text_inline( 'Other', 'reason-other' ),
1892
+ 'input_type' => 'textfield',
1893
+ 'input_placeholder' => ''
1894
+ );
1895
+
1896
+ $long_term_user_reasons = array(
1897
+ array(
1898
+ 'id' => self::REASON_NO_LONGER_NEEDED,
1899
+ 'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
1900
+ 'input_type' => '',
1901
+ 'input_placeholder' => ''
1902
+ ),
1903
+ $reason_found_better_plugin,
1904
+ array(
1905
+ 'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
1906
+ 'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
1907
+ 'input_type' => '',
1908
+ 'input_placeholder' => ''
1909
+ ),
1910
+ array(
1911
+ 'id' => self::REASON_BROKE_MY_SITE,
1912
+ 'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
1913
+ 'input_type' => '',
1914
+ 'input_placeholder' => '',
1915
+ 'internal_message' => $contact_support_template
1916
+ ),
1917
+ array(
1918
+ 'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
1919
+ 'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
1920
+ 'input_type' => '',
1921
+ 'input_placeholder' => '',
1922
+ 'internal_message' => $contact_support_template
1923
+ )
1924
+ );
1925
+
1926
+ if ( $this->is_paying() ) {
1927
+ $long_term_user_reasons[] = array(
1928
+ 'id' => self::REASON_CANT_PAY_ANYMORE,
1929
+ 'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
1930
+ 'input_type' => 'textfield',
1931
+ 'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
1932
+ );
1933
+ }
1934
+
1935
+ $reason_dont_share_info = array(
1936
+ 'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
1937
+ 'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
1938
+ 'input_type' => '',
1939
+ 'input_placeholder' => ''
1940
+ );
1941
+
1942
+ /**
1943
+ * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
1944
+ * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
1945
+ * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
1946
+ * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
1947
+ * button in the opt-in form is shown/hidden).
1948
+ */
1949
+ if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
1950
+ $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
1951
+ }
1952
+
1953
+ $uninstall_reasons = array(
1954
+ 'long-term' => $long_term_user_reasons,
1955
+ 'non-registered-and-non-anonymous-short-term' => array(
1956
+ array(
1957
+ 'id' => self::REASON_DIDNT_WORK,
1958
+ 'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
1959
+ 'input_type' => '',
1960
+ 'input_placeholder' => ''
1961
+ ),
1962
+ $reason_dont_share_info,
1963
+ $reason_found_better_plugin
1964
+ ),
1965
+ 'short-term' => array(
1966
+ array(
1967
+ 'id' => self::REASON_COULDNT_MAKE_IT_WORK,
1968
+ 'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
1969
+ 'input_type' => '',
1970
+ 'input_placeholder' => '',
1971
+ 'internal_message' => $contact_support_template
1972
+ ),
1973
+ $reason_found_better_plugin,
1974
+ array(
1975
+ 'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
1976
+ 'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
1977
+ 'input_type' => 'textarea',
1978
+ 'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
1979
+ ),
1980
+ array(
1981
+ 'id' => self::REASON_NOT_WORKING,
1982
+ 'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
1983
+ 'input_type' => 'textarea',
1984
+ 'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
1985
+ ),
1986
+ array(
1987
+ 'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
1988
+ 'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
1989
+ 'input_type' => 'textarea',
1990
+ 'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
1991
+ ),
1992
+ array(
1993
+ 'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
1994
+ 'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
1995
+ 'input_type' => 'textarea',
1996
+ 'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
1997
+ )
1998
+ )
1999
+ );
2000
+
2001
+ // Randomize the reasons for the current user type.
2002
+ shuffle( $uninstall_reasons[ $user_type ] );
2003
+
2004
+ // Keep the following reasons as the last items in the list.
2005
+ $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
2006
+ $uninstall_reasons[ $user_type ][] = $reason_other;
2007
+
2008
+ $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
2009
+
2010
+ return $uninstall_reasons[ $user_type ];
2011
+ }
2012
+
2013
+ /**
2014
+ * Called after the user has submitted his reason for deactivating the plugin.
2015
+ *
2016
+ * @author Leo Fajardo (@leorw)
2017
+ * @since 1.1.2
2018
+ */
2019
+ function _submit_uninstall_reason_action() {
2020
+ $this->_logger->entrance();
2021
+
2022
+ $this->check_ajax_referer( 'submit_uninstall_reason' );
2023
+
2024
+ $reason_id = fs_request_get( 'reason_id' );
2025
+
2026
+ // Check if the given reason ID is an unsigned integer.
2027
+ if ( ! ctype_digit( $reason_id ) ) {
2028
+ exit;
2029
+ }
2030
+
2031
+ $reason_info = trim( fs_request_get( 'reason_info', '' ) );
2032
+ if ( ! empty( $reason_info ) ) {
2033
+ $reason_info = substr( $reason_info, 0, 128 );
2034
+ }
2035
+
2036
+ $reason = (object) array(
2037
+ 'id' => $reason_id,
2038
+ 'info' => $reason_info,
2039
+ 'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
2040
+ );
2041
+
2042
+ $this->_storage->store( 'uninstall_reason', $reason );
2043
+
2044
+ /**
2045
+ * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
2046
+ * not support uninstall hook.
2047
+ *
2048
+ * @author Leo Fajardo (@leorw)
2049
+ * @since 1.2.2
2050
+ */
2051
+ if ( $this->is_theme() ) {
2052
+ if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
2053
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
2054
+ }
2055
+
2056
+ $this->_uninstall_plugin_event( false );
2057
+ $this->remove_sdk_reference();
2058
+ }
2059
+
2060
+ // Print '1' for successful operation.
2061
+ echo 1;
2062
+ exit;
2063
+ }
2064
+
2065
+ /**
2066
+ * @author Leo Fajardo (@leorw)
2067
+ * @since 2.0.2
2068
+ */
2069
+ function _delete_theme_update_data_action() {
2070
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
2071
+ }
2072
+
2073
+ #endregion
2074
+
2075
+ #----------------------------------------------------------------------------------
2076
+ #region Instance
2077
+ #----------------------------------------------------------------------------------
2078
+
2079
+ /**
2080
+ * Main singleton instance.
2081
+ *
2082
+ * @author Vova Feldman (@svovaf)
2083
+ * @since 1.0.0
2084
+ *
2085
+ * @param number $module_id
2086
+ * @param string|bool $slug
2087
+ * @param bool $is_init Is initiation sequence.
2088
+ *
2089
+ * @return Freemius|false
2090
+ */
2091
+ static function instance( $module_id, $slug = false, $is_init = false ) {
2092
+ if ( empty( $module_id ) ) {
2093
+ return false;
2094
+ }
2095
+
2096
+ /**
2097
+ * Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation.
2098
+ */
2099
+ self::_load_required_static();
2100
+
2101
+ if ( ! is_numeric( $module_id ) ) {
2102
+ if ( ! $is_init && true === $slug ) {
2103
+ $is_init = true;
2104
+ }
2105
+
2106
+ $slug = $module_id;
2107
+
2108
+ $module = FS_Plugin_Manager::instance( $slug )->get();
2109
+
2110
+ if ( is_object( $module ) ) {
2111
+ $module_id = $module->id;
2112
+ }
2113
+ }
2114
+
2115
+ $key = 'm_' . $module_id;
2116
+
2117
+ if ( ! isset( self::$_instances[ $key ] ) ) {
2118
+ self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
2119
+ }
2120
+
2121
+ return self::$_instances[ $key ];
2122
+ }
2123
+
2124
+ /**
2125
+ * @author Vova Feldman (@svovaf)
2126
+ * @since 1.0.6
2127
+ *
2128
+ * @param number $addon_id
2129
+ *
2130
+ * @return bool
2131
+ */
2132
+ private static function has_instance( $addon_id ) {
2133
+ return isset( self::$_instances[ 'm_' . $addon_id ] );
2134
+ }
2135
+
2136
+ /**
2137
+ * @author Leo Fajardo (@leorw)
2138
+ * @since 1.2.2
2139
+ *
2140
+ * @param string|number $id_or_slug
2141
+ *
2142
+ * @return number|false
2143
+ */
2144
+ private static function get_module_id( $id_or_slug ) {
2145
+ if ( is_numeric( $id_or_slug ) ) {
2146
+ return $id_or_slug;
2147
+ }
2148
+
2149
+ foreach ( self::$_instances as $instance ) {
2150
+ if ( $instance->is_plugin() && ( $id_or_slug === $instance->get_slug() ) ) {
2151
+ return $instance->get_id();
2152
+ }
2153
+ }
2154
+
2155
+ return false;
2156
+ }
2157
+
2158
+ /**
2159
+ * @author Vova Feldman (@svovaf)
2160
+ * @since 1.0.6
2161
+ *
2162
+ * @param number $id
2163
+ *
2164
+ * @return false|Freemius
2165
+ */
2166
+ static function get_instance_by_id( $id ) {
2167
+ return isset ( self::$_instances[ 'm_' . $id ] ) ?
2168
+ self::$_instances[ 'm_' . $id ] :
2169
+ false;
2170
+ }
2171
+
2172
+ /**
2173
+ *
2174
+ * @author Vova Feldman (@svovaf)
2175
+ * @since 1.0.1
2176
+ *
2177
+ * @param $plugin_file
2178
+ *
2179
+ * @return false|Freemius
2180
+ */
2181
+ static function get_instance_by_file( $plugin_file ) {
2182
+ $slug = self::find_slug_by_basename( $plugin_file );
2183
+
2184
+ return ( false !== $slug ) ?
2185
+ self::instance( self::get_module_id( $slug ) ) :
2186
+ false;
2187
+ }
2188
+
2189
+ /**
2190
+ * @author Vova Feldman (@svovaf)
2191
+ * @since 1.0.6
2192
+ *
2193
+ * @return false|Freemius
2194
+ */
2195
+ function get_parent_instance() {
2196
+ return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
2197
+ }
2198
+
2199
+ /**
2200
+ * @author Vova Feldman (@svovaf)
2201
+ * @since 1.0.6
2202
+ *
2203
+ * @param string|number $id_or_slug
2204
+ *
2205
+ * @return false|Freemius
2206
+ */
2207
+ function get_addon_instance( $id_or_slug ) {
2208
+ $addon_id = self::get_module_id( $id_or_slug );
2209
+
2210
+ return self::instance( $addon_id );
2211
+ }
2212
+
2213
+ #endregion ------------------------------------------------------------------
2214
+
2215
+ /**
2216
+ * @author Vova Feldman (@svovaf)
2217
+ * @since 1.0.6
2218
+ *
2219
+ * @return bool
2220
+ */
2221
+ function is_parent_plugin_installed() {
2222
+ $is_active = self::has_instance( $this->_plugin->parent_plugin_id );
2223
+
2224
+ if ( $is_active ) {
2225
+ return true;
2226
+ }
2227
+
2228
+ /**
2229
+ * Parent module might be a theme. If that's the case, the add-on's FS
2230
+ * instance will be loaded prior to the theme's FS instance, therefore,
2231
+ * we need to check if it's active with a "look ahead".
2232
+ *
2233
+ * @author Vova Feldman
2234
+ * @since 1.2.2.3
2235
+ */
2236
+ global $fs_active_plugins;
2237
+ if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
2238
+ $active_theme = wp_get_theme();
2239
+
2240
+ foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
2241
+ if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
2242
+ if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
2243
+ // Parent module is a theme and it's currently active.
2244
+ return true;
2245
+ }
2246
+ }
2247
+ }
2248
+ }
2249
+
2250
+ return false;
2251
+ }
2252
+
2253
+ /**
2254
+ * Check if add-on parent plugin in activation mode.
2255
+ *
2256
+ * @author Vova Feldman (@svovaf)
2257
+ * @since 1.0.7
2258
+ *
2259
+ * @return bool
2260
+ */
2261
+ function is_parent_in_activation() {
2262
+ $parent_fs = $this->get_parent_instance();
2263
+ if ( ! is_object( $parent_fs ) ) {
2264
+ return false;
2265
+ }
2266
+
2267
+ return ( $parent_fs->is_activation_mode() );
2268
+ }
2269
+
2270
+ /**
2271
+ * Is plugin in activation mode.
2272
+ *
2273
+ * @author Vova Feldman (@svovaf)
2274
+ * @since 1.0.7
2275
+ *
2276
+ * @param bool $and_on
2277
+ *
2278
+ * @return bool
2279
+ */
2280
+ function is_activation_mode( $and_on = true ) {
2281
+ return fs_is_network_admin() ?
2282
+ $this->is_network_activation_mode( $and_on ) :
2283
+ $this->is_site_activation_mode( $and_on );
2284
+ }
2285
+
2286
+ /**
2287
+ * Is plugin in activation mode.
2288
+ *
2289
+ * @author Vova Feldman (@svovaf)
2290
+ * @since 1.0.7
2291
+ *
2292
+ * @param bool $and_on
2293
+ *
2294
+ * @return bool
2295
+ */
2296
+ function is_site_activation_mode( $and_on = true ) {
2297
+ return (
2298
+ ( $this->is_on() || ! $and_on ) &&
2299
+ ( ! $this->is_registered() ||
2300
+ ( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
2301
+ ( ! $this->is_enable_anonymous() ||
2302
+ ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
2303
+ );
2304
+ }
2305
+
2306
+ /**
2307
+ * Checks if the SDK in network activation mode.
2308
+ *
2309
+ * @author Leo Fajardo (@leorw)
2310
+ * @since 2.0.0
2311
+ *
2312
+ * @param bool $and_on
2313
+ *
2314
+ * @return bool
2315
+ */
2316
+ private function is_network_activation_mode( $and_on = true ) {
2317
+ if ( ! $this->_is_network_active ) {
2318
+ // Not network activated.
2319
+ return false;
2320
+ }
2321
+
2322
+ if ( $this->is_network_upgrade_mode() ) {
2323
+ // Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped.
2324
+ return true;
2325
+ }
2326
+
2327
+ if ( ! $this->is_site_activation_mode( $and_on ) ) {
2328
+ // Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well.
2329
+ return false;
2330
+ }
2331
+
2332
+ if ( $this->is_network_delegated_connection() ) {
2333
+ // Super-admin delegated the connection to the site admins -> not activation mode.
2334
+ return false;
2335
+ }
2336
+
2337
+ if ( $this->is_network_anonymous() ) {
2338
+ // Super-admin skipped the connection network wide -> not activation mode.
2339
+ return false;
2340
+ }
2341
+
2342
+ if ( $this->is_network_registered() ) {
2343
+ // Super-admin connected at least one site -> not activation mode.
2344
+ return false;
2345
+ }
2346
+
2347
+ return true;
2348
+ }
2349
+
2350
+ /**
2351
+ * Check if current page is the opt-in/pending-activation page.
2352
+ *
2353
+ * @author Vova Feldman (@svovaf)
2354
+ * @since 1.2.1.7
2355
+ *
2356
+ * @return bool
2357
+ */
2358
+ function is_activation_page() {
2359
+ if ( $this->_menu->is_main_settings_page() ) {
2360
+ return true;
2361
+ }
2362
+
2363
+ if ( ! $this->is_activation_mode() ) {
2364
+ return false;
2365
+ }
2366
+
2367
+ // Check if current page is matching the activation page.
2368
+ return $this->is_matching_url( $this->get_activation_url() );
2369
+ }
2370
+
2371
+ /**
2372
+ * Check if URL path's are matching and that all querystring
2373
+ * arguments of the $sub_url exist in the $url with the same values.
2374
+ *
2375
+ * WARNING:
2376
+ * 1. This method doesn't check if the sub/domain are matching.
2377
+ * 2. Ignore case sensitivity.
2378
+ *
2379
+ * @author Vova Feldman (@svovaf)
2380
+ * @since 1.2.1.7
2381
+ *
2382
+ * @param string $sub_url
2383
+ * @param string $url If argument is not set, check if the sub_url matching the current's page URL.
2384
+ *
2385
+ * @return bool
2386
+ */
2387
+ private function is_matching_url( $sub_url, $url = '' ) {
2388
+ if ( empty( $url ) ) {
2389
+ $url = $_SERVER['REQUEST_URI'];
2390
+ }
2391
+
2392
+ $url = strtolower( $url );
2393
+ $sub_url = strtolower( $sub_url );
2394
+
2395
+ if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
2396
+ // Different path - DO NOT OVERRIDE PAGE.
2397
+ return false;
2398
+ }
2399
+
2400
+ $url_params = array();
2401
+ parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
2402
+
2403
+ $sub_url_params = array();
2404
+ parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
2405
+
2406
+ foreach ( $sub_url_params as $key => $val ) {
2407
+ if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
2408
+ // Not matching query string - DO NOT OVERRIDE PAGE.
2409
+ return false;
2410
+ }
2411
+ }
2412
+
2413
+ return true;
2414
+ }
2415
+
2416
+ /**
2417
+ * Get the basenames of all active plugins for specific blog. Including network activated plugins.
2418
+ *
2419
+ * @author Vova Feldman (@svovaf)
2420
+ * @since 2.0.0
2421
+ *
2422
+ * @param int $blog_id
2423
+ *
2424
+ * @return string[]
2425
+ */
2426
+ private static function get_active_plugins_basenames( $blog_id = 0 ) {
2427
+ if ( is_multisite() && $blog_id > 0 ) {
2428
+ $active_basenames = get_blog_option( $blog_id, 'active_plugins' );
2429
+ } else {
2430
+ $active_basenames = get_option( 'active_plugins' );
2431
+ }
2432
+
2433
+ if ( is_multisite() ) {
2434
+ $network_active_basenames = get_site_option( 'active_sitewide_plugins' );
2435
+
2436
+ if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) {
2437
+ $active_basenames = array_merge( $active_basenames, $network_active_basenames );
2438
+ }
2439
+ }
2440
+
2441
+ return $active_basenames;
2442
+ }
2443
+
2444
+ /**
2445
+ * Get collection of all active plugins. Including network activated plugins.
2446
+ *
2447
+ * @author Vova Feldman (@svovaf)
2448
+ * @since 1.0.9
2449
+ *
2450
+ * @param int $blog_id Since 2.0.0
2451
+ *
2452
+ * @return array[string]array
2453
+ */
2454
+ private static function get_active_plugins( $blog_id = 0 ) {
2455
+ self::require_plugin_essentials();
2456
+
2457
+ $active_plugin = array();
2458
+ $all_plugins = get_plugins();
2459
+ $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
2460
+
2461
+ foreach ( $active_plugins_basenames as $plugin_basename ) {
2462
+ $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
2463
+ }
2464
+
2465
+ return $active_plugin;
2466
+ }
2467
+
2468
+ /**
2469
+ * Get collection of all site active plugins for a specified blog.
2470
+ *
2471
+ * @author Vova Feldman (@svovaf)
2472
+ * @since 2.0.0
2473
+ *
2474
+ * @param int $blog_id
2475
+ *
2476
+ * @return array[string]array
2477
+ */
2478
+ private static function get_site_active_plugins( $blog_id = 0 ) {
2479
+ $active_basenames = ( is_multisite() && $blog_id > 0 ) ?
2480
+ get_blog_option( $blog_id, 'active_plugins' ) :
2481
+ get_option( 'active_plugins' );
2482
+
2483
+ $active = array();
2484
+ foreach ( $active_basenames as $basename ) {
2485
+ $active[ $basename ] = array(
2486
+ 'is_active' => true,
2487
+ 'Version' => '1.0', // Dummy version.
2488
+ 'slug' => self::get_plugin_slug( $basename ),
2489
+ );
2490
+ }
2491
+
2492
+ return $active;
2493
+ }
2494
+
2495
+ /**
2496
+ * Get collection of all plugins with their activation status for a specified blog.
2497
+ *
2498
+ * @author Vova Feldman (@svovaf)
2499
+ * @since 1.1.8
2500
+ *
2501
+ * @param int $blog_id Since 2.0.0
2502
+ *
2503
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
2504
+ */
2505
+ private static function get_all_plugins( $blog_id = 0 ) {
2506
+ self::require_plugin_essentials();
2507
+
2508
+ $all_plugins = get_plugins();
2509
+
2510
+ $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
2511
+
2512
+ foreach ( $all_plugins as $basename => &$data ) {
2513
+ // By default set to inactive (next foreach update the active plugins).
2514
+ $data['is_active'] = false;
2515
+ // Enrich with plugin slug.
2516
+ $data['slug'] = self::get_plugin_slug( $basename );
2517
+ }
2518
+
2519
+ // Flag active plugins.
2520
+ foreach ( $active_plugins_basenames as $basename ) {
2521
+ if ( isset( $all_plugins[ $basename ] ) ) {
2522
+ $all_plugins[ $basename ]['is_active'] = true;
2523
+ }
2524
+ }
2525
+
2526
+ return $all_plugins;
2527
+ }
2528
+
2529
+ /**
2530
+ * Get collection of all plugins and if they are network level activated.
2531
+ *
2532
+ * @author Vova Feldman (@svovaf)
2533
+ * @since 2.0.0
2534
+ *
2535
+ * @return array Key is the plugin basename and the value is an array of the plugin data.
2536
+ */
2537
+ private static function get_network_plugins() {
2538
+ self::require_plugin_essentials();
2539
+
2540
+ $all_plugins = get_plugins();
2541
+
2542
+ $network_active_basenames = is_multisite() ?
2543
+ get_site_option( 'active_sitewide_plugins' ) :
2544
+ array();
2545
+
2546
+ foreach ( $all_plugins as $basename => &$data ) {
2547
+ // By default set to inactive (next foreach update the active plugins).
2548
+ $data['is_active'] = false;
2549
+ // Enrich with plugin slug.
2550
+ $data['slug'] = self::get_plugin_slug( $basename );
2551
+ }
2552
+
2553
+ // Flag active plugins.
2554
+ foreach ( $network_active_basenames as $basename ) {
2555
+ if ( isset( $all_plugins[ $basename ] ) ) {
2556
+ $all_plugins[ $basename ]['is_active'] = true;
2557
+ }
2558
+ }
2559
+
2560
+ return $all_plugins;
2561
+ }
2562
+
2563
+ /**
2564
+ * Cached result of get_site_transient( 'update_plugins' )
2565
+ *
2566
+ * @author Vova Feldman (@svovaf)
2567
+ * @since 1.1.8
2568
+ *
2569
+ * @var object
2570
+ */
2571
+ private static $_plugins_info;
2572
+
2573
+ /**
2574
+ * Helper function to get specified plugin's slug.
2575
+ *
2576
+ * @author Vova Feldman (@svovaf)
2577
+ * @since 1.1.8
2578
+ *
2579
+ * @param $basename
2580
+ *
2581
+ * @return string
2582
+ */
2583
+ private static function get_plugin_slug( $basename ) {
2584
+ if ( ! isset( self::$_plugins_info ) ) {
2585
+ self::$_plugins_info = get_site_transient( 'update_plugins' );
2586
+ }
2587
+
2588
+ $slug = '';
2589
+
2590
+ if ( is_object( self::$_plugins_info ) ) {
2591
+ if ( isset( self::$_plugins_info->no_update ) &&
2592
+ isset( self::$_plugins_info->no_update[ $basename ] ) &&
2593
+ ! empty( self::$_plugins_info->no_update[ $basename ]->slug )
2594
+ ) {
2595
+ $slug = self::$_plugins_info->no_update[ $basename ]->slug;
2596
+ } else if ( isset( self::$_plugins_info->response ) &&
2597
+ isset( self::$_plugins_info->response[ $basename ] ) &&
2598
+ ! empty( self::$_plugins_info->response[ $basename ]->slug )
2599
+ ) {
2600
+ $slug = self::$_plugins_info->response[ $basename ]->slug;
2601
+ }
2602
+ }
2603
+
2604
+ if ( empty( $slug ) ) {
2605
+ // Try to find slug from FS data.
2606
+ $slug = self::find_slug_by_basename( $basename );
2607
+ }
2608
+
2609
+ if ( empty( $slug ) ) {
2610
+ // Fallback to plugin's folder name.
2611
+ $slug = dirname( $basename );
2612
+ }
2613
+
2614
+ return $slug;
2615
+ }
2616
+
2617
+ private static $_statics_loaded = false;
2618
+
2619
+ /**
2620
+ * Load static resources.
2621
+ *
2622
+ * @author Vova Feldman (@svovaf)
2623
+ * @since 1.0.1
2624
+ */
2625
+ private static function _load_required_static() {
2626
+ if ( self::$_statics_loaded ) {
2627
+ return;
2628
+ }
2629
+
2630
+ self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
2631
+
2632
+ self::$_static_logger->entrance();
2633
+
2634
+ self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
2635
+
2636
+ if ( is_multisite() ) {
2637
+ /**
2638
+ * If the id_slug_type_path_map exists on the site level but doesn't exist on the
2639
+ * network level storage, it means that we need to process the storage with migration.
2640
+ *
2641
+ * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, id_slug_type_path_map will be already set in the network level storage.
2642
+ *
2643
+ * @author Vova Feldman (@svovaf)
2644
+ * @since 2.0.0
2645
+ */
2646
+ if ( null === self::$_accounts->get_option( 'id_slug_type_path_map', null, true ) &&
2647
+ null !== self::$_accounts->get_option( 'id_slug_type_path_map', null, false )
2648
+ ) {
2649
+ self::migrate_accounts_to_network();
2650
+
2651
+ // Migrate API options from site level to network level.
2652
+ $api_network_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
2653
+ $api_network_options->migrate_to_network();
2654
+
2655
+ // Migrate API cache to network level storage.
2656
+ FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME )->migrate_to_network();
2657
+ }
2658
+ }
2659
+
2660
+ self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' );
2661
+
2662
+ if ( ! WP_FS__DEMO_MODE ) {
2663
+ add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
2664
+ 'Freemius',
2665
+ '_add_debug_section'
2666
+ ) );
2667
+ }
2668
+
2669
+ add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
2670
+
2671
+ self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
2672
+
2673
+ self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
2674
+
2675
+ self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
2676
+
2677
+ if ( 0 == did_action( 'plugins_loaded' ) ) {
2678
+ add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
2679
+ }
2680
+
2681
+ add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) );
2682
+
2683
+ self::$_statics_loaded = true;
2684
+ }
2685
+
2686
+ #----------------------------------------------------------------------------------
2687
+ #region Localization
2688
+ #----------------------------------------------------------------------------------
2689
+
2690
+ /**
2691
+ * Load framework's text domain.
2692
+ *
2693
+ * @author Vova Feldman (@svovaf)
2694
+ * @since 1.2.1
2695
+ */
2696
+ static function _load_textdomain() {
2697
+ if ( ! is_admin() ) {
2698
+ return;
2699
+ }
2700
+
2701
+ global $fs_active_plugins;
2702
+
2703
+ // Works both for plugins and themes.
2704
+ load_plugin_textdomain(
2705
+ 'freemius',
2706
+ false,
2707
+ $fs_active_plugins->newest->sdk_path . '/languages/'
2708
+ );
2709
+ }
2710
+
2711
+ #endregion
2712
+
2713
+ #----------------------------------------------------------------------------------
2714
+ #region Debugging
2715
+ #----------------------------------------------------------------------------------
2716
+
2717
+ /**
2718
+ * @author Vova Feldman (@svovaf)
2719
+ * @since 1.0.8
2720
+ */
2721
+ static function _add_debug_section() {
2722
+ if ( ! is_super_admin() ) {
2723
+ // Add debug page only for super-admins.
2724
+ return;
2725
+ }
2726
+
2727
+ self::$_static_logger->entrance();
2728
+
2729
+ $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
2730
+
2731
+ if ( WP_FS__DEV_MODE ) {
2732
+ // Add top-level debug menu item.
2733
+ $hook = FS_Admin_Menu_Manager::add_page(
2734
+ $title,
2735
+ $title,
2736
+ 'manage_options',
2737
+ 'freemius',
2738
+ array( 'Freemius', '_debug_page_render' )
2739
+ );
2740
+ } else {
2741
+ // Add hidden debug page.
2742
+ $hook = FS_Admin_Menu_Manager::add_subpage(
2743
+ null,
2744
+ $title,
2745
+ $title,
2746
+ 'manage_options',
2747
+ 'freemius',
2748
+ array( 'Freemius', '_debug_page_render' )
2749
+ );
2750
+ }
2751
+
2752
+ if ( ! empty( $hook ) ) {
2753
+ add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
2754
+ }
2755
+ }
2756
+
2757
+ /**
2758
+ * @author Vova Feldman (@svovaf)
2759
+ * @since 1.1.7.3
2760
+ */
2761
+ static function _toggle_debug_mode() {
2762
+ $is_on = fs_request_get( 'is_on', false, 'post' );
2763
+
2764
+ if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
2765
+ update_option( 'fs_debug_mode', $is_on );
2766
+
2767
+ // Turn on/off storage logging.
2768
+ FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
2769
+ }
2770
+
2771
+ exit;
2772
+ }
2773
+
2774
+ /**
2775
+ * @author Vova Feldman (@svovaf)
2776
+ * @since 1.2.1.6
2777
+ */
2778
+ static function _get_debug_log() {
2779
+ $logs = FS_Logger::load_db_logs(
2780
+ fs_request_get( 'filters', false, 'post' ),
2781
+ ! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
2782
+ ! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
2783
+ );
2784
+
2785
+ self::shoot_ajax_success( $logs );
2786
+ }
2787
+
2788
+ /**
2789
+ * @author Vova Feldman (@svovaf)
2790
+ * @since 1.2.1.7
2791
+ */
2792
+ static function _get_db_option() {
2793
+ $option_name = fs_request_get( 'option_name' );
2794
+
2795
+ $value = get_option( $option_name );
2796
+
2797
+ $result = array(
2798
+ 'name' => $option_name,
2799
+ );
2800
+
2801
+ if ( false !== $value ) {
2802
+ if ( ! is_string( $value ) ) {
2803
+ $value = json_encode( $value );
2804
+ }
2805
+
2806
+ $result['value'] = $value;
2807
+ }
2808
+
2809
+ self::shoot_ajax_success( $result );
2810
+ }
2811
+
2812
+ /**
2813
+ * @author Vova Feldman (@svovaf)
2814
+ * @since 1.2.1.7
2815
+ */
2816
+ static function _set_db_option() {
2817
+ $option_name = fs_request_get( 'option_name' );
2818
+ $option_value = fs_request_get( 'option_value' );
2819
+
2820
+ if ( ! empty( $option_value ) ) {
2821
+ update_option( $option_name, $option_value );
2822
+ }
2823
+
2824
+ self::shoot_ajax_success();
2825
+ }
2826
+
2827
+ /**
2828
+ * @author Vova Feldman (@svovaf)
2829
+ * @since 1.0.8
2830
+ */
2831
+ static function _debug_page_actions() {
2832
+ self::_clean_admin_content_section();
2833
+
2834
+ if ( fs_request_is_action( 'restart_freemius' ) ) {
2835
+ check_admin_referer( 'restart_freemius' );
2836
+
2837
+ if ( ! is_multisite() ) {
2838
+ // Clear accounts data.
2839
+ self::$_accounts->clear( null, true );
2840
+ } else {
2841
+ $sites = self::get_sites();
2842
+ foreach ( $sites as $site ) {
2843
+ $blog_id = self::get_site_blog_id( $site );
2844
+ self::$_accounts->clear( $blog_id, true );
2845
+ }
2846
+
2847
+ // Clear network level storage.
2848
+ self::$_accounts->clear( true, true );
2849
+ }
2850
+
2851
+ // Clear SDK reference cache.
2852
+ delete_option( 'fs_active_plugins' );
2853
+ } else if ( fs_request_is_action( 'clear_updates_data' ) ) {
2854
+ check_admin_referer( 'clear_updates_data' );
2855
+
2856
+ if ( ! is_multisite() ) {
2857
+ set_site_transient( 'update_plugins', null );
2858
+ set_site_transient( 'update_themes', null );
2859
+ } else {
2860
+ $current_blog_id = get_current_blog_id();
2861
+
2862
+ $sites = self::get_sites();
2863
+ foreach ( $sites as $site ) {
2864
+ switch_to_blog( self::get_site_blog_id( $site ) );
2865
+
2866
+ set_site_transient( 'update_plugins', null );
2867
+ set_site_transient( 'update_themes', null );
2868
+ }
2869
+
2870
+ switch_to_blog( $current_blog_id );
2871
+ }
2872
+ } else if ( fs_request_is_action( 'simulate_trial' ) ) {
2873
+ check_admin_referer( 'simulate_trial' );
2874
+
2875
+ $fs = freemius( fs_request_get( 'module_id' ) );
2876
+
2877
+ // Update SDK install to at least 24 hours before.
2878
+ $fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
2879
+ // Unset the trial shown timestamp.
2880
+ unset( $fs->_storage->trial_promotion_shown );
2881
+ } else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
2882
+ check_admin_referer( 'simulate_network_upgrade' );
2883
+
2884
+ $fs = freemius( fs_request_get( 'module_id' ) );
2885
+
2886
+ self::set_network_upgrade_mode( $fs->_storage );
2887
+ } else if ( fs_request_is_action( 'delete_install' ) ) {
2888
+ check_admin_referer( 'delete_install' );
2889
+
2890
+ self::_delete_site_by_slug(
2891
+ fs_request_get( 'slug' ),
2892
+ fs_request_get( 'module_type' ),
2893
+ true,
2894
+ fs_request_get( 'blog_id', null )
2895
+ );
2896
+ } else if ( fs_request_is_action( 'delete_user' ) ) {
2897
+ check_admin_referer( 'delete_user' );
2898
+
2899
+ self::delete_user( fs_request_get( 'user_id' ) );
2900
+ } else if ( fs_request_is_action( 'download_logs' ) ) {
2901
+ check_admin_referer( 'download_logs' );
2902
+
2903
+ $download_url = FS_Logger::download_db_logs(
2904
+ fs_request_get( 'filters', false, 'post' )
2905
+ );
2906
+
2907
+ if ( false === $download_url ) {
2908
+ wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
2909
+ }
2910
+
2911
+ fs_redirect( $download_url );
2912
+ }
2913
+ }
2914
+
2915
+ /**
2916
+ * @author Vova Feldman (@svovaf)
2917
+ * @since 1.0.8
2918
+ */
2919
+ static function _debug_page_render() {
2920
+ self::$_static_logger->entrance();
2921
+
2922
+ if ( ! is_multisite() ) {
2923
+ $all_plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
2924
+ $all_themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME );
2925
+ } else {
2926
+ $sites = self::get_sites();
2927
+
2928
+ $all_plugins_installs = array();
2929
+ $all_themes_installs = array();
2930
+
2931
+ foreach ( $sites as $site ) {
2932
+ $blog_id = self::get_site_blog_id( $site );
2933
+
2934
+ $plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
2935
+
2936
+ foreach ( $plugins_installs as $slug => $install ) {
2937
+ if ( ! isset( $all_plugins_installs[ $slug ] ) ) {
2938
+ $all_plugins_installs[ $slug ] = array();
2939
+ }
2940
+
2941
+ $install->blog_id = $blog_id;
2942
+
2943
+ $all_plugins_installs[ $slug ][] = $install;
2944
+ }
2945
+
2946
+ $themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id );
2947
+
2948
+ foreach ( $themes_installs as $slug => $install ) {
2949
+ if ( ! isset( $all_themes_installs[ $slug ] ) ) {
2950
+ $all_themes_installs[ $slug ] = array();
2951
+ }
2952
+
2953
+ $install->blog_id = $blog_id;
2954
+
2955
+ $all_themes_installs[ $slug ][] = $install;
2956
+ }
2957
+ }
2958
+ }
2959
+
2960
+ $licenses_by_module_type = self::get_all_licenses_by_module_type();
2961
+
2962
+ $vars = array(
2963
+ 'plugin_sites' => $all_plugins_installs,
2964
+ 'theme_sites' => $all_themes_installs,
2965
+ 'users' => self::get_all_users(),
2966
+ 'addons' => self::get_all_addons(),
2967
+ 'account_addons' => self::get_all_account_addons(),
2968
+ 'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
2969
+ 'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ]
2970
+ );
2971
+
2972
+ fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
2973
+ fs_require_once_template( 'debug.php', $vars );
2974
+ }
2975
+
2976
+ #endregion
2977
+
2978
+ #----------------------------------------------------------------------------------
2979
+ #region Connectivity Issues
2980
+ #----------------------------------------------------------------------------------
2981
+
2982
+ /**
2983
+ * Check if Freemius should be turned on for the current plugin install.
2984
+ *
2985
+ * Note:
2986
+ * $this->_is_on is updated in has_api_connectivity()
2987
+ *
2988
+ * @author Vova Feldman (@svovaf)
2989
+ * @since 1.0.9
2990
+ *
2991
+ * @return bool
2992
+ */
2993
+ function is_on() {
2994
+ self::$_static_logger->entrance();
2995
+
2996
+ if ( isset( $this->_is_on ) ) {
2997
+ return $this->_is_on;
2998
+ }
2999
+
3000
+ // If already installed or pending then sure it's on :)
3001
+ if ( $this->is_registered() || $this->is_pending_activation() ) {
3002
+ $this->_is_on = true;
3003
+
3004
+ return true;
3005
+ }
3006
+
3007
+ return false;
3008
+ }
3009
+
3010
+ /**
3011
+ * @author Vova Feldman (@svovaf)
3012
+ * @since 1.1.7.3
3013
+ *
3014
+ * @param bool $flush_if_no_connectivity
3015
+ *
3016
+ * @return bool
3017
+ */
3018
+ private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
3019
+ if ( ! isset( $this->_storage->connectivity_test ) ) {
3020
+ // Connectivity test was never executed, or cache was cleared.
3021
+ return true;
3022
+ }
3023
+
3024
+ if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
3025
+ if ( WP_FS__IS_HTTP_REQUEST ) {
3026
+ if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
3027
+ // Domain changed.
3028
+ return true;
3029
+ }
3030
+
3031
+ if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
3032
+ // Server IP changed.
3033
+ return true;
3034
+ }
3035
+ }
3036
+ }
3037
+
3038
+ if ( $this->_storage->connectivity_test['is_connected'] &&
3039
+ $this->_storage->connectivity_test['is_active']
3040
+ ) {
3041
+ // API connected and Freemius is active - no need to run connectivity check.
3042
+ return false;
3043
+ }
3044
+
3045
+ if ( $flush_if_no_connectivity ) {
3046
+ /**
3047
+ * If explicitly asked to flush when no connectivity - do it only
3048
+ * if at least 10 sec passed from the last API connectivity test.
3049
+ */
3050
+ return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
3051
+ ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
3052
+ }
3053
+
3054
+ /**
3055
+ * @since 1.1.7 Don't check for connectivity on plugin downgrade.
3056
+ */
3057
+ $version = $this->get_plugin_version();
3058
+ if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
3059
+ // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
3060
+ return true;
3061
+ }
3062
+
3063
+ return false;
3064
+ }
3065
+
3066
+ /**
3067
+ * @author Vova Feldman (@svovaf)
3068
+ * @since 1.1.7.4
3069
+ *
3070
+ * @param int|null $blog_id Since 2.0.0.
3071
+ * @param bool $is_gdpr_test Since 2.0.2. Perform only the GDPR test.
3072
+ *
3073
+ * @return object|false
3074
+ */
3075
+ private function ping( $blog_id = null, $is_gdpr_test = false ) {
3076
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
3077
+ return false;
3078
+ }
3079
+
3080
+ $version = $this->get_plugin_version();
3081
+
3082
+ $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
3083
+
3084
+ return $this->get_api_plugin_scope()->ping(
3085
+ $this->get_anonymous_id( $blog_id ),
3086
+ array(
3087
+ 'is_update' => json_encode( $is_update ),
3088
+ 'version' => $version,
3089
+ 'sdk' => $this->version,
3090
+ 'is_admin' => json_encode( is_admin() ),
3091
+ 'is_ajax' => json_encode( self::is_ajax() ),
3092
+ 'is_cron' => json_encode( self::is_cron() ),
3093
+ 'is_gdpr_test' => $is_gdpr_test,
3094
+ 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
3095
+ )
3096
+ );
3097
+ }
3098
+
3099
+ /**
3100
+ * Check if there's any connectivity issue to Freemius API.
3101
+ *
3102
+ * @author Vova Feldman (@svovaf)
3103
+ * @since 1.0.9
3104
+ *
3105
+ * @param bool $flush_if_no_connectivity
3106
+ *
3107
+ * @return bool
3108
+ */
3109
+ function has_api_connectivity( $flush_if_no_connectivity = false ) {
3110
+ $this->_logger->entrance();
3111
+
3112
+ if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
3113
+ return $this->_has_api_connection;
3114
+ }
3115
+
3116
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
3117
+ isset( $this->_storage->connectivity_test ) &&
3118
+ true === $this->_storage->connectivity_test['is_connected']
3119
+ ) {
3120
+ unset( $this->_storage->connectivity_test );
3121
+ }
3122
+
3123
+ if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
3124
+ $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
3125
+ /**
3126
+ * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
3127
+ *
3128
+ * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
3129
+ */
3130
+ $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
3131
+ $this->is_premium() ||
3132
+ ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
3133
+
3134
+ return $this->_has_api_connection;
3135
+ }
3136
+
3137
+ $pong = $this->ping();
3138
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
3139
+
3140
+ if ( ! $is_connected ) {
3141
+ // API failure.
3142
+ $this->_add_connectivity_issue_message( $pong );
3143
+ }
3144
+
3145
+ if ( $is_connected ) {
3146
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
3147
+ }
3148
+
3149
+ $this->store_connectivity_info( $pong, $is_connected );
3150
+
3151
+ return $this->_has_api_connection;
3152
+ }
3153
+
3154
+ /**
3155
+ * @author Vova Feldman (@svovaf)
3156
+ * @since 1.1.7.4
3157
+ *
3158
+ * @param object $pong
3159
+ * @param bool $is_connected
3160
+ */
3161
+ private function store_connectivity_info( $pong, $is_connected ) {
3162
+ $this->_logger->entrance();
3163
+
3164
+ $version = $this->get_plugin_version();
3165
+
3166
+ if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
3167
+ $is_active = false;
3168
+ } else {
3169
+ $is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
3170
+ }
3171
+
3172
+ $is_active = $this->apply_filters(
3173
+ 'is_on',
3174
+ $is_active,
3175
+ $this->is_plugin_update(),
3176
+ $version
3177
+ );
3178
+
3179
+ $this->_storage->connectivity_test = array(
3180
+ 'is_connected' => $is_connected,
3181
+ 'host' => $_SERVER['HTTP_HOST'],
3182
+ 'server_ip' => WP_FS__REMOTE_ADDR,
3183
+ 'is_active' => $is_active,
3184
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
3185
+ // Last version with connectivity attempt.
3186
+ 'version' => $version,
3187
+ );
3188
+
3189
+ $this->_has_api_connection = $is_connected;
3190
+ $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
3191
+ }
3192
+
3193
+ /**
3194
+ * Force turning Freemius on.
3195
+ *
3196
+ * @author Vova Feldman (@svovaf)
3197
+ * @since 1.1.8.1
3198
+ *
3199
+ * @return bool TRUE if successfully turned on.
3200
+ */
3201
+ private function turn_on() {
3202
+ $this->_logger->entrance();
3203
+
3204
+ if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
3205
+ return false;
3206
+ }
3207
+
3208
+ $updated_connectivity = $this->_storage->connectivity_test;
3209
+ $updated_connectivity['is_active'] = true;
3210
+ $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
3211
+ $this->_storage->connectivity_test = $updated_connectivity;
3212
+
3213
+ $this->_is_on = true;
3214
+
3215
+ return true;
3216
+ }
3217
+
3218
+ /**
3219
+ * Anonymous and unique site identifier (Hash).
3220
+ *
3221
+ * @author Vova Feldman (@svovaf)
3222
+ * @since 1.1.0
3223
+ *
3224
+ * @param null|int $blog_id Since 2.0.0
3225
+ *
3226
+ * @return string
3227
+ */
3228
+ function get_anonymous_id( $blog_id = null ) {
3229
+ $unique_id = self::$_accounts->get_option( 'unique_id', null, $blog_id );
3230
+
3231
+ if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
3232
+ $key = fs_strip_url_protocol( get_site_url( $blog_id ) );
3233
+
3234
+ $secure_auth = SECURE_AUTH_KEY;
3235
+ if ( empty( $secure_auth ) || false !== strpos( $secure_auth, ' ' ) ) {
3236
+ // Protect against default auth key.
3237
+ $secure_auth = md5( microtime() );
3238
+ }
3239
+
3240
+ /**
3241
+ * Base the unique identifier on the WP secure authentication key. Which
3242
+ * turns the key into a secret anonymous identifier. This will help us
3243
+ * to avoid duplicate installs generation on the backend upon opt-in.
3244
+ *
3245
+ * @author Vova Feldman (@svovaf)
3246
+ * @since 1.2.3
3247
+ */
3248
+ $unique_id = md5( $key . $secure_auth );
3249
+
3250
+ self::$_accounts->set_option( 'unique_id', $unique_id, true, $blog_id );
3251
+ }
3252
+
3253
+ $this->_logger->departure( $unique_id );
3254
+
3255
+ return $unique_id;
3256
+ }
3257
+
3258
+ /**
3259
+ * @author Vova Feldman (@svovaf)
3260
+ * @since 1.1.7.4
3261
+ *
3262
+ * @return \WP_User
3263
+ */
3264
+ static function _get_current_wp_user() {
3265
+ self::require_pluggable_essentials();
3266
+ self::wp_cookie_constants();
3267
+
3268
+ return wp_get_current_user();
3269
+ }
3270
+
3271
+ /**
3272
+ * Define cookie constants which are required by Freemius::_get_current_wp_user() since
3273
+ * it uses wp_get_current_user() which needs the cookie constants set. When a plugin
3274
+ * is network activated the cookie constants are only configured after the network
3275
+ * plugins activation, therefore, if we don't define those constants WP will throw
3276
+ * PHP warnings/notices.
3277
+ *
3278
+ * @author Vova Feldman (@svovaf)
3279
+ * @since 2.1.1
3280
+ */
3281
+ private static function wp_cookie_constants() {
3282
+ if ( defined( 'LOGGED_IN_COOKIE' ) &&
3283
+ ( defined( 'AUTH_COOKIE' ) || defined( 'SECURE_AUTH_COOKIE' ) )
3284
+ ) {
3285
+ return;
3286
+ }
3287
+
3288
+ /**
3289
+ * Used to guarantee unique hash cookies
3290
+ *
3291
+ * @since 1.5.0
3292
+ */
3293
+ if ( ! defined( 'COOKIEHASH' ) ) {
3294
+ $siteurl = get_site_option( 'siteurl' );
3295
+ if ( $siteurl ) {
3296
+ define( 'COOKIEHASH', md5( $siteurl ) );
3297
+ } else {
3298
+ define( 'COOKIEHASH', '' );
3299
+ }
3300
+ }
3301
+
3302
+ if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
3303
+ define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
3304
+ }
3305
+
3306
+ /**
3307
+ * @since 2.5.0
3308
+ */
3309
+ if ( ! defined( 'AUTH_COOKIE' ) ) {
3310
+ define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
3311
+ }
3312
+
3313
+ /**
3314
+ * @since 2.6.0
3315
+ */
3316
+ if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
3317
+ define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
3318
+ }
3319
+ }
3320
+
3321
+ /**
3322
+ * @author Vova Feldman (@svovaf)
3323
+ * @since 2.1.0
3324
+ *
3325
+ * @return int
3326
+ */
3327
+ static function get_current_wp_user_id() {
3328
+ $wp_user = self::_get_current_wp_user();
3329
+
3330
+ return $wp_user->ID;
3331
+ }
3332
+
3333
+ /**
3334
+ * @author Vova Feldman (@svovaf)
3335
+ * @since 1.2.1.7
3336
+ *
3337
+ * @param string $email
3338
+ *
3339
+ * @return bool
3340
+ */
3341
+ static function is_valid_email( $email ) {
3342
+ if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
3343
+ return false;
3344
+ }
3345
+
3346
+ $parts = explode( '@', $email );
3347
+
3348
+ if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
3349
+ return false;
3350
+ }
3351
+
3352
+ $blacklist = array(
3353
+ 'admin.',
3354
+ 'webmaster.',
3355
+ 'localhost.',
3356
+ 'dev.',
3357
+ 'development.',
3358
+ 'test.',
3359
+ 'stage.',
3360
+ 'staging.',
3361
+ );
3362
+
3363
+ // Make sure domain is not one of the blacklisted.
3364
+ foreach ( $blacklist as $invalid ) {
3365
+ if ( 0 === strpos( $parts[1], $invalid ) ) {
3366
+ return false;
3367
+ }
3368
+ }
3369
+
3370
+ // Get the UTF encoded domain name.
3371
+ $domain = idn_to_ascii( $parts[1] ) . '.';
3372
+
3373
+ return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
3374
+ }
3375
+
3376
+ /**
3377
+ * Generate API connectivity issue message.
3378
+ *
3379
+ * @author Vova Feldman (@svovaf)
3380
+ * @since 1.0.9
3381
+ *
3382
+ * @param mixed $api_result
3383
+ * @param bool $is_first_failure
3384
+ */
3385
+ function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
3386
+ if ( ! $this->is_premium() && $this->_enable_anonymous ) {
3387
+ // Don't add message if it's the free version and can run anonymously.
3388
+ return;
3389
+ }
3390
+
3391
+ if ( ! function_exists( 'wp_nonce_url' ) ) {
3392
+ require_once ABSPATH . 'wp-includes/functions.php';
3393
+ }
3394
+
3395
+ $current_user = self::_get_current_wp_user();
3396
+ // $admin_email = get_option( 'admin_email' );
3397
+ $admin_email = $current_user->user_email;
3398
+
3399
+ // Aliases.
3400
+ $deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
3401
+ $deactivate_plugin_desc = $this->esc_html_inline( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'deactivate-plugin-desc' );
3402
+ $install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
3403
+ $install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
3404
+ $fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
3405
+ $fix_issue_desc = $this->esc_html_inline( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'fix-issue-desc' );
3406
+ /* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
3407
+ $x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
3408
+ $sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
3409
+ $happy_to_resolve_issue_asap = $this->esc_html_inline( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'happy-to-resolve-issue-asap' );
3410
+
3411
+ $message = false;
3412
+ if ( is_object( $api_result ) &&
3413
+ isset( $api_result->error ) &&
3414
+ isset( $api_result->error->code )
3415
+ ) {
3416
+ switch ( $api_result->error->code ) {
3417
+ case 'curl_missing':
3418
+ $missing_methods = '';
3419
+ if ( is_array( $api_result->missing_methods ) &&
3420
+ ! empty( $api_result->missing_methods )
3421
+ ) {
3422
+ foreach ( $api_result->missing_methods as $m ) {
3423
+ if ( 'curl_version' === $m ) {
3424
+ continue;
3425
+ }
3426
+
3427
+ if ( ! empty( $missing_methods ) ) {
3428
+ $missing_methods .= ', ';
3429
+ }
3430
+
3431
+ $missing_methods .= sprintf( '<code>%s</code>', $m );
3432
+ }
3433
+
3434
+ if ( ! empty( $missing_methods ) ) {
3435
+ $missing_methods = sprintf(
3436
+ '<br><br><b>%s</b> %s',
3437
+ $this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
3438
+ $missing_methods
3439
+ );
3440
+ }
3441
+ }
3442
+
3443
+ $message = sprintf(
3444
+ $x_requires_access_to_api . ' ' .
3445
+ $this->esc_html_inline( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.', 'curl-missing-message' ) . ' ' .
3446
+ $missing_methods .
3447
+ ' %s',
3448
+ '<b>' . $this->get_plugin_name() . '</b>',
3449
+ sprintf(
3450
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
3451
+ sprintf(
3452
+ '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
3453
+ $this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
3454
+ ' - ' . sprintf(
3455
+ $this->get_text_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'curl-missing-no-clue-desc' ),
3456
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
3457
+ )
3458
+ ),
3459
+ sprintf(
3460
+ '<b>%s</b> - %s',
3461
+ $sysadmin_title,
3462
+ esc_html( sprintf( $this->get_text_inline( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.', 'curl-missing-sysadmin-desc' ), $this->get_module_label( true ) ) )
3463
+ ),
3464
+ sprintf(
3465
+ '<a href="%s"><b>%s</b></a> - %s',
3466
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
3467
+ $deactivate_plugin_title,
3468
+ $deactivate_plugin_desc
3469
+ )
3470
+ )
3471
+ );
3472
+ break;
3473
+ case 'cloudflare_ddos_protection':
3474
+ $message = sprintf(
3475
+ $x_requires_access_to_api . ' ' .
3476
+ $this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
3477
+ $happy_to_resolve_issue_asap .
3478
+ ' %s',
3479
+ '<b>' . $this->get_plugin_name() . '</b>',
3480
+ sprintf(
3481
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
3482
+ sprintf(
3483
+ '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
3484
+ $fix_issue_title,
3485
+ ' - ' . sprintf(
3486
+ $fix_issue_desc,
3487
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
3488
+ )
3489
+ ),
3490
+ sprintf(
3491
+ '<a href="%s" target="_blank"><b>%s</b></a> - %s',
3492
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
3493
+ $install_previous_title,
3494
+ $install_previous_desc
3495
+ ),
3496
+ sprintf(
3497
+ '<a href="%s"><b>%s</b></a> - %s',
3498
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
3499
+ $deactivate_plugin_title,
3500
+ $deactivate_plugin_desc
3501
+ )
3502
+ )
3503
+ );
3504
+ break;
3505
+ case 'squid_cache_block':
3506
+ $message = sprintf(
3507
+ $x_requires_access_to_api . ' ' .
3508
+ $this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
3509
+ ' %s',
3510
+ '<b>' . $this->get_plugin_name() . '</b>',
3511
+ sprintf(
3512
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
3513
+ sprintf(
3514
+ '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
3515
+ $this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
3516
+ sprintf(
3517
+ $this->esc_html_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'squid-no-clue-desc' ),
3518
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
3519
+ )
3520
+ ),
3521
+ sprintf(
3522
+ '<b>%s</b> - %s',
3523
+ $sysadmin_title,
3524
+ sprintf(
3525
+ $this->esc_html_inline( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.', 'squid-sysadmin-desc' ),
3526
+ // We use a filter since the plugin might require additional API connectivity.
3527
+ '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array(
3528
+ 'api.freemius.com',
3529
+ 'wp.freemius.com'
3530
+ ) ) ) . '</b>',
3531
+ $this->_module_type
3532
+ )
3533
+ ),
3534
+ sprintf(
3535
+ '<a href="%s"><b>%s</b></a> - %s',
3536
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
3537
+ $deactivate_plugin_title,
3538
+ $deactivate_plugin_desc
3539
+ )
3540
+ )
3541
+ );
3542
+ break;
3543
  // default:
3544
  // $message = $this->get_text_inline( 'connectivity-test-fails-message' );
3545
  // break;
3546
+ }
3547
+ }
3548
+
3549
+ $message_id = 'failed_connect_api';
3550
+ $type = 'error';
3551
+
3552
+ $connectivity_test_fails_message = $this->esc_html_inline( 'From unknown reason, the API connectivity test failed.', 'connectivity-test-fails-message' );
3553
+
3554
+ if ( false === $message ) {
3555
+ if ( $is_first_failure ) {
3556
+ // First attempt failed.
3557
+ $message = sprintf(
3558
+ $x_requires_access_to_api . ' ' .
3559
+ $connectivity_test_fails_message . ' ' .
3560
+ $this->esc_html_inline( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?', 'connectivity-test-maybe-temporary' ) . '<br><br>' .
3561
+ '%s',
3562
+ '<b>' . $this->get_plugin_name() . '</b>',
3563
+ sprintf(
3564
+ '<div id="fs_firewall_issue_options">%s %s</div>',
3565
+ sprintf(
3566
+ '<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
3567
+ $this->get_text_inline( 'Yes - do your thing', 'yes-do-your-thing' )
3568
+ ),
3569
+ sprintf(
3570
+ '<a href="%s" class="button">%s</a>',
3571
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
3572
+ $this->get_text_inline( 'No - just deactivate', 'no-deactivate' )
3573
+ )
3574
+ )
3575
+ );
3576
+
3577
+ $message_id = 'failed_connect_api_first';
3578
+ $type = 'promotion';
3579
+ } else {
3580
+ // Second connectivity attempt failed.
3581
+ $message = sprintf(
3582
+ $x_requires_access_to_api . ' ' .
3583
+ $connectivity_test_fails_message . ' ' .
3584
+ $happy_to_resolve_issue_asap .
3585
+ ' %s',
3586
+ '<b>' . $this->get_plugin_name() . '</b>',
3587
+ sprintf(
3588
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
3589
+ sprintf(
3590
+ '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
3591
+ $fix_issue_title,
3592
+ ' - ' . sprintf(
3593
+ $fix_issue_desc,
3594
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
3595
+ )
3596
+ ),
3597
+ sprintf(
3598
+ '<a href="%s" target="_blank"><b>%s</b></a> - %s',
3599
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
3600
+ $install_previous_title,
3601
+ $install_previous_desc
3602
+ ),
3603
+ sprintf(
3604
+ '<a href="%s"><b>%s</b></a> - %s',
3605
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
3606
+ $deactivate_plugin_title,
3607
+ $deactivate_plugin_desc
3608
+ )
3609
+ )
3610
+ );
3611
+ }
3612
+ }
3613
+
3614
+ $this->_admin_notices->add_sticky(
3615
+ $message,
3616
+ $message_id,
3617
+ $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
3618
+ $type
3619
+ );
3620
+ }
3621
+
3622
+ /**
3623
+ * Handle user request to resolve connectivity issue.
3624
+ * This method will send an email to Freemius API technical staff for resolution.
3625
+ * The email will contain server's info and installed plugins (might be caching issue).
3626
+ *
3627
+ * @author Vova Feldman (@svovaf)
3628
+ * @since 1.0.9
3629
+ */
3630
+ function _email_about_firewall_issue() {
3631
+ $this->_admin_notices->remove_sticky( 'failed_connect_api' );
3632
+
3633
+ $pong = $this->ping();
3634
+
3635
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
3636
+
3637
+ if ( $is_connected ) {
3638
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
3639
+
3640
+ $this->store_connectivity_info( $pong, $is_connected );
3641
+
3642
+ echo $this->get_after_plugin_activation_redirect_url();
3643
+ exit;
3644
+ }
3645
+
3646
+ $current_user = self::_get_current_wp_user();
3647
+ $admin_email = $current_user->user_email;
3648
+
3649
+ $error_type = fs_request_get( 'error_type', 'general' );
3650
+
3651
+ switch ( $error_type ) {
3652
+ case 'squid':
3653
+ $title = 'Squid ACL Blocking Issue';
3654
+ break;
3655
+ case 'cloudflare':
3656
+ $title = 'CloudFlare Blocking Issue';
3657
+ break;
3658
+ default:
3659
+ $title = 'API Connectivity Issue';
3660
+ break;
3661
+ }
3662
+
3663
+ $custom_email_sections = array();
3664
+
3665
+ // Add 'API Error' custom email section.
3666
+ $custom_email_sections['api_error'] = array(
3667
+ 'title' => 'API Error',
3668
+ 'rows' => array(
3669
+ 'ping' => array(
3670
+ 'API Error',
3671
+ is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
3672
+ ),
3673
+ )
3674
+ );
3675
+
3676
+ // Send email with technical details to resolve API connectivity issues.
3677
+ $this->send_email(
3678
+ 'api@freemius.com', // recipient
3679
+ $title . ' [' . $this->get_plugin_name() . ']', // subject
3680
+ $custom_email_sections,
3681
+ array( "Reply-To: $admin_email <$admin_email>" ) // headers
3682
+ );
3683
+
3684
+ $this->_admin_notices->add_sticky(
3685
+ sprintf(
3686
+ $this->get_text_inline( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'fix-request-sent-message' ),
3687
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
3688
+ ),
3689
+ 'server_details_sent'
3690
+ );
3691
+
3692
+ // Action was taken, tell that API connectivity troubleshooting should be off now.
3693
+
3694
+ echo "1";
3695
+ exit;
3696
+ }
3697
+
3698
+ /**
3699
+ * Handle connectivity test retry approved by the user.
3700
+ *
3701
+ * @author Vova Feldman (@svovaf)
3702
+ * @since 1.1.7.4
3703
+ */
3704
+ function _retry_connectivity_test() {
3705
+ $this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
3706
+
3707
+ $pong = $this->ping();
3708
+
3709
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
3710
+
3711
+ if ( $is_connected ) {
3712
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
3713
+
3714
+ $this->store_connectivity_info( $pong, $is_connected );
3715
+
3716
+ echo $this->get_after_plugin_activation_redirect_url();
3717
+ } else {
3718
+ // Add connectivity issue message after 2nd failed attempt.
3719
+ $this->_add_connectivity_issue_message( $pong, false );
3720
+
3721
+ echo "1";
3722
+ }
3723
+
3724
+ exit;
3725
+ }
3726
+
3727
+ static function _add_firewall_issues_javascript() {
3728
+ $params = array();
3729
+ fs_require_once_template( 'firewall-issues-js.php', $params );
3730
+ }
3731
+
3732
+ #endregion
3733
+
3734
+ #----------------------------------------------------------------------------------
3735
+ #region Email
3736
+ #----------------------------------------------------------------------------------
3737
+
3738
+ /**
3739
+ * Generates and sends an HTML email with customizable sections.
3740
+ *
3741
+ * @author Leo Fajardo (@leorw)
3742
+ * @since 1.1.2
3743
+ *
3744
+ * @param string $to_address
3745
+ * @param string $subject
3746
+ * @param array $sections
3747
+ * @param array $headers
3748
+ *
3749
+ * @return bool Whether the email contents were sent successfully.
3750
+ */
3751
+ private function send_email(
3752
+ $to_address,
3753
+ $subject,
3754
+ $sections = array(),
3755
+ $headers = array()
3756
+ ) {
3757
+ $default_sections = $this->get_email_sections();
3758
+
3759
+ // Insert new sections or replace the default email sections.
3760
+ if ( is_array( $sections ) && ! empty( $sections ) ) {
3761
+ foreach ( $sections as $section_id => $custom_section ) {
3762
+ if ( ! isset( $default_sections[ $section_id ] ) ) {
3763
+ // If the section does not exist, add it.
3764
+ $default_sections[ $section_id ] = $custom_section;
3765
+ } else {
3766
+ // If the section already exists, override it.
3767
+ $current_section = $default_sections[ $section_id ];
3768
+
3769
+ // Replace the current section's title if a custom section title exists.
3770
+ if ( isset( $custom_section['title'] ) ) {
3771
+ $current_section['title'] = $custom_section['title'];
3772
+ }
3773
+
3774
+ // Insert new rows under the current section or replace the default rows.
3775
+ if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
3776
+ foreach ( $custom_section['rows'] as $row_id => $row ) {
3777
+ $current_section['rows'][ $row_id ] = $row;
3778
+ }
3779
+ }
3780
+
3781
+ $default_sections[ $section_id ] = $current_section;
3782
+ }
3783
+ }
3784
+ }
3785
+
3786
+ $vars = array( 'sections' => $default_sections );
3787
+ $message = fs_get_template( 'email.php', $vars );
3788
+
3789
+ // Set the type of email to HTML.
3790
+ $headers[] = 'Content-type: text/html; charset=UTF-8';
3791
+
3792
+ $header_string = implode( "\r\n", $headers );
3793
+
3794
+ return wp_mail(
3795
+ $to_address,
3796
+ $subject,
3797
+ $message,
3798
+ $header_string
3799
+ );
3800
+ }
3801
+
3802
+ /**
3803
+ * Generates the data for the sections of the email content.
3804
+ *
3805
+ * @author Leo Fajardo (@leorw)
3806
+ * @since 1.1.2
3807
+ *
3808
+ * @return array
3809
+ */
3810
+ private function get_email_sections() {
3811
+ // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
3812
+ $current_user = self::_get_current_wp_user();
3813
+
3814
+ // Retrieve the cURL version information so that we can get the version number below.
3815
+ $curl_version_information = curl_version();
3816
+
3817
+ $active_plugin = self::get_active_plugins();
3818
+
3819
+ // Generate the list of active plugins separated by new line.
3820
+ $active_plugin_string = '';
3821
+ foreach ( $active_plugin as $plugin ) {
3822
+ $active_plugin_string .= sprintf(
3823
+ '<a href="%s">%s</a> [v%s]<br>',
3824
+ $plugin['PluginURI'],
3825
+ $plugin['Name'],
3826
+ $plugin['Version']
3827
+ );
3828
+ }
3829
+
3830
+ $server_ip = WP_FS__REMOTE_ADDR;
3831
+
3832
+ // Add PHP info for deeper investigation.
3833
+ ob_start();
3834
+ phpinfo();
3835
+ $php_info = ob_get_clean();
3836
+
3837
+ $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
3838
+
3839
+ // Generate the default email sections.
3840
+ $sections = array(
3841
+ 'sdk' => array(
3842
+ 'title' => 'SDK',
3843
+ 'rows' => array(
3844
+ 'fs_version' => array( 'FS Version', $this->version ),
3845
+ 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
3846
+ )
3847
+ ),
3848
+ 'plugin' => array(
3849
+ 'title' => ucfirst( $this->get_module_type() ),
3850
+ 'rows' => array(
3851
+ 'name' => array( 'Name', $this->get_plugin_name() ),
3852
+ 'version' => array( 'Version', $this->get_plugin_version() )
3853
+ )
3854
+ ),
3855
+ 'api' => array(
3856
+ 'title' => 'API Subdomain',
3857
+ 'rows' => array(
3858
+ 'dns' => array(
3859
+ 'DNS_CNAME',
3860
+ function_exists( 'dns_get_record' ) ?
3861
+ var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) :
3862
+ 'dns_get_record() disabled/blocked'
3863
+ ),
3864
+ 'ip' => array(
3865
+ 'IP',
3866
+ function_exists( 'gethostbyname' ) ?
3867
+ gethostbyname( $api_domain ) :
3868
+ 'gethostbyname() disabled/blocked'
3869
+ ),
3870
+ ),
3871
+ ),
3872
+ 'site' => array(
3873
+ 'title' => 'Site',
3874
+ 'rows' => array(
3875
+ 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
3876
+ 'address' => array( 'Address', site_url() ),
3877
+ 'host' => array(
3878
+ 'HTTP_HOST',
3879
+ ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
3880
+ ),
3881
+ 'hosting' => array(
3882
+ 'Hosting Company' => fs_request_has( 'hosting_company' ) ?
3883
+ fs_request_get( 'hosting_company' ) :
3884
+ 'Unknown',
3885
+ ),
3886
+ 'server_addr' => array(
3887
+ 'SERVER_ADDR',
3888
+ '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
3889
+ )
3890
+ )
3891
+ ),
3892
+ 'user' => array(
3893
+ 'title' => 'User',
3894
+ 'rows' => array(
3895
+ 'email' => array( 'Email', $current_user->user_email ),
3896
+ 'first' => array( 'First', $current_user->user_firstname ),
3897
+ 'last' => array( 'Last', $current_user->user_lastname )
3898
+ )
3899
+ ),
3900
+ 'plugins' => array(
3901
+ 'title' => 'Plugins',
3902
+ 'rows' => array(
3903
+ 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
3904
+ )
3905
+ ),
3906
+ 'php_info' => array(
3907
+ 'title' => 'PHP Info',
3908
+ 'rows' => array(
3909
+ 'info' => array( $php_info )
3910
+ ),
3911
+ )
3912
+ );
3913
+
3914
+ // Allow the sections to be modified by other code.
3915
+ $sections = $this->apply_filters( 'email_template_sections', $sections );
3916
+
3917
+ return $sections;
3918
+ }
3919
+
3920
+ #endregion
3921
+
3922
+ #----------------------------------------------------------------------------------
3923
+ #region Initialization
3924
+ #----------------------------------------------------------------------------------
3925
+
3926
+ /**
3927
+ * Init plugin's Freemius instance.
3928
+ *
3929
+ * @author Vova Feldman (@svovaf)
3930
+ * @since 1.0.1
3931
+ *
3932
+ * @param number $id
3933
+ * @param string $public_key
3934
+ * @param bool $is_live
3935
+ * @param bool $is_premium
3936
+ */
3937
+ function init( $id, $public_key, $is_live = true, $is_premium = true ) {
3938
+ $this->_logger->entrance();
3939
+
3940
+ $this->dynamic_init( array(
3941
+ 'id' => $id,
3942
+ 'public_key' => $public_key,
3943
+ 'is_live' => $is_live,
3944
+ 'is_premium' => $is_premium,
3945
+ ) );
3946
+ }
3947
+
3948
+ /**
3949
+ * Dynamic initiator, originally created to support initiation
3950
+ * with parent_id for add-ons.
3951
+ *
3952
+ * @author Vova Feldman (@svovaf)
3953
+ * @since 1.0.6
3954
+ *
3955
+ * @param array $plugin_info
3956
+ *
3957
+ * @throws Freemius_Exception
3958
+ */
3959
+ function dynamic_init( array $plugin_info ) {
3960
+ $this->_logger->entrance();
3961
+
3962
+ $this->parse_settings( $plugin_info );
3963
+
3964
+ if ( ! self::is_ajax() ) {
3965
+ if ( ! $this->is_addon() || $this->is_only_premium() ) {
3966
+ add_action(
3967
+ ( $this->_is_network_active && fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu',
3968
+ array( &$this, '_prepare_admin_menu' ),
3969
+ WP_FS__LOWEST_PRIORITY
3970
+ );
3971
+ }
3972
+ }
3973
+
3974
+ if ( $this->should_stop_execution() ) {
3975
+ return;
3976
+ }
3977
+
3978
+ if ( ! $this->is_registered() ) {
3979
+ if ( $this->is_anonymous() ) {
3980
+ // If user skipped, no need to test connectivity.
3981
+ $this->_has_api_connection = true;
3982
+ $this->_is_on = true;
3983
+ } else {
3984
+ if ( ! $this->has_api_connectivity() ) {
3985
+ if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
3986
+ $this->_admin_notices->has_sticky( 'failed_connect_api' )
3987
+ ) {
3988
+ if ( ! $this->_enable_anonymous || $this->is_premium() ) {
3989
+ // If anonymous mode is disabled, add firewall admin-notice message.
3990
+ add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
3991
+
3992
+ $ajax_action_suffix = $this->_slug . ( $this->is_theme() ? ':theme' : '' );
3993
+ add_action( "wp_ajax_fs_resolve_firewall_issues_{$ajax_action_suffix}", array(
3994
+ &$this,
3995
+ '_email_about_firewall_issue'
3996
+ ) );
3997
+
3998
+ add_action( "wp_ajax_fs_retry_connectivity_test_{$ajax_action_suffix}", array(
3999
+ &$this,
4000
+ '_retry_connectivity_test'
4001
+ ) );
4002
+
4003
+ /**
4004
+ * Currently the admin notice manager relies on the module's type and slug. The new AJAX actions manager uses module IDs, hence, consider to replace the if block above with the commented code below after adjusting the admin notices manager to work with module IDs.
4005
+ *
4006
+ * @author Vova Feldman (@svovaf)
4007
+ * @since 2.0.0
4008
+ */
4009
+ /*$this->add_ajax_action( 'resolve_firewall_issues', array(
4010
+ &$this,
4011
+ '_email_about_firewall_issue'
4012
+ ) );
4013
+
4014
+ $this->add_ajax_action( 'retry_connectivity_test', array(
4015
+ &$this,
4016
+ '_retry_connectivity_test'
4017
+ ) );*/
4018
+ }
4019
+ }
4020
+
4021
+ return;
4022
+ } else {
4023
+ $this->_admin_notices->remove_sticky( array(
4024
+ 'failed_connect_api_first',
4025
+ 'failed_connect_api',
4026
+ ) );
4027
+
4028
+ if ( $this->_anonymous_mode ) {
4029
+ // Simulate anonymous mode.
4030
+ $this->_is_anonymous = true;
4031
+ }
4032
+ }
4033
+ }
4034
+ }
4035
+
4036
+ /**
4037
+ * This should be executed even if Freemius is off for the core module,
4038
+ * otherwise, the add-ons dialogbox won't work properly. This is esepcially
4039
+ * relevant when the developer decided to turn FS off for existing users.
4040
+ *
4041
+ * @author Vova Feldman (@svovaf)
4042
+ */
4043
+ if ( $this->is_user_in_admin() &&
4044
+ ! $this->is_addon() &&
4045
+ $this->has_addons() &&
4046
+ 'plugin-information' === fs_request_get( 'tab', false ) &&
4047
+ $this->get_id() == fs_request_get( 'parent_plugin_id', false )
4048
+ ) {
4049
+ require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
4050
+
4051
+ new FS_Plugin_Info_Dialog( $this );
4052
+ }
4053
+
4054
+ // Check if Freemius is on for the current plugin.
4055
+ // This MUST be executed after all the plugin variables has been loaded.
4056
+ if ( ! $this->is_registered() && ! $this->is_on() ) {
4057
+ return;
4058
+ }
4059
+
4060
+ if ( $this->has_api_connectivity() ) {
4061
+ if ( self::is_cron() ) {
4062
+ $this->hook_callback_to_sync_cron();
4063
+ } else if ( $this->is_user_in_admin() ) {
4064
+ /**
4065
+ * Schedule daily data sync cron if:
4066
+ *
4067
+ * 1. User opted-in (for tracking).
4068
+ * 2. If skipped, but later upgraded (opted-in via upgrade).
4069
+ *
4070
+ * @author Vova Feldman (@svovaf)
4071
+ * @since 1.1.7.3
4072
+ *
4073
+ */
4074
+ if ( $this->is_registered() ) {
4075
+ if ( ! $this->is_sync_cron_on() && $this->is_tracking_allowed() ) {
4076
+ $this->schedule_sync_cron();
4077
+ }
4078
+ }
4079
+
4080
+ /**
4081
+ * Check if requested for manual blocking background sync.
4082
+ */
4083
+ if ( fs_request_has( 'background_sync' ) ) {
4084
+ $this->run_manual_sync();
4085
+ }
4086
+ }
4087
+ }
4088
+
4089
+ if ( $this->is_registered() ) {
4090
+ $this->hook_callback_to_install_sync();
4091
+ }
4092
+
4093
+ if ( $this->is_addon() ) {
4094
+ if ( $this->is_parent_plugin_installed() ) {
4095
+ // Link to parent FS.
4096
+ $this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
4097
+
4098
+ // Get parent plugin reference.
4099
+ $this->_parent_plugin = $this->_parent->get_plugin();
4100
+ }
4101
+ }
4102
+
4103
+ if ( $this->is_user_in_admin() ) {
4104
+ if ( $this->is_addon() ) {
4105
+ if ( ! $this->is_parent_plugin_installed() ) {
4106
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
4107
+
4108
+ if ( isset( $plugin_info['parent'] ) ) {
4109
+ $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
4110
+ }
4111
+
4112
+ $this->_admin_notices->add(
4113
+ ( ! empty( $parent_name ) ?
4114
+ sprintf( $this->get_text_x_inline( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'addon-x-cannot-run-without-y' ), $this->get_plugin_name(), $parent_name ) :
4115
+ sprintf( $this->get_text_x_inline( '%s cannot run without the plugin.', 'addonX cannot run...', 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
4116
+ ),
4117
+ $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
4118
+ 'error'
4119
+ );
4120
+
4121
+ return;
4122
+ } else {
4123
+ if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
4124
+ // If parent plugin activated, automatically install add-on for the user.
4125
+ $this->_activate_addon_account( $this->_parent );
4126
+ } else if ( ! $this->_parent->is_registered() && $this->is_registered() ) {
4127
+ // If add-on activated and parent not, automatically install parent for the user.
4128
+ $this->activate_parent_account( $this->_parent );
4129
+ }
4130
+
4131
+ // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
4132
+ if ( $this->is_premium() ) {
4133
+ // Remove add-on download admin-notice.
4134
+ $this->_parent->_admin_notices->remove_sticky( array(
4135
+ 'addon_plan_upgraded_' . $this->_slug,
4136
+ 'no_addon_license_' . $this->_slug,
4137
+ ) );
4138
+ }
4139
+
4140
+ // $this->deactivate_premium_only_addon_without_license();
4141
+ }
4142
+ }
4143
+
4144
+ add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
4145
+
4146
+ // if ( $this->is_registered() ||
4147
+ // $this->is_anonymous() ||
4148
+ // $this->is_pending_activation()
4149
+ // ) {
4150
+ // $this->_init_admin();
4151
+ // }
4152
+ }
4153
+
4154
+ /**
4155
+ * Should be called outside `$this->is_user_in_admin()` scope
4156
+ * because the updater has some logic that needs to be executed
4157
+ * during AJAX calls.
4158
+ *
4159
+ * Currently we need to hook to the `http_request_host_is_external` filter.
4160
+ * In the future, there might be additional logic added.
4161
+ *
4162
+ * @author Vova Feldman
4163
+ * @since 1.2.1.6
4164
+ */
4165
+ if ( $this->is_premium() && $this->has_release_on_freemius() ) {
4166
+ FS_Plugin_Updater::instance( $this );
4167
+ }
4168
+
4169
+ $this->do_action( 'initiated' );
4170
+
4171
+ if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
4172
+ if ( isset( $this->_storage->prev_is_premium ) ) {
4173
+ $this->apply_filters(
4174
+ 'after_code_type_change',
4175
+ // New code type.
4176
+ $this->_plugin->is_premium
4177
+ );
4178
+ } else {
4179
+ // Set for code type for the first time.
4180
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
4181
+ }
4182
+ }
4183
+
4184
+ if ( ! $this->is_addon() ) {
4185
+ if ( $this->is_registered() ) {
4186
+ // Fix for upgrade from versions < 1.0.9.
4187
+ if ( ! isset( $this->_storage->activation_timestamp ) ) {
4188
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
4189
+ }
4190
+
4191
+ $this->do_action( 'after_init_plugin_registered' );
4192
+ } else if ( $this->is_anonymous() ) {
4193
+ $this->do_action( 'after_init_plugin_anonymous' );
4194
+ } else if ( $this->is_pending_activation() ) {
4195
+ $this->do_action( 'after_init_plugin_pending_activations' );
4196
+ }
4197
+ } else {
4198
+ if ( $this->is_registered() ) {
4199
+ $this->do_action( 'after_init_addon_registered' );
4200
+ } else if ( $this->is_anonymous() ) {
4201
+ $this->do_action( 'after_init_addon_anonymous' );
4202
+ } else if ( $this->is_pending_activation() ) {
4203
+ $this->do_action( 'after_init_addon_pending_activations' );
4204
+ }
4205
+ }
4206
+ }
4207
+
4208
+ /**
4209
+ * @author Leo Fajardo (@leorw)
4210
+ *
4211
+ * @since 1.2.1.5
4212
+ */
4213
+ function _stop_tracking_callback() {
4214
+ $this->_logger->entrance();
4215
+
4216
+ $this->check_ajax_referer( 'stop_tracking' );
4217
+
4218
+ $result = $this->stop_tracking( fs_is_network_admin() );
4219
+
4220
+ if ( true === $result ) {
4221
+ self::shoot_ajax_success();
4222
+ }
4223
+
4224
+ $this->_logger->api_error( $result );
4225
+
4226
+ self::shoot_ajax_failure(
4227
+ sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
4228
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
4229
+ $result->error->message :
4230
+ var_export( $result, true ) )
4231
+ );
4232
+ }
4233
+
4234
+ /**
4235
+ * @author Leo Fajardo (@leorw)
4236
+ * @since 1.2.1.5
4237
+ */
4238
+ function _allow_tracking_callback() {
4239
+ $this->_logger->entrance();
4240
+
4241
+ $this->check_ajax_referer( 'allow_tracking' );
4242
+
4243
+ $result = $this->allow_tracking( fs_is_network_admin() );
4244
+
4245
+ if ( true === $result ) {
4246
+ self::shoot_ajax_success();
4247
+ }
4248
+
4249
+ $this->_logger->api_error( $result );
4250
+
4251
+ self::shoot_ajax_failure(
4252
+ sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
4253
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
4254
+ $result->error->message :
4255
+ var_export( $result, true ) )
4256
+ );
4257
+ }
4258
+
4259
+ /**
4260
+ * Opt-out from usage tracking.
4261
+ *
4262
+ * Note: This will not delete the account information but will stop all tracking.
4263
+ *
4264
+ * Returns:
4265
+ * 1. FALSE - If the user never opted-in.
4266
+ * 2. TRUE - If successfully opted-out.
4267
+ * 3. object - API result on failure.
4268
+ *
4269
+ * @author Leo Fajardo (@leorw)
4270
+ * @since 1.2.1.5
4271
+ *
4272
+ * @return bool|object
4273
+ */
4274
+ function stop_site_tracking() {
4275
+ $this->_logger->entrance();
4276
+
4277
+ if ( ! $this->is_registered() ) {
4278
+ // User never opted-in.
4279
+ return false;
4280
+ }
4281
+
4282
+ if ( $this->is_tracking_prohibited() ) {
4283
+ // Already disconnected.
4284
+ return true;
4285
+ }
4286
+
4287
+ // Send update to FS.
4288
+ $result = $this->get_api_site_scope()->call( '/?fields=is_disconnected', 'put', array(
4289
+ 'is_disconnected' => true
4290
+ ) );
4291
+
4292
+ if ( ! $this->is_api_result_entity( $result ) ||
4293
+ ! isset( $result->is_disconnected ) ||
4294
+ ! $result->is_disconnected
4295
+ ) {
4296
+ $this->_logger->api_error( $result );
4297
+
4298
+ return $result;
4299
+ }
4300
+
4301
+ $this->_site->is_disconnected = $result->is_disconnected;
4302
+ $this->_store_site();
4303
+
4304
+ $this->clear_sync_cron();
4305
+
4306
+ // Successfully disconnected.
4307
+ return true;
4308
+ }
4309
+
4310
+ /**
4311
+ * Opt-out network from usage tracking.
4312
+ *
4313
+ * Note: This will not delete the account information but will stop all tracking.
4314
+ *
4315
+ * Returns:
4316
+ * 1. FALSE - If the user never opted-in.
4317
+ * 2. TRUE - If successfully opted-out.
4318
+ * 3. object - API result on failure.
4319
+ *
4320
+ * @author Leo Fajardo (@leorw)
4321
+ * @since 1.2.1.5
4322
+ *
4323
+ * @return bool|object
4324
+ */
4325
+ function stop_network_tracking() {
4326
+ $this->_logger->entrance();
4327
+
4328
+ if ( ! $this->is_registered() ) {
4329
+ // User never opted-in.
4330
+ return false;
4331
+ }
4332
+
4333
+ $install_id_2_blog_id = array();
4334
+ $installs_map = $this->get_blog_install_map();
4335
+
4336
+ $opt_out_all = true;
4337
+
4338
+ $params = array();
4339
+ foreach ( $installs_map as $blog_id => $install ) {
4340
+ if ( $install->is_tracking_prohibited() ) {
4341
+ // Already opted-out.
4342
+ continue;
4343
+ }
4344
+
4345
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
4346
+ // Opt-out only from non-delegated installs.
4347
+ $opt_out_all = false;
4348
+ continue;
4349
+ }
4350
+
4351
+ $params[] = array( 'id' => $install->id );
4352
+
4353
+ $install_id_2_blog_id[ $install->id ] = $blog_id;
4354
+ }
4355
+
4356
+ if ( empty( $install_id_2_blog_id ) ) {
4357
+ return true;
4358
+ }
4359
+
4360
+ $params[] = array( 'is_disconnected' => true );
4361
+
4362
+ // Send update to FS.
4363
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
4364
+
4365
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
4366
+ $this->_logger->api_error( $result );
4367
+
4368
+ return $result;
4369
+ }
4370
+
4371
+ foreach ( $result->installs as $r_install ) {
4372
+ $blog_id = $install_id_2_blog_id[ $r_install->id ];
4373
+ $install = $installs_map[ $blog_id ];
4374
+ $install->is_disconnected = $r_install->is_disconnected;
4375
+ $this->_store_site( true, $blog_id, $install );
4376
+ }
4377
+
4378
+ $this->clear_sync_cron( $opt_out_all );
4379
+
4380
+ // Successfully disconnected.
4381
+ return true;
4382
+ }
4383
+
4384
+ /**
4385
+ * Opt-out from usage tracking.
4386
+ *
4387
+ * Note: This will not delete the account information but will stop all tracking.
4388
+ *
4389
+ * Returns:
4390
+ * 1. FALSE - If the user never opted-in.
4391
+ * 2. TRUE - If successfully opted-out.
4392
+ * 3. object - API result on failure.
4393
+ *
4394
+ * @author Leo Fajardo (@leorw)
4395
+ * @since 1.2.1.5
4396
+ *
4397
+ * @param bool $is_network_action
4398
+ *
4399
+ * @return bool|object
4400
+ */
4401
+ function stop_tracking( $is_network_action = false ) {
4402
+ $this->_logger->entrance();
4403
+
4404
+ return $is_network_action ?
4405
+ $this->stop_network_tracking() :
4406
+ $this->stop_site_tracking();
4407
+ }
4408
+
4409
+ /**
4410
+ * Opt-in back into usage tracking.
4411
+ *
4412
+ * Note: This will only work if the user opted-in previously.
4413
+ *
4414
+ * Returns:
4415
+ * 1. FALSE - If the user never opted-in.
4416
+ * 2. TRUE - If successfully opted-in back to usage tracking.
4417
+ * 3. object - API result on failure.
4418
+ *
4419
+ * @author Leo Fajardo (@leorw)
4420
+ * @since 1.2.1.5
4421
+ *
4422
+ * @return bool|object
4423
+ */
4424
+ function allow_site_tracking() {
4425
+ $this->_logger->entrance();
4426
+
4427
+ if ( ! $this->is_registered() ) {
4428
+ // User never opted-in.
4429
+ return false;
4430
+ }
4431
+
4432
+ if ( $this->is_tracking_allowed() ) {
4433
+ // Tracking already allowed.
4434
+ return true;
4435
+ }
4436
+
4437
+ $result = $this->get_api_site_scope()->call( '/?is_disconnected', 'put', array(
4438
+ 'is_disconnected' => false
4439
+ ) );
4440
+
4441
+ if ( ! $this->is_api_result_entity( $result ) ||
4442
+ ! isset( $result->is_disconnected ) ||
4443
+ $result->is_disconnected
4444
+ ) {
4445
+ $this->_logger->api_error( $result );
4446
+
4447
+ return $result;
4448
+ }
4449
+
4450
+ $this->_site->is_disconnected = $result->is_disconnected;
4451
+ $this->_store_site();
4452
+
4453
+ $this->schedule_sync_cron();
4454
+
4455
+ // Successfully reconnected.
4456
+ return true;
4457
+ }
4458
+
4459
+ /**
4460
+ * Opt-in network back into usage tracking.
4461
+ *
4462
+ * Note: This will only work if the user opted-in previously.
4463
+ *
4464
+ * Returns:
4465
+ * 1. FALSE - If the user never opted-in.
4466
+ * 2. TRUE - If successfully opted-in back to usage tracking.
4467
+ * 3. object - API result on failure.
4468
+ *
4469
+ * @author Leo Fajardo (@leorw)
4470
+ * @since 1.2.1.5
4471
+ *
4472
+ * @return bool|object
4473
+ */
4474
+ function allow_network_tracking() {
4475
+ $this->_logger->entrance();
4476
+
4477
+ if ( ! $this->is_registered() ) {
4478
+ // User never opted-in.
4479
+ return false;
4480
+ }
4481
+
4482
+ $install_id_2_blog_id = array();
4483
+ $installs_map = $this->get_blog_install_map();
4484
+
4485
+ $params = array();
4486
+ foreach ( $installs_map as $blog_id => $install ) {
4487
+ if ( $install->is_tracking_allowed() ) {
4488
+ continue;
4489
+ }
4490
+
4491
+ $params[] = array( 'id' => $install->id );
4492
+
4493
+ $install_id_2_blog_id[ $install->id ] = $blog_id;
4494
+ }
4495
+
4496
+ if ( empty( $install_id_2_blog_id ) ) {
4497
+ return true;
4498
+ }
4499
+
4500
+ $params[] = array( 'is_disconnected' => false );
4501
+
4502
+ // Send update to FS.
4503
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
4504
+
4505
+
4506
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
4507
+ $this->_logger->api_error( $result );
4508
+
4509
+ return $result;
4510
+ }
4511
+
4512
+ foreach ( $result->installs as $r_install ) {
4513
+ $blog_id = $install_id_2_blog_id[ $r_install->id ];
4514
+ $install = $installs_map[ $blog_id ];
4515
+ $install->is_disconnected = $r_install->is_disconnected;
4516
+ $this->_store_site( true, $blog_id, $install );
4517
+ }
4518
+
4519
+ $this->schedule_sync_cron();
4520
+
4521
+ // Successfully reconnected.
4522
+ return true;
4523
+ }
4524
+
4525
+ /**
4526
+ * Opt-in back into usage tracking.
4527
+ *
4528
+ * Note: This will only work if the user opted-in previously.
4529
+ *
4530
+ * Returns:
4531
+ * 1. FALSE - If the user never opted-in.
4532
+ * 2. TRUE - If successfully opted-in back to usage tracking.
4533
+ * 3. object - API result on failure.
4534
+ *
4535
+ * @author Leo Fajardo (@leorw)
4536
+ * @since 1.2.1.5
4537
+ *
4538
+ * @param bool $is_network_action
4539
+ *
4540
+ * @return bool|object
4541
+ */
4542
+ function allow_tracking( $is_network_action = false ) {
4543
+ $this->_logger->entrance();
4544
+
4545
+ return $is_network_action ?
4546
+ $this->allow_network_tracking() :
4547
+ $this->allow_site_tracking();
4548
+ }
4549
+
4550
+ /**
4551
+ * If user opted-in and later disabled usage-tracking,
4552
+ * re-allow tracking for licensing and updates.
4553
+ *
4554
+ * @author Leo Fajardo (@leorw)
4555
+ * @since 1.2.1.5
4556
+ *
4557
+ * @param bool $is_context_single_site
4558
+ */
4559
+ private function reconnect_locally( $is_context_single_site = false ) {
4560
+ $this->_logger->entrance();
4561
+
4562
+ if ( ! $this->is_registered() ) {
4563
+ return;
4564
+ }
4565
+
4566
+ if ( ! fs_is_network_admin() || $is_context_single_site ) {
4567
+ if ( $this->is_tracking_prohibited() ) {
4568
+ $this->_site->is_disconnected = false;
4569
+ $this->_store_site();
4570
+ }
4571
+ } else {
4572
+ $installs_map = $this->get_blog_install_map();
4573
+ foreach ( $installs_map as $blog_id => $install ) {
4574
+ /**
4575
+ * @var FS_Site $install
4576
+ */
4577
+ if ( $install->is_tracking_prohibited() ) {
4578
+ $install->is_disconnected = false;
4579
+ $this->_store_site( true, $blog_id, $install );
4580
+ }
4581
+ }
4582
+ }
4583
+ }
4584
+
4585
+ /**
4586
+ * Parse plugin's settings (as defined by the plugin dev).
4587
+ *
4588
+ * @author Vova Feldman (@svovaf)
4589
+ * @since 1.1.7.3
4590
+ *
4591
+ * @param array $plugin_info
4592
+ *
4593
+ * @throws \Freemius_Exception
4594
+ */
4595
+ private function parse_settings( &$plugin_info ) {
4596
+ $this->_logger->entrance();
4597
+
4598
+ $id = $this->get_numeric_option( $plugin_info, 'id', false );
4599
+ $public_key = $this->get_option( $plugin_info, 'public_key', false );
4600
+ $secret_key = $this->get_option( $plugin_info, 'secret_key', null );
4601
+ $parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
4602
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
4603
+
4604
+ /**
4605
+ * @author Vova Feldman (@svovaf)
4606
+ * @since 1.1.9 Try to pull secret key from external config.
4607
+ */
4608
+ if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
4609
+ $secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
4610
+ }
4611
+
4612
+ if ( isset( $plugin_info['parent'] ) ) {
4613
+ $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
4614
+ // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
4615
+ // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
4616
+ // $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
4617
+ }
4618
+
4619
+ if ( false === $id ) {
4620
+ throw new Freemius_Exception( array(
4621
+ 'error' => array(
4622
+ 'type' => 'ParameterNotSet',
4623
+ 'message' => 'Plugin id parameter is not set.',
4624
+ 'code' => 'plugin_id_not_set',
4625
+ 'http' => 500,
4626
+ )
4627
+ ) );
4628
+ }
4629
+ if ( false === $public_key ) {
4630
+ throw new Freemius_Exception( array(
4631
+ 'error' => array(
4632
+ 'type' => 'ParameterNotSet',
4633
+ 'message' => 'Plugin public_key parameter is not set.',
4634
+ 'code' => 'plugin_public_key_not_set',
4635
+ 'http' => 500,
4636
+ )
4637
+ ) );
4638
+ }
4639
+
4640
+ $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
4641
+ $this->_plugin :
4642
+ new FS_Plugin();
4643
+
4644
+ $plugin->update( array(
4645
+ 'id' => $id,
4646
+ 'type' => $this->get_option( $plugin_info, 'type', $this->_module_type ),
4647
+ 'public_key' => $public_key,
4648
+ 'slug' => $this->_slug,
4649
+ 'parent_plugin_id' => $parent_id,
4650
+ 'version' => $this->get_plugin_version(),
4651
+ 'title' => $this->get_plugin_name(),
4652
+ 'file' => $this->_plugin_basename,
4653
+ 'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
4654
+ 'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
4655
+ 'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
4656
+ ) );
4657
+
4658
+ if ( $plugin->is_updated() ) {
4659
+ // Update plugin details.
4660
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
4661
+ }
4662
+ // Set the secret key after storing the plugin, we don't want to store the key in the storage.
4663
+ $this->_plugin->secret_key = $secret_key;
4664
+
4665
+ if ( ! isset( $plugin_info['menu'] ) ) {
4666
+ $plugin_info['menu'] = array();
4667
+
4668
+ if ( ! empty( $this->_storage->sdk_last_version ) &&
4669
+ version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
4670
+ ) {
4671
+ // Backward compatibility to 1.1.2
4672
+ $plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
4673
+ $plugin_info['menu_slug'] :
4674
+ $this->_slug;
4675
+ }
4676
+ }
4677
+
4678
+ $this->_menu = FS_Admin_Menu_Manager::instance(
4679
+ $this->_module_id,
4680
+ $this->_module_type,
4681
+ $this->get_unique_affix()
4682
+ );
4683
+
4684
+ $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
4685
+
4686
+ $this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
4687
+ $this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
4688
+ $this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
4689
+ $this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
4690
+ $this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
4691
+ $this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
4692
+ if ( $this->_is_premium_only ) {
4693
+ // If premium only plugin, disable anonymous mode.
4694
+ $this->_enable_anonymous = false;
4695
+ $this->_anonymous_mode = false;
4696
+ } else {
4697
+ $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
4698
+ $this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
4699
+ }
4700
+ $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
4701
+
4702
+ if ( ! empty( $plugin_info['trial'] ) ) {
4703
+ $this->_trial_days = $this->get_numeric_option(
4704
+ $plugin_info['trial'],
4705
+ 'days',
4706
+ // Default to 0 - trial without days specification.
4707
+ 0
4708
+ );
4709
+
4710
+ $this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
4711
+ }
4712
+ }
4713
+
4714
+ /**
4715
+ * @param string[] $options
4716
+ * @param string $key
4717
+ * @param mixed $default
4718
+ *
4719
+ * @return bool
4720
+ */
4721
+ private function get_option( &$options, $key, $default = false ) {
4722
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
4723
+ }
4724
+
4725
+ private function get_bool_option( &$options, $key, $default = false ) {
4726
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
4727
+ }
4728
+
4729
+ private function get_numeric_option( &$options, $key, $default = false ) {
4730
+ return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
4731
+ }
4732
+
4733
+ /**
4734
+ * Gate keeper.
4735
+ *
4736
+ * @author Vova Feldman (@svovaf)
4737
+ * @since 1.1.7.3
4738
+ *
4739
+ * @return bool
4740
+ */
4741
+ private function should_stop_execution() {
4742
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
4743
+ /**
4744
+ * Don't execute Freemius until plugin was fully loaded at least once,
4745
+ * to give the opportunity for the activation hook to run before pinging
4746
+ * the API for connectivity test. This logic is relevant for the
4747
+ * identification of new plugin install vs. plugin update.
4748
+ *
4749
+ * @author Vova Feldman (@svovaf)
4750
+ * @since 1.1.9
4751
+ */
4752
+ return true;
4753
+ }
4754
+
4755
+ if ( $this->is_activation_mode() ) {
4756
+ if ( ! is_admin() ) {
4757
+ /**
4758
+ * If in activation mode, don't execute Freemius outside of the
4759
+ * admin dashboard.
4760
+ *
4761
+ * @author Vova Feldman (@svovaf)
4762
+ * @since 1.1.7.3
4763
+ */
4764
+ return true;
4765
+ }
4766
+
4767
+ if ( ! WP_FS__IS_HTTP_REQUEST ) {
4768
+ /**
4769
+ * If in activation and executed without HTTP context (e.g. CLI, Cronjob),
4770
+ * then don't start Freemius.
4771
+ *
4772
+ * @author Vova Feldman (@svovaf)
4773
+ * @since 1.1.6.3
4774
+ *
4775
+ * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
4776
+ */
4777
+ return true;
4778
+ }
4779
+
4780
+ if ( self::is_cron() ) {
4781
+ /**
4782
+ * If in activation mode, don't execute Freemius during wp crons
4783
+ * (wp crons have HTTP context - called as HTTP request).
4784
+ *
4785
+ * @author Vova Feldman (@svovaf)
4786
+ * @since 1.1.7.3
4787
+ */
4788
+ return true;
4789
+ }
4790
+
4791
+ if ( self::is_ajax() &&
4792
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
4793
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api' )
4794
+ ) {
4795
+ /**
4796
+ * During activation, if running in AJAX mode, unless there's a sticky
4797
+ * connectivity issue notice, don't run Freemius.
4798
+ *
4799
+ * @author Vova Feldman (@svovaf)
4800
+ * @since 1.1.7.3
4801
+ */
4802
+ return true;
4803
+ }
4804
+ }
4805
+
4806
+ return false;
4807
+ }
4808
+
4809
+ /**
4810
+ * Triggered after code type has changed.
4811
+ *
4812
+ * @author Vova Feldman (@svovaf)
4813
+ * @since 1.1.9.1
4814
+ */
4815
+ function _after_code_type_change() {
4816
+ $this->_logger->entrance();
4817
+
4818
+ if ( $this->is_theme() ) {
4819
+ // Expire the cache of the previous tabs since the theme may
4820
+ // have setting updates after code type has changed.
4821
+ $this->_cache->expire( 'tabs' );
4822
+ $this->_cache->expire( 'tabs_stylesheets' );
4823
+ }
4824
+
4825
+ if ( $this->is_registered() ) {
4826
+ if ( ! $this->is_addon() ) {
4827
+ add_action(
4828
+ is_admin() ? 'admin_init' : 'init',
4829
+ array( &$this, '_plugin_code_type_changed' )
4830
+ );
4831
+ }
4832
+
4833
+ if ( $this->is_premium() ) {
4834
+ // Purge cached payments after switching to the premium version.
4835
+ // @todo This logic doesn't handle purging the cache for serviceware module upgrade.
4836
+ $this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" );
4837
+ }
4838
+ }
4839
+ }
4840
+
4841
+ /**
4842
+ * Handles plugin's code type change (free <--> premium).
4843
+ *
4844
+ * @author Vova Feldman (@svovaf)
4845
+ * @since 1.0.9
4846
+ */
4847
+ function _plugin_code_type_changed() {
4848
+ $this->_logger->entrance();
4849
+
4850
+ if ( $this->is_premium() ) {
4851
+ $this->reconnect_locally();
4852
+
4853
+ // Activated premium code.
4854
+ $this->do_action( 'after_premium_version_activation' );
4855
+
4856
+ // Remove all sticky messages related to download of the premium version.
4857
+ $this->_admin_notices->remove_sticky( array(
4858
+ 'trial_started',
4859
+ 'plan_upgraded',
4860
+ 'plan_changed',
4861
+ 'license_activated',
4862
+ ) );
4863
+
4864
+ $notice = '';
4865
+ if ( ! $this->is_only_premium() ) {
4866
+ $notice = sprintf( $this->get_text_inline( 'Premium %s version was successfully activated.', 'premium-activated-message' ), $this->_module_type );
4867
+ }
4868
+
4869
+ $license_notice = $this->get_license_network_activation_notice();
4870
+ if ( ! empty( $license_notice ) ) {
4871
+ $notice .= ' ' . $license_notice;
4872
+ }
4873
+
4874
+ if ( ! empty( $notice ) ) {
4875
+ $this->_admin_notices->add_sticky(
4876
+ trim( $notice ),
4877
+ 'premium_activated',
4878
+ $this->get_text_x_inline( 'W00t',
4879
+ 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
4880
+ );
4881
+ }
4882
+ } else {
4883
+ // Remove sticky message related to premium code activation.
4884
+ $this->_admin_notices->remove_sticky( 'premium_activated' );
4885
+
4886
+ // Activated free code (after had the premium before).
4887
+ $this->do_action( 'after_free_version_reactivation' );
4888
+
4889
+ if ( $this->is_paying() && ! $this->is_premium() ) {
4890
+ $this->_admin_notices->add_sticky(
4891
+ sprintf(
4892
+ /* translators: %s: License type (e.g. you have a professional license) */
4893
+ $this->get_text_inline( 'You have a %s license.', 'you-have-x-license' ),
4894
+ $this->get_plan_title()
4895
+ ) . $this->get_complete_upgrade_instructions(),
4896
+ 'plan_upgraded',
4897
+ $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
4898
+ );
4899
+ }
4900
+ }
4901
+
4902
+ // Schedule code type changes event.
4903
+ $this->schedule_install_sync();
4904
+
4905
+ /**
4906
+ * Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
4907
+ * triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
4908
+ * of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
4909
+ * activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
4910
+ * the main file of the "free" version will be loaded first before calling the hooked callback. Since the
4911
+ * free and premium versions are almost identical (same class or have same functions), a fatal error like
4912
+ * "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
4913
+ */
4914
+ $this->unregister_uninstall_hook();
4915
+
4916
+ $this->clear_module_main_file_cache();
4917
+
4918
+ // Update is_premium of latest version.
4919
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
4920
+ }
4921
+
4922
+ #endregion
4923
+
4924
+ #----------------------------------------------------------------------------------
4925
+ #region Add-ons
4926
+ #----------------------------------------------------------------------------------
4927
+
4928
+ /**
4929
+ * Check if add-on installed and activated on site.
4930
+ *
4931
+ * @author Vova Feldman (@svovaf)
4932
+ * @since 1.0.6
4933
+ *
4934
+ * @param string|number $id_or_slug
4935
+ * @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
4936
+ *
4937
+ * @return bool
4938
+ */
4939
+ function is_addon_activated( $id_or_slug, $is_premium = null ) {
4940
+ $this->_logger->entrance();
4941
+
4942
+ $addon_id = self::get_module_id( $id_or_slug );
4943
+ $is_activated = self::has_instance( $addon_id );
4944
+
4945
+ if ( ! $is_activated ) {
4946
+ return false;
4947
+ }
4948
+
4949
+ if ( is_bool( $is_premium ) ) {
4950
+ // Check if the specified code version is activate.
4951
+ $addon = $this->get_addon_instance( $addon_id );
4952
+ $is_activated = ( $is_premium === $addon->is_premium() );
4953
+ }
4954
+
4955
+ return $is_activated;
4956
+ }
4957
+
4958
+ /**
4959
+ * Check if add-on was connected to install
4960
+ *
4961
+ * @author Vova Feldman (@svovaf)
4962
+ * @since 1.1.7
4963
+ *
4964
+ * @param string|number $id_or_slug
4965
+ *
4966
+ * @return bool
4967
+ */
4968
+ function is_addon_connected( $id_or_slug ) {
4969
+ $this->_logger->entrance();
4970
+
4971
+ $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
4972
+
4973
+ $addon_id = self::get_module_id( $id_or_slug );
4974
+ $addon = $this->get_addon( $addon_id );
4975
+ $slug = $addon->slug;
4976
+ if ( ! isset( $sites[ $slug ] ) ) {
4977
+ return false;
4978
+ }
4979
+
4980
+ $site = $sites[ $slug ];
4981
+
4982
+ $plugin = FS_Plugin_Manager::instance( $addon_id )->get();
4983
+
4984
+ if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
4985
+ // The given slug do NOT belong to any of the plugin's add-ons.
4986
+ return false;
4987
+ }
4988
+
4989
+ return ( is_object( $site ) &&
4990
+ is_numeric( $site->id ) &&
4991
+ is_numeric( $site->user_id ) &&
4992
+ FS_Plugin_Plan::is_valid_id( $site->plan_id )
4993
+ );
4994
+ }
4995
+
4996
+ /**
4997
+ * Determines if add-on installed.
4998
+ *
4999
+ * NOTE: This is a heuristic and only works if the folder/file named as the slug.
5000
+ *
5001
+ * @author Vova Feldman (@svovaf)
5002
+ * @since 1.0.6
5003
+ *
5004
+ * @param string|number $id_or_slug
5005
+ *
5006
+ * @return bool
5007
+ */
5008
+ function is_addon_installed( $id_or_slug ) {
5009
+ $this->_logger->entrance();
5010
+
5011
+ $addon_id = self::get_module_id( $id_or_slug );
5012
+
5013
+ return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) );
5014
+ }
5015
+
5016
+ /**
5017
+ * Get add-on basename.
5018
+ *
5019
+ * @author Vova Feldman (@svovaf)
5020
+ * @since 1.0.6
5021
+ *
5022
+ * @param string|number $id_or_slug
5023
+ *
5024
+ * @return string
5025
+ */
5026
+ function get_addon_basename( $id_or_slug ) {
5027
+ $addon_id = self::get_module_id( $id_or_slug );
5028
+
5029
+ if ( $this->is_addon_activated( $addon_id ) ) {
5030
+ return self::instance( $addon_id )->get_plugin_basename();
5031
+ }
5032
+
5033
+ $addon = $this->get_addon( $addon_id );
5034
+ $premium_basename = "{$addon->slug}-premium/{$addon->slug}.php";
5035
+
5036
+ if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
5037
+ return $premium_basename;
5038
+ }
5039
+
5040
+ $all_plugins = $this->get_all_plugins();
5041
+
5042
+ foreach ( $all_plugins as $basename => &$data ) {
5043
+ if ( $addon->slug === $data['slug'] ||
5044
+ $addon->slug . '-premium' === $data['slug']
5045
+ ) {
5046
+ return $basename;
5047
+ }
5048
+ }
5049
+
5050
+ $free_basename = "{$addon->slug}/{$addon->slug}.php";
5051
+
5052
+ return $free_basename;
5053
+ }
5054
+
5055
+ /**
5056
+ * Get installed add-ons instances.
5057
+ *
5058
+ * @author Vova Feldman (@svovaf)
5059
+ * @since 1.0.6
5060
+ *
5061
+ * @return Freemius[]
5062
+ */
5063
+ function get_installed_addons() {
5064
+ $installed_addons = array();
5065
+ foreach ( self::$_instances as $instance ) {
5066
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
5067
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
5068
+ $installed_addons[] = $instance;
5069
+ }
5070
+ }
5071
+ }
5072
+
5073
+ return $installed_addons;
5074
+ }
5075
+
5076
+ /**
5077
+ * Check if any add-ons of the plugin are installed.
5078
+ *
5079
+ * @author Leo Fajardo (@leorw)
5080
+ * @since 1.1.1
5081
+ *
5082
+ * @return bool
5083
+ */
5084
+ function has_installed_addons() {
5085
+ if ( ! $this->has_addons() ) {
5086
+ return false;
5087
+ }
5088
+
5089
+ foreach ( self::$_instances as $instance ) {
5090
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
5091
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
5092
+ return true;
5093
+ }
5094
+ }
5095
+ }
5096
+
5097
+ return false;
5098
+ }
5099
+
5100
+ /**
5101
+ * Tell Freemius that the current plugin is an add-on.
5102
+ *
5103
+ * @author Vova Feldman (@svovaf)
5104
+ * @since 1.0.6
5105
+ *
5106
+ * @param number $parent_plugin_id The parent plugin ID
5107
+ */
5108
+ function init_addon( $parent_plugin_id ) {
5109
+ $this->_plugin->parent_plugin_id = $parent_plugin_id;
5110
+ }
5111
+
5112
+ /**
5113
+ * @author Vova Feldman (@svovaf)
5114
+ * @since 1.0.6
5115
+ *
5116
+ * @return bool
5117
+ */
5118
+ function is_addon() {
5119
+ return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
5120
+ }
5121
+
5122
+ /**
5123
+ * Deactivate add-on if it's premium only and the user does't have a valid license.
5124
+ *
5125
+ * @param bool $is_after_trial_cancel
5126
+ *
5127
+ * @return bool If add-on was deactivated.
5128
+ */
5129
+ private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
5130
+ if ( ! $this->has_free_plan() &&
5131
+ ! $this->has_features_enabled_license() &&
5132
+ ! $this->_has_premium_license()
5133
+ ) {
5134
+ if ( $this->is_registered() ) {
5135
+ // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
5136
+ // if (empty($this->_storage->activation_timestamp) ||
5137
+ // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
5138
+ // ) {
5139
+ /**
5140
+ * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
5141
+ *
5142
+ * Retry syncing the user add-on licenses.
5143
+ */
5144
+ // Sync licenses.
5145
+ $this->_sync_licenses();
5146
+ // }
5147
+
5148
+ // Try to activate premium license.
5149
+ $this->_activate_license( true );
5150
+ }
5151
+
5152
+ if ( ! $this->has_free_plan() &&
5153
+ ! $this->has_features_enabled_license() &&
5154
+ ! $this->_has_premium_license()
5155
+ ) {
5156
+ // @todo Check if deactivate plugins also call the deactivation hook.
5157
+
5158
+ $this->_parent->_admin_notices->add_sticky(
5159
+ sprintf(
5160
+ ( $is_after_trial_cancel ?
5161
+ $this->_parent->get_text_inline(
5162
+ '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.',
5163
+ 'addon-trial-cancelled-message'
5164
+ ) :
5165
+ $this->_parent->get_text_inline(
5166
+ '%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
5167
+ 'addon-no-license-message'
5168
+ )
5169
+ ),
5170
+ '<b>' . $this->_plugin->title . '</b>'
5171
+ ) . ' ' . sprintf(
5172
+ '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
5173
+ $this->_parent->addon_url( $this->_slug ),
5174
+ esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
5175
+ $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
5176
+ ),
5177
+ 'no_addon_license_' . $this->_slug,
5178
+ ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
5179
+ ( $is_after_trial_cancel ? 'success' : 'error' )
5180
+ );
5181
+
5182
+ deactivate_plugins( array( $this->_plugin_basename ), true );
5183
+
5184
+ return true;
5185
+ }
5186
+ }
5187
+
5188
+ return false;
5189
+ }
5190
+
5191
+ #endregion
5192
+
5193
+ #----------------------------------------------------------------------------------
5194
+ #region Sandbox
5195
+ #----------------------------------------------------------------------------------
5196
+
5197
+ /**
5198
+ * Set Freemius into sandbox mode for debugging.
5199
+ *
5200
+ * @author Vova Feldman (@svovaf)
5201
+ * @since 1.0.4
5202
+ *
5203
+ * @param string $secret_key
5204
+ */
5205
+ function init_sandbox( $secret_key ) {
5206
+ $this->_plugin->secret_key = $secret_key;
5207
+
5208
+ // Update plugin details.
5209
+ FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true );
5210
+ }
5211
+
5212
+ /**
5213
+ * Check if running payments in sandbox mode.
5214
+ *
5215
+ * @author Vova Feldman (@svovaf)
5216
+ * @since 1.0.4
5217
+ *
5218
+ * @return bool
5219
+ */
5220
+ function is_payments_sandbox() {
5221
+ return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
5222
+ }
5223
+
5224
+ #endregion
5225
+
5226
+ /**
5227
+ * Check if running test vs. live plugin.
5228
+ *
5229
+ * @author Vova Feldman (@svovaf)
5230
+ * @since 1.0.5
5231
+ *
5232
+ * @return bool
5233
+ */
5234
+ function is_live() {
5235
+ return $this->_plugin->is_live;
5236
+ }
5237
+
5238
+ /**
5239
+ * Check if super-admin skipped connection for all sites in the network.
5240
+ *
5241
+ * @author Vova Feldman (@svovaf)
5242
+ * @since 2.0.0
5243
+ */
5244
+ function is_network_anonymous() {
5245
+ if ( ! $this->_is_network_active ) {
5246
+ return false;
5247
+ }
5248
+
5249
+ $is_anonymous_ms = $this->_storage->get( 'is_anonymous_ms' );
5250
+
5251
+ if ( empty( $is_anonymous_ms ) ) {
5252
+ return false;
5253
+ }
5254
+
5255
+ return $is_anonymous_ms['is'];
5256
+ }
5257
+
5258
+ /**
5259
+ * Check if super-admin opted-in for all sites in the network.
5260
+ *
5261
+ * @author Vova Feldman (@svovaf)
5262
+ * @since 2.0.0
5263
+ */
5264
+ function is_network_connected() {
5265
+ if ( ! $this->_is_network_active ) {
5266
+ return false;
5267
+ }
5268
+
5269
+ return $this->_storage->get( 'is_network_connected' );
5270
+ }
5271
+
5272
+ /**
5273
+ * Check if the user skipped connecting the account with Freemius.
5274
+ *
5275
+ * @author Vova Feldman (@svovaf)
5276
+ * @since 1.0.7
5277
+ *
5278
+ * @return bool
5279
+ */
5280
+ function is_anonymous() {
5281
+ if ( ! isset( $this->_is_anonymous ) ) {
5282
+ if ( $this->is_network_anonymous() ) {
5283
+ $this->_is_anonymous = true;
5284
+ } else {
5285
+ if ( ! isset( $this->_storage->is_anonymous ) ) {
5286
+ // Not skipped.
5287
+ $this->_is_anonymous = false;
5288
+ } else if ( is_bool( $this->_storage->is_anonymous ) ) {
5289
+ // For back compatibility, since the variable was boolean before.
5290
+ $this->_is_anonymous = $this->_storage->is_anonymous;
5291
+
5292
+ // Upgrade stored data format to 1.1.3 format.
5293
+ $this->set_anonymous_mode( $this->_storage->is_anonymous );
5294
+ } else {
5295
+ // Version 1.1.3 and later.
5296
+ $this->_is_anonymous = $this->_storage->is_anonymous['is'];
5297
+ }
5298
+ }
5299
+ }
5300
+
5301
+ return $this->_is_anonymous;
5302
+ }
5303
+
5304
+ /**
5305
+ * Check if the user skipped the connection of a specified site.
5306
+ *
5307
+ * @author Vova Feldman (@svovaf)
5308
+ * @since 2.0.0
5309
+ *
5310
+ * @param int $blog_id
5311
+ *
5312
+ * @return bool
5313
+ */
5314
+ function is_anonymous_site( $blog_id = 0 ) {
5315
+ if ( $this->is_network_anonymous() ) {
5316
+ return true;
5317
+ }
5318
+
5319
+ $is_anonymous = $this->_storage->get( 'is_anonymous', false, $blog_id );
5320
+
5321
+ if ( empty( $is_anonymous ) ) {
5322
+ return false;
5323
+ }
5324
+
5325
+ return $is_anonymous['is'];
5326
+ }
5327
+
5328
+ /**
5329
+ * Check if user connected his account and install pending email activation.
5330
+ *
5331
+ * @author Vova Feldman (@svovaf)
5332
+ * @since 1.0.7
5333
+ *
5334
+ * @return bool
5335
+ */
5336
+ function is_pending_activation() {
5337
+ return $this->_storage->get( 'is_pending_activation', false );
5338
+ }
5339
+
5340
+ /**
5341
+ * Check if plugin must be WordPress.org compliant.
5342
+ *
5343
+ * @since 1.0.7
5344
+ *
5345
+ * @return bool
5346
+ */
5347
+ function is_org_repo_compliant() {
5348
+ return $this->_is_org_compliant;
5349
+ }
5350
+
5351
+ #--------------------------------------------------------------------------------
5352
+ #region WP Cron Common
5353
+ #--------------------------------------------------------------------------------
5354
+
5355
+ /**
5356
+ * @author Vova Feldman (@svovaf)
5357
+ * @since 2.0.0
5358
+ *
5359
+ * @param string $name Cron name.
5360
+ *
5361
+ * @return object
5362
+ */
5363
+ private function get_cron_data( $name ) {
5364
+ $this->_logger->entrance( $name );
5365
+
5366
+ /**
5367
+ * @var object $cron_data
5368
+ */
5369
+ return $this->_storage->get( "{$name}_cron", null );
5370
+ }
5371
+
5372
+ /**
5373
+ * @author Vova Feldman (@svovaf)
5374
+ * @since 2.0.0
5375
+ *
5376
+ * @param string $name Cron name.
5377
+ */
5378
+ private function clear_cron_data( $name ) {
5379
+ $this->_logger->entrance( $name );
5380
+
5381
+ $this->_storage->remove( "{$name}_cron" );
5382
+ }
5383
+
5384
+ /**
5385
+ * @author Vova Feldman (@svovaf)
5386
+ * @since 2.0.0
5387
+ *
5388
+ * @param string $name Cron name.
5389
+ * @param int $cron_blog_id The cron executing blog ID.
5390
+ */
5391
+ private function set_cron_data( $name, $cron_blog_id = 0 ) {
5392
+ $this->_logger->entrance( $name );
5393
+
5394
+ $this->_storage->store( "{$name}_cron", (object) array(
5395
+ 'version' => $this->get_plugin_version(),
5396
+ 'blog_id' => $cron_blog_id,
5397
+ 'sdk_version' => $this->version,
5398
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
5399
+ 'on' => true,
5400
+ ) );
5401
+ }
5402
+
5403
+ /**
5404
+ * Get the cron's executing blog ID.
5405
+ *
5406
+ * @author Vova Feldman (@svovaf)
5407
+ * @since 2.0.0
5408
+ *
5409
+ * @param string $name Cron name.
5410
+ *
5411
+ * @return int
5412
+ */
5413
+ private function get_cron_blog_id( $name ) {
5414
+ $this->_logger->entrance( $name );
5415
+
5416
+ /**
5417
+ * @var object $cron_data
5418
+ */
5419
+ $cron_data = $this->get_cron_data( $name );
5420
+
5421
+ return ( is_object( $cron_data ) && is_numeric( $cron_data->blog_id ) ) ?
5422
+ $cron_data->blog_id :
5423
+ 0;
5424
+ }
5425
+
5426
+ /**
5427
+ * @author Vova Feldman (@svovaf)
5428
+ * @since 2.0.0
5429
+ *
5430
+ * @param string $name Cron name.
5431
+ *
5432
+ * @return bool
5433
+ */
5434
+ private function is_cron_on( $name ) {
5435
+ $this->_logger->entrance( $name );
5436
+
5437
+ /**
5438
+ * @var object $cron_data
5439
+ */
5440
+ $cron_data = $this->get_cron_data( $name );
5441
+
5442
+ return ( ! is_null( $cron_data ) && true === $cron_data->on );
5443
+ }
5444
+
5445
+ /**
5446
+ * Unix timestamp for previous cron execution or false if never executed.
5447
+ *
5448
+ * @author Vova Feldman (@svovaf)
5449
+ * @since 2.0.0
5450
+ *
5451
+ * @param string $name Cron name.
5452
+ *
5453
+ * @return int|false
5454
+ */
5455
+ private function cron_last_execution( $name ) {
5456
+ $this->_logger->entrance( $name );
5457
+
5458
+ return $this->_storage->get( "{$name}_timestamp" );
5459
+ }
5460
+
5461
+ /**
5462
+ * Set cron execution time to now.
5463
+ *
5464
+ * @author Vova Feldman (@svovaf)
5465
+ * @since 2.0.0
5466
+ *
5467
+ * @param string $name Cron name.
5468
+ */
5469
+ private function set_cron_execution_timestamp( $name ) {
5470
+ $this->_logger->entrance( $name );
5471
+
5472
+ $this->_storage->store( "{$name}_timestamp", time() );
5473
+ }
5474
+
5475
+ /**
5476
+ * Check if cron was executed in the last $period of seconds.
5477
+ *
5478
+ * @author Vova Feldman (@svovaf)
5479
+ * @since 2.0.0
5480
+ *
5481
+ * @param string $name Cron name.
5482
+ * @param int $period In seconds
5483
+ *
5484
+ * @return bool
5485
+ */
5486
+ private function is_cron_executed( $name, $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
5487
+ $this->_logger->entrance( $name );
5488
+
5489
+ $last_execution = $this->set_cron_execution_timestamp( $name );
5490
+
5491
+ if ( ! is_numeric( $last_execution ) ) {
5492
+ return false;
5493
+ }
5494
+
5495
+ return ( $last_execution > ( WP_FS__SCRIPT_START_TIME - $period ) );
5496
+ }
5497
+
5498
+ /**
5499
+ * WP Cron is executed on a site level. When running in a multisite network environment
5500
+ * with the network integration activated, for optimization reasons, we are consolidating
5501
+ * the installs data sync cron to be executed only from a single site.
5502
+ *
5503
+ * @author Vova Feldman (@svovaf)
5504
+ * @since 2.0.0
5505
+ *
5506
+ * @param int $except_blog_id Target any except the excluded blog ID.
5507
+ *
5508
+ * @return int
5509
+ */
5510
+ private function get_cron_target_blog_id( $except_blog_id = 0 ) {
5511
+ if ( ! is_multisite() ) {
5512
+ return 0;
5513
+ }
5514
+
5515
+ if ( $this->_is_network_active &&
5516
+ is_numeric( $this->_storage->network_install_blog_id ) &&
5517
+ $except_blog_id != $this->_storage->network_install_blog_id &&
5518
+ self::is_site_active( $this->_storage->network_install_blog_id )
5519
+ ) {
5520
+ // Try to run cron from the main network blog.
5521
+ $install = $this->get_install_by_blog_id( $this->_storage->network_install_blog_id );
5522
+
5523
+ if ( is_object( $install ) &&
5524
+ ( $this->is_premium() || $install->is_tracking_allowed() )
5525
+ ) {
5526
+ return $this->_storage->network_install_blog_id;
5527
+ }
5528
+ }
5529
+
5530
+ // Get first opted-in blog ID with active tracking.
5531
+ $installs = $this->get_blog_install_map();
5532
+ foreach ( $installs as $blog_id => $install ) {
5533
+ if ( $except_blog_id != $blog_id &&
5534
+ self::is_site_active( $blog_id ) &&
5535
+ ( $this->is_premium() || $install->is_tracking_allowed() )
5536
+ ) {
5537
+ return $blog_id;
5538
+ }
5539
+ }
5540
+
5541
+ return 0;
5542
+ }
5543
+
5544
+ /**
5545
+ * @author Vova Feldman (@svovaf)
5546
+ * @since 2.0.0
5547
+ *
5548
+ * @param string $name Cron name.
5549
+ * @param string $action_tag Callback action tag.
5550
+ * @param bool $is_network_clear If set to TRUE, clear sync cron even if there are installs that are still connected.
5551
+ */
5552
+ private function clear_cron( $name, $action_tag = '', $is_network_clear = false ) {
5553
+ $this->_logger->entrance( $name );
5554
+
5555
+ if ( ! $this->is_cron_on( $name ) ) {
5556
+ return;
5557
+ }
5558
+
5559
+ $clear_cron = true;
5560
+ if ( ! $is_network_clear && $this->_is_network_active ) {
5561
+ $installs = $this->get_blog_install_map();
5562
+
5563
+ foreach ( $installs as $blog_id => $install ) {
5564
+ /**
5565
+ * @var FS_Site $install
5566
+ */
5567
+ if ( $install->is_tracking_allowed() ) {
5568
+ $clear_cron = false;
5569
+ break;
5570
+ }
5571
+ }
5572
+ }
5573
+
5574
+ if ( ! $clear_cron ) {
5575
+ return;
5576
+ }
5577
+
5578
+ /**
5579
+ * @var object $cron_data
5580
+ */
5581
+ $cron_data = $this->get_cron_data( $name );
5582
+
5583
+ $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
5584
+ $cron_data->blog_id :
5585
+ 0;
5586
+
5587
+ $this->clear_cron_data( $name );
5588
+
5589
+ if ( 0 < $cron_blog_id ) {
5590
+ switch_to_blog( $cron_blog_id );
5591
+ }
5592
+
5593
+ if ( empty( $action_tag ) ) {
5594
+ $action_tag = $name;
5595
+ }
5596
+
5597
+ wp_clear_scheduled_hook( $this->get_action_tag( $action_tag ) );
5598
+
5599
+ if ( 0 < $cron_blog_id ) {
5600
+ restore_current_blog();
5601
+ }
5602
+ }
5603
+
5604
+ /**
5605
+ * Unix timestamp for next cron execution or false if not scheduled.
5606
+ *
5607
+ * @author Vova Feldman (@svovaf)
5608
+ * @since 2.0.0
5609
+ *
5610
+ * @param string $name Cron name.
5611
+ * @param string $action_tag Callback action tag.
5612
+ *
5613
+ * @return int|false
5614
+ */
5615
+ private function get_next_scheduled_cron( $name, $action_tag = '' ) {
5616
+ $this->_logger->entrance( $name );
5617
+
5618
+ if ( ! $this->is_cron_on( $name ) ) {
5619
+ return false;
5620
+ }
5621
+
5622
+ /**
5623
+ * @var object $cron_data
5624
+ */
5625
+ $cron_data = $this->get_cron_data( $name );
5626
+
5627
+ $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
5628
+ $cron_data->blog_id :
5629
+ 0;
5630
+
5631
+ if ( 0 < $cron_blog_id ) {
5632
+ switch_to_blog( $cron_blog_id );
5633
+ }
5634
+
5635
+ if ( empty( $action_tag ) ) {
5636
+ $action_tag = $name;
5637
+ }
5638
+
5639
+ $next_scheduled = wp_next_scheduled( $this->get_action_tag( $action_tag ) );
5640
+
5641
+ if ( 0 < $cron_blog_id ) {
5642
+ restore_current_blog();
5643
+ }
5644
+
5645
+ return $next_scheduled;
5646
+ }
5647
+
5648
+ /**
5649
+ * @author Vova Feldman (@svovaf)
5650
+ * @since 2.0.0
5651
+ *
5652
+ * @param string $name Cron name.
5653
+ * @param string $action_tag Callback action tag.
5654
+ * @param string $recurrence 'single' or 'daily'.
5655
+ * @param int $start_at Defaults to now.
5656
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
5657
+ * @param int $except_blog_id Target any except the excluded blog ID.
5658
+ */
5659
+ private function schedule_cron(
5660
+ $name,
5661
+ $action_tag = '',
5662
+ $recurrence = 'single',
5663
+ $start_at = WP_FS__SCRIPT_START_TIME,
5664
+ $randomize_start = true,
5665
+ $except_blog_id = 0
5666
+ ) {
5667
+ $this->_logger->entrance( $name );
5668
+
5669
+ $this->clear_cron( $name, $action_tag, true );
5670
+
5671
+ $cron_blog_id = $this->get_cron_target_blog_id( $except_blog_id );
5672
+
5673
+ if ( is_multisite() && 0 == $cron_blog_id ) {
5674
+ // Don't schedule cron since couldn't find a target blog.
5675
+ return;
5676
+ }
5677
+
5678
+ if ( 0 < $cron_blog_id ) {
5679
+ switch_to_blog( $cron_blog_id );
5680
+ }
5681
+
5682
+ if ( 'daily' === $recurrence ) {
5683
+ if ( $randomize_start ) {
5684
+ // Schedule first sync with a random 12 hour time range from now.
5685
+ $start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
5686
+ }
5687
+
5688
+ // Schedule daily WP cron.
5689
+ wp_schedule_event(
5690
+ $start_at,
5691
+ 'daily',
5692
+ $this->get_action_tag( $action_tag )
5693
+ );
5694
+ } else if ( 'single' === $recurrence ) {
5695
+ // Schedule single cron.
5696
+ wp_schedule_single_event(
5697
+ $start_at,
5698
+ $this->get_action_tag( $action_tag )
5699
+ );
5700
+ }
5701
+
5702
+ $this->set_cron_data( $name, $cron_blog_id );
5703
+
5704
+ if ( 0 < $cron_blog_id ) {
5705
+ restore_current_blog();
5706
+ }
5707
+ }
5708
+
5709
+ /**
5710
+ * Consolidated cron execution for performance optimization. The max number of API requests is based on the number of unique opted-in users.
5711
+ * that doesn't halt page loading.
5712
+ *
5713
+ * @author Vova Feldman (@svovaf)
5714
+ * @since 2.0.0
5715
+ *
5716
+ * @param string $name Cron name.
5717
+ * @param callable $callable The function that should be executed.
5718
+ */
5719
+ private function execute_cron( $name, $callable ) {
5720
+ $this->_logger->entrance( $name );
5721
+
5722
+ // Store the last time data sync was executed.
5723
+ $this->set_cron_execution_timestamp( $name );
5724
+
5725
+ // Check if API is temporary down.
5726
+ if ( FS_Api::is_temporary_down() ) {
5727
+ return;
5728
+ }
5729
+
5730
+ // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
5731
+
5732
+ $users_2_blog_ids = array();
5733
+
5734
+ if ( ! is_multisite() ) {
5735
+ // Add dummy blog.
5736
+ $users_2_blog_ids[0] = array( 0 );
5737
+ } else {
5738
+ $installs = $this->get_blog_install_map();
5739
+ foreach ( $installs as $blog_id => $install ) {
5740
+ if ( $this->is_premium() || $install->is_tracking_allowed() ) {
5741
+ if ( ! isset( $users_2_blog_ids[ $install->user_id ] ) ) {
5742
+ $users_2_blog_ids[ $install->user_id ] = array();
5743
+ }
5744
+
5745
+ $users_2_blog_ids[ $install->user_id ][] = $blog_id;
5746
+ }
5747
+ }
5748
+ }
5749
+
5750
+ foreach ( $users_2_blog_ids as $user_id => $blog_ids ) {
5751
+ if ( 0 < $blog_ids[0] ) {
5752
+ $this->switch_to_blog( $blog_ids[0] );
5753
+ }
5754
+
5755
+ call_user_func_array( $callable, array( $blog_ids ) );
5756
+
5757
+ foreach ( $blog_ids as $blog_id ) {
5758
+ $this->do_action( "after_{$name}_cron", $blog_id );
5759
+ }
5760
+ }
5761
+
5762
+ if ( is_multisite() ) {
5763
+ $this->do_action( "after_{$name}_cron_multisite" );
5764
+ }
5765
+ }
5766
+
5767
+ #endregion
5768
+
5769
+ #----------------------------------------------------------------------------------
5770
+ #region Daily Sync Cron
5771
+ #----------------------------------------------------------------------------------
5772
+
5773
+
5774
+ /**
5775
+ * @author Vova Feldman (@svovaf)
5776
+ * @since 2.0.0
5777
+ *
5778
+ * @return bool
5779
+ */
5780
+ private function is_sync_cron_scheduled() {
5781
+ return $this->is_cron_on( 'sync' );
5782
+ }
5783
+
5784
+ /**
5785
+ * Get the sync cron's executing blog ID.
5786
+ *
5787
+ * @author Vova Feldman (@svovaf)
5788
+ * @since 2.0.0
5789
+ *
5790
+ * @return int
5791
+ */
5792
+ private function get_sync_cron_blog_id() {
5793
+ return $this->get_cron_blog_id( 'sync' );
5794
+ }
5795
+
5796
+ /**
5797
+ * @author Vova Feldman (@svovaf)
5798
+ * @since 1.1.7.3
5799
+ */
5800
+ private function run_manual_sync() {
5801
+ self::require_pluggable_essentials();
5802
+
5803
+ if ( ! $this->is_user_admin() ) {
5804
+ return;
5805
+ }
5806
+
5807
+ // Run manual sync.
5808
+ $this->_sync_cron();
5809
+
5810
+ // Reschedule next cron to run 24 hours from now (performance optimization).
5811
+ $this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
5812
+ }
5813
+
5814
+ /**
5815
+ * Data sync cron job. Replaces the background sync non blocking HTTP request
5816
+ * that doesn't halt page loading.
5817
+ *
5818
+ * @author Vova Feldman (@svovaf)
5819
+ * @since 1.1.7.3
5820
+ * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
5821
+ */
5822
+ function _sync_cron() {
5823
+ $this->_logger->entrance();
5824
+
5825
+ $this->execute_cron( 'sync', array( &$this, '_sync_cron_method' ) );
5826
+ }
5827
+
5828
+ /**
5829
+ * The actual data sync cron logic.
5830
+ *
5831
+ * @author Vova Feldman (@svovaf)
5832
+ * @since 2.0.0
5833
+ *
5834
+ * @param int[] $blog_ids
5835
+ */
5836
+ function _sync_cron_method( array $blog_ids ) {
5837
+ if ( $this->is_registered() ) {
5838
+ if ( $this->has_paid_plan() ) {
5839
+ // Initiate background plan sync.
5840
+ $this->_sync_license( true );
5841
+
5842
+ if ( $this->is_paying() ) {
5843
+ // Check for premium plugin updates.
5844
+ $this->check_updates( true );
5845
+ }
5846
+ } else {
5847
+ // Sync install(s) (only if something changed locally).
5848
+ if ( 1 < count( $blog_ids ) ) {
5849
+ $this->sync_installs();
5850
+ } else {
5851
+ $this->sync_install();
5852
+ }
5853
+ }
5854
+ }
5855
+ }
5856
+
5857
+ /**
5858
+ * Check if sync was executed in the last $period of seconds.
5859
+ *
5860
+ * @author Vova Feldman (@svovaf)
5861
+ * @since 1.1.7.3
5862
+ *
5863
+ * @param int $period In seconds
5864
+ *
5865
+ * @return bool
5866
+ */
5867
+ private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
5868
+ return $this->is_cron_executed( 'sync', $period );
5869
+ }
5870
+
5871
+ /**
5872
+ * @author Vova Feldman (@svovaf)
5873
+ * @since 1.1.7.3
5874
+ *
5875
+ * @return bool
5876
+ */
5877
+ private function is_sync_cron_on() {
5878
+ return $this->is_cron_on( 'sync' );
5879
+ }
5880
+
5881
+ /**
5882
+ * @author Vova Feldman (@svovaf)
5883
+ * @since 1.1.7.3
5884
+ *
5885
+ * @param int $start_at Defaults to now.
5886
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
5887
+ * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
5888
+ */
5889
+ private function schedule_sync_cron(
5890
+ $start_at = WP_FS__SCRIPT_START_TIME,
5891
+ $randomize_start = true,
5892
+ $except_blog_id = 0
5893
+ ) {
5894
+ $this->schedule_cron(
5895
+ 'sync',
5896
+ 'data_sync',
5897
+ 'daily',
5898
+ $start_at,
5899
+ $randomize_start,
5900
+ $except_blog_id
5901
+ );
5902
+ }
5903
+
5904
+ /**
5905
+ * Add the actual sync function to the cron job hook.
5906
+ *
5907
+ * @author Vova Feldman (@svovaf)
5908
+ * @since 1.1.7.3
5909
+ */
5910
+ private function hook_callback_to_sync_cron() {
5911
+ $this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
5912
+ }
5913
+
5914
+ /**
5915
+ * @author Vova Feldman (@svovaf)
5916
+ * @since 1.1.7.3
5917
+ *
5918
+ * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
5919
+ */
5920
+ private function clear_sync_cron( $is_network_clear = false ) {
5921
+ $this->_logger->entrance();
5922
+
5923
+ $this->clear_cron( 'sync', 'data_sync', $is_network_clear );
5924
+ }
5925
+
5926
+ /**
5927
+ * Unix timestamp for next sync cron execution or false if not scheduled.
5928
+ *
5929
+ * @author Vova Feldman (@svovaf)
5930
+ * @since 1.1.7.3
5931
+ *
5932
+ * @return int|false
5933
+ */
5934
+ function next_sync_cron() {
5935
+ return $this->get_next_scheduled_cron( 'sync', 'data_sync' );
5936
+ }
5937
+
5938
+ /**
5939
+ * Unix timestamp for previous sync cron execution or false if never executed.
5940
+ *
5941
+ * @author Vova Feldman (@svovaf)
5942
+ * @since 1.1.7.3
5943
+ *
5944
+ * @return int|false
5945
+ */
5946
+ function last_sync_cron() {
5947
+ return $this->cron_last_execution( 'sync' );
5948
+ }
5949
+
5950
+ #endregion Daily Sync Cron ------------------------------------------------------------------
5951
+
5952
+ #----------------------------------------------------------------------------------
5953
+ #region Async Install Sync
5954
+ #----------------------------------------------------------------------------------
5955
+
5956
+ /**
5957
+ * @author Vova Feldman (@svovaf)
5958
+ * @since 1.1.7.3
5959
+ *
5960
+ * @return bool
5961
+ */
5962
+ private function is_install_sync_scheduled() {
5963
+ return $this->is_cron_on( 'install_sync' );
5964
+ }
5965
+
5966
+ /**
5967
+ * Get the sync cron's executing blog ID.
5968
+ *
5969
+ * @author Vova Feldman (@svovaf)
5970
+ * @since 2.0.0
5971
+ *
5972
+ * @return int
5973
+ */
5974
+ private function get_install_sync_cron_blog_id() {
5975
+ return $this->get_cron_blog_id( 'install_sync' );
5976
+ }
5977
+
5978
+ /**
5979
+ * Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
5980
+ *
5981
+ * @author Vova Feldman (@svovaf)
5982
+ * @since 1.1.7.3
5983
+ *
5984
+ * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
5985
+ */
5986
+ private function schedule_install_sync( $except_blog_id = 0 ) {
5987
+ $this->schedule_cron( 'install_sync', 'install_sync', 'single', 0, false, $except_blog_id );
5988
+ }
5989
+
5990
+ /**
5991
+ * Unix timestamp for previous install sync cron execution or false if never executed.
5992
+ *
5993
+ * @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being updated. But for sure the sync event is working.
5994
+ *
5995
+ * @author Vova Feldman (@svovaf)
5996
+ * @since 1.1.7.3
5997
+ *
5998
+ * @return int|false
5999
+ */
6000
+ function last_install_sync() {
6001
+ return $this->cron_last_execution( 'install_sync' );
6002
+ }
6003
+
6004
+ /**
6005
+ * Unix timestamp for next install sync cron execution or false if not scheduled.
6006
+ *
6007
+ * @author Vova Feldman (@svovaf)
6008
+ * @since 1.1.7.3
6009
+ *
6010
+ * @return int|false
6011
+ */
6012
+ function next_install_sync() {
6013
+ return $this->get_next_scheduled_cron( 'install_sync', 'install_sync' );
6014
+ }
6015
+
6016
+ /**
6017
+ * Add the actual install sync function to the cron job hook.
6018
+ *
6019
+ * @author Vova Feldman (@svovaf)
6020
+ * @since 1.1.7.3
6021
+ */
6022
+ private function hook_callback_to_install_sync() {
6023
+ $this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
6024
+ }
6025
+
6026
+ /**
6027
+ * @author Vova Feldman (@svovaf)
6028
+ * @since 1.1.7.3
6029
+ *
6030
+ * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
6031
+ */
6032
+ private function clear_install_sync_cron( $is_network_clear = false ) {
6033
+ $this->_logger->entrance();
6034
+
6035
+ $this->clear_cron( 'install_sync', 'install_sync', $is_network_clear );
6036
+ }
6037
+
6038
+ /**
6039
+ * @author Vova Feldman (@svovaf)
6040
+ * @since 1.1.7.3
6041
+ * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
6042
+ */
6043
+ public function _run_sync_install() {
6044
+ $this->_logger->entrance();
6045
+
6046
+ $this->execute_cron( 'sync', array( &$this, '_sync_install_cron_method' ) );
6047
+ }
6048
+
6049
+ /**
6050
+ * The actual install(s) sync cron logic.
6051
+ *
6052
+ * @author Vova Feldman (@svovaf)
6053
+ * @since 2.0.0
6054
+ *
6055
+ * @param int[] $blog_ids
6056
+ */
6057
+ function _sync_install_cron_method( array $blog_ids ) {
6058
+ if ( $this->is_registered() ) {
6059
+ if ( 1 < count( $blog_ids ) ) {
6060
+ $this->sync_installs( array(), true );
6061
+ } else {
6062
+ $this->sync_install( array(), true );
6063
+ }
6064
+ }
6065
+ }
6066
+
6067
+ #endregion Async Install Sync ------------------------------------------------------------------
6068
+
6069
+ /**
6070
+ * Show a notice that activation is currently pending.
6071
+ *
6072
+ * @author Vova Feldman (@svovaf)
6073
+ * @since 1.0.7
6074
+ *
6075
+ * @param bool|string $email
6076
+ * @param bool $is_pending_trial Since 1.2.1.5
6077
+ */
6078
+ function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) {
6079
+ if ( ! is_string( $email ) ) {
6080
+ $current_user = self::_get_current_wp_user();
6081
+ $email = $current_user->user_email;
6082
+ }
6083
+
6084
+ $this->_admin_notices->add_sticky(
6085
+ sprintf(
6086
+ $this->get_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message' ),
6087
+ '<b>' . $this->get_plugin_name() . '</b>',
6088
+ '<b>' . $email . '</b>',
6089
+ ( $is_pending_trial ?
6090
+ $this->get_text_inline( 'start the trial', 'start-the-trial' ) :
6091
+ $this->get_text_inline( 'complete the install', 'complete-the-install' ) )
6092
+ ),
6093
+ 'activation_pending',
6094
+ 'Thanks!'
6095
+ );
6096
+ }
6097
+
6098
+ /**
6099
+ * Check if currently in plugin activation.
6100
+ *
6101
+ * @author Vova Feldman (@svovaf)
6102
+ * @since 1.1.4
6103
+ *
6104
+ * @return bool
6105
+ */
6106
+ function is_plugin_activation() {
6107
+ $result = get_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
6108
+
6109
+ return !empty($result);
6110
+ }
6111
+
6112
+ /**
6113
+ *
6114
+ * NOTE: admin_menu action executed before admin_init.
6115
+ *
6116
+ * @author Vova Feldman (@svovaf)
6117
+ * @since 1.0.7
6118
+ */
6119
+ function _admin_init_action() {
6120
+ /**
6121
+ * Automatically redirect to connect/activation page after plugin activation.
6122
+ *
6123
+ * @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
6124
+ */
6125
+ if ( $this->is_plugin_activation() ) {
6126
+ delete_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
6127
+
6128
+ if ( isset( $_GET['activate-multi'] ) ) {
6129
+ /**
6130
+ * Don't redirect if activating multiple plugins at once (bulk activation).
6131
+ */
6132
+ } else {
6133
+ $this->_redirect_on_activation_hook();
6134
+ return;
6135
+ }
6136
+ }
6137
+
6138
+ if ( fs_request_is_action( $this->get_unique_affix() . '_skip_activation' ) ) {
6139
+ check_admin_referer( $this->get_unique_affix() . '_skip_activation' );
6140
+
6141
+ $this->skip_connection( null, fs_is_network_admin() );
6142
+
6143
+ fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) );
6144
+ }
6145
+
6146
+ if ( $this->is_network_activation_mode() &&
6147
+ fs_request_is_action( $this->get_unique_affix() . '_delegate_activation' )
6148
+ ) {
6149
+ check_admin_referer( $this->get_unique_affix() . '_delegate_activation' );
6150
+
6151
+ $this->delegate_connection();
6152
+
6153
+ fs_redirect( $this->get_after_activation_url( 'after_delegation_url' ) );
6154
+ }
6155
+
6156
+ $this->_add_upgrade_action_link();
6157
+
6158
+ if ( ! $this->is_addon() &&
6159
+ ! ( ! $this->_is_network_active && fs_is_network_admin() ) &&
6160
+ (
6161
+ // Not registered nor anonymous.
6162
+ ( ! $this->is_registered() && ! $this->is_anonymous() ) ||
6163
+ // OR, network level and in network upgrade mode.
6164
+ ( fs_is_network_admin() && $this->_is_network_active && $this->is_network_upgrade_mode() )
6165
+ )
6166
+ ) {
6167
+ if ( ! $this->is_pending_activation() ) {
6168
+ if ( ! $this->_menu->is_main_settings_page() ) {
6169
+ /**
6170
+ * If a user visits any other admin page before activating the premium-only theme with a valid
6171
+ * license, reactivate the previous theme.
6172
+ *
6173
+ * @author Leo Fajardo (@leorw)
6174
+ * @since 1.2.2
6175
+ */
6176
+ if ( $this->is_theme()
6177
+ && $this->is_only_premium()
6178
+ && ! $this->has_settings_menu()
6179
+ && ! isset( $_REQUEST['fs_action'] )
6180
+ && $this->can_activate_previous_theme()
6181
+ ) {
6182
+ $this->activate_previous_theme();
6183
+
6184
+ return;
6185
+ }
6186
+
6187
+ if ( ! fs_is_network_admin() &&
6188
+ $this->is_network_activation_mode() &&
6189
+ ! $this->is_delegated_connection()
6190
+ ) {
6191
+ return;
6192
+ }
6193
+
6194
+ if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
6195
+ // Show notice for new plugin installations.
6196
+ $this->_admin_notices->add(
6197
+ sprintf(
6198
+ $this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
6199
+ sprintf( '<b><a href="%s">%s</a></b>',
6200
+ $this->get_activation_url( array(), ! $this->is_delegated_connection() ),
6201
+ sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
6202
+ '%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
6203
+ )
6204
+ ),
6205
+ '',
6206
+ 'update-nag'
6207
+ );
6208
+ } else {
6209
+ if ( $this->should_add_sticky_optin_notice() ) {
6210
+ $this->add_sticky_optin_admin_notice();
6211
+ }
6212
+
6213
+ if ( $this->has_filter( 'optin_pointer_element' ) ) {
6214
+ // Don't show admin nag if plugin update.
6215
+ wp_enqueue_script( 'wp-pointer' );
6216
+ wp_enqueue_style( 'wp-pointer' );
6217
+
6218
+ $this->_enqueue_connect_essentials();
6219
+
6220
+ add_action( 'admin_print_footer_scripts', array(
6221
+ $this,
6222
+ '_add_connect_pointer_script'
6223
+ ) );
6224
+ }
6225
+ }
6226
+ }
6227
+ }
6228
+
6229
+ if ( $this->is_theme() &&
6230
+ $this->_menu->is_main_settings_page()
6231
+ ) {
6232
+ $this->_show_theme_activation_optin_dialog();
6233
+ }
6234
+ }
6235
+ }
6236
+
6237
+ /**
6238
+ * @author Vova Feldman (@svovaf)
6239
+ * @since 2.0.0
6240
+ *
6241
+ * @return bool
6242
+ */
6243
+ private function should_add_sticky_optin_notice() {
6244
+ if ( fs_is_network_admin() ) {
6245
+ if ( ! $this->_is_network_active ) {
6246
+ return false;
6247
+ }
6248
+
6249
+ if ( ! $this->is_network_activation_mode() ) {
6250
+ return false;
6251
+ }
6252
+
6253
+ return ! isset( $this->_storage->sticky_optin_added_ms );
6254
+ }
6255
+
6256
+ if ( ! $this->is_activation_mode() ) {
6257
+ return false;
6258
+ }
6259
+
6260
+ // If running from a blog admin and delegated the connection.
6261
+ return ! isset( $this->_storage->sticky_optin_added );
6262
+ }
6263
+
6264
+ /**
6265
+ * @author Leo Fajardo (@leorw)
6266
+ * @since 2.0.0
6267
+ */
6268
+ private function add_sticky_optin_admin_notice() {
6269
+ if ( ! $this->_is_network_active || ! fs_is_network_admin() ) {
6270
+ $this->_storage->sticky_optin_added = true;
6271
+ } else {
6272
+ $this->_storage->sticky_optin_added_ms = true;
6273
+ }
6274
+
6275
+ // Show notice for new plugin installations.
6276
+ $this->_admin_notices->add_sticky(
6277
+ sprintf(
6278
+ $this->get_text_inline( 'We made a few tweaks to the %s, %s', 'few-plugin-tweaks' ),
6279
+ $this->_module_type,
6280
+ sprintf( '<b><a href="%s">%s</a></b>',
6281
+ $this->get_activation_url(),
6282
+ sprintf( $this->get_text_inline( 'Opt in to make "%s" Better!', 'optin-x-now' ), $this->get_plugin_name() )
6283
+ )
6284
+ ),
6285
+ 'connect_account',
6286
+ '',
6287
+ 'update-nag'
6288
+ );
6289
+ }
6290
+
6291
+ /**
6292
+ * Enqueue connect requires scripts and styles.
6293
+ *
6294
+ * @author Vova Feldman (@svovaf)
6295
+ * @since 1.1.4
6296
+ */
6297
+ function _enqueue_connect_essentials() {
6298
+ wp_enqueue_script( 'jquery' );
6299
+ wp_enqueue_script( 'json2' );
6300
+
6301
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
6302
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
6303
+
6304
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
6305
+ }
6306
+
6307
+ /**
6308
+ * Add connect / opt-in pointer.
6309
+ *
6310
+ * @author Vova Feldman (@svovaf)
6311
+ * @since 1.1.4
6312
+ */
6313
+ function _add_connect_pointer_script() {
6314
+ $vars = array( 'id' => $this->_module_id );
6315
+ $pointer_content = fs_get_template( 'connect.php', $vars );
6316
+ ?>
6317
+ <script type="text/javascript">// <![CDATA[
6318
+ jQuery(document).ready(function ($) {
6319
+ if ('undefined' !== typeof(jQuery().pointer)) {
6320
+
6321
+ var element = <?php echo $this->apply_filters( 'optin_pointer_element', '$("#non_existing_element");' ) ?>;
6322
+
6323
+ if (element.length > 0) {
6324
+ var optin = $(element).pointer($.extend(true, {}, {
6325
+ content : <?php echo json_encode( $pointer_content ) ?>,
6326
+ position : {
6327
+ edge : 'left',
6328
+ align: 'center'
6329
+ },
6330
+ buttons : function () {
6331
+ // Don't show pointer buttons.
6332
+ return '';
6333
+ },
6334
+ pointerWidth: 482
6335
+ }, <?php echo $this->apply_filters( 'optin_pointer_options_json', '{}' ) ?>));
6336
+
6337
+ <?php
6338
+ echo $this->apply_filters( 'optin_pointer_execute', "
6339
+
6340
+ optin.pointer('open');
6341
+
6342
+ // Tag the opt-in pointer with custom class.
6343
+ $('.wp-pointer #fs_connect')
6344
+ .parents('.wp-pointer.wp-pointer-top')
6345
+ .addClass('fs-opt-in-pointer');
6346
+
6347
+ ", 'element', 'optin' ) ?>
6348
+ }
6349
+ }
6350
+ });
6351
+ // ]]></script>
6352
+ <?php
6353
+ }
6354
+
6355
+ /**
6356
+ * Return current page's URL.
6357
+ *
6358
+ * @author Vova Feldman (@svovaf)
6359
+ * @since 1.0.7
6360
+ *
6361
+ * @return string
6362
+ */
6363
+ function current_page_url() {
6364
+ $url = 'http';
6365
+
6366
+ if ( isset( $_SERVER["HTTPS"] ) ) {
6367
+ if ( $_SERVER["HTTPS"] == "on" ) {
6368
+ $url .= "s";
6369
+ }
6370
+ }
6371
+ $url .= "://";
6372
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
6373
+ $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
6374
+ } else {
6375
+ $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
6376
+ }
6377
+
6378
+ return esc_url( $url );
6379
+ }
6380
+
6381
+ /**
6382
+ * Check if the current page is the plugin's main admin settings page.
6383
+ *
6384
+ * @author Vova Feldman (@svovaf)
6385
+ * @since 1.0.7
6386
+ *
6387
+ * @return bool
6388
+ */
6389
+ function _is_plugin_page() {
6390
+ return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
6391
+ fs_is_plugin_page( $this->_slug );
6392
+ }
6393
+
6394
+ /* Events
6395
+ ------------------------------------------------------------------------------------------------------------------*/
6396
+ /**
6397
+ * Delete site install from Database.
6398
+ *
6399
+ * @author Vova Feldman (@svovaf)
6400
+ * @since 1.0.1
6401
+ *
6402
+ * @param bool $store
6403
+ * @param int|null $blog_id Since 2.0.0
6404
+ *
6405
+ * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
6406
+ */
6407
+ function _delete_site( $store = true, $blog_id = null ) {
6408
+ return self::_delete_site_by_slug( $this->_slug, $this->_module_type, $store, $blog_id );
6409
+ }
6410
+
6411
+ /**
6412
+ * Delete site install from Database.
6413
+ *
6414
+ * @author Vova Feldman (@svovaf)
6415
+ * @since 1.2.2.7
6416
+ *
6417
+ * @param string $slug
6418
+ * @param string $module_type
6419
+ * @param bool $store
6420
+ * @param int|null $blog_id Since 2.0.0
6421
+ *
6422
+ * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
6423
+ */
6424
+ static function _delete_site_by_slug( $slug, $module_type, $store = true, $blog_id = null ) {
6425
+ $sites = self::get_all_sites( $module_type, $blog_id );
6426
+
6427
+ $install_id = false;
6428
+
6429
+ if ( isset( $sites[ $slug ] ) ) {
6430
+ if ( is_object( $sites[ $slug ] ) ) {
6431
+ $install_id = $sites[ $slug ]->id;
6432
+ }
6433
+
6434
+ unset( $sites[ $slug ] );
6435
+
6436
+ self::set_account_option_by_module( $module_type, 'sites', $sites, $store, $blog_id );
6437
+ }
6438
+
6439
+ return $install_id;
6440
+ }
6441
+
6442
+ /**
6443
+ * Delete user.
6444
+ *
6445
+ * @author Vova Feldman (@svovaf)
6446
+ * @since 2.0.0
6447
+ *
6448
+ * @param number $user_id
6449
+ * @param bool $store
6450
+ *
6451
+ * @return false|int The user ID if deleted. Otherwise, FALSE (when install not exist).
6452
+ */
6453
+ private static function delete_user( $user_id, $store = true ) {
6454
+ $users = self::get_all_users();
6455
+
6456
+ if ( ! is_array( $users ) || ! isset( $users[ $user_id ] ) ) {
6457
+ return false;
6458
+ }
6459
+
6460
+ unset( $users[ $user_id ] );
6461
+
6462
+ self::$_accounts->set_option( 'users', $users, $store );
6463
+
6464
+ return $user_id;
6465
+ }
6466
+
6467
+ /**
6468
+ * Delete plugin's plans information.
6469
+ *
6470
+ * @param bool $store Flush to Database if true.
6471
+ * @param bool $keep_associated_plans If set to false, delete all plans, even if a plan is associated with an install.
6472
+ *
6473
+ * @author Vova Feldman (@svovaf)
6474
+ * @since 1.0.9
6475
+ */
6476
+ private function _delete_plans( $store = true, $keep_associated_plans = true ) {
6477
+ $this->_logger->entrance();
6478
+
6479
+ $plans = self::get_all_plans( $this->_module_type );
6480
+
6481
+ $plans_to_keep = array();
6482
+
6483
+ if ( $keep_associated_plans ) {
6484
+ $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
6485
+ foreach ( $plans_ids_to_keep as $plan_id ) {
6486
+ $plan = self::_get_plan_by_id( $plan_id );
6487
+ if ( is_object( $plan ) ) {
6488
+ $plans_to_keep[] = $plan;
6489
+ }
6490
+ }
6491
+ }
6492
+
6493
+ if ( ! empty( $plans_to_keep ) ) {
6494
+ $plans[ $this->_slug ] = $plans_to_keep;
6495
+ } else {
6496
+ unset( $plans[ $this->_slug ] );
6497
+ }
6498
+
6499
+ $this->set_account_option( 'plans', $plans, $store );
6500
+ }
6501
+
6502
+ /**
6503
+ * Delete all plugin licenses.
6504
+ *
6505
+ * @author Vova Feldman (@svovaf)
6506
+ * @since 1.0.9
6507
+ *
6508
+ * @param bool $store
6509
+ */
6510
+ private function _delete_licenses( $store = true ) {
6511
+ $this->_logger->entrance();
6512
+
6513
+ $all_licenses = self::get_all_licenses();
6514
+
6515
+ unset( $all_licenses[ $this->_module_id ] );
6516
+
6517
+ self::$_accounts->set_option( 'all_licenses', $all_licenses, $store );
6518
+ }
6519
+
6520
+ /**
6521
+ * Check if Freemius was added on new plugin installation.
6522
+ *
6523
+ * @author Vova Feldman (@svovaf)
6524
+ * @since 1.1.5
6525
+ *
6526
+ * @return bool
6527
+ */
6528
+ function is_plugin_new_install() {
6529
+ return isset( $this->_storage->is_plugin_new_install ) &&
6530
+ $this->_storage->is_plugin_new_install;
6531
+ }
6532
+
6533
+ /**
6534
+ * Check if it's the first plugin release that is running Freemius.
6535
+ *
6536
+ * @author Vova Feldman (@svovaf)
6537
+ * @since 1.2.1.5
6538
+ *
6539
+ * @return bool
6540
+ */
6541
+ function is_first_freemius_powered_version() {
6542
+ return empty( $this->_storage->plugin_last_version );
6543
+ }
6544
+
6545
+ /**
6546
+ * @author Leo Fajardo (@leorw)
6547
+ * @since 1.2.2
6548
+ *
6549
+ * @return bool|string
6550
+ */
6551
+ private function get_previous_theme_slug() {
6552
+ return isset( $this->_storage->previous_theme ) ?
6553
+ $this->_storage->previous_theme :
6554
+ false;
6555
+ }
6556
+
6557
+ /**
6558
+ * @author Leo Fajardo (@leorw)
6559
+ * @since 1.2.2
6560
+ *
6561
+ * @return string
6562
+ */
6563
+ private function can_activate_previous_theme() {
6564
+ $slug = $this->get_previous_theme_slug();
6565
+ if ( false !== $slug && current_user_can( 'switch_themes' ) ) {
6566
+ $theme_instance = wp_get_theme( $slug );
6567
+
6568
+ return $theme_instance->exists();
6569
+ }
6570
+
6571
+ return false;
6572
+ }
6573
+
6574
+ /**
6575
+ * @author Leo Fajardo (@leorw)
6576
+ * @since 1.2.2
6577
+ */
6578
+ private function activate_previous_theme() {
6579
+ switch_theme( $this->get_previous_theme_slug() );
6580
+ unset( $this->_storage->previous_theme );
6581
+
6582
+ global $pagenow;
6583
+ if ( 'themes.php' === $pagenow ) {
6584
+ /**
6585
+ * Refresh the active theme information.
6586
+ *
6587
+ * @author Leo Fajardo (@leorw)
6588
+ * @since 1.2.2
6589
+ */
6590
+ fs_redirect( $this->admin_url( $pagenow ) );
6591
+ }
6592
+ }
6593
+
6594
+ /**
6595
+ * @author Leo Fajardo (@leorw)
6596
+ * @since 1.2.2
6597
+ *
6598
+ * @return string
6599
+ */
6600
+ function get_previous_theme_activation_url() {
6601
+ if ( ! $this->can_activate_previous_theme() ) {
6602
+ return '';
6603
+ }
6604
+
6605
+ /**
6606
+ * Activation URL
6607
+ *
6608
+ * @author Leo Fajardo (@leorw)
6609
+ * @since 1.2.2
6610
+ */
6611
+ return wp_nonce_url(
6612
+ $this->admin_url( 'themes.php?action=activate&stylesheet=' . urlencode( $this->get_previous_theme_slug() ) ),
6613
+ 'switch-theme_' . $this->get_previous_theme_slug()
6614
+ );
6615
+ }
6616
+
6617
+ /**
6618
+ * Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in
6619
+ * form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is
6620
+ * activated, the close button will appear and will reactivate the previous theme if clicked. If the previous
6621
+ * theme doesn't exist, then there will be no close button.
6622
+ *
6623
+ * @author Leo Fajardo (@leorw)
6624
+ * @since 1.2.2
6625
+ *
6626
+ * @param string $slug_or_name Old theme's slug or name.
6627
+ * @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
6628
+ */
6629
+ function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) {
6630
+ $this->_storage->previous_theme = ( false !== $old_theme ) ?
6631
+ $old_theme->get_stylesheet() :
6632
+ $slug_or_name;
6633
+
6634
+ $this->_activate_plugin_event_hook();
6635
+ }
6636
+
6637
+ /**
6638
+ * Plugin activated hook.
6639
+ *
6640
+ * @author Vova Feldman (@svovaf)
6641
+ * @since 1.0.1
6642
+ *
6643
+ * @uses FS_Api
6644
+ */
6645
+ function _activate_plugin_event_hook() {
6646
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
6647
+
6648
+ if ( ! $this->is_user_admin() ) {
6649
+ return;
6650
+ }
6651
+
6652
+ $this->unregister_uninstall_hook();
6653
+
6654
+ // Clear API cache on activation.
6655
+ FS_Api::clear_cache();
6656
+
6657
+ $is_premium_version_activation = ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) );
6658
+
6659
+ $this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
6660
+
6661
+ // 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
6662
+ // 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
6663
+ $other_version_basename = $is_premium_version_activation ?
6664
+ $this->_free_plugin_basename :
6665
+ $this->premium_plugin_basename();
6666
+
6667
+ if ( ! $this->_is_network_active ) {
6668
+ /**
6669
+ * During the activation, the plugin isn't yet active, therefore,
6670
+ * _is_network_active will be set to false even if it's a network level
6671
+ * activation. So we need to fix that by looking at the is_network_admin() value.
6672
+ *
6673
+ * @author Vova Feldman
6674
+ */
6675
+ $this->_is_network_active = (
6676
+ $this->_is_multisite_integrated &&
6677
+ // Themes are always network activated, but the ACTUAL activation is per site.
6678
+ $this->is_plugin() &&
6679
+ fs_is_network_admin()
6680
+ );
6681
+ }
6682
+
6683
+ /**
6684
+ * If the other module version is activate, deactivate it.
6685
+ *
6686
+ * is_plugin_active() checks if the plugin active on the site or the network level
6687
+ * and deactivate_plugins() deactivates the plugin whether its activated on the site
6688
+ * or network level.
6689
+ *
6690
+ * @author Leo Fajardo (@leorw)
6691
+ * @since 1.2.2
6692
+ */
6693
+ if ( is_plugin_active( $other_version_basename ) ) {
6694
+ deactivate_plugins( $other_version_basename );
6695
+ }
6696
+
6697
+ if ( $this->is_registered() ) {
6698
+ if ( $is_premium_version_activation ) {
6699
+ $this->reconnect_locally();
6700
+ }
6701
+
6702
+
6703
+ // Schedule re-activation event and sync.
6704
+ // $this->sync_install( array(), true );
6705
+ $this->schedule_install_sync();
6706
+
6707
+ // If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
6708
+ if ( $is_premium_version_activation ) {
6709
+ $this->_admin_notices->add(
6710
+ sprintf( $this->get_text_inline( 'The upgrade of %s was successfully completed.', 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
6711
+ $this->get_text_x_inline( 'W00t',
6712
+ 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
6713
+ );
6714
+ }
6715
+ } else if ( $this->is_anonymous() ) {
6716
+ if ( isset( $this->_storage->is_anonymous_ms ) && $this->_storage->is_anonymous_ms['is'] ) {
6717
+ $plugin_version = $this->_storage->is_anonymous_ms['version'];
6718
+ $network = true;
6719
+ } else {
6720
+ $plugin_version = $this->_storage->is_anonymous['version'];
6721
+ $network = false;
6722
+ }
6723
+
6724
+ /**
6725
+ * Reset "skipped" click cache on the following:
6726
+ * 1. Freemius DEV mode.
6727
+ * 2. WordPress DEBUG mode.
6728
+ * 3. If a plugin and the user skipped the exact same version before.
6729
+ *
6730
+ * @since 1.2.2.7 Ulrich Pogson (@grapplerulrich) asked to not reset the SKIPPED flag if the exact same THEME version was activated before unless the developer is running with WP_DEBUG on, or Freemius debug mode on (WP_FS__DEV_MODE).
6731
+ *
6732
+ * @todo 4. If explicitly asked to retry after every activation.
6733
+ */
6734
+ if ( WP_FS__DEV_MODE ||
6735
+ (
6736
+ ( $this->is_plugin() || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) &&
6737
+ $this->get_plugin_version() == $plugin_version
6738
+ )
6739
+ ) {
6740
+ $this->reset_anonymous_mode( $network );
6741
+ }
6742
+ }
6743
+
6744
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
6745
+ /**
6746
+ * If no previous version of plugin's version exist, it means that it's either
6747
+ * the first time that the plugin installed on the site, or the plugin was installed
6748
+ * before but didn't have Freemius integrated.
6749
+ *
6750
+ * Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
6751
+ * on manual activation via the dashboard, is_plugin_activation() is TRUE
6752
+ * only after immediate activation.
6753
+ *
6754
+ * @since 1.1.4
6755
+ * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
6756
+ */
6757
+ $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
6758
+ }
6759
+
6760
+ if ( ! $this->_anonymous_mode &&
6761
+ $this->has_api_connectivity( WP_FS__DEV_MODE ) &&
6762
+ ! $this->_isAutoInstall
6763
+ ) {
6764
+ // Store hint that the plugin was just activated to enable auto-redirection to settings.
6765
+ set_transient( "fs_{$this->_module_type}_{$this->_slug}_activated", true, 60 );
6766
+ }
6767
+
6768
+ /**
6769
+ * Activation hook is executed after the plugin's main file is loaded, therefore,
6770
+ * after the plugin was loaded. The logic is located at activate_plugin()
6771
+ * ./wp-admin/includes/plugin.php.
6772
+ *
6773
+ * @author Vova Feldman (@svovaf)
6774
+ * @since 1.1.9
6775
+ */
6776
+ $this->_storage->was_plugin_loaded = true;
6777
+ }
6778
+
6779
+ /**
6780
+ * Delete account.
6781
+ *
6782
+ * @author Vova Feldman (@svovaf)
6783
+ * @since 1.0.3
6784
+ *
6785
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
6786
+ */
6787
+ function delete_account_event( $check_user = true ) {
6788
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
6789
+
6790
+ if ( $check_user && ! $this->is_user_admin() ) {
6791
+ return;
6792
+ }
6793
+
6794
+ $this->do_action( 'before_account_delete' );
6795
+
6796
+ // Clear all admin notices.
6797
+ $this->_admin_notices->clear_all_sticky( false );
6798
+
6799
+ $this->_delete_site( false );
6800
+
6801
+ $delete_network_common_data = true;
6802
+
6803
+ if ( $this->_is_network_active ) {
6804
+ $installs = $this->get_blog_install_map();
6805
+
6806
+ // Don't delete common network data unless no other installs left.
6807
+ $delete_network_common_data = empty( $installs );
6808
+ }
6809
+
6810
+ if ( $delete_network_common_data ) {
6811
+ $this->_delete_plans( false );
6812
+
6813
+ $this->_delete_licenses( false );
6814
+
6815
+ // Delete add-ons related to plugin's account.
6816
+ $this->_delete_account_addons( false );
6817
+ }
6818
+
6819
+ // @todo Delete plans and licenses of add-ons.
6820
+
6821
+ self::$_accounts->store();
6822
+
6823
+ /**
6824
+ * IMPORTANT:
6825
+ * Clear crons must be executed before clearing all storage.
6826
+ * Otherwise, the cron will not be cleared.
6827
+ */
6828
+ if ( $delete_network_common_data ) {
6829
+ $this->clear_sync_cron();
6830
+ }
6831
+
6832
+ $this->clear_install_sync_cron();
6833
+
6834
+ // Clear all storage data.
6835
+ $this->_storage->clear_all( true, array(
6836
+ 'connectivity_test',
6837
+ 'is_on',
6838
+ ), false );
6839
+
6840
+ // Send delete event.
6841
+ $this->get_api_site_scope()->call( '/', 'delete' );
6842
+
6843
+ $this->do_action( 'after_account_delete' );
6844
+ }
6845
+
6846
+ /**
6847
+ * Delete network level account.
6848
+ *
6849
+ * @author Vova Feldman (@svovaf)
6850
+ * @since 2.0.0
6851
+ *
6852
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
6853
+ */
6854
+ function delete_network_account_event( $check_user = true ) {
6855
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
6856
+
6857
+ if ( $check_user && ! $this->is_user_admin() ) {
6858
+ return;
6859
+ }
6860
+
6861
+ $this->do_action( 'before_network_account_delete' );
6862
+
6863
+ // Clear all admin notices.
6864
+ $this->_admin_notices->clear_all_sticky();
6865
+
6866
+ $this->_delete_plans( false, false );
6867
+
6868
+ $this->_delete_licenses( false );
6869
+
6870
+ // Delete add-ons related to plugin's account.
6871
+ $this->_delete_account_addons( false );
6872
+
6873
+ // @todo Delete plans and licenses of add-ons.
6874
+
6875
+ self::$_accounts->store( true );
6876
+
6877
+ /**
6878
+ * IMPORTANT:
6879
+ * Clear crons must be executed before clearing all storage.
6880
+ * Otherwise, the cron will not be cleared.
6881
+ */
6882
+ $this->clear_sync_cron( true );
6883
+ $this->clear_install_sync_cron( true );
6884
+
6885
+ $sites = self::get_sites();
6886
+
6887
+ $install_ids = array();
6888
+ foreach ( $sites as $site ) {
6889
+ $blog_id = self::get_site_blog_id( $site );
6890
+
6891
+ $install_id = $this->_delete_site( true, $blog_id );
6892
+
6893
+ // Clear all storage data.
6894
+ $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id );
6895
+
6896
+ if ( FS_Site::is_valid_id( $install_id ) ) {
6897
+ $install_ids[] = $install_id;
6898
+ }
6899
+
6900
+ switch_to_blog( $blog_id );
6901
+
6902
+ $this->do_action( 'after_account_delete' );
6903
+
6904
+ restore_current_blog();
6905
+ }
6906
+
6907
+ $this->_storage->clear_all( true, array(
6908
+ 'connectivity_test',
6909
+ 'is_on',
6910
+ ), true );
6911
+
6912
+ // Send delete event.
6913
+ if ( ! empty( $install_ids ) ) {
6914
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' );
6915
+ }
6916
+
6917
+ $this->do_action( 'after_network_account_delete' );
6918
+ }
6919
+
6920
+ /**
6921
+ * Plugin deactivation hook.
6922
+ *
6923
+ * @author Vova Feldman (@svovaf)
6924
+ * @since 1.0.1
6925
+ */
6926
+ function _deactivate_plugin_hook() {
6927
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
6928
+
6929
+ if ( ! $this->is_user_admin() ) {
6930
+ return;
6931
+ }
6932
+
6933
+ $is_network_deactivation = fs_is_network_admin();
6934
+ $storage_keys_for_removal = array();
6935
+
6936
+ $this->_admin_notices->clear_all_sticky();
6937
+
6938
+ $storage_keys_for_removal[] = 'sticky_optin_added';
6939
+ if ( isset( $this->_storage->sticky_optin_added ) ) {
6940
+ unset( $this->_storage->sticky_optin_added );
6941
+ }
6942
+
6943
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
6944
+ // Remember that plugin was already installed.
6945
+ $this->_storage->is_plugin_new_install = false;
6946
+ }
6947
+
6948
+ // Hook to plugin uninstall.
6949
+ register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
6950
+
6951
+ $this->clear_module_main_file_cache();
6952
+ $this->clear_sync_cron( $this->_is_network_active );
6953
+ $this->clear_install_sync_cron();
6954
+
6955
+ if ( $this->is_registered() ) {
6956
+ if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
6957
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
6958
+ }
6959
+
6960
+ if ( $is_network_deactivation ) {
6961
+ // Send deactivation event.
6962
+ $this->sync_installs( array(
6963
+ 'is_active' => false,
6964
+ ) );
6965
+ } else {
6966
+ // Send deactivation event.
6967
+ $this->sync_install( array(
6968
+ 'is_active' => false,
6969
+ ) );
6970
+ }
6971
+ } else {
6972
+ if ( ! $this->has_api_connectivity() ) {
6973
+ // Reset connectivity test cache.
6974
+ unset( $this->_storage->connectivity_test );
6975
+
6976
+ $storage_keys_for_removal[] = 'connectivity_test';
6977
+ }
6978
+ }
6979
+
6980
+ if ( $is_network_deactivation ) {
6981
+ if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
6982
+ unset( $this->_storage->sticky_optin_added_ms );
6983
+ }
6984
+
6985
+ if ( ! empty( $storage_keys_for_removal ) ) {
6986
+ $sites = self::get_sites();
6987
+
6988
+ foreach ( $sites as $site ) {
6989
+ $blog_id = self::get_site_blog_id( $site );
6990
+
6991
+ foreach ( $storage_keys_for_removal as $key ) {
6992
+ $this->_storage->remove( $key, false, $blog_id );
6993
+ }
6994
+
6995
+ $this->_storage->save( $blog_id );
6996
+ }
6997
+ }
6998
+ }
6999
+
7000
+ // Clear API cache on deactivation.
7001
+ FS_Api::clear_cache();
7002
+
7003
+ $this->remove_sdk_reference();
7004
+ }
7005
+
7006
+ /**
7007
+ * @author Vova Feldman (@svovaf)
7008
+ * @since 1.1.6
7009
+ */
7010
+ private function remove_sdk_reference() {
7011
+ global $fs_active_plugins;
7012
+
7013
+ foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) {
7014
+ if ( $this->_plugin_basename == $data->plugin_path ) {
7015
+ unset( $fs_active_plugins->plugins[ $sdk_path ] );
7016
+ break;
7017
+ }
7018
+ }
7019
+
7020
+ fs_fallback_to_newest_active_sdk();
7021
+ }
7022
+
7023
+ /**
7024
+ * @author Vova Feldman (@svovaf)
7025
+ * @since 1.1.3
7026
+ *
7027
+ * @param bool $is_anonymous
7028
+ * @param bool|int $network_or_blog_id Since 2.0.0
7029
+ */
7030
+ private function set_anonymous_mode( $is_anonymous = true, $network_or_blog_id = 0 ) {
7031
+ // Store information regarding skip to try and opt-in the user
7032
+ // again in the future.
7033
+ $skip_info = array(
7034
+ 'is' => $is_anonymous,
7035
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
7036
+ 'version' => $this->get_plugin_version(),
7037
+ );
7038
+
7039
+ if ( true === $network_or_blog_id ) {
7040
+ $this->_storage->is_anonymous_ms = $skip_info;
7041
+ } else {
7042
+ $this->_storage->store( 'is_anonymous', $skip_info, $network_or_blog_id );
7043
+ }
7044
+
7045
+ $this->network_upgrade_mode_completed();
7046
+
7047
+ // Update anonymous mode cache.
7048
+ $this->_is_anonymous = $is_anonymous;
7049
+ }
7050
+
7051
+ /**
7052
+ * @author Vova Feldman (@svovaf)
7053
+ * @since 2.0.0
7054
+ *
7055
+ * @param int $blog_id Site ID.
7056
+ * @param int $user_id User ID.
7057
+ * @param string $domain Site domain.
7058
+ * @param string $path Site path.
7059
+ * @param int $network_id Network ID. Only relevant on multi-network installations.
7060
+ * @param array $meta Metadata. Used to set initial site options.
7061
+ *
7062
+ * @uses Freemius::is_license_network_active() to check if the context license was network activated by the super-admin.
7063
+ * @uses Freemius::is_network_connected() to check if the super-admin network opted-in.
7064
+ * @uses Freemius::is_network_anonymous() to check if the super-admin network skipped.
7065
+ * @uses Freemius::is_network_delegated_connection() to check if the super-admin network delegated the connection to the site admins.
7066
+ */
7067
+ function _after_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
7068
+ $this->_logger->entrance();
7069
+
7070
+ if ( $this->is_premium() &&
7071
+ $this->is_network_connected() &&
7072
+ is_object( $this->_license ) &&
7073
+ $this->_license->can_activate( FS_Site::is_localhost_by_address( $domain ) ) &&
7074
+ $this->is_license_network_active( $blog_id )
7075
+ ) {
7076
+ /**
7077
+ * Running the premium version, the license was network activated, and the license can also be activated on the current site -> so try to opt-in with the license key.
7078
+ */
7079
+ $current_blog_id = get_current_blog_id();
7080
+ $license = clone $this->_license;
7081
+
7082
+ $this->switch_to_blog( $blog_id );
7083
+
7084
+ // Opt-in with network user.
7085
+ $this->install_with_user(
7086
+ $this->get_network_user(),
7087
+ $license->secret_key,
7088
+ false,
7089
+ false,
7090
+ false
7091
+ );
7092
+
7093
+ if ( is_object( $this->_site ) ) {
7094
+ if ( $this->_site->license_id == $license->id ) {
7095
+ /**
7096
+ * If the license was activated successfully, sync the license data from the remote server.
7097
+ */
7098
+ $this->_license = $license;
7099
+ $this->sync_site_license();
7100
+ }
7101
+ }
7102
+
7103
+ $this->switch_to_blog( $current_blog_id );
7104
+
7105
+ if ( is_object( $this->_site ) ) {
7106
+ // Already connected (with or without a license), so no need to continue.
7107
+ return;
7108
+ }
7109
+ }
7110
+
7111
+ if ( $this->is_network_anonymous() ) {
7112
+ /**
7113
+ * Opt-in was network skipped so automatically skip the opt-in for the new site.
7114
+ */
7115
+ $this->skip_site_connection( $blog_id );
7116
+ } else if ( $this->is_network_delegated_connection() ) {
7117
+ /**
7118
+ * Opt-in was network delegated so automatically delegate the opt-in for the new site's admin.
7119
+ */
7120
+ $this->delegate_site_connection( $blog_id );
7121
+ } else if ( $this->is_network_connected() ) {
7122
+ /**
7123
+ * Opt-in was network activated so automatically opt-in with the network user and new site admin.
7124
+ */
7125
+ $current_blog_id = get_current_blog_id();
7126
+
7127
+ $this->switch_to_blog( $blog_id );
7128
+
7129
+ // Opt-in with network user.
7130
+ $this->install_with_user(
7131
+ $this->get_network_user(),
7132
+ false,
7133
+ false,
7134
+ false,
7135
+ false
7136
+ );
7137
+
7138
+ $this->switch_to_blog( $current_blog_id );
7139
+ } else {
7140
+ /**
7141
+ * If the super-admin mixed different options (connect, skip, delegated):
7142
+ * a) If at least one site connection was delegated, then automatically delegate connection.
7143
+ * b) Otherwise, it means that at least one site was skipped and at least one site was connected. For a simplified UX in the initial release of the multisite network integration, skip the connection for the newly created site. If the super-admin will want to opt-in they can still do that from the network level Account page.
7144
+ */
7145
+ $has_delegated_site = false;
7146
+
7147
+ $sites = self::get_sites();
7148
+ foreach ( $sites as $site ) {
7149
+ $blog_id = self::get_site_blog_id( $site );
7150
+
7151
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
7152
+ $has_delegated_site = true;
7153
+ break;
7154
+ }
7155
+ }
7156
+
7157
+ if ( $has_delegated_site ) {
7158
+ $this->delegate_site_connection( $blog_id );
7159
+ } else {
7160
+ $this->skip_site_connection( $blog_id );
7161
+ }
7162
+ }
7163
+ }
7164
+
7165
+ /**
7166
+ * @author Vova Feldman (@svovaf)
7167
+ * @since 1.1.3
7168
+ *
7169
+ * @param bool|int $network_or_blog_id Since 2.0.0.
7170
+ */
7171
+ private function reset_anonymous_mode( $network_or_blog_id = 0 ) {
7172
+ if ( true === $network_or_blog_id ) {
7173
+ unset( $this->_storage->is_anonymous_ms );
7174
+ } else {
7175
+ $this->_storage->remove( 'is_anonymous', true, $network_or_blog_id );
7176
+ }
7177
+
7178
+ /**
7179
+ * Ensure that this field is also "false", otherwise, if the current module's type is "theme" and the module
7180
+ * has no menus, the opt-in popup will not be shown immediately (in this case, the user will have to click
7181
+ * on the admin notice that contains the opt-in link in order to trigger the opt-in popup).
7182
+ *
7183
+ * @author Leo Fajardo (@leorw)
7184
+ * @since 1.2.2
7185
+ */
7186
+ if ( ! $this->_is_network_active ||
7187
+ 0 === $network_or_blog_id ||
7188
+ get_current_blog_id() == $network_or_blog_id ||
7189
+ ( true === $network_or_blog_id && fs_is_network_admin() )
7190
+ ) {
7191
+ unset( $this->_is_anonymous );
7192
+ }
7193
+ }
7194
+
7195
+ /**
7196
+ * Clears the anonymous mode and redirects to the opt-in screen.
7197
+ *
7198
+ * @author Vova Feldman (@svovaf)
7199
+ * @since 1.1.7
7200
+ */
7201
+ function connect_again() {
7202
+ if ( ! $this->is_anonymous() ) {
7203
+ return;
7204
+ }
7205
+
7206
+ $this->reset_anonymous_mode( fs_is_network_admin() );
7207
+
7208
+ fs_redirect( $this->get_activation_url() );
7209
+ }
7210
+
7211
+ /**
7212
+ * Skip account connect, and set anonymous mode.
7213
+ *
7214
+ * @author Vova Feldman (@svovaf)
7215
+ * @since 1.1.1
7216
+ *
7217
+ * @param array|null $sites Since 2.0.0. Specific sites.
7218
+ * @param bool $skip_all_network Since 2.0.0. If true, skip connection for all sites.
7219
+ */
7220
+ function skip_connection( $sites = null, $skip_all_network = false ) {
7221
+ $this->_logger->entrance();
7222
+
7223
+ $this->_admin_notices->remove_sticky( 'connect_account' );
7224
+
7225
+ if ( $skip_all_network ) {
7226
+ $this->set_anonymous_mode( true, true );
7227
+ }
7228
+
7229
+ if ( ! $skip_all_network && empty( $sites ) ) {
7230
+ $this->skip_site_connection();
7231
+ } else {
7232
+ $uids = array();
7233
+
7234
+ if ( $skip_all_network ) {
7235
+ $this->set_anonymous_mode( true, true );
7236
+
7237
+ $sites = self::get_sites();
7238
+ foreach ( $sites as $site ) {
7239
+ $blog_id = self::get_site_blog_id( $site );
7240
+ $this->skip_site_connection( $blog_id, false );
7241
+ $uids[] = $this->get_anonymous_id( $blog_id );
7242
+ }
7243
+ } else if ( ! empty( $sites ) ) {
7244
+ foreach ( $sites as $site ) {
7245
+ $uids[] = $site['uid'];
7246
+ $this->skip_site_connection( $site['blog_id'], false );
7247
+ }
7248
+ }
7249
+
7250
+ // Send anonymous skip event.
7251
+ // No user identified info nor any tracking will be sent after the user skips the opt-in.
7252
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
7253
+ 'uids' => $uids,
7254
+ ) );
7255
+ }
7256
+
7257
+ $this->network_upgrade_mode_completed();
7258
+ }
7259
+
7260
+ /**
7261
+ * Skip connection for specific site in the network.
7262
+ *
7263
+ * @author Vova Feldman (@svovaf)
7264
+ * @since 2.0.0
7265
+ *
7266
+ * @param int|null $blog_id
7267
+ * @param bool $send_skip
7268
+ */
7269
+ private function skip_site_connection( $blog_id = null, $send_skip = true ) {
7270
+ $this->_logger->entrance();
7271
+
7272
+ $this->_admin_notices->remove_sticky( 'connect_account', $blog_id );
7273
+
7274
+ $this->set_anonymous_mode( true, $blog_id );
7275
+
7276
+ if ( $send_skip ) {
7277
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
7278
+ 'uids' => array( $this->get_anonymous_id( $blog_id ) ),
7279
+ ) );
7280
+ }
7281
+ }
7282
+
7283
+ /**
7284
+ * Plugin version update hook.
7285
+ *
7286
+ * @author Vova Feldman (@svovaf)
7287
+ * @since 1.0.4
7288
+ */
7289
+ private function update_plugin_version_event() {
7290
+ $this->_logger->entrance();
7291
+
7292
+ if ( ! $this->is_registered() ) {
7293
+ return;
7294
+ }
7295
+
7296
+ $this->schedule_install_sync();
7297
+ // $this->sync_install( array(), true );
7298
+ }
7299
+
7300
+ /**
7301
+ * Generate an MD5 signature of a plugins collection.
7302
+ * This helper methods used to identify changes in a plugins collection.
7303
+ *
7304
+ * @author Vova Feldman (@svovaf)
7305
+ * @since 2.0.0
7306
+ *
7307
+ * @param array [string]array $plugins
7308
+ *
7309
+ * @return string
7310
+ */
7311
+ private function get_plugins_thumbprint( $plugins ) {
7312
+ ksort( $plugins );
7313
+
7314
+ $thumbprint = '';
7315
+ foreach ( $plugins as $basename => $data ) {
7316
+ $thumbprint .= $data['slug'] . ',' .
7317
+ $data['Version'] . ',' .
7318
+ ( $data['is_active'] ? '1' : '0' ) . ';';
7319
+ }
7320
+
7321
+ return md5( $thumbprint );
7322
+ }
7323
+
7324
+ /**
7325
+ * Return a list of modified plugins since the last sync.
7326
+ *
7327
+ * Note:
7328
+ * There's no point to store a plugins counter since even if the number of
7329
+ * plugins didn't change, we still need to check if the versions are all the
7330
+ * same and the activity state is similar.
7331
+ *
7332
+ * @author Vova Feldman (@svovaf)
7333
+ * @since 1.1.8
7334
+ *
7335
+ * @return array|false
7336
+ */
7337
+ private function get_plugins_data_for_api() {
7338
+ // Alias.
7339
+ $site_active_plugins_option_name = 'active_plugins';
7340
+ $network_plugins_option_name = 'all_plugins';
7341
+
7342
+ /**
7343
+ * Collection of all site level active plugins.
7344
+ */
7345
+ $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
7346
+
7347
+ if ( ! is_object( $site_active_plugins_cache ) ) {
7348
+ $site_active_plugins_cache = (object) array(
7349
+ 'timestamp' => '',
7350
+ 'md5' => '',
7351
+ 'plugins' => array(),
7352
+ );
7353
+ }
7354
+
7355
+ $time = time();
7356
+
7357
+ if ( ! empty( $site_active_plugins_cache->timestamp ) &&
7358
+ ( $time - $site_active_plugins_cache->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
7359
+ ) {
7360
+ // Don't send plugin updates if last update was in the past 5 min.
7361
+ return false;
7362
+ }
7363
+
7364
+ // Write timestamp to lock the logic.
7365
+ $site_active_plugins_cache->timestamp = $time;
7366
+ self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
7367
+
7368
+ // Reload options from DB.
7369
+ self::$_accounts->load( true );
7370
+ $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
7371
+
7372
+ if ( $time != $site_active_plugins_cache->timestamp ) {
7373
+ // If timestamp is different, then another thread captured the lock.
7374
+ return false;
7375
+ }
7376
+
7377
+ /**
7378
+ * Collection of all plugins (network level).
7379
+ */
7380
+ $network_plugins_cache = self::$_accounts->get_option( $network_plugins_option_name );
7381
+
7382
+ if ( ! is_object( $network_plugins_cache ) ) {
7383
+ $network_plugins_cache = (object) array(
7384
+ 'timestamp' => '',
7385
+ 'md5' => '',
7386
+ 'plugins' => array(),
7387
+ );
7388
+ }
7389
+
7390
+ // Check if there's a change in plugins.
7391
+ $network_plugins = self::get_network_plugins();
7392
+ $site_active_plugins = self::get_site_active_plugins();
7393
+
7394
+ $network_plugins_thumbprint = $this->get_plugins_thumbprint( $network_plugins );
7395
+ $site_active_plugins_thumbprint = $this->get_plugins_thumbprint( $site_active_plugins );
7396
+
7397
+ // Check if plugins status changed (version or active/inactive).
7398
+ $network_plugins_changed = ( $network_plugins_cache->md5 !== $network_plugins_thumbprint );
7399
+ $site_active_plugins_changed = ( $site_active_plugins_cache->md5 !== $site_active_plugins_thumbprint );
7400
+
7401
+ if ( ! $network_plugins_changed &&
7402
+ ! $site_active_plugins_changed
7403
+ ) {
7404
+ // No changes.
7405
+ return array();
7406
+ }
7407
+
7408
+ $plugins_update_data = array();
7409
+
7410
+ foreach ( $network_plugins_cache->plugins as $basename => $data ) {
7411
+ if ( ! isset( $network_plugins[ $basename ] ) ) {
7412
+ // Plugin uninstalled.
7413
+ $uninstalled_plugin_data = $data;
7414
+ $uninstalled_plugin_data['is_active'] = false;
7415
+ $uninstalled_plugin_data['is_uninstalled'] = true;
7416
+ $plugins_update_data[] = $uninstalled_plugin_data;
7417
+
7418
+ unset( $network_plugins[ $basename ] );
7419
+
7420
+ unset( $network_plugins_cache->plugins[ $basename ] );
7421
+ unset( $site_active_plugins_cache->plugins[ $basename ] );
7422
+
7423
+ continue;
7424
+ }
7425
+
7426
+ $was_active = $data['is_active'] ||
7427
+ ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
7428
+ true === $site_active_plugins_cache->plugins[ $basename ]['is_active'] );
7429
+ $is_active = $network_plugins[ $basename ]['is_active'] ||
7430
+ ( isset( $site_active_plugins[ $basename ] ) &&
7431
+ $site_active_plugins[ $basename ]['is_active'] );
7432
+
7433
+ if ( ! isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
7434
+ isset( $site_active_plugins[ $basename ] )
7435
+ ) {
7436
+ // Plugin was site level activated.
7437
+ $site_active_plugins_cache->plugins[ $basename ] = $network_plugins[ $basename ];
7438
+ $site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
7439
+ } else if ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
7440
+ ! isset( $site_active_plugins[ $basename ] )
7441
+ ) {
7442
+ // Plugin was site level deactivated.
7443
+ unset( $site_active_plugins_cache->plugins[ $basename ] );
7444
+ }
7445
+
7446
+ $prev_version = $data['version'];
7447
+ $current_version = $network_plugins[ $basename ]['Version'];
7448
+
7449
+ if ( $was_active !== $is_active || $prev_version !== $current_version ) {
7450
+ // Plugin activated or deactivated, or version changed.
7451
+
7452
+ if ( $was_active !== $is_active ) {
7453
+ if ( $data['is_active'] != $network_plugins[ $basename ]['is_active'] ) {
7454
+ $network_plugins_cache->plugins[ $basename ]['is_active'] = $data['is_active'];
7455
+ }
7456
+ }
7457
+
7458
+ if ( $prev_version !== $current_version ) {
7459
+ $network_plugins_cache->plugins[ $basename ]['Version'] = $current_version;
7460
+ }
7461
+
7462
+ $updated_plugin_data = $data;
7463
+ $updated_plugin_data['is_active'] = $is_active;
7464
+ $updated_plugin_data['version'] = $current_version;
7465
+ $updated_plugin_data['title'] = $network_plugins[ $basename ]['Name'];
7466
+ $plugins_update_data[] = $updated_plugin_data;
7467
+ }
7468
+ }
7469
+
7470
+ // Find new plugins that weren't yet seen before.
7471
+ foreach ( $network_plugins as $basename => $data ) {
7472
+ if ( ! isset( $network_plugins_cache->plugins[ $basename ] ) ) {
7473
+ // New plugin.
7474
+ $new_plugin = array(
7475
+ 'slug' => $data['slug'],
7476
+ 'version' => $data['Version'],
7477
+ 'title' => $data['Name'],
7478
+ 'is_active' => $data['is_active'],
7479
+ 'is_uninstalled' => false,
7480
+ );
7481
+
7482
+ $plugins_update_data[] = $new_plugin;
7483
+ $network_plugins_cache->plugins[ $basename ] = $new_plugin;
7484
+
7485
+ if ( isset( $site_active_plugins[ $basename ] ) ) {
7486
+ $site_active_plugins_cache->plugins[ $basename ] = $new_plugin;
7487
+ $site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
7488
+ }
7489
+ }
7490
+ }
7491
+
7492
+ $site_active_plugins_cache->md5 = $site_active_plugins_thumbprint;
7493
+ $site_active_plugins_cache->timestamp = $time;
7494
+ self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
7495
+
7496
+ $network_plugins_cache->md5 = $network_plugins_thumbprint;
7497
+ $network_plugins_cache->timestamp = $time;
7498
+ self::$_accounts->set_option( $network_plugins_option_name, $network_plugins_cache, true );
7499
+
7500
+ return $plugins_update_data;
7501
+ }
7502
+
7503
+ /**
7504
+ * Return a list of modified themes since the last sync.
7505
+ *
7506
+ * Note:
7507
+ * There's no point to store a themes counter since even if the number of
7508
+ * themes didn't change, we still need to check if the versions are all the
7509
+ * same and the activity state is similar.
7510
+ *
7511
+ * @author Vova Feldman (@svovaf)
7512
+ * @since 1.1.8
7513
+ *
7514
+ * @return array|false
7515
+ */
7516
+ private function get_themes_data_for_api() {
7517
+ // Alias.
7518
+ $option_name = 'all_themes';
7519
+
7520
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
7521
+
7522
+ if ( ! is_object( $all_cached_themes ) ) {
7523
+ $all_cached_themes = (object) array(
7524
+ 'timestamp' => '',
7525
+ 'md5' => '',
7526
+ 'themes' => array(),
7527
+ );
7528
+ }
7529
+
7530
+ $time = time();
7531
+
7532
+ if ( ! empty( $all_cached_themes->timestamp ) &&
7533
+ ( $time - $all_cached_themes->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
7534
+ ) {
7535
+ // Don't send theme updates if last update was in the past 5 min.
7536
+ return false;
7537
+ }
7538
+
7539
+ // Write timestamp to lock the logic.
7540
+ $all_cached_themes->timestamp = $time;
7541
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
7542
+
7543
+ // Reload options from DB.
7544
+ self::$_accounts->load( true );
7545
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
7546
+
7547
+ if ( $time != $all_cached_themes->timestamp ) {
7548
+ // If timestamp is different, then another thread captured the lock.
7549
+ return false;
7550
+ }
7551
+
7552
+ // Get active theme.
7553
+ $active_theme = wp_get_theme();
7554
+ $active_theme_stylesheet = $active_theme->get_stylesheet();
7555
+
7556
+ // Check if there's a change in themes.
7557
+ $all_themes = wp_get_themes();
7558
+
7559
+ // Check if themes changed.
7560
+ ksort( $all_themes );
7561
+
7562
+ $themes_signature = '';
7563
+ foreach ( $all_themes as $slug => $data ) {
7564
+ $is_active = ( $slug === $active_theme_stylesheet );
7565
+ $themes_signature .= $slug . ',' .
7566
+ $data->version . ',' .
7567
+ ( $is_active ? '1' : '0' ) . ';';
7568
+ }
7569
+
7570
+ // Check if themes status changed (version or active/inactive).
7571
+ $themes_changed = ( $all_cached_themes->md5 !== md5( $themes_signature ) );
7572
+
7573
+ $themes_update_data = array();
7574
+
7575
+ if ( $themes_changed ) {
7576
+ // Change in themes, report changes.
7577
+
7578
+ // Update existing themes info.
7579
+ foreach ( $all_cached_themes->themes as $slug => $data ) {
7580
+ $is_active = ( $slug === $active_theme_stylesheet );
7581
+
7582
+ if ( ! isset( $all_themes[ $slug ] ) ) {
7583
+ // Plugin uninstalled.
7584
+ $uninstalled_theme_data = $data;
7585
+ $uninstalled_theme_data['is_active'] = false;
7586
+ $uninstalled_theme_data['is_uninstalled'] = true;
7587
+ $themes_update_data[] = $uninstalled_theme_data;
7588
+
7589
+ unset( $all_themes[ $slug ] );
7590
+ unset( $all_cached_themes->themes[ $slug ] );
7591
+ } else if ( $data['is_active'] !== $is_active ||
7592
+ $data['version'] !== $all_themes[ $slug ]->version
7593
+ ) {
7594
+ // Plugin activated or deactivated, or version changed.
7595
+
7596
+ $all_cached_themes->themes[ $slug ]['is_active'] = $is_active;
7597
+ $all_cached_themes->themes[ $slug ]['version'] = $all_themes[ $slug ]->version;
7598
+
7599
+ $themes_update_data[] = $all_cached_themes->themes[ $slug ];
7600
+ }
7601
+ }
7602
+
7603
+ // Find new themes that weren't yet seen before.
7604
+ foreach ( $all_themes as $slug => $data ) {
7605
+ if ( ! isset( $all_cached_themes->themes[ $slug ] ) ) {
7606
+ $is_active = ( $slug === $active_theme_stylesheet );
7607
+
7608
+ // New plugin.
7609
+ $new_plugin = array(
7610
+ 'slug' => $slug,
7611
+ 'version' => $data->version,
7612
+ 'title' => $data->name,
7613
+ 'is_active' => $is_active,
7614
+ 'is_uninstalled' => false,
7615
+ );
7616
+
7617
+ $themes_update_data[] = $new_plugin;
7618
+ $all_cached_themes->themes[ $slug ] = $new_plugin;
7619
+ }
7620
+ }
7621
+
7622
+ $all_cached_themes->md5 = md5( $themes_signature );
7623
+ $all_cached_themes->timestamp = time();
7624
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
7625
+ }
7626
+
7627
+ return $themes_update_data;
7628
+ }
7629
+
7630
+ /**
7631
+ * Get site data for API install request.
7632
+ *
7633
+ * @author Vova Feldman (@svovaf)
7634
+ * @since 1.1.2
7635
+ *
7636
+ * @param string[] string $override
7637
+ * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
7638
+ * @param bool $include_themes Since 1.1.8 by default include plugin changes.
7639
+ *
7640
+ * @return array
7641
+ */
7642
+ private function get_install_data_for_api(
7643
+ array $override,
7644
+ $include_plugins = true,
7645
+ $include_themes = true
7646
+ ) {
7647
+ /**
7648
+ * @since 1.1.8 Also send plugin updates.
7649
+ */
7650
+ if ( $include_plugins && ! isset( $override['plugins'] ) ) {
7651
+ $plugins = $this->get_plugins_data_for_api();
7652
+ if ( ! empty( $plugins ) ) {
7653
+ $override['plugins'] = $plugins;
7654
+ }
7655
+ }
7656
+ /**
7657
+ * @since 1.1.8 Also send themes updates.
7658
+ */
7659
+ if ( $include_themes && ! isset( $override['themes'] ) ) {
7660
+ $themes = $this->get_themes_data_for_api();
7661
+ if ( ! empty( $themes ) ) {
7662
+ $override['themes'] = $themes;
7663
+ }
7664
+ }
7665
+
7666
+ return array_merge( array(
7667
+ 'version' => $this->get_plugin_version(),
7668
+ 'is_premium' => $this->is_premium(),
7669
+ 'language' => get_bloginfo( 'language' ),
7670
+ 'charset' => get_bloginfo( 'charset' ),
7671
+ 'platform_version' => get_bloginfo( 'version' ),
7672
+ 'sdk_version' => $this->version,
7673
+ 'programming_language_version' => phpversion(),
7674
+ 'title' => get_bloginfo( 'name' ),
7675
+ 'url' => get_site_url(),
7676
+ // Special params.
7677
+ 'is_active' => true,
7678
+ 'is_disconnected' => $this->is_tracking_prohibited(),
7679
+ 'is_uninstalled' => false,
7680
+ ), $override );
7681
+ }
7682
+
7683
+ /**
7684
+ * Update installs details.
7685
+ *
7686
+ * @todo V1 of multiste network support doesn't support plugin and theme data sending.
7687
+ *
7688
+ * @author Vova Feldman (@svovaf)
7689
+ * @since 2.0.0
7690
+ *
7691
+ * @param string[] string $override
7692
+ * @param bool $only_diff
7693
+ * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
7694
+ * @param bool $include_themes Since 1.1.8 by default include plugin changes.
7695
+ *
7696
+ * @return array
7697
+ */
7698
+ private function get_installs_data_for_api(
7699
+ array $override,
7700
+ $only_diff = false,
7701
+ $include_plugins = true,
7702
+ $include_themes = true
7703
+ ) {
7704
+ /**
7705
+ * @since 1.1.8 Also send plugin updates.
7706
+ */
7707
+ // if ( $include_plugins && ! isset( $override['plugins'] ) ) {
7708
+ // $plugins = $this->get_plugins_data_for_api();
7709
+ // if ( ! empty( $plugins ) ) {
7710
+ // $override['plugins'] = $plugins;
7711
+ // }
7712
+ // }
7713
+ /**
7714
+ * @since 1.1.8 Also send themes updates.
7715
+ */
7716
+ // if ( $include_themes && ! isset( $override['themes'] ) ) {
7717
+ // $themes = $this->get_themes_data_for_api();
7718
+ // if ( ! empty( $themes ) ) {
7719
+ // $override['themes'] = $themes;
7720
+ // }
7721
+ // }
7722
+
7723
+ // Common properties.
7724
+ $common = array_merge( array(
7725
+ 'version' => $this->get_plugin_version(),
7726
+ 'is_premium' => $this->is_premium(),
7727
+ 'sdk_version' => $this->version,
7728
+ 'programming_language_version' => phpversion(),
7729
+ 'platform_version' => get_bloginfo( 'version' ),
7730
+ ), $override );
7731
+
7732
+
7733
+ $is_common_diff_for_any_site = false;
7734
+ $common_diff_union = array();
7735
+
7736
+ $installs_data = array();
7737
+
7738
+ $sites = self::get_sites();
7739
+
7740
+ foreach ( $sites as $site ) {
7741
+ $blog_id = self::get_site_blog_id( $site );
7742
+
7743
+ $install = $this->get_install_by_blog_id( $blog_id );
7744
+
7745
+ if ( is_object( $install ) ) {
7746
+ if ( $install->user_id != $this->_user->id ) {
7747
+ // Install belongs to a different owner.
7748
+ continue;
7749
+ }
7750
+
7751
+ if ( ! $this->is_premium() && $install->is_tracking_prohibited() ) {
7752
+ // Don't send updates regarding opted-out installs.
7753
+ continue;
7754
+ }
7755
+
7756
+ $install_data = $this->get_site_info( $site );
7757
+
7758
+ $uid = $install_data['uid'];
7759
+
7760
+ unset( $install_data['blog_id'] );
7761
+ unset( $install_data['uid'] );
7762
+
7763
+ $install_data['is_disconnected'] = $install->is_disconnected;
7764
+ $install_data['is_active'] = $this->is_active_for_site( $blog_id );
7765
+ $install_data['is_uninstalled'] = $install->is_uninstalled;
7766
+
7767
+ $common_diff = null;
7768
+ $is_common_diff = false;
7769
+ if ( $only_diff ) {
7770
+ $install_data = $this->get_install_diff_for_api( $install_data, $install, $override );
7771
+ $common_diff = $this->get_install_diff_for_api( $common, $install, $override );
7772
+
7773
+ $is_common_diff = ! empty( $common_diff );
7774
+
7775
+ if ( $is_common_diff ) {
7776
+ foreach ( $common_diff as $k => $v ) {
7777
+ if ( ! isset( $common_diff_union[ $k ] ) ) {
7778
+ $common_diff_union[ $k ] = $v;
7779
+ }
7780
+ }
7781
+ }
7782
+
7783
+ $is_common_diff_for_any_site = $is_common_diff_for_any_site || $is_common_diff;
7784
+ }
7785
+
7786
+ if ( ! empty( $install_data ) || $is_common_diff ) {
7787
+ // Add install ID and site unique ID.
7788
+ $install_data['id'] = $install->id;
7789
+ $install_data['uid'] = $uid;
7790
+
7791
+ $installs_data[] = $install_data;
7792
+ }
7793
+ }
7794
+ }
7795
+
7796
+ restore_current_blog();
7797
+
7798
+ if ( 0 < count( $installs_data ) && ( $is_common_diff_for_any_site || ! $only_diff ) ) {
7799
+ if ( ! $only_diff ) {
7800
+ $installs_data[] = $common;
7801
+ } else if ( ! empty( $common_diff_union ) ) {
7802
+ $installs_data[] = $common_diff_union;
7803
+ }
7804
+ }
7805
+
7806
+ foreach ( $installs_data as &$data ) {
7807
+ $data = (object) $data;
7808
+ }
7809
+
7810
+ return $installs_data;
7811
+ }
7812
+
7813
+ /**
7814
+ * Compare site actual data to the stored install data and return the differences for an API data sync.
7815
+ *
7816
+ * @author Vova Feldman (@svovaf)
7817
+ * @since 2.0.0
7818
+ *
7819
+ * @param array $site
7820
+ * @param FS_Site $install
7821
+ * @param string[] string $override
7822
+ *
7823
+ * @return array
7824
+ */
7825
+ private function get_install_diff_for_api( $site, $install, $override = array() ) {
7826
+ $diff = array();
7827
+ $special = array();
7828
+ $special_override = false;
7829
+
7830
+ foreach ( $site as $p => $v ) {
7831
+ if ( property_exists( $install, $p ) ) {
7832
+ if ( ( is_bool( $install->{$p} ) || ! empty( $install->{$p} ) ) &&
7833
+ $install->{$p} != $v
7834
+ ) {
7835
+ $install->{$p} = $v;
7836
+ $diff[ $p ] = $v;
7837
+ }
7838
+ } else {
7839
+ $special[ $p ] = $v;
7840
+
7841
+ if ( isset( $override[ $p ] ) ||
7842
+ 'plugins' === $p ||
7843
+ 'themes' === $p
7844
+ ) {
7845
+ $special_override = true;
7846
+ }
7847
+ }
7848
+ }
7849
+
7850
+ if ( $special_override || 0 < count( $diff ) ) {
7851
+ // Add special params only if has at least one
7852
+ // standard param, or if explicitly requested to
7853
+ // override a special param or a param which is not exist
7854
+ // in the install object.
7855
+ $diff = array_merge( $diff, $special );
7856
+ }
7857
+
7858
+ return $diff;
7859
+ }
7860
+
7861
+ /**
7862
+ * Update install only if changed.
7863
+ *
7864
+ * @author Vova Feldman (@svovaf)
7865
+ * @since 1.0.9
7866
+ *
7867
+ * @param string[] string $override
7868
+ * @param bool $flush
7869
+ *
7870
+ * @return false|object|string
7871
+ */
7872
+ private function send_install_update( $override = array(), $flush = false ) {
7873
+ $this->_logger->entrance();
7874
+
7875
+ $check_properties = $this->get_install_data_for_api( $override );
7876
+
7877
+ if ( $flush ) {
7878
+ $params = $check_properties;
7879
+ } else {
7880
+ $params = $this->get_install_diff_for_api( $check_properties, $this->_site, $override );
7881
+ }
7882
+
7883
+ if ( 0 < count( $params ) ) {
7884
+ if ( ! is_multisite() ) {
7885
+ // Update last install sync timestamp.
7886
+ $this->set_cron_execution_timestamp( 'install_sync' );
7887
+ }
7888
+
7889
+ $params['uid'] = $this->get_anonymous_id();
7890
+
7891
+ // Send updated values to FS.
7892
+ $site = $this->get_api_site_scope()->call( '/', 'put', $params );
7893
+
7894
+ if ( $this->is_api_result_entity( $site ) ) {
7895
+ if ( ! is_multisite() ) {
7896
+ // I successfully sent install update, clear scheduled sync if exist.
7897
+ $this->clear_install_sync_cron();
7898
+ }
7899
+ }
7900
+
7901
+ return $site;
7902
+ }
7903
+
7904
+ return false;
7905
+ }
7906
+
7907
+ /**
7908
+ * Update installs only if changed.
7909
+ *
7910
+ * @author Vova Feldman (@svovaf)
7911
+ * @since 2.0.0
7912
+ *
7913
+ * @param string[] string $override
7914
+ * @param bool $flush
7915
+ *
7916
+ * @return false|object|string
7917
+ */
7918
+ private function send_installs_update( $override = array(), $flush = false ) {
7919
+ $this->_logger->entrance();
7920
+
7921
+ $installs_data = $this->get_installs_data_for_api( $override, ! $flush );
7922
+
7923
+ if ( empty( $installs_data ) ) {
7924
+ return false;
7925
+ }
7926
+
7927
+ // Update last install sync timestamp.
7928
+ $this->set_cron_execution_timestamp( 'install_sync' );
7929
+
7930
+ // Send updated values to FS.
7931
+ $result = $this->get_api_user_scope()->call( "/plugins/{$this->_plugin->id}/installs.json", 'put', $installs_data );
7932
+
7933
+ if ( $this->is_api_result_object( $result, 'installs' ) ) {
7934
+ // I successfully sent installs update, clear scheduled sync if exist.
7935
+ $this->clear_install_sync_cron();
7936
+ }
7937
+
7938
+ return $result;
7939
+ }
7940
+
7941
+ /**
7942
+ * Update install only if changed.
7943
+ *
7944
+ * @author Vova Feldman (@svovaf)
7945
+ * @since 1.0.9
7946
+ *
7947
+ * @param string[] string $override
7948
+ * @param bool $flush
7949
+ */
7950
+ private function sync_install( $override = array(), $flush = false ) {
7951
+ $this->_logger->entrance();
7952
+
7953
+ $site = $this->send_install_update( $override, $flush );
7954
+
7955
+ if ( false === $site ) {
7956
+ // No sync required.
7957
+ return;
7958
+ }
7959
+
7960
+ if ( ! $this->is_api_result_entity( $site ) ) {
7961
+ // Failed to sync, don't update locally.
7962
+ return;
7963
+ }
7964
+
7965
+ $this->_site = new FS_Site( $site );
7966
+
7967
+ $this->_store_site( true );
7968
+ }
7969
+
7970
+ /**
7971
+ * Update install only if changed.
7972
+ *
7973
+ * @author Vova Feldman (@svovaf)
7974
+ * @since 1.0.9
7975
+ *
7976
+ * @param string[] string $override
7977
+ * @param bool $flush
7978
+ */
7979
+ private function sync_installs( $override = array(), $flush = false ) {
7980
+ $this->_logger->entrance();
7981
+
7982
+ $result = $this->send_installs_update( $override, $flush );
7983
+
7984
+ if ( false === $result ) {
7985
+ // No sync required.
7986
+ return;
7987
+ }
7988
+
7989
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
7990
+ // Failed to sync, don't update locally.
7991
+ return;
7992
+ }
7993
+
7994
+ $address_to_blog_map = $this->get_address_to_blog_map();
7995
+
7996
+ foreach ( $result->installs as $install ) {
7997
+ $this->_site = new FS_Site( $install );
7998
+
7999
+ $address = trailingslashit( fs_strip_url_protocol( $install->url ) );
8000
+ $blog_id = $address_to_blog_map[ $address ];
8001
+
8002
+ $this->_store_site( true, $blog_id );
8003
+ }
8004
+ }
8005
+
8006
+ /**
8007
+ * Track install's custom event.
8008
+ *
8009
+ * IMPORTANT:
8010
+ * Custom event tracking is currently only supported for specific clients.
8011
+ * If you are not one of them, please don't use this method. If you will,
8012
+ * the API will simply ignore your request based on the plugin ID.
8013
+ *
8014
+ * Need custom tracking for your plugin or theme?
8015
+ * If you are interested in custom event tracking please contact yo@freemius.com
8016
+ * for further details.
8017
+ *
8018
+ * @author Vova Feldman (@svovaf)
8019
+ * @since 1.2.1
8020
+ *
8021
+ * @param string $name Event name.
8022
+ * @param array $properties Associative key/value array with primitive values only
8023
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
8024
+ * @param bool $once If true, event will be tracked only once. IMPORTANT: Still trigger the API call.
8025
+ *
8026
+ * @return object|false Event data or FALSE on failure.
8027
+ *
8028
+ * @throws \Freemius_InvalidArgumentException
8029
+ */
8030
+ public function track_event( $name, $properties = array(), $process_at = false, $once = false ) {
8031
+ $this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) );
8032
+
8033
+ if ( ! $this->is_registered() ) {
8034
+ return false;
8035
+ }
8036
+
8037
+ $event = array( 'type' => $name );
8038
+
8039
+ if ( is_numeric( $process_at ) && $process_at > time() ) {
8040
+ $event['process_at'] = $process_at;
8041
+ }
8042
+
8043
+ if ( $once ) {
8044
+ $event['once'] = true;
8045
+ }
8046
+
8047
+ if ( ! empty( $properties ) ) {
8048
+ // Verify associative array values are primitive.
8049
+ foreach ( $properties as $k => $v ) {
8050
+ if ( ! is_scalar( $v ) ) {
8051
+ throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' );
8052
+ }
8053
+ }
8054
+
8055
+ $event['properties'] = $properties;
8056
+ }
8057
+
8058
+ $result = $this->get_api_site_scope()->call( 'events.json', 'post', $event );
8059
+
8060
+ return $this->is_api_error( $result ) ?
8061
+ false :
8062
+ $result;
8063
+ }
8064
+
8065
+ /**
8066
+ * Track install's custom event only once, but it still triggers the API call.
8067
+ *
8068
+ * IMPORTANT:
8069
+ * Custom event tracking is currently only supported for specific clients.
8070
+ * If you are not one of them, please don't use this method. If you will,
8071
+ * the API will simply ignore your request based on the plugin ID.
8072
+ *
8073
+ * Need custom tracking for your plugin or theme?
8074
+ * If you are interested in custom event tracking please contact yo@freemius.com
8075
+ * for further details.
8076
+ *
8077
+ * @author Vova Feldman (@svovaf)
8078
+ * @since 1.2.1
8079
+ *
8080
+ * @param string $name Event name.
8081
+ * @param array $properties Associative key/value array with primitive values only
8082
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
8083
+ *
8084
+ * @return object|false Event data or FALSE on failure.
8085
+ *
8086
+ * @throws \Freemius_InvalidArgumentException
8087
+ *
8088
+ * @user Freemius::track_event()
8089
+ */
8090
+ public function track_event_once( $name, $properties = array(), $process_at = false ) {
8091
+ return $this->track_event( $name, $properties, $process_at, true );
8092
+ }
8093
+
8094
+ /**
8095
+ * Plugin uninstall hook.
8096
+ *
8097
+ * @author Vova Feldman (@svovaf)
8098
+ * @since 1.0.1
8099
+ *
8100
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
8101
+ */
8102
+ function _uninstall_plugin_event( $check_user = true ) {
8103
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
8104
+
8105
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
8106
+ return;
8107
+ }
8108
+
8109
+ $params = array();
8110
+ $uninstall_reason = null;
8111
+ if ( isset( $this->_storage->uninstall_reason ) ) {
8112
+ $uninstall_reason = $this->_storage->uninstall_reason;
8113
+ $params['reason_id'] = $uninstall_reason->id;
8114
+ $params['reason_info'] = $uninstall_reason->info;
8115
+ }
8116
+
8117
+ if ( ! $this->is_registered() ) {
8118
+ // Send anonymous uninstall event only if user submitted a feedback.
8119
+ if ( isset( $uninstall_reason ) ) {
8120
+ if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) {
8121
+ $this->opt_in( false, false, false, false, true );
8122
+ } else {
8123
+ $params['uid'] = $this->get_anonymous_id();
8124
+ $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
8125
+ }
8126
+ }
8127
+ } else {
8128
+ $params = array_merge( $params, array(
8129
+ 'is_active' => false,
8130
+ 'is_uninstalled' => true,
8131
+ ) );
8132
+
8133
+ if ( $this->_is_network_active ) {
8134
+ // Send uninstall event.
8135
+ $this->send_installs_update( $params );
8136
+ } else {
8137
+ // Send uninstall event.
8138
+ $this->send_install_update( $params );
8139
+ }
8140
+ }
8141
+
8142
+ // @todo Decide if we want to delete plugin information from db.
8143
+ }
8144
+
8145
+ /**
8146
+ * @author Vova Feldman (@svovaf)
8147
+ * @since 1.1.1
8148
+ *
8149
+ * @return string
8150
+ */
8151
+ function premium_plugin_basename() {
8152
+ return "{$this->_slug}-premium/" . basename( $this->_free_plugin_basename );
8153
+ }
8154
+
8155
+ /**
8156
+ * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
8157
+ *
8158
+ * @author Vova Feldman (@svovaf)
8159
+ * @since 1.0.2
8160
+ */
8161
+ public static function _uninstall_plugin_hook() {
8162
+ self::_load_required_static();
8163
+
8164
+ self::$_static_logger->entrance();
8165
+
8166
+ if ( ! current_user_can( 'activate_plugins' ) ) {
8167
+ return;
8168
+ }
8169
+
8170
+ $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
8171
+
8172
+ self::$_static_logger->info( 'plugin = ' . $plugin_file );
8173
+
8174
+ define( 'WP_FS__UNINSTALL_MODE', true );
8175
+
8176
+ $fs = self::get_instance_by_file( $plugin_file );
8177
+
8178
+ if ( is_object( $fs ) ) {
8179
+ self::require_plugin_essentials();
8180
+
8181
+ if ( is_plugin_active( $fs->_free_plugin_basename ) ||
8182
+ is_plugin_active( $fs->premium_plugin_basename() )
8183
+ ) {
8184
+ // Deleting Free or Premium plugin version while the other version still installed.
8185
+ return;
8186
+ }
8187
+
8188
+ $fs->_uninstall_plugin_event();
8189
+
8190
+ $fs->do_action( 'after_uninstall' );
8191
+ }
8192
+ }
8193
+
8194
+ #----------------------------------------------------------------------------------
8195
+ #region Plugin Information
8196
+ #----------------------------------------------------------------------------------
8197
+
8198
+ /**
8199
+ * Load WordPress core plugin.php essential module.
8200
+ *
8201
+ * @author Vova Feldman (@svovaf)
8202
+ * @since 1.1.1
8203
+ */
8204
+ private static function require_plugin_essentials() {
8205
+ if ( ! function_exists( 'get_plugins' ) ) {
8206
+ self::$_static_logger->log( 'Including wp-admin/includes/plugin.php...' );
8207
+
8208
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
8209
+ }
8210
+ }
8211
+
8212
+ /**
8213
+ * Load WordPress core pluggable.php module.
8214
+ *
8215
+ * @author Vova Feldman (@svovaf)
8216
+ * @since 1.1.2
8217
+ */
8218
+ private static function require_pluggable_essentials() {
8219
+ if ( ! function_exists( 'wp_get_current_user' ) ) {
8220
+ require_once ABSPATH . 'wp-includes/pluggable.php';
8221
+ }
8222
+ }
8223
+
8224
+ /**
8225
+ * Return plugin data.
8226
+ *
8227
+ * @author Vova Feldman (@svovaf)
8228
+ * @since 1.0.1
8229
+ *
8230
+ * @return array
8231
+ */
8232
+ function get_plugin_data() {
8233
+ if ( ! isset( $this->_plugin_data ) ) {
8234
+ self::require_plugin_essentials();
8235
+
8236
+ if ( $this->is_plugin() ) {
8237
+ /**
8238
+ * @author Vova Feldman (@svovaf)
8239
+ * @since 1.2.0 When using get_plugin_data() do NOT translate plugin data.
8240
+ *
8241
+ * @link https://github.com/Freemius/wordpress-sdk/issues/77
8242
+ */
8243
+ $plugin_data = get_plugin_data(
8244
+ $this->_plugin_main_file_path,
8245
+ false,
8246
+ false
8247
+ );
8248
+ } else {
8249
+ $theme_data = wp_get_theme();
8250
+
8251
+ if ( $this->_plugin_basename !== $theme_data->get_stylesheet() && is_child_theme() ) {
8252
+ $parent_theme = $theme_data->parent();
8253
+
8254
+ if ( ( $parent_theme instanceof WP_Theme ) && $this->_plugin_basename === $parent_theme->get_stylesheet() ) {
8255
+ $theme_data = $parent_theme;
8256
+ }
8257
+ }
8258
+
8259
+ $plugin_data = array(
8260
+ 'Name' => $theme_data->get( 'Name' ),
8261
+ 'Version' => $theme_data->get( 'Version' ),
8262
+ 'Author' => $theme_data->get( 'Author' ),
8263
+ 'Description' => $theme_data->get( 'Description' ),
8264
+ 'PluginURI' => $theme_data->get( 'ThemeURI' ),
8265
+ );
8266
+ }
8267
+
8268
+ $this->_plugin_data = $plugin_data;
8269
+ }
8270
+
8271
+ return $this->_plugin_data;
8272
+ }
8273
+
8274
+ /**
8275
+ * @author Vova Feldman (@svovaf)
8276
+ * @since 1.0.1
8277
+ * @since 1.2.2.5 If slug not set load slug by module ID.
8278
+ *
8279
+ * @return string Plugin slug.
8280
+ */
8281
+ function get_slug() {
8282
+ if ( ! isset( $this->_slug ) ) {
8283
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
8284
+ $this->_slug = $id_slug_type_path_map[ $this->_module_id ]['slug'];
8285
+ }
8286
+
8287
+ return $this->_slug;
8288
+ }
8289
+
8290
+ /**
8291
+ * @author Vova Feldman (@svovaf)
8292
+ * @since 1.2.1.7
8293
+ *
8294
+ * @return string Plugin slug.
8295
+ */
8296
+ function get_target_folder_name() {
8297
+ return $this->_slug . ( $this->can_use_premium_code() ? '-premium' : '' );
8298
+ }
8299
+
8300
+ /**
8301
+ * @author Vova Feldman (@svovaf)
8302
+ * @since 1.0.1
8303
+ *
8304
+ * @return number Plugin ID.
8305
+ */
8306
+ function get_id() {
8307
+ return $this->_plugin->id;
8308
+ }
8309
+
8310
+ /**
8311
+ * @author Vova Feldman (@svovaf)
8312
+ * @since 1.2.1.5
8313
+ *
8314
+ * @return string Freemius SDK version
8315
+ */
8316
+ function get_sdk_version() {
8317
+ return $this->version;
8318
+ }
8319
+
8320
+ /**
8321
+ * @author Vova Feldman (@svovaf)
8322
+ * @since 1.2.1.5
8323
+ *
8324
+ * @return number Parent plugin ID (if parent exist).
8325
+ */
8326
+ function get_parent_id() {
8327
+ return $this->is_addon() ?
8328
+ $this->get_parent_instance()->get_id() :
8329
+ $this->_plugin->id;
8330
+ }
8331
+
8332
+ /**
8333
+ * @author Vova Feldman (@svovaf)
8334
+ * @since 1.0.1
8335
+ *
8336
+ * @return string Plugin public key.
8337
+ */
8338
+ function get_public_key() {
8339
+ return $this->_plugin->public_key;
8340
+ }
8341
+
8342
+ /**
8343
+ * Will be available only on sandbox mode.
8344
+ *
8345
+ * @author Vova Feldman (@svovaf)
8346
+ * @since 1.0.4
8347
+ *
8348
+ * @return mixed Plugin secret key.
8349
+ */
8350
+ function get_secret_key() {
8351
+ return $this->_plugin->secret_key;
8352
+ }
8353
+
8354
+ /**
8355
+ * @author Vova Feldman (@svovaf)
8356
+ * @since 1.1.1
8357
+ *
8358
+ * @return bool
8359
+ */
8360
+ function has_secret_key() {
8361
+ return ! empty( $this->_plugin->secret_key );
8362
+ }
8363
+
8364
+ /**
8365
+ * @author Vova Feldman (@svovaf)
8366
+ * @since 1.0.9
8367
+ *
8368
+ * @return string
8369
+ */
8370
+ function get_plugin_name() {
8371
+ $this->_logger->entrance();
8372
+
8373
+ if ( ! isset( $this->_plugin_name ) ) {
8374
+ $plugin_data = $this->get_plugin_data();
8375
+
8376
+ // Get name.
8377
+ $this->_plugin_name = $plugin_data['Name'];
8378
+
8379
+ // Check if plugin name contains "(Premium)" suffix and remove it.
8380
+ $suffix = ' (premium)';
8381
+ $suffix_len = strlen( $suffix );
8382
+
8383
+ if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
8384
+ $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
8385
+ ) {
8386
+ $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
8387
+ }
8388
+
8389
+ $this->_logger->departure( 'Name = ' . $this->_plugin_name );
8390
+ }
8391
+
8392
+ return $this->_plugin_name;
8393
+ }
8394
+
8395
+ /**
8396
+ * @author Vova Feldman (@svovaf)
8397
+ * @since 1.0.0
8398
+ *
8399
+ * @return string
8400
+ */
8401
+ function get_plugin_version() {
8402
+ $this->_logger->entrance();
8403
+
8404
+ $plugin_data = $this->get_plugin_data();
8405
+
8406
+ $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
8407
+
8408
+ return $this->apply_filters( 'plugin_version', $plugin_data['Version'] );
8409
+ }
8410
+
8411
+ /**
8412
+ * @author Vova Feldman (@svovaf)
8413
+ * @since 1.2.1.7
8414
+ *
8415
+ * @return string
8416
+ */
8417
+ function get_plugin_title() {
8418
+ $this->_logger->entrance();
8419
+
8420
+ $title = $this->_plugin->title;
8421
+
8422
+ return $this->apply_filters( 'plugin_title', $title );
8423
+ }
8424
+
8425
+ /**
8426
+ * @author Vova Feldman (@svovaf)
8427
+ * @since 1.2.2.7
8428
+ *
8429
+ * @param bool $lowercase
8430
+ *
8431
+ * @return string
8432
+ */
8433
+ function get_module_label( $lowercase = false ) {
8434
+ $label = $this->is_addon() ?
8435
+ $this->get_text_inline( 'Add-On', 'addon' ) :
8436
+ ( $this->is_plugin() ?
8437
+ $this->get_text_inline( 'Plugin', 'plugin' ) :
8438
+ $this->get_text_inline( 'Theme', 'theme' ) );
8439
+
8440
+ if ( $lowercase ) {
8441
+ $label = strtolower( $label );
8442
+ }
8443
+
8444
+ return $label;
8445
+ }
8446
+
8447
+ /**
8448
+ * @author Vova Feldman (@svovaf)
8449
+ * @since 1.0.4
8450
+ *
8451
+ * @return string
8452
+ */
8453
+ function get_plugin_basename() {
8454
+ if ( ! isset( $this->_plugin_basename ) ) {
8455
+ if ( $this->is_plugin() ) {
8456
+ $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
8457
+ } else {
8458
+ $this->_plugin_basename = basename( dirname( $this->_plugin_main_file_path ) );
8459
+ }
8460
+ }
8461
+
8462
+ return $this->_plugin_basename;
8463
+ }
8464
+
8465
+ function get_plugin_folder_name() {
8466
+ $this->_logger->entrance();
8467
+
8468
+ $plugin_folder = $this->_plugin_basename;
8469
+
8470
+ while ( '.' !== dirname( $plugin_folder ) ) {
8471
+ $plugin_folder = dirname( $plugin_folder );
8472
+ }
8473
+
8474
+ $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
8475
+
8476
+ return $plugin_folder;
8477
+ }
8478
+
8479
+ #endregion ------------------------------------------------------------------
8480
+
8481
+ /* Account
8482
+ ------------------------------------------------------------------------------------------------------------------*/
8483
+
8484
+ /**
8485
+ * Find plugin's slug by plugin's basename.
8486
+ *
8487
+ * @author Vova Feldman (@svovaf)
8488
+ * @since 1.0.9
8489
+ *
8490
+ * @param string $plugin_base_name
8491
+ *
8492
+ * @return false|string
8493
+ */
8494
+ private static function find_slug_by_basename( $plugin_base_name ) {
8495
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
8496
+
8497
+ if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
8498
+ return false;
8499
+ }
8500
+
8501
+ return $file_slug_map[ $plugin_base_name ];
8502
+ }
8503
+
8504
+ /**
8505
+ * Store the map between the plugin's basename to the slug.
8506
+ *
8507
+ * @author Vova Feldman (@svovaf)
8508
+ * @since 1.0.9
8509
+ */
8510
+ private function store_file_slug_map() {
8511
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
8512
+
8513
+ if ( ! array( $file_slug_map ) ) {
8514
+ $file_slug_map = array();
8515
+ }
8516
+
8517
+ if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
8518
+ $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
8519
+ ) {
8520
+ $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
8521
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
8522
+ }
8523
+ }
8524
+
8525
+ /**
8526
+ * @return array[number]FS_User
8527
+ */
8528
+ static function get_all_users() {
8529
+ $users = self::$_accounts->get_option( 'users', array() );
8530
+
8531
+ if ( ! is_array( $users ) ) {
8532
+ $users = array();
8533
+ }
8534
+
8535
+ return $users;
8536
+ }
8537
+
8538
+ /**
8539
+ * @param string $module_type
8540
+ * @param null|int $blog_id Since 2.0.0
8541
+ *
8542
+ * @return array[string]FS_Site
8543
+ */
8544
+ private static function get_all_sites(
8545
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN,
8546
+ $blog_id = null
8547
+ ) {
8548
+ $sites = self::get_account_option( 'sites', $module_type, $blog_id );
8549
+
8550
+ if ( ! is_array( $sites ) ) {
8551
+ $sites = array();
8552
+ }
8553
+
8554
+ return $sites;
8555
+ }
8556
+
8557
+ /**
8558
+ * @author Leo Fajardo (@leorw)
8559
+ *
8560
+ * @since 1.2.2
8561
+ *
8562
+ * @param string $option_name
8563
+ * @param string $module_type
8564
+ * @param null|int $network_level_or_blog_id Since 2.0.0
8565
+ *
8566
+ * @return mixed
8567
+ */
8568
+ private static function get_account_option( $option_name, $module_type = null, $network_level_or_blog_id = null ) {
8569
+ if ( ! is_null( $module_type ) && WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) {
8570
+ $option_name = $module_type . '_' . $option_name;
8571
+ }
8572
+
8573
+ return self::$_accounts->get_option( $option_name, array(), $network_level_or_blog_id );
8574
+ }
8575
+
8576
+ /**
8577
+ * @author Leo Fajardo (@leorw)
8578
+ *
8579
+ * @since 1.2.2
8580
+ *
8581
+ * @param string $option_name
8582
+ * @param mixed $option_value
8583
+ * @param bool $store
8584
+ * @param null|int $network_level_or_blog_id Since 2.0.0
8585
+ */
8586
+ private function set_account_option( $option_name, $option_value, $store, $network_level_or_blog_id = null ) {
8587
+ self::set_account_option_by_module(
8588
+ $this->_module_type,
8589
+ $option_name,
8590
+ $option_value,
8591
+ $store,
8592
+ $network_level_or_blog_id
8593
+ );
8594
+ }
8595
+
8596
+ /**
8597
+ * @author Vova Feldman (@svovaf)
8598
+ *
8599
+ * @since 1.2.2.7
8600
+ *
8601
+ * @param string $module_type
8602
+ * @param string $option_name
8603
+ * @param mixed $option_value
8604
+ * @param bool $store
8605
+ * @param null|int $network_level_or_blog_id Since 2.0.0
8606
+ */
8607
+ private static function set_account_option_by_module(
8608
+ $module_type,
8609
+ $option_name,
8610
+ $option_value,
8611
+ $store,
8612
+ $network_level_or_blog_id = null
8613
+ ) {
8614
+ if ( WP_FS__MODULE_TYPE_PLUGIN != $module_type ) {
8615
+ $option_name = $module_type . '_' . $option_name;
8616
+ }
8617
+
8618
+ self::$_accounts->set_option( $option_name, $option_value, $store, $network_level_or_blog_id );
8619
+ }
8620
+
8621
+ /**
8622
+ * @author Vova Feldman (@svovaf)
8623
+ * @since 1.0.6
8624
+ *
8625
+ * @param number|null $module_id
8626
+ *
8627
+ * @return FS_Plugin_License[]
8628
+ */
8629
+ private static function get_all_licenses( $module_id = null ) {
8630
+ $licenses = self::get_account_option( 'all_licenses' );
8631
+
8632
+ if ( ! is_array( $licenses ) ) {
8633
+ $licenses = array();
8634
+ }
8635
+
8636
+ if ( is_null( $module_id ) ) {
8637
+ return $licenses;
8638
+ }
8639
+
8640
+ $licenses = isset( $licenses[ $module_id ] ) ?
8641
+ $licenses[ $module_id ] :
8642
+ array();
8643
+
8644
+ return $licenses;
8645
+ }
8646
+
8647
+ /**
8648
+ * @author Leo Fajardo (@leorw)
8649
+ * @since 2.0.0
8650
+ *
8651
+ * @return array
8652
+ */
8653
+ private static function get_all_licenses_by_module_type() {
8654
+ $licenses = self::get_account_option( 'all_licenses' );
8655
+
8656
+ $licenses_by_module_type = array(
8657
+ WP_FS__MODULE_TYPE_PLUGIN => array(),
8658
+ WP_FS__MODULE_TYPE_THEME => array()
8659
+ );
8660
+
8661
+ if ( ! is_array( $licenses ) ) {
8662
+ return $licenses_by_module_type;
8663
+ }
8664
+
8665
+ foreach ( $licenses as $module_id => $module_licenses ) {
8666
+ $fs = self::get_instance_by_id( $module_id );
8667
+ if ( false === $fs ) {
8668
+ continue;
8669
+ }
8670
+
8671
+ $licenses_by_module_type[ $fs->_module_type ] = array_merge( $licenses_by_module_type[ $fs->_module_type ], $module_licenses );
8672
+ }
8673
+
8674
+ return $licenses_by_module_type;
8675
+ }
8676
+
8677
+ /**
8678
+ * @author Leo Fajardo (@leorw)
8679
+ * @since 2.0.0
8680
+ *
8681
+ * @param number $module_id
8682
+ * @param number|null $user_id
8683
+ *
8684
+ * @return array
8685
+ */
8686
+ private static function get_user_id_license_ids_map( $module_id, $user_id = null ) {
8687
+ $all_modules_user_id_license_ids_map = self::get_account_option( 'user_id_license_ids_map' );
8688
+
8689
+ if ( ! is_array( $all_modules_user_id_license_ids_map ) ) {
8690
+ $all_modules_user_id_license_ids_map = array();
8691
+ }
8692
+
8693
+ $user_id_license_ids_map = isset( $all_modules_user_id_license_ids_map[ $module_id ] ) ?
8694
+ $all_modules_user_id_license_ids_map[ $module_id ] :
8695
+ array();
8696
+
8697
+ if ( FS_User::is_valid_id( $user_id ) ) {
8698
+ $user_id_license_ids_map = isset( $user_id_license_ids_map[ $user_id ] ) ?
8699
+ $user_id_license_ids_map[ $user_id ] :
8700
+ array();
8701
+ }
8702
+
8703
+ return $user_id_license_ids_map;
8704
+ }
8705
+
8706
+ /**
8707
+ * @author Leo Fajardo (@leorw)
8708
+ * @since 2.0.0
8709
+ *
8710
+ * @param array $new_user_id_license_ids_map
8711
+ * @param number $module_id
8712
+ * @param number|null $user_id
8713
+ */
8714
+ private static function store_user_id_license_ids_map( $new_user_id_license_ids_map, $module_id, $user_id = null ) {
8715
+ $all_modules_user_id_license_ids_map = self::get_account_option( 'user_id_license_ids_map' );
8716
+ if ( ! is_array( $all_modules_user_id_license_ids_map ) ) {
8717
+ $all_modules_user_id_license_ids_map = array();
8718
+ }
8719
+
8720
+ if ( ! isset( $all_modules_user_id_license_ids_map[ $module_id ] ) ) {
8721
+ $all_modules_user_id_license_ids_map[ $module_id ] = array();
8722
+ }
8723
+
8724
+ if ( FS_User::is_valid_id( $user_id ) ) {
8725
+ $all_modules_user_id_license_ids_map[ $module_id ][ $user_id ] = $new_user_id_license_ids_map;
8726
+ } else {
8727
+ $all_modules_user_id_license_ids_map[ $module_id ] = $new_user_id_license_ids_map;
8728
+ }
8729
+
8730
+ self::$_accounts->set_option( 'user_id_license_ids_map', $all_modules_user_id_license_ids_map, true );
8731
+ }
8732
+
8733
+ /**
8734
+ * Get a collection of the user's linked license IDs.
8735
+ *
8736
+ * @author Vova Feldman (@svovaf)
8737
+ * @since 2.0.0
8738
+ *
8739
+ * @param number $user_id
8740
+ *
8741
+ * @return number[]
8742
+ */
8743
+ private function get_user_linked_license_ids( $user_id ) {
8744
+ return self::get_user_id_license_ids_map( $this->_module_id, $user_id );
8745
+ }
8746
+
8747
+ /**
8748
+ * Override the user's linked license IDs with a new IDs collection.
8749
+ *
8750
+ * @author Vova Feldman (@svovaf)
8751
+ * @since 2.0.0
8752
+ *
8753
+ * @param number $user_id
8754
+ * @param number[] $license_ids
8755
+ */
8756
+ private function set_user_linked_license_ids( $user_id, array $license_ids ) {
8757
+ self::store_user_id_license_ids_map( $license_ids, $this->_module_id, $user_id );
8758
+ }
8759
+
8760
+ /**
8761
+ * Link a specified license ID to a given user.
8762
+ *
8763
+ * @author Vova Feldman (@svovaf)
8764
+ * @since 2.0.0
8765
+ *
8766
+ * @param number $license_id
8767
+ * @param number $user_id
8768
+ */
8769
+ private function link_license_2_user( $license_id, $user_id ) {
8770
+ $license_ids = $this->get_user_linked_license_ids( $user_id );
8771
+
8772
+ if ( in_array( $license_id, $license_ids ) ) {
8773
+ // License already linked.
8774
+ return;
8775
+ }
8776
+
8777
+ $license_ids[] = $license_id;
8778
+
8779
+ $this->set_user_linked_license_ids( $user_id, $license_ids );
8780
+ }
8781
+
8782
+ /**
8783
+ * @param string|bool $module_type
8784
+ *
8785
+ * @return FS_Plugin_Plan[]
8786
+ */
8787
+ private static function get_all_plans( $module_type = false ) {
8788
+ $plans = self::get_account_option( 'plans', $module_type );
8789
+
8790
+ if ( ! is_array( $plans ) ) {
8791
+ $plans = array();
8792
+ }
8793
+
8794
+ return $plans;
8795
+ }
8796
+
8797
+ /**
8798
+ * @author Vova Feldman (@svovaf)
8799
+ * @since 1.0.4
8800
+ *
8801
+ * @return FS_Plugin_Tag[]
8802
+ */
8803
+ private static function get_all_updates() {
8804
+ $updates = self::$_accounts->get_option( 'updates', array() );
8805
+
8806
+ if ( ! is_array( $updates ) ) {
8807
+ $updates = array();
8808
+ }
8809
+
8810
+ return $updates;
8811
+ }
8812
+
8813
+ /**
8814
+ * @author Vova Feldman (@svovaf)
8815
+ * @since 1.0.6
8816
+ *
8817
+ * @return array<number,FS_Plugin[]>|false
8818
+ */
8819
+ private static function get_all_addons() {
8820
+ $addons = self::$_accounts->get_option( 'addons', array() );
8821
+
8822
+ if ( ! is_array( $addons ) ) {
8823
+ $addons = array();
8824
+ }
8825
+
8826
+ return $addons;
8827
+ }
8828
+
8829
+ /**
8830
+ * @author Vova Feldman (@svovaf)
8831
+ * @since 1.0.6
8832
+ *
8833
+ * @return FS_Plugin[]|false
8834
+ */
8835
+ private static function get_all_account_addons() {
8836
+ $addons = self::$_accounts->get_option( 'account_addons', array() );
8837
+
8838
+ if ( ! is_array( $addons ) ) {
8839
+ $addons = array();
8840
+ }
8841
+
8842
+ return $addons;
8843
+ }
8844
+
8845
+ /**
8846
+ * Check if user has connected his account (opted-in).
8847
+ *
8848
+ * Note:
8849
+ * If the user opted-in and opted-out on a later stage,
8850
+ * this will still return true. If you want to check if the
8851
+ * user is currently opted-in, use:
8852
+ * `$fs->is_registered() && $fs->is_tracking_allowed()`
8853
+ *
8854
+ * @author Vova Feldman (@svovaf)
8855
+ * @since 1.0.1
8856
+ * @return bool
8857
+ */
8858
+ function is_registered() {
8859
+ return is_object( $this->_user );
8860
+ }
8861
+
8862
+ /**
8863
+ * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
8864
+ *
8865
+ * @author Leo Fajardo (@leorw)
8866
+ * @since 1.2.1.5
8867
+ *
8868
+ * @return bool
8869
+ */
8870
+ function is_tracking_allowed() {
8871
+ return ( is_object( $this->_site ) && $this->_site->is_tracking_allowed() );
8872
+ }
8873
+
8874
+ /**
8875
+ * @author Vova Feldman (@svovaf)
8876
+ * @since 1.0.4
8877
+ *
8878
+ * @return FS_Plugin
8879
+ */
8880
+ function get_plugin() {
8881
+ return $this->_plugin;
8882
+ }
8883
+
8884
+ /**
8885
+ * @author Vova Feldman (@svovaf)
8886
+ * @since 1.0.3
8887
+ *
8888
+ * @return FS_User
8889
+ */
8890
+ function get_user() {
8891
+ return $this->_user;
8892
+ }
8893
+
8894
+ /**
8895
+ * @author Vova Feldman (@svovaf)
8896
+ * @since 1.0.3
8897
+ *
8898
+ * @return FS_Site
8899
+ */
8900
+ function get_site() {
8901
+ return $this->_site;
8902
+ }
8903
+
8904
+ /**
8905
+ * Get plugin add-ons.
8906
+ *
8907
+ * @author Vova Feldman (@svovaf)
8908
+ * @since 1.0.6
8909
+ *
8910
+ * @since 1.1.7.3 If not yet loaded, fetch data from the API.
8911
+ *
8912
+ * @param bool $flush
8913
+ *
8914
+ * @return FS_Plugin[]|false
8915
+ */
8916
+ function get_addons( $flush = false ) {
8917
+ $this->_logger->entrance();
8918
+
8919
+ if ( ! $this->_has_addons ) {
8920
+ return false;
8921
+ }
8922
+
8923
+ $addons = $this->sync_addons( $flush );
8924
+
8925
+ return ( ! is_array( $addons ) || empty( $addons ) ) ?
8926
+ false :
8927
+ $addons;
8928
+ }
8929
+
8930
+ /**
8931
+ * @author Vova Feldman (@svovaf)
8932
+ * @since 1.0.6
8933
+ *
8934
+ * @return FS_Plugin[]|false
8935
+ */
8936
+ function get_account_addons() {
8937
+ $this->_logger->entrance();
8938
+
8939
+ $addons = self::get_all_account_addons();
8940
+
8941
+ if ( ! is_array( $addons ) ||
8942
+ ! isset( $addons[ $this->_plugin->id ] ) ||
8943
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
8944
+ 0 === count( $addons[ $this->_plugin->id ] )
8945
+ ) {
8946
+ return false;
8947
+ }
8948
+
8949
+ return $addons[ $this->_plugin->id ];
8950
+ }
8951
+
8952
+ /**
8953
+ * Check if user has any
8954
+ *
8955
+ * @author Vova Feldman (@svovaf)
8956
+ * @since 1.1.6
8957
+ *
8958
+ * @return bool
8959
+ */
8960
+ function has_account_addons() {
8961
+ $addons = $this->get_account_addons();
8962
+
8963
+ return is_array( $addons ) && ( 0 < count( $addons ) );
8964
+ }
8965
+
8966
+
8967
+ /**
8968
+ * Get add-on by ID (from local data).
8969
+ *
8970
+ * @author Vova Feldman (@svovaf)
8971
+ * @since 1.0.6
8972
+ *
8973
+ * @param number $id
8974
+ *
8975
+ * @return FS_Plugin|false
8976
+ */
8977
+ function get_addon( $id ) {
8978
+ $this->_logger->entrance();
8979
+
8980
+ $addons = $this->get_addons();
8981
+
8982
+ if ( is_array( $addons ) ) {
8983
+ foreach ( $addons as $addon ) {
8984
+ if ( $id == $addon->id ) {
8985
+ return $addon;
8986
+ }
8987
+ }
8988
+ }
8989
+
8990
+ return false;
8991
+ }
8992
+
8993
+ /**
8994
+ * Get add-on by slug (from local data).
8995
+ *
8996
+ * @author Vova Feldman (@svovaf)
8997
+ * @since 1.0.6
8998
+ *
8999
+ * @param string $slug
9000
+ *
9001
+ * @param bool $flush
9002
+ *
9003
+ * @return FS_Plugin|false
9004
+ */
9005
+ function get_addon_by_slug( $slug, $flush = false ) {
9006
+ $this->_logger->entrance();
9007
+
9008
+ $addons = $this->get_addons( $flush );
9009
+
9010
+ if ( is_array( $addons ) ) {
9011
+ foreach ( $addons as $addon ) {
9012
+ if ( $slug === $addon->slug ) {
9013
+ return $addon;
9014
+ }
9015
+ }
9016
+ }
9017
+
9018
+ return false;
9019
+ }
9020
+
9021
+ /**
9022
+ * @author Vova Feldman (@svovaf)
9023
+ * @since 2.0.0
9024
+ *
9025
+ * @param number $user_id
9026
+ *
9027
+ * @return FS_User
9028
+ */
9029
+ static function _get_user_by_id( $user_id ) {
9030
+ self::$_static_logger->entrance( "user_id = {$user_id}" );
9031
+
9032
+ $users = self::get_all_users();
9033
+
9034
+ if ( is_array( $users ) ) {
9035
+ if ( isset( $users[ $user_id ] ) &&
9036
+ $users[ $user_id ] instanceof FS_User &&
9037
+ $user_id == $users[ $user_id ]->id
9038
+ ) {
9039
+ return $users[ $user_id ];
9040
+ }
9041
+
9042
+ // If user wasn't found by the key, iterate over all the users collection.
9043
+ foreach ( $users as $user ) {
9044
+ /**
9045
+ * @var FS_User $user
9046
+ */
9047
+ if ( $user_id == $user->id ) {
9048
+ return $user;
9049
+ }
9050
+ }
9051
+ }
9052
+
9053
+ return null;
9054
+ }
9055
+
9056
+ /**
9057
+ * Checks if a Freemius user_id is associated with a super-admin.
9058
+ *
9059
+ * @author Vova Feldman (@svovaf)
9060
+ * @since 2.0.0
9061
+ *
9062
+ * @param number $user_id
9063
+ *
9064
+ * @return bool
9065
+ */
9066
+ private static function is_super_admin( $user_id ) {
9067
+ $is_super_admin = false;
9068
+
9069
+ $user = self::_get_user_by_id( $user_id );
9070
+
9071
+ if ( $user instanceof FS_User && ! empty( $user->email ) ) {
9072
+ self::require_pluggable_essentials();
9073
+
9074
+ $wp_user = get_user_by( 'email', $user->email );
9075
+
9076
+ if ( $wp_user instanceof WP_User ) {
9077
+ $super_admins = get_super_admins();
9078
+ $is_super_admin = ( is_array( $super_admins ) && in_array( $wp_user->user_login, $super_admins ) );
9079
+ }
9080
+ }
9081
+
9082
+ return $is_super_admin;
9083
+ }
9084
+
9085
+ #----------------------------------------------------------------------------------
9086
+ #region Plans & Licensing
9087
+ #----------------------------------------------------------------------------------
9088
+
9089
+ /**
9090
+ * Check if running premium plugin code.
9091
+ *
9092
+ * @author Vova Feldman (@svovaf)
9093
+ * @since 1.0.5
9094
+ *
9095
+ * @return bool
9096
+ */
9097
+ function is_premium() {
9098
+ return $this->_plugin->is_premium;
9099
+ }
9100
+
9101
+ /**
9102
+ * Get site's plan ID.
9103
+ *
9104
+ * @author Vova Feldman (@svovaf)
9105
+ * @since 1.0.2
9106
+ *
9107
+ * @return number
9108
+ */
9109
+ function get_plan_id() {
9110
+ return $this->_site->plan_id;
9111
+ }
9112
+
9113
+ /**
9114
+ * Get site's plan title.
9115
+ *
9116
+ * @author Vova Feldman (@svovaf)
9117
+ * @since 1.0.2
9118
+ *
9119
+ * @return string
9120
+ */
9121
+ function get_plan_title() {
9122
+ $plan = $this->get_plan();
9123
+
9124
+ return is_object( $plan ) ? $plan->title : 'PLAN_TITLE';
9125
+ }
9126
+
9127
+ /**
9128
+ * Get site's plan name.
9129
+ *
9130
+ * @author Vova Feldman (@svovaf)
9131
+ * @since 2.0.0
9132
+ *
9133
+ * @return string
9134
+ */
9135
+ function get_plan_name() {
9136
+ $plan = $this->get_plan();
9137
+
9138
+ return is_object( $plan ) ? $plan->name : 'PLAN_NAME';
9139
+ }
9140
+
9141
+ /**
9142
+ * @author Vova Feldman (@svovaf)
9143
+ * @since 1.0.9
9144
+ *
9145
+ * @return FS_Plugin_Plan|false
9146
+ */
9147
+ function get_plan() {
9148
+ if ( ! is_object( $this->_site ) ) {
9149
+ return false;
9150
+ }
9151
+
9152
+ return FS_Plugin_Plan::is_valid_id( $this->_site->plan_id ) ?
9153
+ $this->_get_plan_by_id( $this->_site->plan_id ) :
9154
+ false;
9155
+ }
9156
+
9157
+ /**
9158
+ * @author Vova Feldman (@svovaf)
9159
+ * @since 1.0.3
9160
+ *
9161
+ * @return bool
9162
+ */
9163
+ function is_trial() {
9164
+ $this->_logger->entrance();
9165
+
9166
+ if ( ! $this->is_registered() || ! is_object( $this->_site ) ) {
9167
+ return false;
9168
+ }
9169
+
9170
+ return $this->_site->is_trial();
9171
+ }
9172
+
9173
+ /**
9174
+ * Check if currently in a trial with payment method (credit card or paypal).
9175
+ *
9176
+ * @author Vova Feldman (@svovaf)
9177
+ * @since 1.1.7
9178
+ *
9179
+ * @return bool
9180
+ */
9181
+ function is_paid_trial() {
9182
+ $this->_logger->entrance();
9183
+
9184
+ if ( ! $this->is_trial() ) {
9185
+ return false;
9186
+ }
9187
+
9188
+ return $this->has_active_valid_license() && ( $this->_site->trial_plan_id == $this->_license->plan_id );
9189
+ }
9190
+
9191
+ /**
9192
+ * Check if trial already utilized.
9193
+ *
9194
+ * @since 1.0.9
9195
+ *
9196
+ * @return bool
9197
+ */
9198
+ function is_trial_utilized() {
9199
+ $this->_logger->entrance();
9200
+
9201
+ if ( ! $this->is_registered() ) {
9202
+ return false;
9203
+ }
9204
+
9205
+ return $this->_site->is_trial_utilized();
9206
+ }
9207
+
9208
+ /**
9209
+ * Get trial plan information (if in trial).
9210
+ *
9211
+ * @author Vova Feldman (@svovaf)
9212
+ * @since 1.0.9
9213
+ *
9214
+ * @return bool|FS_Plugin_Plan
9215
+ */
9216
+ function get_trial_plan() {
9217
+ $this->_logger->entrance();
9218
+
9219
+ if ( ! $this->is_trial() ) {
9220
+ return false;
9221
+ }
9222
+
9223
+ // Try to load plan from local cache.
9224
+ $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
9225
+
9226
+ if ( ! is_object( $trial_plan ) ) {
9227
+ $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
9228
+
9229
+ /**
9230
+ * If managed to fetch the plan, add it to the plans collection.
9231
+ */
9232
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
9233
+ if ( ! is_array( $this->_plans ) ) {
9234
+ $this->_plans = array();
9235
+ }
9236
+
9237
+ $this->_plans[] = $trial_plan;
9238
+ $this->_store_plans();
9239
+ }
9240
+ }
9241
+
9242
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
9243
+ return $trial_plan;
9244
+ }
9245
+
9246
+ /**
9247
+ * If for some reason failed to get the trial plan, fallback to a dummy name and title.
9248
+ */
9249
+ $trial_plan = new FS_Plugin_Plan();
9250
+ $trial_plan->id = $this->_site->trial_plan_id;
9251
+ $trial_plan->name = 'pro';
9252
+ $trial_plan->title = 'Pro';
9253
+
9254
+ return $trial_plan;
9255
+ }
9256
+
9257
+ /**
9258
+ * Check if the user has an activate, non-expired license on current plugin's install.
9259
+ *
9260
+ * @since 1.0.9
9261
+ *
9262
+ * @return bool
9263
+ */
9264
+ function is_paying() {
9265
+ $this->_logger->entrance();
9266
+
9267
+ if ( ! $this->is_registered() ) {
9268
+ return false;
9269
+ }
9270
+
9271
+ if ( ! $this->has_paid_plan() ) {
9272
+ return false;
9273
+ }
9274
+
9275
+ return (
9276
+ ! $this->is_trial() &&
9277
+ 'free' !== $this->get_plan_name() &&
9278
+ $this->has_active_valid_license()
9279
+ );
9280
+ }
9281
+
9282
+ /**
9283
+ * @author Vova Feldman (@svovaf)
9284
+ * @since 1.0.4
9285
+ *
9286
+ * @return bool
9287
+ */
9288
+ function is_free_plan() {
9289
+ if ( ! $this->is_registered() ) {
9290
+ return true;
9291
+ }
9292
+
9293
+ if ( ! $this->has_paid_plan() ) {
9294
+ return true;
9295
+ }
9296
+
9297
+ return (
9298
+ 'free' === $this->get_plan_name() ||
9299
+ ! $this->has_features_enabled_license()
9300
+ );
9301
+ }
9302
+
9303
+ /**
9304
+ * @author Vova Feldman (@svovaf)
9305
+ * @since 1.0.5
9306
+ *
9307
+ * @return bool
9308
+ */
9309
+ function _has_premium_license() {
9310
+ $this->_logger->entrance();
9311
+
9312
+ $premium_license = $this->_get_available_premium_license();
9313
+
9314
+ return ( false !== $premium_license );
9315
+ }
9316
+
9317
+ /**
9318
+ * Check if user has any licenses associated with the plugin (including expired or blocking).
9319
+ *
9320
+ * @author Vova Feldman (@svovaf)
9321
+ * @since 1.1.7.3
9322
+ *
9323
+ * @return bool
9324
+ */
9325
+ function has_any_license() {
9326
+ return is_array( $this->_licenses ) && ( 0 < count( $this->_licenses ) );
9327
+ }
9328
+
9329
+ /**
9330
+ * @author Vova Feldman (@svovaf)
9331
+ * @since 1.0.5
9332
+ *
9333
+ * @param bool|null $is_localhost
9334
+ *
9335
+ * @return FS_Plugin_License|false
9336
+ */
9337
+ function _get_available_premium_license( $is_localhost = null ) {
9338
+ $this->_logger->entrance();
9339
+
9340
+ $licenses = $this->get_available_premium_licenses( $is_localhost );
9341
+ if ( ! empty( $licenses ) ) {
9342
+ return $licenses[0];
9343
+ }
9344
+
9345
+ return false;
9346
+ }
9347
+
9348
+ /**
9349
+ * @author Vova Feldman (@svovaf)
9350
+ * @since 1.0.5
9351
+ *
9352
+ * @param bool|null $is_localhost
9353
+ *
9354
+ * @return FS_Plugin_License[]
9355
+ */
9356
+ function get_available_premium_licenses( $is_localhost = null ) {
9357
+ $this->_logger->entrance();
9358
+
9359
+ $licenses = array();
9360
+ if ( ! $this->has_paid_plan() ) {
9361
+ return $licenses;
9362
+ }
9363
+
9364
+ if ( is_array( $this->_licenses ) ) {
9365
+ foreach ( $this->_licenses as $license ) {
9366
+ if ( ! $license->can_activate( $is_localhost ) ) {
9367
+ continue;
9368
+ }
9369
+
9370
+ $licenses[] = $license;
9371
+ }
9372
+ }
9373
+
9374
+ return $licenses;
9375
+ }
9376
+
9377
+ /**
9378
+ * Sync local plugin plans with remote server.
9379
+ *
9380
+ * IMPORTANT: If for some reason a site is associated with deleted plan, we'll preserve the plan's information and append it as the last plan. This means that if plan is deleted, the is_plan() method will ALWAYS return true for any given argument (it becomes the most inclusive plan).
9381
+ *
9382
+ * @author Vova Feldman (@svovaf)
9383
+ * @since 1.0.5
9384
+ *
9385
+ * @return FS_Plugin_Plan[]|object
9386
+ */
9387
+ function _sync_plans() {
9388
+ $plans = $this->_fetch_plugin_plans();
9389
+
9390
+ if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) {
9391
+ $plans_map = array();
9392
+ foreach ( $plans as $plan ) {
9393
+ $plans_map[ $plan->id ] = true;
9394
+ }
9395
+
9396
+ $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
9397
+
9398
+ foreach ( $plans_ids_to_keep as $plan_id ) {
9399
+ if ( isset( $plans_map[ $plan_id ] ) ) {
9400
+ continue;
9401
+ }
9402
+
9403
+ $missing_plan = self::_get_plan_by_id( $plan_id );
9404
+
9405
+ if ( is_object( $missing_plan ) ) {
9406
+ $plans[] = $missing_plan;
9407
+ }
9408
+ }
9409
+
9410
+ $this->_plans = $plans;
9411
+ $this->_store_plans();
9412
+ }
9413
+
9414
+ $this->do_action( 'after_plans_sync', $plans );
9415
+
9416
+ return $this->_plans;
9417
+ }
9418
+
9419
+ /**
9420
+ * Check if specified plan exists locally. If not, fetch it and store it.
9421
+ *
9422
+ * @author Vova Feldman (@svovaf)
9423
+ * @since 2.0.0
9424
+ *
9425
+ * @param number $plan_id
9426
+ *
9427
+ * @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
9428
+ */
9429
+ private function sync_plan_if_not_exist( $plan_id ) {
9430
+ $plan = self::_get_plan_by_id( $plan_id );
9431
+
9432
+ if ( is_object( $plan ) ) {
9433
+ // Plan already exists.
9434
+ return $plan;
9435
+ }
9436
+
9437
+ $plan = $this->fetch_plan_by_id( $plan_id );
9438
+
9439
+ if ( $plan instanceof FS_Plugin_Plan ) {
9440
+ $this->_plans[] = $plan;
9441
+ $this->_store_plans();
9442
+
9443
+ return $plan;
9444
+ }
9445
+
9446
+ return $plan;
9447
+ }
9448
+
9449
+ /**
9450
+ * Check if specified license exists locally. If not, fetch it and store it.
9451
+ *
9452
+ * @author Vova Feldman (@svovaf)
9453
+ * @since 2.0.0
9454
+ *
9455
+ * @param number $license_id
9456
+ * @param string $license_key
9457
+ *
9458
+ * @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
9459
+ */
9460
+ private function sync_license_if_not_exist( $license_id, $license_key ) {
9461
+ $license = $this->_get_license_by_id( $license_id );
9462
+
9463
+ if ( is_object( $license ) ) {
9464
+ // License already exists.
9465
+ return $license;
9466
+ }
9467
+
9468
+ $license = $this->fetch_license_by_key( $license_id, $license_key );
9469
+
9470
+ if ( $license instanceof FS_Plugin_License ) {
9471
+ $this->_licenses[] = $license;
9472
+ $this->_license = $license;
9473
+ $this->_store_licenses();
9474
+
9475
+ return $license;
9476
+ }
9477
+
9478
+ return $license;
9479
+ }
9480
+
9481
+ /**
9482
+ * Get a collection of unique plan IDs that are associated with any installs in the network.
9483
+ *
9484
+ * @author Leo Fajardo (@leorw)
9485
+ * @since 2.0.0
9486
+ *
9487
+ * @return number[]
9488
+ */
9489
+ private function get_plans_ids_associated_with_installs() {
9490
+ if ( ! $this->_is_network_active ) {
9491
+ if ( ! is_object( $this->_site ) ||
9492
+ ! FS_Plugin_Plan::is_valid_id( $this->_site->plan_id )
9493
+ ) {
9494
+ return array();
9495
+ }
9496
+
9497
+ return array( $this->_site->plan_id );
9498
+ }
9499
+
9500
+ $plan_ids = array();
9501
+ $sites = self::get_sites();
9502
+ foreach ( $sites as $site ) {
9503
+ $blog_id = self::get_site_blog_id( $site );
9504
+ $install = $this->get_install_by_blog_id( $blog_id );
9505
+
9506
+ if ( ! is_object( $install ) ||
9507
+ ! FS_Plugin_Plan::is_valid_id( $install->plan_id )
9508
+ ) {
9509
+ continue;
9510
+ }
9511
+
9512
+ $plan_ids[ $install->plan_id ] = true;
9513
+ }
9514
+
9515
+ return array_keys( $plan_ids );
9516
+ }
9517
+
9518
+ /**
9519
+ * Get a collection of unique license IDs that are associated with any installs in the network.
9520
+ *
9521
+ * @author Leo Fajardo (@leorw)
9522
+ * @since 2.0.0
9523
+ *
9524
+ * @return number[]
9525
+ */
9526
+ private function get_license_ids_associated_with_installs() {
9527
+ if ( ! $this->_is_network_active ) {
9528
+ if ( ! is_object( $this->_site ) ||
9529
+ ! FS_Plugin_License::is_valid_id( $this->_site->license_id )
9530
+ ) {
9531
+ return array();
9532
+ }
9533
+
9534
+ return array( $this->_site->license_id );
9535
+ }
9536
+
9537
+ $license_ids = array();
9538
+ $sites = self::get_sites();
9539
+ foreach ( $sites as $site ) {
9540
+ $blog_id = self::get_site_blog_id( $site );
9541
+ $install = $this->get_install_by_blog_id( $blog_id );
9542
+
9543
+ if ( ! is_object( $install ) ||
9544
+ ! FS_Plugin_License::is_valid_id( $install->license_id )
9545
+ ) {
9546
+ continue;
9547
+ }
9548
+
9549
+ $license_ids[ $install->license_id ] = true;
9550
+ }
9551
+
9552
+ return array_keys( $license_ids );
9553
+ }
9554
+
9555
+ /**
9556
+ * @author Vova Feldman (@svovaf)
9557
+ * @since 1.0.5
9558
+ *
9559
+ * @param number $id
9560
+ *
9561
+ * @return FS_Plugin_Plan|false
9562
+ */
9563
+ function _get_plan_by_id( $id ) {
9564
+ $this->_logger->entrance();
9565
+
9566
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
9567
+ $this->_sync_plans();
9568
+ }
9569
+
9570
+ foreach ( $this->_plans as $plan ) {
9571
+ if ( $id == $plan->id ) {
9572
+ return $plan;
9573
+ }
9574
+ }
9575
+
9576
+ return false;
9577
+ }
9578
+
9579
+ /**
9580
+ * @author Vova Feldman (@svovaf)
9581
+ * @since 1.1.8.1
9582
+ *
9583
+ * @param string $name
9584
+ *
9585
+ * @return FS_Plugin_Plan|false
9586
+ */
9587
+ private function get_plan_by_name( $name ) {
9588
+ $this->_logger->entrance();
9589
+
9590
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
9591
+ $this->_sync_plans();
9592
+ }
9593
+
9594
+ foreach ( $this->_plans as $plan ) {
9595
+ if ( $name == $plan->name ) {
9596
+ return $plan;
9597
+ }
9598
+ }
9599
+
9600
+ return false;
9601
+ }
9602
+
9603
+ /**
9604
+ * Sync local licenses with remote server.
9605
+ *
9606
+ * @author Vova Feldman (@svovaf)
9607
+ * @since 1.0.6
9608
+ *
9609
+ * @param number|bool $site_license_id
9610
+ * @param number|null $blog_id
9611
+ *
9612
+ * @return FS_Plugin_License[]|object
9613
+ */
9614
+ function _sync_licenses( $site_license_id = false, $blog_id = null ) {
9615
+ $this->_logger->entrance();
9616
+
9617
+ $is_network_admin = fs_is_network_admin();
9618
+
9619
+ if ( $is_network_admin && is_null( $blog_id ) ) {
9620
+ $all_licenses = self::get_all_licenses( $this->_module_id );
9621
+ } else {
9622
+ $all_licenses = $this->get_user_licenses( $this->_user->id );
9623
+ }
9624
+
9625
+ $foreign_licenses = array(
9626
+ 'ids' => array(),
9627
+ 'license_keys' => array()
9628
+ );
9629
+
9630
+ $all_licenses_map = array();
9631
+ foreach ( $all_licenses as $license ) {
9632
+ $all_licenses_map[ $license->id ] = true;
9633
+ if ( $license->user_id == $this->_user->id || $license->id == $site_license_id ) {
9634
+ continue;
9635
+ }
9636
+
9637
+ $foreign_licenses['ids'][] = $license->id;
9638
+ $foreign_licenses['license_keys'][] = $license->secret_key;
9639
+ }
9640
+
9641
+ if ( empty( $foreign_licenses['ids'] ) ) {
9642
+ $foreign_licenses = array();
9643
+ }
9644
+
9645
+ $licenses = $this->_fetch_licenses( false, $site_license_id, $foreign_licenses, $blog_id );
9646
+
9647
+ if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
9648
+ $licenses_map = array();
9649
+ foreach ( $licenses as $license ) {
9650
+ $licenses_map[ $license->id ] = true;
9651
+ }
9652
+
9653
+ // $license_ids_to_keep = $this->get_license_ids_associated_with_installs();
9654
+ // foreach ( $license_ids_to_keep as $license_id ) {
9655
+ // if ( isset( $licenses_map[ $license_id ] ) ) {
9656
+ // continue;
9657
+ // }
9658
+ //
9659
+ // $missing_license = self::_get_license_by_id( $license_id, false );
9660
+ // if ( is_object( $missing_license ) ) {
9661
+ // $licenses[] = $missing_license;
9662
+ // $licenses_map[ $missing_license->id ] = true;
9663
+ // }
9664
+ // }
9665
+
9666
+ $user_license_ids = $this->get_user_linked_license_ids( $this->_user->id );
9667
+
9668
+ foreach ( $user_license_ids as $key => $license_id ) {
9669
+ if ( ! isset( $licenses_map[ $license_id ] ) ) {
9670
+ // Remove access to licenses that no longer exist.
9671
+ unset( $user_license_ids[ $key ] );
9672
+ }
9673
+ }
9674
+
9675
+ if ( ! empty( $user_license_ids ) ) {
9676
+ foreach ( $licenses_map as $license_id => $value ) {
9677
+ if ( ! isset( $all_licenses_map[ $license_id ] ) ) {
9678
+ // Associate new licenses with the user who triggered the license syncing.
9679
+ $user_license_ids[] = $license_id;
9680
+ }
9681
+ }
9682
+
9683
+ $user_license_ids = array_unique( $user_license_ids );
9684
+ } else {
9685
+ $user_license_ids = array_keys( $licenses_map );
9686
+ }
9687
+
9688
+ if ( ! $is_network_admin || ! is_null( $blog_id ) ) {
9689
+ $user_licenses = array();
9690
+ foreach ( $licenses as $license ) {
9691
+ if ( ! in_array( $license->id, $user_license_ids ) ) {
9692
+ continue;
9693
+ }
9694
+
9695
+ $user_licenses[] = $license;
9696
+ }
9697
+
9698
+ $this->_licenses = $user_licenses;
9699
+ } else {
9700
+ $this->_licenses = $licenses;
9701
+ }
9702
+
9703
+ $this->set_user_linked_license_ids( $this->_user->id, $user_license_ids );
9704
+
9705
+ $this->_store_licenses( true, $this->_module_id, $licenses );
9706
+ }
9707
+
9708
+ // Update current license.
9709
+ if ( is_object( $this->_license ) ) {
9710
+ $this->_license = $this->_get_license_by_id( $this->_license->id );
9711
+ }
9712
+
9713
+ return $this->_licenses;
9714
+ }
9715
+
9716
+ /**
9717
+ * @author Vova Feldman (@svovaf)
9718
+ * @since 1.0.5
9719
+ *
9720
+ * @param number $id
9721
+ * @param bool $sync_licenses
9722
+ *
9723
+ * @return FS_Plugin_License|false
9724
+ */
9725
+ function _get_license_by_id( $id, $sync_licenses = true ) {
9726
+ $this->_logger->entrance();
9727
+
9728
+ if ( ! FS_Plugin_License::is_valid_id( $id ) ) {
9729
+ return false;
9730
+ }
9731
+
9732
+ /**
9733
+ * When running from the network level admin and opted-in from the network,
9734
+ * check if the license exists in the network user licenses collection.
9735
+ *
9736
+ * @author Vova Feldman (@svovaf)
9737
+ * @since 2.0.0
9738
+ */
9739
+ if ( fs_is_network_admin() &&
9740
+ $this->is_network_registered() &&
9741
+ ( ! is_object( $this->_user ) || $this->_storage->network_user_id != $this->_user->id )
9742
+ ) {
9743
+ $licenses = $this->get_user_licenses( $this->_storage->network_user_id );
9744
+
9745
+ foreach ( $licenses as $license ) {
9746
+ if ( $id == $license->id ) {
9747
+ return $license;
9748
+ }
9749
+ }
9750
+ }
9751
+
9752
+ if ( ! $this->has_any_license() && $sync_licenses ) {
9753
+ $this->_sync_licenses( $id );
9754
+ }
9755
+
9756
+ if ( is_array( $this->_licenses ) ) {
9757
+ foreach ( $this->_licenses as $license ) {
9758
+ if ( $id == $license->id ) {
9759
+ return $license;
9760
+ }
9761
+ }
9762
+ }
9763
+
9764
+ return false;
9765
+ }
9766
+
9767
+ /**
9768
+ * Get license by ID. Unlike _get_license_by_id(), this method only checks the local storage and return any license, whether it's associated with the current context user/install or not.
9769
+ *
9770
+ * @author Vova Feldman (@svovaf)
9771
+ * @since 2.0.0
9772
+ *
9773
+ * @param number $id
9774
+ *
9775
+ * @return FS_Plugin_License
9776
+ */
9777
+ private function get_license_by_id( $id ) {
9778
+ $licenses = self::get_all_licenses( $this->_module_id );
9779
+
9780
+ if ( is_array( $licenses ) && ! empty( $licenses ) ) {
9781
+ foreach ( $licenses as $license ) {
9782
+ if ( $id == $license->id ) {
9783
+ return $license;
9784
+ }
9785
+ }
9786
+ }
9787
+
9788
+ return null;
9789
+ }
9790
+
9791
+ /**
9792
+ * Synchronize the site's context license by fetching the license form the API and updating the local data with it.
9793
+ *
9794
+ * @author Vova Feldman (@svovaf)
9795
+ * @since 2.0.0
9796
+ *
9797
+ * @return \FS_Plugin_License|mixed
9798
+ */
9799
+ private function sync_site_license() {
9800
+ $api = $this->get_api_user_scope();
9801
+
9802
+ $result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true );
9803
+
9804
+ if ( ! $this->is_api_result_entity( $result ) ) {
9805
+ return $result;
9806
+ }
9807
+
9808
+ $license = $this->_update_site_license( new FS_Plugin_License( $result ) );
9809
+ $this->_store_licenses();
9810
+
9811
+ return $license;
9812
+ }
9813
+
9814
+ /**
9815
+ * Get all user's available licenses for the current module.
9816
+ *
9817
+ * @author Vova Feldman (@svovaf)
9818
+ * @since 2.0.0
9819
+ *
9820
+ * @param number $user_id
9821
+ *
9822
+ * @return FS_Plugin_License[]
9823
+ */
9824
+ private function get_user_licenses( $user_id ) {
9825
+ $all_licenses = self::get_all_licenses( $this->_module_id );
9826
+ if ( empty( $all_licenses ) ) {
9827
+ return array();
9828
+ }
9829
+
9830
+ $user_license_ids = $this->get_user_linked_license_ids( $user_id );
9831
+ if ( empty( $user_license_ids ) ) {
9832
+ return array();
9833
+ }
9834
+
9835
+ $licenses = array();
9836
+ foreach ( $all_licenses as $license ) {
9837
+ if ( in_array( $license->id, $user_license_ids ) ) {
9838
+ $licenses[] = $license;
9839
+ }
9840
+ }
9841
+
9842
+ return $licenses;
9843
+ }
9844
+
9845
+ /**
9846
+ * Checks if the context license is network activated except on the given blog ID.
9847
+ *
9848
+ * @author Vova Feldman (@svovaf)
9849
+ * @since 2.0.0
9850
+ *
9851
+ * @param int $except_blog_id
9852
+ *
9853
+ * @return bool
9854
+ */
9855
+ private function is_license_network_active( $except_blog_id = 0 ) {
9856
+ $this->_logger->entrance();
9857
+
9858
+ if ( ! is_object( $this->_license ) ) {
9859
+ return false;
9860
+ }
9861
+
9862
+ $sites = self::get_sites();
9863
+
9864
+ if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) {
9865
+ // There are more sites than the number of activations, so license cannot be network activated.
9866
+ return false;
9867
+ }
9868
+
9869
+ foreach ( $sites as $site ) {
9870
+ $blog_id = self::get_site_blog_id( $site );
9871
+
9872
+ if ( $except_blog_id == $blog_id ) {
9873
+ // Skip excluded blog.
9874
+ continue;
9875
+ }
9876
+
9877
+ $install = $this->get_install_by_blog_id( $blog_id );
9878
+
9879
+ if ( is_object( $install ) && $install->license_id != $this->_license->id ) {
9880
+ return false;
9881
+ }
9882
+ }
9883
+
9884
+ return true;
9885
+ }
9886
+
9887
+ /**
9888
+ * Checks if license can be activated on all the network sites (opted-in or skipped) that are not yet associated with a license. If possible, try to make the activation, if not return false.
9889
+ *
9890
+ * Notice: On success, this method will also update the license activations counters (without updating the license in the storage).
9891
+ *
9892
+ * @author Vova Feldman (@svovaf)
9893
+ * @since 2.0.0
9894
+ *
9895
+ * @param \FS_User $user
9896
+ * @param \FS_Plugin_License $license
9897
+ *
9898
+ * @return bool
9899
+ */
9900
+ private function try_activate_license_on_network( FS_User $user, FS_Plugin_License $license ) {
9901
+ $this->_logger->entrance();
9902
+
9903
+ $result = $this->can_activate_license_on_network( $license );
9904
+
9905
+ if ( false === $result ) {
9906
+ return false;
9907
+ }
9908
+
9909
+ $installs_without_license = $result['installs'];
9910
+ if ( ! empty( $installs_without_license ) ) {
9911
+ $this->activate_license_on_many_installs( $user, $license->secret_key, $installs_without_license );
9912
+ }
9913
+
9914
+ $disconnected_site_ids = $result['sites'];
9915
+ if ( ! empty( $disconnected_site_ids ) ) {
9916
+ $this->activate_license_on_many_sites( $user, $license->secret_key, $disconnected_site_ids );
9917
+ }
9918
+
9919
+ $this->link_license_2_user( $license->id, $user->id );
9920
+
9921
+ // Sync license after activations.
9922
+ $license->activated += $result['production_count'];
9923
+ $license->activated_local += $result['localhost_count'];
9924
+
9925
+ // $this->_store_licenses()
9926
+
9927
+ return true;
9928
+ }
9929
+
9930
+ /**
9931
+ * Checks if the given license can be activated on the whole network.
9932
+ *
9933
+ * @author Vova Feldman (@svovaf)
9934
+ * @since 2.0.0
9935
+ *
9936
+ * @param \FS_Plugin_License $license
9937
+ *
9938
+ * @return false|array {
9939
+ * @type array[int]FS_Site $installs Blog ID to install map.
9940
+ * @type int[] $sites Non-connected blog IDs.
9941
+ * @type int $production_count Production sites count.
9942
+ * @type int $localhost_count Production sites count.
9943
+ * }
9944
+ */
9945
+ private function can_activate_license_on_network( FS_Plugin_License $license ) {
9946
+ $sites = self::get_sites();
9947
+
9948
+ $production_count = 0;
9949
+ $localhost_count = 0;
9950
+
9951
+ $installs_without_license = array();
9952
+ $disconnected_site_ids = array();
9953
+
9954
+ foreach ( $sites as $site ) {
9955
+ $blog_id = self::get_site_blog_id( $site );
9956
+ $install = $this->get_install_by_blog_id( $blog_id );
9957
+
9958
+ if ( is_object( $install ) ) {
9959
+ if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) {
9960
+ // License already activated on the install.
9961
+ continue;
9962
+ }
9963
+
9964
+ $url = $install->url;
9965
+
9966
+ $installs_without_license[ $blog_id ] = $install;
9967
+ } else {
9968
+ $url = is_object( $site ) ?
9969
+ $site->siteurl :
9970
+ get_site_url( $blog_id );
9971
+
9972
+ $disconnected_site_ids[] = $blog_id;
9973
+ }
9974
+
9975
+ if ( FS_Site::is_localhost_by_address( $url ) ) {
9976
+ $localhost_count ++;
9977
+ } else {
9978
+ $production_count ++;
9979
+ }
9980
+ }
9981
+
9982
+ if ( ! $license->can_activate_bulk( $production_count, $localhost_count ) ) {
9983
+ return false;
9984
+ }
9985
+
9986
+ return array(
9987
+ 'installs' => $installs_without_license,
9988
+ 'sites' => $disconnected_site_ids,
9989
+ 'production_count' => $production_count,
9990
+ 'localhost_count' => $localhost_count,
9991
+ );
9992
+ }
9993
+
9994
+ /**
9995
+ * Activate a given license on a collection of installs.
9996
+ *
9997
+ * @author Vova Feldman (@svovaf)
9998
+ * @since 2.0.0
9999
+ *
10000
+ * @param \FS_User $user
10001
+ * @param string $license_key
10002
+ * @param array $blog_2_install_map {
10003
+ * @key int Blog ID.
10004
+ * @value FS_Site Blog's associated install.
10005
+ * }
10006
+ *
10007
+ * @return mixed|true
10008
+ */
10009
+ private function activate_license_on_many_installs(
10010
+ FS_User $user,
10011
+ $license_key,
10012
+ array $blog_2_install_map
10013
+ ) {
10014
+ $params = array(
10015
+ array( 'license_key' => $this->apply_filters( 'license_key', $license_key ) )
10016
+ );
10017
+
10018
+ $install_2_blog_map = array();
10019
+ foreach ( $blog_2_install_map as $blog_id => $install ) {
10020
+ $params[] = array( 'id' => $install->id );
10021
+
10022
+ $install_2_blog_map[ $install->id ] = $blog_id;
10023
+ }
10024
+
10025
+ $result = $this->get_api_user_scope_by_user( $user )->call(
10026
+ "plugins/{$this->_plugin->id}/installs.json",
10027
+ 'PUT',
10028
+ $params
10029
+ );
10030
+
10031
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
10032
+ return $result;
10033
+ }
10034
+
10035
+ foreach ( $result->installs as $r_install ) {
10036
+ $install = new FS_Site( $r_install );
10037
+ $install->is_disconnected = false;
10038
+
10039
+ // Update install.
10040
+ $this->_store_site(
10041
+ true,
10042
+ $install_2_blog_map[ $r_install->id ],
10043
+ $install
10044
+ );
10045
+ }
10046
+
10047
+ return true;
10048
+ }
10049
+
10050
+ /**
10051
+ * Activate a given license on a collection of blogs/sites that are not yet opted-in.
10052
+ *
10053
+ * @author Vova Feldman (@svovaf)
10054
+ * @since 2.0.0
10055
+ *
10056
+ * @param \FS_User $user
10057
+ * @param string $license_key
10058
+ * @param int[] $site_ids
10059
+ *
10060
+ * @return true|mixed True if successful, otherwise, the API result.
10061
+ */
10062
+ private function activate_license_on_many_sites(
10063
+ FS_User $user,
10064
+ $license_key,
10065
+ array $site_ids
10066
+ ) {
10067
+ $sites = array();
10068
+ foreach ( $site_ids as $site_id ) {
10069
+ $sites[] = $this->get_site_info( array( 'blog_id' => $site_id ) );
10070
+ }
10071
+
10072
+ // Install the plugin.
10073
+ $result = $this->create_installs_with_user(
10074
+ $user,
10075
+ $license_key,
10076
+ false,
10077
+ $sites,
10078
+ false,
10079
+ true
10080
+ );
10081
+
10082
+ if ( ! $this->is_api_result_entity( $result ) &&
10083
+ ! $this->is_api_result_object( $result, 'installs' )
10084
+ ) {
10085
+ return $result;
10086
+ }
10087
+
10088
+ $installs = array();
10089
+ foreach ( $result->installs as $install ) {
10090
+ $installs[] = new FS_Site( $install );
10091
+ }
10092
+
10093
+ // Map site addresses to their blog IDs.
10094
+ $address_to_blog_map = $this->get_address_to_blog_map();
10095
+
10096
+ $first_blog_id = null;
10097
+
10098
+ foreach ( $installs as $install ) {
10099
+ $address = trailingslashit( fs_strip_url_protocol( $install->url ) );
10100
+ $blog_id = $address_to_blog_map[ $address ];
10101
+
10102
+ $this->_store_site( true, $blog_id, $install );
10103
+
10104
+ $this->reset_anonymous_mode( $blog_id );
10105
+
10106
+ if ( is_null( $first_blog_id ) ) {
10107
+ $first_blog_id = $blog_id;
10108
+ }
10109
+ }
10110
+
10111
+ if ( ! FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ) {
10112
+ $this->_storage->network_install_blog_id = $first_blog_id;
10113
+ }
10114
+
10115
+ return true;
10116
+ }
10117
+
10118
+ /**
10119
+ * Sync site's license with user licenses.
10120
+ *
10121
+ * @author Vova Feldman (@svovaf)
10122
+ * @since 1.0.6
10123
+ *
10124
+ * @param FS_Plugin_License|null $new_license
10125
+ *
10126
+ * @return FS_Plugin_License|null
10127
+ */
10128
+ function _update_site_license( $new_license ) {
10129
+ $this->_logger->entrance();
10130
+
10131
+ $this->_license = $new_license;
10132
+
10133
+ if ( ! is_object( $new_license ) ) {
10134
+ $this->_site->license_id = null;
10135
+ $this->_sync_site_subscription( null );
10136
+
10137
+ return $this->_license;
10138
+ }
10139
+
10140
+ $this->_site->license_id = $this->_license->id;
10141
+
10142
+ if ( ! is_array( $this->_licenses ) ) {
10143
+ $this->_licenses = array();
10144
+ }
10145
+
10146
+ $is_license_found = false;
10147
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
10148
+ if ( $new_license->id == $this->_licenses[ $i ]->id ) {
10149
+ $this->_licenses[ $i ] = $new_license;
10150
+
10151
+ $is_license_found = true;
10152
+ break;
10153
+ }
10154
+ }
10155
+
10156
+ // If new license just append.
10157
+ if ( ! $is_license_found ) {
10158
+ $this->_licenses[] = $new_license;
10159
+ }
10160
+
10161
+ $this->_sync_site_subscription( $new_license );
10162
+
10163
+ return $this->_license;
10164
+ }
10165
+
10166
+ /**
10167
+ * Sync site's subscription.
10168
+ *
10169
+ * @author Vova Feldman (@svovaf)
10170
+ * @since 1.0.9
10171
+ *
10172
+ * @param FS_Plugin_License|null $license
10173
+ *
10174
+ * @return bool|\FS_Subscription
10175
+ */
10176
+ private function _sync_site_subscription( $license ) {
10177
+ if ( ! is_object( $license ) ) {
10178
+ $this->delete_unused_subscriptions();
10179
+
10180
+ return false;
10181
+ }
10182
+
10183
+ // Load subscription details if not lifetime.
10184
+ $subscription = $license->is_lifetime() ?
10185
+ false :
10186
+ $this->_fetch_site_license_subscription();
10187
+
10188
+ if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
10189
+ $this->store_subscription( $subscription );
10190
+ } else {
10191
+ $this->delete_unused_subscriptions();
10192
+ }
10193
+
10194
+ return $subscription;
10195
+ }
10196
+
10197
+ /**
10198
+ * @author Vova Feldman (@svovaf)
10199
+ * @since 1.0.6
10200
+ *
10201
+ * @return bool|\FS_Plugin_License
10202
+ */
10203
+ function _get_license() {
10204
+ if ( ! fs_is_network_admin() || is_object( $this->_license ) ) {
10205
+ return $this->_license;
10206
+ }
10207
+
10208
+ return $this->_get_available_premium_license();
10209
+ }
10210
+
10211
+ /**
10212
+ * @param number $license_id
10213
+ *
10214
+ * @return null|\FS_Subscription
10215
+ */
10216
+ function _get_subscription( $license_id ) {
10217
+ if ( ! isset( $this->_storage->subscriptions ) ||
10218
+ empty( $this->_storage->subscriptions )
10219
+ ) {
10220
+ return null;
10221
+ }
10222
+
10223
+ foreach ( $this->_storage->subscriptions as $subscription ) {
10224
+ if ( $subscription->license_id == $license_id ) {
10225
+ return $subscription;
10226
+ }
10227
+ }
10228
+
10229
+ return null;
10230
+ }
10231
+
10232
+ /**
10233
+ * @author Leo Fajardo (@leorw)
10234
+ * @since 2.0.0
10235
+ *
10236
+ * @param FS_Subscription $subscription
10237
+ */
10238
+ function store_subscription( FS_Subscription $subscription ) {
10239
+ if ( ! isset( $this->_storage->subscriptions ) ) {
10240
+ $this->_storage->subscriptions = array();
10241
+ }
10242
+
10243
+ if ( empty( $this->_storage->subscriptions ) || ! is_multisite() ) {
10244
+ $this->_storage->subscriptions = array( $subscription );
10245
+
10246
+ return;
10247
+ }
10248
+
10249
+ $subscriptions = $this->_storage->subscriptions;
10250
+
10251
+ $updated_subscription = false;
10252
+ foreach ( $subscriptions as $key => $existing_subscription ) {
10253
+ if ( $existing_subscription->id == $subscription->id ) {
10254
+ $subscriptions[ $key ] = $subscription;
10255
+ $updated_subscription = true;
10256
+ break;
10257
+ }
10258
+ }
10259
+
10260
+ if ( ! $updated_subscription ) {
10261
+ $subscriptions[] = $subscription;
10262
+ }
10263
+
10264
+ $this->_storage->subscriptions = $subscriptions;
10265
+ }
10266
+
10267
+ /**
10268
+ * @author Leo Fajardo (@leorw)
10269
+ * @since 2.0.0
10270
+ */
10271
+ function delete_unused_subscriptions() {
10272
+ if ( ! isset( $this->_storage->subscriptions ) ||
10273
+ empty( $this->_storage->subscriptions ) ||
10274
+ // Clean up only if there are already at least 3 subscriptions.
10275
+ ( count( $this->_storage->subscriptions ) < 3 )
10276
+ ) {
10277
+ return;
10278
+ }
10279
+
10280
+ if ( ! is_multisite() ) {
10281
+ // If not multisite, there should only be 1 subscription, so just clear the array.
10282
+ $this->_storage->subscriptions = array();
10283
+
10284
+ return;
10285
+ }
10286
+
10287
+ $subscriptions_to_keep_by_license_id_map = array();
10288
+ $sites = self::get_sites();
10289
+ foreach ( $sites as $site ) {
10290
+ $blog_id = self::get_site_blog_id( $site );
10291
+ $install = $this->get_install_by_blog_id( $blog_id );
10292
+
10293
+ if ( ! is_object( $install ) ||
10294
+ ! FS_Plugin_License::is_valid_id( $install->license_id )
10295
+ ) {
10296
+ continue;
10297
+ }
10298
+
10299
+ $subscriptions_to_keep_by_license_id_map[ $install->license_id ] = true;
10300
+ }
10301
+
10302
+ if ( empty( $subscriptions_to_keep_by_license_id_map ) ) {
10303
+ $this->_storage->subscriptions = array();
10304
+
10305
+ return;
10306
+ }
10307
+
10308
+ foreach ( $this->_storage->subscriptions as $key => $subscription ) {
10309
+ if ( ! isset( $subscriptions_to_keep_by_license_id_map[ $subscription->license_id ] ) ) {
10310
+ unset( $this->_storage->subscriptions[ $key ] );
10311
+ }
10312
+ }
10313
+ }
10314
+
10315
+ /**
10316
+ * @author Vova Feldman (@svovaf)
10317
+ * @since 1.0.2
10318
+ *
10319
+ * @param string $plan Plan name
10320
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
10321
+ *
10322
+ * @return bool
10323
+ */
10324
+ function is_plan( $plan, $exact = false ) {
10325
+ $this->_logger->entrance();
10326
+
10327
+ if ( ! $this->is_registered() ) {
10328
+ return false;
10329
+ }
10330
+
10331
+ $plan = strtolower( $plan );
10332
+
10333
+ $current_plan_name = $this->get_plan_name();
10334
+
10335
+ if ( $current_plan_name === $plan ) {
10336
+ // Exact plan.
10337
+ return true;
10338
+ } else if ( $exact ) {
10339
+ // Required exact, but plans are different.
10340
+ return false;
10341
+ }
10342
+
10343
+ $current_plan_order = - 1;
10344
+ $required_plan_order = - 1;
10345
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
10346
+ if ( $plan === $this->_plans[ $i ]->name ) {
10347
+ $required_plan_order = $i;
10348
+ } else if ( $current_plan_name === $this->_plans[ $i ]->name ) {
10349
+ $current_plan_order = $i;
10350
+ }
10351
+ }
10352
+
10353
+ return ( $current_plan_order > $required_plan_order );
10354
+ }
10355
+
10356
+ /**
10357
+ * Check if module has only one plan.
10358
+ *
10359
+ * @author Vova Feldman (@svovaf)
10360
+ * @since 1.2.1.7
10361
+ *
10362
+ * @return bool
10363
+ */
10364
+ function is_single_plan() {
10365
+ $this->_logger->entrance();
10366
+
10367
+ if ( ! $this->is_registered() ||
10368
+ ! is_array( $this->_plans ) ||
10369
+ 0 === count( $this->_plans )
10370
+ ) {
10371
+ return true;
10372
+ }
10373
+
10374
+ return ( 1 === count( $this->_plans ) );
10375
+ }
10376
+
10377
+ /**
10378
+ * Check if plan based on trial. If not in trial mode, should return false.
10379
+ *
10380
+ * @since 1.0.9
10381
+ *
10382
+ * @param string $plan Plan name
10383
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
10384
+ *
10385
+ * @return bool
10386
+ */
10387
+ function is_trial_plan( $plan, $exact = false ) {
10388
+ $this->_logger->entrance();
10389
+
10390
+ if ( ! $this->is_registered() ) {
10391
+ return false;
10392
+ }
10393
+
10394
+ if ( ! $this->is_trial() ) {
10395
+ return false;
10396
+ }
10397
+
10398
+ $trial_plan = $this->get_trial_plan();
10399
+
10400
+ if ( $trial_plan->name === $plan ) {
10401
+ // Exact plan.
10402
+ return true;
10403
+ } else if ( $exact ) {
10404
+ // Required exact, but plans are different.
10405
+ return false;
10406
+ }
10407
+
10408
+ $current_plan_order = - 1;
10409
+ $required_plan_order = - 1;
10410
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
10411
+ if ( $plan === $this->_plans[ $i ]->name ) {
10412
+ $required_plan_order = $i;
10413
+ } else if ( $trial_plan->name === $this->_plans[ $i ]->name ) {
10414
+ $current_plan_order = $i;
10415
+ }
10416
+ }
10417
+
10418
+ return ( $current_plan_order > $required_plan_order );
10419
+ }
10420
+
10421
+ /**
10422
+ * Check if plugin has any paid plans.
10423
+ *
10424
+ * @author Vova Feldman (@svovaf)
10425
+ * @since 1.0.7
10426
+ *
10427
+ * @return bool
10428
+ */
10429
+ function has_paid_plan() {
10430
+ return $this->_has_paid_plans ||
10431
+ FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
10432
+ }
10433
+
10434
+ /**
10435
+ * Check if plugin has any plan with a trail.
10436
+ *
10437
+ * @author Vova Feldman (@svovaf)
10438
+ * @since 1.0.9
10439
+ *
10440
+ * @return bool
10441
+ */
10442
+ function has_trial_plan() {
10443
+ /**
10444
+ * @author Vova Feldman(@svovaf)
10445
+ * @since 1.2.1.5
10446
+ *
10447
+ * Allow setting a trial from the SDK without calling the API.
10448
+ * But, if the user did opt-in, continue using the real data from the API.
10449
+ */
10450
+ if ( $this->_trial_days >= 0 ) {
10451
+ return true;
10452
+ }
10453
+
10454
+ return $this->_storage->get( 'has_trial_plan', false );
10455
+ }
10456
+
10457
+ /**
10458
+ * Check if plugin has any free plan, or is it premium only.
10459
+ *
10460
+ * Note: If no plans configured, assume plugin is free.
10461
+ *
10462
+ * @author Vova Feldman (@svovaf)
10463
+ * @since 1.0.7
10464
+ *
10465
+ * @return bool
10466
+ */
10467
+ function has_free_plan() {
10468
+ return ! $this->is_only_premium();
10469
+ }
10470
+
10471
+ /**
10472
+ * Displays a license activation dialog box when the user clicks on the "Activate License"
10473
+ * or "Change License" link on the plugins
10474
+ * page.
10475
+ *
10476
+ * @author Leo Fajardo (@leorw)
10477
+ * @since 1.1.9
10478
+ */
10479
+ function _add_license_activation_dialog_box() {
10480
+ $vars = array(
10481
+ 'id' => $this->_module_id,
10482
+ );
10483
+
10484
+ fs_require_template( 'forms/license-activation.php', $vars );
10485
+ fs_require_template( 'forms/resend-key.php', $vars );
10486
+ }
10487
+
10488
+ /**
10489
+ * @author Leo Fajardo (@leorw)
10490
+ * @since 2.0.2
10491
+ */
10492
+ function _add_premium_version_upgrade_selection_dialog_box() {
10493
+ $modules_update = get_site_transient( $this->is_theme() ? 'update_themes' : 'update_plugins' );
10494
+ if ( ! isset( $modules_update->response[ $this->_plugin_basename ] ) ) {
10495
+ return;
10496
+ }
10497
+
10498
+ $vars = array(
10499
+ 'id' => $this->_module_id,
10500
+ 'new_version' => is_object( $modules_update->response[ $this->_plugin_basename ] ) ?
10501
+ $modules_update->response[ $this->_plugin_basename ]->new_version :
10502
+ $modules_update->response[ $this->_plugin_basename ]['new_version']
10503
+ );
10504
+
10505
+ fs_require_template( 'forms/premium-versions-upgrade-metadata.php', $vars );
10506
+ fs_require_once_template( 'forms/premium-versions-upgrade-handler.php', $vars );
10507
+ }
10508
+
10509
+ /**
10510
+ * Displays the opt-out dialog box when the user clicks on the "Opt Out" link on the "Plugins"
10511
+ * page.
10512
+ *
10513
+ * @author Leo Fajardo (@leorw)
10514
+ * @since 1.2.1.5
10515
+ */
10516
+ function _add_optout_dialog() {
10517
+ if ( $this->is_theme() ) {
10518
+ $vars = null;
10519
+ fs_require_once_template( '/js/jquery.content-change.php', $vars );
10520
+ }
10521
+
10522
+ $vars = array( 'id' => $this->_module_id );
10523
+ fs_require_template( 'forms/optout.php', $vars );
10524
+ }
10525
+
10526
+ /**
10527
+ * Prepare page to include all required UI and logic for the license activation dialog.
10528
+ *
10529
+ * @author Vova Feldman (@svovaf)
10530
+ * @since 1.2.0
10531
+ */
10532
+ function _add_license_activation() {
10533
+ if ( ! $this->is_user_admin() ) {
10534
+ // Only admins can activate a license.
10535
+ return;
10536
+ }
10537
+
10538
+ if ( ! $this->has_paid_plan() ) {
10539
+ // Module doesn't have any paid plans.
10540
+ return;
10541
+ }
10542
+
10543
+ if ( ! $this->is_premium() ) {
10544
+ // Only add license activation logic to the premium version.
10545
+ return;
10546
+ }
10547
+
10548
+ // Add license activation link and AJAX request handler.
10549
+ if ( self::is_plugins_page() ) {
10550
+ /**
10551
+ * @since 1.2.0 Add license action link only on plugins page.
10552
+ */
10553
+ $this->_add_license_action_link();
10554
+ }
10555
+
10556
+ // Add license activation AJAX callback.
10557
+ $this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) );
10558
+
10559
+ // Add resend license AJAX callback.
10560
+ $this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) );
10561
+ }
10562
+
10563
+ /**
10564
+ * @author Leo Fajardo (@leorw)
10565
+ * @since 2.0.2
10566
+ */
10567
+ function _add_premium_version_upgrade_selection() {
10568
+ if ( ! $this->is_user_admin() ) {
10569
+ return;
10570
+ }
10571
+
10572
+ if ( ! $this->is_premium() || $this->has_active_valid_license() ) {
10573
+ // This is relevant only to the free versions and premium versions without an active license.
10574
+ return;
10575
+ }
10576
+
10577
+ if ( self::is_updates_page() || ( $this->is_plugin() && self::is_plugins_page() ) ) {
10578
+ $this->_add_premium_version_upgrade_selection_action();
10579
+ }
10580
+ }
10581
+
10582
+ /**
10583
+ * @author Leo Fajardo (@leorw)
10584
+ *
10585
+ * @since 1.1.9
10586
+ * @since 2.0.0 When a super-admin that hasn't connected before is network activating a license and excluding some of the sites for the license activation, go over the unselected sites in the network and if a site is not connected, skipped, nor delegated, if it's a freemium product then just skip the connection for the site, if it's a premium only product, delegate the connection and license activation to the site admin (Vova Feldman @svovaf).
10587
+ */
10588
+ function _activate_license_ajax_action() {
10589
+ $this->_logger->entrance();
10590
+
10591
+ $this->check_ajax_referer( 'activate_license' );
10592
+
10593
+ $license_key = trim( fs_request_get( 'license_key' ) );
10594
+
10595
+ if ( empty( $license_key ) ) {
10596
+ exit;
10597
+ }
10598
+
10599
+ $plugin_id = fs_request_get( 'module_id', '', 'post' );
10600
+ $fs = ( $plugin_id == $this->_module_id ) ?
10601
+ $this :
10602
+ $this->get_addon_instance( $plugin_id );
10603
+
10604
+ $error = false;
10605
+ $next_page = false;
10606
+
10607
+ $sites = fs_is_network_admin() ?
10608
+ fs_request_get( 'sites', array(), 'post' ) :
10609
+ array();
10610
+
10611
+ $blog_id = fs_request_get( 'blog_id' );
10612
+ $has_valid_blog_id = is_numeric( $blog_id );
10613
+
10614
+ if ( $fs->is_registered() ) {
10615
+ if ( fs_is_network_admin() && ! $has_valid_blog_id ) {
10616
+ // If no specific blog ID was provided, activate the license for all sites in the network.
10617
+ $blog_2_install_map = array();
10618
+ $site_ids = array();
10619
+
10620
+ foreach ( $sites as $site ) {
10621
+ if ( ! isset( $site['blog_id'] ) || ! is_numeric( $site['blog_id'] ) ) {
10622
+ continue;
10623
+ }
10624
+
10625
+ $install = $this->get_install_by_blog_id( $site['blog_id'] );
10626
+
10627
+ if ( is_object( $install ) ) {
10628
+ $blog_2_install_map[ $site['blog_id'] ] = $install;
10629
+ } else {
10630
+ $site_ids[] = $site['blog_id'];
10631
+ }
10632
+ }
10633
+
10634
+ $user = $this->get_current_or_network_user();
10635
+
10636
+ if ( ! empty( $blog_2_install_map ) ) {
10637
+ $result = $this->activate_license_on_many_installs( $user, $license_key, $blog_2_install_map );
10638
+
10639
+ if ( true !== $result ) {
10640
+ $error = FS_Api::is_api_error_object( $result ) ?
10641
+ $result->error->message :
10642
+ var_export( $result, true );
10643
+ }
10644
+ }
10645
+
10646
+ if ( empty( $error ) && ! empty( $site_ids ) ) {
10647
+ $result = $this->activate_license_on_many_sites( $user, $license_key, $site_ids );
10648
+
10649
+ if ( true !== $result ) {
10650
+ $error = FS_Api::is_api_error_object( $result ) ?
10651
+ $result->error->message :
10652
+ var_export( $result, true );
10653
+ }
10654
+ }
10655
+ } else {
10656
+ if ( $has_valid_blog_id ) {
10657
+ /**
10658
+ * If a specific blog ID was provided, activate the license only for the install that is
10659
+ * associated with the given blog ID.
10660
+ *
10661
+ * @author Leo Fajardo (@leorw)
10662
+ */
10663
+ $this->switch_to_blog( $blog_id );
10664
+ }
10665
+
10666
+ $api = $fs->get_api_site_scope();
10667
+
10668
+ $params = array(
10669
+ 'license_key' => $fs->apply_filters( 'license_key', $license_key )
10670
+ );
10671
+
10672
+ $install = $api->call( '/', 'put', $params );
10673
+
10674
+ if ( FS_Api::is_api_error( $install ) ) {
10675
+ $error = FS_Api::is_api_error_object( $install ) ?
10676
+ $install->error->message :
10677
+ var_export( $install->error, true );
10678
+ } else {
10679
+ $fs->reconnect_locally( $has_valid_blog_id );
10680
+ }
10681
+ }
10682
+
10683
+ if ( empty( $error ) ) {
10684
+ $this->network_upgrade_mode_completed();
10685
+
10686
+ $fs->_sync_license( true, $has_valid_blog_id );
10687
+
10688
+ $next_page = $fs->is_addon() ?
10689
+ $fs->get_parent_instance()->get_account_url() :
10690
+ $fs->get_account_url();
10691
+ }
10692
+ } else {
10693
+ $next_page = $fs->opt_in(
10694
+ false,
10695
+ false,
10696
+ false,
10697
+ $license_key,
10698
+ false,
10699
+ false,
10700
+ false,
10701
+ fs_request_get_bool( 'is_marketing_allowed', null ),
10702
+ $sites
10703
+ );
10704
+
10705
+ if ( isset( $next_page->error ) ) {
10706
+ $error = $next_page->error;
10707
+ } else {
10708
+ if ( fs_is_network_admin() ) {
10709
+ /**
10710
+ * Get the list of sites that were just opted-in (and license activated).
10711
+ * This is an optimization for the next part below saving some DB queries.
10712
+ */
10713
+ $connected_sites = array();
10714
+ foreach ( $sites as $site ) {
10715
+ if ( isset( $site['blog_id'] ) && is_numeric( $site['blog_id'] ) ) {
10716
+ $connected_sites[ $site['blog_id'] ] = true;
10717
+ }
10718
+ }
10719
+
10720
+ $all_sites = self::get_sites();
10721
+ $pending_sites = array();
10722
+
10723
+ /**
10724
+ * Check if there are any sites that are not connected, skipped, nor delegated. For every site that falls into that category, if the product is freemium, skip the connection. If the product is premium only, delegate the connection to the site administrator.
10725
+ *
10726
+ * @author Vova Feldman (@svovaf)
10727
+ */
10728
+ foreach ( $all_sites as $site ) {
10729
+ $blog_id = self::get_site_blog_id( $site );
10730
+
10731
+ if ( isset( $connected_sites[ $blog_id ] ) ) {
10732
+ // Site was just connected.
10733
+ continue;
10734
+ }
10735
+
10736
+ if ( $this->is_installed_on_site( $blog_id ) ) {
10737
+ // Site was already connected before.
10738
+ continue;
10739
+ }
10740
+
10741
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
10742
+ // Site's connection was delegated.
10743
+ continue;
10744
+ }
10745
+
10746
+ if ( $this->is_anonymous_site( $blog_id ) ) {
10747
+ // Site connection was already skipped.
10748
+ continue;
10749
+ }
10750
+
10751
+ $pending_sites[] = self::get_site_info( $site );
10752
+ }
10753
+
10754
+ if ( ! empty( $pending_sites ) ) {
10755
+ if ( $this->is_freemium() ) {
10756
+ $this->skip_connection( $pending_sites );
10757
+ } else {
10758
+ $this->delegate_connection( $pending_sites );
10759
+ }
10760
+ }
10761
+ }
10762
+ }
10763
+ }
10764
+
10765
+ $result = array(
10766
+ 'success' => ( false === $error )
10767
+ );
10768
+
10769
+ if ( false !== $error ) {
10770
+ $result['error'] = $error;
10771
+ } else {
10772
+ $result['next_page'] = $next_page;
10773
+ }
10774
+
10775
+ echo json_encode( $result );
10776
+
10777
+ exit;
10778
+ }
10779
+
10780
+ /**
10781
+ * @author Leo Fajardo (@leorw)
10782
+ * @since 1.2.3.1
10783
+ */
10784
+ function _network_activate_ajax_action() {
10785
+ $this->_logger->entrance();
10786
+
10787
+ $this->check_ajax_referer( 'network_activate' );
10788
+
10789
+ $plugin_id = fs_request_get( 'module_id', '', 'post' );
10790
+ $fs = ( $plugin_id == $this->_module_id ) ?
10791
+ $this :
10792
+ $this->get_addon_instance( $plugin_id );
10793
+
10794
+ $error = false;
10795
+
10796
+ $sites = fs_request_get( 'sites', array(), 'post' );
10797
+ if ( is_array( $sites ) && ! empty( $sites ) ) {
10798
+ $sites_by_action = array(
10799
+ 'allow' => array(),
10800
+ 'delegate' => array(),
10801
+ 'skip' => array()
10802
+ );
10803
+
10804
+ foreach ( $sites as $site ) {
10805
+ $sites_by_action[ $site['action'] ][] = $site;
10806
+ }
10807
+
10808
+ $total_sites = count( $sites );
10809
+ $total_sites_to_delegate = count( $sites_by_action['delegate'] );
10810
+
10811
+ $next_page = '';
10812
+ if ( $total_sites === $total_sites_to_delegate &&
10813
+ ! $this->is_network_upgrade_mode()
10814
+ ) {
10815
+ $this->delegate_connection();
10816
+ } else {
10817
+ if ( ! empty( $sites_by_action['delegate'] ) ) {
10818
+ $this->delegate_connection( $sites_by_action['delegate'] );
10819
+ }
10820
+
10821
+ if ( ! empty( $sites_by_action['skip'] ) ) {
10822
+ $this->skip_connection( $sites_by_action['skip'] );
10823
+ }
10824
+
10825
+ if ( ! empty( $sites_by_action['allow'] ) ) {
10826
+ if ( ! $fs->is_registered() || ! $this->_is_network_active ) {
10827
+ $next_page = $fs->opt_in(
10828
+ false,
10829
+ false,
10830
+ false,
10831
+ false,
10832
+ false,
10833
+ false,
10834
+ false,
10835
+ fs_request_get_bool( 'is_marketing_allowed', null ),
10836
+ $sites_by_action['allow']
10837
+ );
10838
+ } else {
10839
+ $next_page = $fs->install_with_user(
10840
+ $this->get_network_user(),
10841
+ false,
10842
+ false,
10843
+ false,
10844
+ true,
10845
+ $sites_by_action['allow']
10846
+ );
10847
+ }
10848
+
10849
+ if ( is_object( $next_page ) && isset( $next_page->error ) ) {
10850
+ $error = $next_page->error;
10851
+ }
10852
+ }
10853
+ }
10854
+
10855
+ if ( empty( $next_page ) ) {
10856
+ $next_page = $this->get_after_activation_url( 'after_network_activation_url' );
10857
+ }
10858
+ } else {
10859
+ $error = $this->get_text_inline( 'Invalid site details collection.', 'invalid_site_details_collection' );
10860
+ }
10861
+
10862
+ $result = array(
10863
+ 'success' => ( false === $error )
10864
+ );
10865
+
10866
+ if ( false !== $error ) {
10867
+ $result['error'] = $error;
10868
+ } else {
10869
+ $result['next_page'] = $next_page;
10870
+ }
10871
+
10872
+ echo json_encode( $result );
10873
+
10874
+ exit;
10875
+ }
10876
+
10877
+ /**
10878
+ * Billing update AJAX callback.
10879
+ *
10880
+ * @author Vova Feldman (@svovaf)
10881
+ * @since 1.2.1.5
10882
+ */
10883
+ function _update_billing_ajax_action() {
10884
+ $this->_logger->entrance();
10885
+
10886
+ $this->check_ajax_referer( 'update_billing' );
10887
+
10888
+ if ( ! $this->is_user_admin() ) {
10889
+ // Only for admins.
10890
+ self::shoot_ajax_failure();
10891
+ }
10892
+
10893
+ $billing = fs_request_get( 'billing' );
10894
+
10895
+ $api = $this->get_api_user_scope();
10896
+ $result = $api->call( '/billing.json', 'put', array_merge( $billing, array(
10897
+ 'plugin_id' => $this->get_parent_id(),
10898
+ ) ) );
10899
+
10900
+ if ( ! $this->is_api_result_entity( $result ) ) {
10901
+ self::shoot_ajax_failure();
10902
+ }
10903
+
10904
+ // Purge cached billing.
10905
+ $this->get_api_user_scope()->purge_cache( 'billing.json' );
10906
+
10907
+ self::shoot_ajax_success();
10908
+ }
10909
+
10910
+ /**
10911
+ * Trial start for anonymous users (AJAX callback).
10912
+ *
10913
+ * @author Vova Feldman (@svovaf)
10914
+ * @since 1.2.1.5
10915
+ */
10916
+ function _start_trial_ajax_action() {
10917
+ $this->_logger->entrance();
10918
+
10919
+ $this->check_ajax_referer( 'start_trial' );
10920
+
10921
+ if ( ! $this->is_user_admin() ) {
10922
+ // Only for admins.
10923
+ self::shoot_ajax_failure();
10924
+ }
10925
+
10926
+ $trial_data = fs_request_get( 'trial' );
10927
+
10928
+ $next_page = $this->opt_in(
10929
+ false,
10930
+ false,
10931
+ false,
10932
+ false,
10933
+ false,
10934
+ $trial_data['plan_id']
10935
+ );
10936
+
10937
+ if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
10938
+ self::shoot_ajax_failure(
10939
+ isset( $next_page->error ) ?
10940
+ $next_page->error->message :
10941
+ var_export( $next_page, true )
10942
+ );
10943
+ }
10944
+
10945
+ $this->shoot_ajax_success( array(
10946
+ 'next_page' => $next_page,
10947
+ ) );
10948
+ }
10949
+
10950
+ /**
10951
+ * @author Leo Fajardo (@leorw)
10952
+ * @since 1.2.0
10953
+ */
10954
+ function _resend_license_key_ajax_action() {
10955
+ $this->_logger->entrance();
10956
+
10957
+ $this->check_ajax_referer( 'resend_license_key' );
10958
+
10959
+ $email_address = sanitize_email( trim( fs_request_get( 'email', '', 'post' ) ) );
10960
+
10961
+ if ( empty( $email_address ) ) {
10962
+ exit;
10963
+ }
10964
+
10965
+ $error = false;
10966
+
10967
+ $api = $this->get_api_plugin_scope();
10968
+ $result = $api->call( '/licenses/resend.json', 'post',
10969
+ array(
10970
+ 'email' => $email_address,
10971
+ 'url' => home_url(),
10972
+ )
10973
+ );
10974
+
10975
+ if ( is_object( $result ) && isset( $result->error ) ) {
10976
+ $error = $result->error;
10977
+
10978
+ if ( in_array( $error->code, array( 'invalid_email', 'no_user' ) ) ) {
10979
+ $error = $this->get_text_inline( "We couldn't find your email address in the system, are you sure it's the right address?", 'email-not-found' );
10980
+ } else if ( 'no_license' === $error->code ) {
10981
+ $error = $this->get_text_inline( "We can't see any active licenses associated with that email address, are you sure it's the right address?", 'no-active-licenses' );
10982
+ } else {
10983
+ $error = $error->message;
10984
+ }
10985
+ }
10986
+
10987
+ $licenses = array(
10988
+ 'success' => ( false === $error )
10989
+ );
10990
+
10991
+ if ( false !== $error ) {
10992
+ $licenses['error'] = sprintf( '%s... %s', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ), strtolower( $error ) );
10993
+ }
10994
+
10995
+ echo json_encode( $licenses );
10996
+
10997
+ exit;
10998
+ }
10999
+
11000
+ /**
11001
+ * @author Vova Feldman (@svovaf)
11002
+ * @since 1.2.1.8
11003
+ *
11004
+ * @var string
11005
+ */
11006
+ private static $_pagenow;
11007
+
11008
+ /**
11009
+ * Get current page or the referer if executing a WP AJAX request.
11010
+ *
11011
+ * @author Vova Feldman (@svovaf)
11012
+ * @since 1.2.1.8
11013
+ *
11014
+ * @return string
11015
+ */
11016
+ static function get_current_page() {
11017
+ if ( ! isset( self::$_pagenow ) ) {
11018
+ global $pagenow;
11019
+
11020
+ self::$_pagenow = $pagenow;
11021
+
11022
+ if ( self::is_ajax() &&
11023
+ 'admin-ajax.php' === $pagenow
11024
+ ) {
11025
+ $referer = fs_get_raw_referer();
11026
+
11027
+ if ( is_string( $referer ) ) {
11028
+ $parts = explode( '?', $referer );
11029
+
11030
+ self::$_pagenow = basename( $parts[0] );
11031
+ }
11032
+ }
11033
+ }
11034
+
11035
+ return self::$_pagenow;
11036
+ }
11037
+
11038
+ /**
11039
+ * Helper method to check if user in the plugins page.
11040
+ *
11041
+ * @author Vova Feldman (@svovaf)
11042
+ * @since 1.2.1.5
11043
+ *
11044
+ * @return bool
11045
+ */
11046
+ static function is_plugins_page() {
11047
+ return ( 'plugins.php' === self::get_current_page() );
11048
+ }
11049
+
11050
+ /**
11051
+ * @author Leo Fajardo (@leorw)
11052
+ * @since 2.0.2
11053
+ *
11054
+ * @return bool
11055
+ */
11056
+ static function is_updates_page() {
11057
+ return ( 'update-core.php' === self::get_current_page() );
11058
+ }
11059
+
11060
+ /**
11061
+ * Helper method to check if user in the themes page.
11062
+ *
11063
+ * @author Vova Feldman (@svovaf)
11064
+ * @since 1.2.2.6
11065
+ *
11066
+ * @return bool
11067
+ */
11068
+ static function is_themes_page() {
11069
+ return ( 'themes.php' === self::get_current_page() );
11070
+ }
11071
+
11072
+ #----------------------------------------------------------------------------------
11073
+ #region Affiliation
11074
+ #----------------------------------------------------------------------------------
11075
+
11076
+ /**
11077
+ * @author Leo Fajardo (@leorw)
11078
+ * @since 1.2.3
11079
+ *
11080
+ * @return bool
11081
+ */
11082
+ function has_affiliate_program() {
11083
+ if ( ! is_object( $this->_plugin ) ) {
11084
+ return false;
11085
+ }
11086
+
11087
+ return $this->_plugin->has_affiliate_program();
11088
+ }
11089
+
11090
+ /**
11091
+ * @author Leo Fajardo (@leorw)
11092
+ * @since 1.2.4
11093
+ */
11094
+ private function fetch_affiliate_terms() {
11095
+ if ( ! is_object( $this->plugin_affiliate_terms ) ) {
11096
+ $plugins_api = $this->get_api_plugin_scope();
11097
+ $affiliate_terms = $plugins_api->get( '/aff.json?type=affiliation', false );
11098
+
11099
+ if ( ! $this->is_api_result_entity( $affiliate_terms ) ) {
11100
+ return;
11101
+ }
11102
+
11103
+ $this->plugin_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
11104
+ }
11105
+ }
11106
+
11107
+ /**
11108
+ * @author Leo Fajardo (@leorw)
11109
+ * @since 1.2.4
11110
+ */
11111
+ private function fetch_affiliate_and_custom_terms() {
11112
+ if ( ! empty( $this->_storage->affiliate_application_data ) ) {
11113
+ $application_data = $this->_storage->affiliate_application_data;
11114
+ $flush = ( ! isset( $application_data['status'] ) || 'pending' === $application_data['status'] );
11115
+
11116
+ $users_api = $this->get_api_user_scope();
11117
+ $result = $users_api->get( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json", $flush );
11118
+ if ( $this->is_api_result_object( $result, 'affiliates' ) ) {
11119
+ if ( ! empty( $result->affiliates ) ) {
11120
+ $affiliate = new FS_Affiliate( $result->affiliates[0] );
11121
+
11122
+ if ( ! isset( $application_data['status'] ) || $application_data['status'] !== $affiliate->status ) {
11123
+ $application_data['status'] = $affiliate->status;
11124
+ $this->_storage->affiliate_application_data = $application_data;
11125
+ }
11126
+
11127
+ if ( $affiliate->is_using_custom_terms ) {
11128
+ $affiliate_terms = $users_api->get( "/plugins/{$this->_plugin->id}/affiliates/{$affiliate->id}/aff/{$affiliate->custom_affiliate_terms_id}.json", $flush );
11129
+ if ( $this->is_api_result_entity( $affiliate_terms ) ) {
11130
+ $this->custom_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
11131
+ }
11132
+ }
11133
+
11134
+ $this->affiliate = $affiliate;
11135
+ }
11136
+ }
11137
+ }
11138
+ }
11139
+
11140
+ /**
11141
+ * @author Leo Fajardo (@leorw)
11142
+ * @since 1.2.3
11143
+ */
11144
+ private function fetch_affiliate_and_terms() {
11145
+ $this->_logger->entrance();
11146
+
11147
+ $this->fetch_affiliate_terms();
11148
+ $this->fetch_affiliate_and_custom_terms();
11149
+ }
11150
+
11151
+ /**
11152
+ * @author Leo Fajardo (@leorw)
11153
+ * @since 1.2.3
11154
+ *
11155
+ * @return FS_Affiliate
11156
+ */
11157
+ function get_affiliate() {
11158
+ return $this->affiliate;
11159
+ }
11160
+
11161
+
11162
+ /**
11163
+ * @author Leo Fajardo (@leorw)
11164
+ * @since 1.2.3
11165
+ *
11166
+ * @return FS_AffiliateTerms
11167
+ */
11168
+ function get_affiliate_terms() {
11169
+ return is_object( $this->custom_affiliate_terms ) ?
11170
+ $this->custom_affiliate_terms :
11171
+ $this->plugin_affiliate_terms;
11172
+ }
11173
+
11174
+ /**
11175
+ * @author Leo Fajardo (@leorw)
11176
+ * @since 1.2.3
11177
+ */
11178
+ function _submit_affiliate_application() {
11179
+ $this->_logger->entrance();
11180
+
11181
+ $this->check_ajax_referer( 'submit_affiliate_application' );
11182
+
11183
+ if ( ! $this->is_user_admin() ) {
11184
+ // Only for admins.
11185
+ self::shoot_ajax_failure();
11186
+ }
11187
+
11188
+ $affiliate = fs_request_get( 'affiliate' );
11189
+
11190
+ if ( empty( $affiliate['promotion_methods'] ) ) {
11191
+ unset( $affiliate['promotion_methods'] );
11192
+ }
11193
+
11194
+ if ( ! empty( $affiliate['additional_domains'] ) ) {
11195
+ $affiliate['additional_domains'] = array_unique( $affiliate['additional_domains'] );
11196
+ }
11197
+
11198
+ if ( ! $this->is_registered() ) {
11199
+ // Opt in but don't track usage.
11200
+ $next_page = $this->opt_in(
11201
+ false,
11202
+ false,
11203
+ false,
11204
+ false,
11205
+ false,
11206
+ false,
11207
+ true
11208
+ );
11209
+
11210
+ if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
11211
+ self::shoot_ajax_failure(
11212
+ isset( $next_page->error ) ?
11213
+ $next_page->error->message :
11214
+ var_export( $next_page, true )
11215
+ );
11216
+ } else if ( $this->is_pending_activation() ) {
11217
+ self::shoot_ajax_failure( $this->get_text_inline( 'Account is pending activation.', 'account-is-pending-activation' ) );
11218
+ }
11219
+ }
11220
+
11221
+ $this->fetch_affiliate_terms();
11222
+
11223
+ $api = $this->get_api_user_scope();
11224
+ $result = $api->call(
11225
+ ( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json" ),
11226
+ 'post',
11227
+ $affiliate
11228
+ );
11229
+
11230
+ if ( $this->is_api_error( $result ) ) {
11231
+ self::shoot_ajax_failure(
11232
+ isset( $result->error ) ?
11233
+ $result->error->message :
11234
+ var_export( $result, true )
11235
+ );
11236
+ } else {
11237
+ if ( $this->_admin_notices->has_sticky( 'affiliate_program' ) ) {
11238
+ $this->_admin_notices->remove_sticky( 'affiliate_program' );
11239
+ }
11240
+
11241
+ $affiliate_application_data = array(
11242
+ 'status' => 'pending',
11243
+ 'stats_description' => $affiliate['stats_description'],
11244
+ 'promotion_method_description' => $affiliate['promotion_method_description'],
11245
+ );
11246
+
11247
+ if ( ! empty( $affiliate['promotion_methods'] ) ) {
11248
+ $affiliate_application_data['promotion_methods'] = $affiliate['promotion_methods'];
11249
+ }
11250
+
11251
+ if ( ! empty( $affiliate['domain'] ) ) {
11252
+ $affiliate_application_data['domain'] = $affiliate['domain'];
11253
+ }
11254
+
11255
+ if ( ! empty( $affiliate['additional_domains'] ) ) {
11256
+ $affiliate_application_data['additional_domains'] = $affiliate['additional_domains'];
11257
+ }
11258
+
11259
+ $this->_storage->affiliate_application_data = $affiliate_application_data;
11260
+ }
11261
+
11262
+ // Purge cached affiliate.
11263
+ $api->purge_cache( 'affiliate.json' );
11264
+
11265
+ self::shoot_ajax_success( $result );
11266
+ }
11267
+
11268
+ /**
11269
+ * @author Leo Fajardo (@leorw)
11270
+ * @since 1.2.3
11271
+ *
11272
+ * @return array|null
11273
+ */
11274
+ function get_affiliate_application_data() {
11275
+ if ( empty( $this->_storage->affiliate_application_data ) ) {
11276
+ return null;
11277
+ }
11278
+
11279
+ return $this->_storage->affiliate_application_data;
11280
+ }
11281
+
11282
+ #endregion Affiliation ------------------------------------------------------------
11283
+
11284
+ #----------------------------------------------------------------------------------
11285
+ #region URL Generators
11286
+ #----------------------------------------------------------------------------------
11287
+
11288
+ /**
11289
+ * Alias to pricing_url().
11290
+ *
11291
+ * @author Vova Feldman (@svovaf)
11292
+ * @since 1.0.2
11293
+ *
11294
+ * @uses pricing_url()
11295
+ *
11296
+ * @param string $period Billing cycle
11297
+ * @param bool $is_trial
11298
+ *
11299
+ * @return string
11300
+ */
11301
+ function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
11302
+ return $this->pricing_url( $period, $is_trial );
11303
+ }
11304
+
11305
+ /**
11306
+ * @author Vova Feldman (@svovaf)
11307
+ * @since 1.0.9
11308
+ *
11309
+ * @uses get_upgrade_url()
11310
+ *
11311
+ * @return string
11312
+ */
11313
+ function get_trial_url() {
11314
+ return $this->get_upgrade_url( WP_FS__PERIOD_ANNUALLY, true );
11315
+ }
11316
+
11317
+ /**
11318
+ * Plugin's pricing URL.
11319
+ *
11320
+ * @author Vova Feldman (@svovaf)
11321
+ * @since 1.0.4
11322
+ *
11323
+ * @param string $billing_cycle Billing cycle
11324
+ *
11325
+ * @param bool $is_trial
11326
+ *
11327
+ * @return string
11328
+ */
11329
+ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
11330
+ $this->_logger->entrance();
11331
+
11332
+ $params = array(
11333
+ 'billing_cycle' => $billing_cycle
11334
+ );
11335
+
11336
+ if ( $is_trial ) {
11337
+ $params['trial'] = 'true';
11338
+ }
11339
+
11340
+ if ( $this->is_addon() ) {
11341
+ return $this->_parent->addon_url( $this->_slug );
11342
+ }
11343
+
11344
+ return $this->_get_admin_page_url( 'pricing', $params );
11345
+ }
11346
+
11347
+ /**
11348
+ * Checkout page URL.
11349
+ *
11350
+ * @author Vova Feldman (@svovaf)
11351
+ * @since 1.0.6
11352
+ *
11353
+ * @param string $billing_cycle Billing cycle
11354
+ * @param bool $is_trial
11355
+ * @param array $extra (optional) Extra parameters, override other query params.
11356
+ *
11357
+ * @return string
11358
+ */
11359
+ function checkout_url(
11360
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
11361
+ $is_trial = false,
11362
+ $extra = array()
11363
+ ) {
11364
+ $this->_logger->entrance();
11365
+
11366
+ $params = array(
11367
+ 'checkout' => 'true',
11368
+ 'billing_cycle' => $billing_cycle,
11369
+ );
11370
+
11371
+ if ( $is_trial ) {
11372
+ $params['trial'] = 'true';
11373
+ }
11374
+
11375
+ /**
11376
+ * Params in extra override other params.
11377
+ */
11378
+ $params = array_merge( $params, $extra );
11379
+
11380
+ return $this->_get_admin_page_url( 'pricing', $params );
11381
+ }
11382
+
11383
+ /**
11384
+ * Add-on checkout URL.
11385
+ *
11386
+ * @author Vova Feldman (@svovaf)
11387
+ * @since 1.1.7
11388
+ *
11389
+ * @param number $addon_id
11390
+ * @param number $pricing_id
11391
+ * @param string $billing_cycle
11392
+ * @param bool $is_trial
11393
+ *
11394
+ * @return string
11395
+ */
11396
+ function addon_checkout_url(
11397
+ $addon_id,
11398
+ $pricing_id,
11399
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
11400
+ $is_trial = false
11401
+ ) {
11402
+ return $this->checkout_url( $billing_cycle, $is_trial, array(
11403
+ 'plugin_id' => $addon_id,
11404
+ 'pricing_id' => $pricing_id,
11405
+ ) );
11406
+ }
11407
+
11408
+ #endregion
11409
+
11410
+ #endregion ------------------------------------------------------------------
11411
+
11412
+ /**
11413
+ * Check if plugin has any add-ons.
11414
+ *
11415
+ * @author Vova Feldman (@svovaf)
11416
+ * @since 1.0.5
11417
+ *
11418
+ * @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
11419
+ *
11420
+ * @return bool
11421
+ */
11422
+ function has_addons() {
11423
+ $this->_logger->entrance();
11424
+
11425
+ return $this->_has_addons;
11426
+ }
11427
+
11428
+ /**
11429
+ * Check if plugin can work in anonymous mode.
11430
+ *
11431
+ * @author Vova Feldman (@svovaf)
11432
+ * @since 1.0.9
11433
+ *
11434
+ * @return bool
11435
+ *
11436
+ * @deprecated Please use is_enable_anonymous() instead.
11437
+ */
11438
+ function enable_anonymous() {
11439
+ return $this->_enable_anonymous;
11440
+ }
11441
+
11442
+ /**
11443
+ * Check if plugin can work in anonymous mode.
11444
+ *
11445
+ * @author Vova Feldman (@svovaf)
11446
+ * @since 1.1.9
11447
+ *
11448
+ * @return bool
11449
+ */
11450
+ function is_enable_anonymous() {
11451
+ return $this->_enable_anonymous;
11452
+ }
11453
+
11454
+ /**
11455
+ * Check if plugin is premium only (no free plans).
11456
+ *
11457
+ * @author Vova Feldman (@svovaf)
11458
+ * @since 1.1.9
11459
+ *
11460
+ * @return bool
11461
+ */
11462
+ function is_only_premium() {
11463
+ return $this->_is_premium_only;
11464
+ }
11465
+
11466
+ /**
11467
+ * Checks if the plugin's type is "plugin". The other type is "theme".
11468
+ *
11469
+ * @author Leo Fajardo (@leorw)
11470
+ * @since 1.2.2
11471
+ *
11472
+ * @return bool
11473
+ */
11474
+ function is_plugin() {
11475
+ return ( WP_FS__MODULE_TYPE_PLUGIN === $this->_module_type );
11476
+ }
11477
+
11478
+ /**
11479
+ * @author Leo Fajardo (@leorw)
11480
+ * @since 1.2.2
11481
+ *
11482
+ * @return string
11483
+ */
11484
+ function get_module_type() {
11485
+ if ( ! isset( $this->_module_type ) ) {
11486
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
11487
+ $this->_module_type = $id_slug_type_path_map[ $this->_module_id ]['type'];
11488
+ }
11489
+
11490
+ return $this->_module_type;
11491
+ }
11492
+
11493
+ /**
11494
+ * @author Leo Fajardo (@leorw)
11495
+ * @since 1.2.2
11496
+ *
11497
+ * @return string
11498
+ */
11499
+ function get_plugin_main_file_path() {
11500
+ return $this->_plugin_main_file_path;
11501
+ }
11502
+
11503
+ /**
11504
+ * Check if module has a premium code version.
11505
+ *
11506
+ * Serviceware module might be freemium without any
11507
+ * premium code version, where the paid features
11508
+ * are all part of the service.
11509
+ *
11510
+ * @author Vova Feldman (@svovaf)
11511
+ * @since 1.2.1.6
11512
+ *
11513
+ * @return bool
11514
+ */
11515
+ function has_premium_version() {
11516
+ return $this->_has_premium_version;
11517
+ }
11518
+
11519
+ /**
11520
+ * Check if feature supported with current site's plan.
11521
+ *
11522
+ * @author Vova Feldman (@svovaf)
11523
+ * @since 1.0.1
11524
+ *
11525
+ * @todo IMPLEMENT
11526
+ *
11527
+ * @param number $feature_id
11528
+ *
11529
+ * @throws Exception
11530
+ */
11531
+ function is_feature_supported( $feature_id ) {
11532
+ throw new Exception( 'not implemented' );
11533
+ }
11534
+
11535
+ /**
11536
+ * @author Vova Feldman (@svovaf)
11537
+ * @since 1.0.1
11538
+ *
11539
+ * @return bool Is running in SSL/HTTPS
11540
+ */
11541
+ function is_ssl() {
11542
+ return WP_FS__IS_HTTPS;
11543
+ }
11544
+
11545
+ /**
11546
+ * @author Vova Feldman (@svovaf)
11547
+ * @since 1.0.9
11548
+ *
11549
+ * @return bool Is running in AJAX call.
11550
+ *
11551
+ * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
11552
+ */
11553
+ static function is_ajax() {
11554
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
11555
+ }
11556
+
11557
+ /**
11558
+ * Check if it's an AJAX call targeted for the current module.
11559
+ *
11560
+ * @author Vova Feldman (@svovaf)
11561
+ * @since 1.2.0
11562
+ *
11563
+ * @param array|string $actions Collection of AJAX actions.
11564
+ *
11565
+ * @return bool
11566
+ */
11567
+ function is_ajax_action( $actions ) {
11568
+ // Verify it's an ajax call.
11569
+ if ( ! self::is_ajax() ) {
11570
+ return false;
11571
+ }
11572
+
11573
+ // Verify the call is relevant for the plugin.
11574
+ if ( $this->_module_id != fs_request_get( 'module_id' ) ) {
11575
+ return false;
11576
+ }
11577
+
11578
+ // Verify it's one of the specified actions.
11579
+ if ( is_string( $actions ) ) {
11580
+ $actions = explode( ',', $actions );
11581
+ }
11582
+
11583
+ if ( is_array( $actions ) && 0 < count( $actions ) ) {
11584
+ $ajax_action = fs_request_get( 'action' );
11585
+
11586
+ foreach ( $actions as $action ) {
11587
+ if ( $ajax_action === $this->get_action_tag( $action ) ) {
11588
+ return true;
11589
+ }
11590
+ }
11591
+ }
11592
+
11593
+ return false;
11594
+ }
11595
+
11596
+ /**
11597
+ * Check if it's an AJAX call targeted for current request.
11598
+ *
11599
+ * @author Vova Feldman (@svovaf)
11600
+ * @since 1.2.0
11601
+ *
11602
+ * @param array|string $actions Collection of AJAX actions.
11603
+ * @param number|null $module_id
11604
+ *
11605
+ * @return bool
11606
+ */
11607
+ static function is_ajax_action_static( $actions, $module_id = null ) {
11608
+ // Verify it's an ajax call.
11609
+ if ( ! self::is_ajax() ) {
11610
+ return false;
11611
+ }
11612
+
11613
+
11614
+ if ( ! empty( $module_id ) ) {
11615
+ // Verify the call is relevant for the plugin.
11616
+ if ( $module_id != fs_request_get( 'module_id' ) ) {
11617
+ return false;
11618
+ }
11619
+ }
11620
+
11621
+ // Verify it's one of the specified actions.
11622
+ if ( is_string( $actions ) ) {
11623
+ $actions = explode( ',', $actions );
11624
+ }
11625
+
11626
+ if ( is_array( $actions ) && 0 < count( $actions ) ) {
11627
+ $ajax_action = fs_request_get( 'action' );
11628
+
11629
+ foreach ( $actions as $action ) {
11630
+ if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) {
11631
+ return true;
11632
+ }
11633
+ }
11634
+ }
11635
+
11636
+ return false;
11637
+ }
11638
+
11639
+ /**
11640
+ * @author Vova Feldman (@svovaf)
11641
+ * @since 1.1.7
11642
+ *
11643
+ * @return bool
11644
+ */
11645
+ static function is_cron() {
11646
+ return ( defined( 'DOING_CRON' ) && DOING_CRON );
11647
+ }
11648
+
11649
+ /**
11650
+ * Check if a real user is visiting the admin dashboard.
11651
+ *
11652
+ * @author Vova Feldman (@svovaf)
11653
+ * @since 1.1.7
11654
+ *
11655
+ * @return bool
11656
+ */
11657
+ function is_user_in_admin() {
11658
+ return is_admin() && ! self::is_ajax() && ! self::is_cron();
11659
+ }
11660
+
11661
+ /**
11662
+ * Check if a real user is in the customizer view.
11663
+ *
11664
+ * @author Vova Feldman (@svovaf)
11665
+ * @since 1.2.2.7
11666
+ *
11667
+ * @return bool
11668
+ */
11669
+ static function is_customizer() {
11670
+ return is_customize_preview();
11671
+ }
11672
+
11673
+ /**
11674
+ * Check if running in HTTPS and if site's plan matching the specified plan.
11675
+ *
11676
+ * @param string $plan
11677
+ * @param bool $exact
11678
+ *
11679
+ * @return bool
11680
+ */
11681
+ function is_ssl_and_plan( $plan, $exact = false ) {
11682
+ return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
11683
+ }
11684
+
11685
+ /**
11686
+ * Construct plugin's settings page URL.
11687
+ *
11688
+ * @author Vova Feldman (@svovaf)
11689
+ * @since 1.0.4
11690
+ *
11691
+ * @param string $page
11692
+ * @param array $params
11693
+ * @param bool|null $network
11694
+ *
11695
+ * @return string
11696
+ */
11697
+ function _get_admin_page_url( $page = '', $params = array(), $network = null ) {
11698
+ if ( is_null( $network ) ) {
11699
+ $network = (
11700
+ $this->_is_network_active &&
11701
+ ( fs_is_network_admin() || ! $this->is_delegated_connection() )
11702
+ );
11703
+ }
11704
+
11705
+ if ( 0 < count( $params ) ) {
11706
+ foreach ( $params as $k => $v ) {
11707
+ $params[ $k ] = urlencode( $v );
11708
+ }
11709
+ }
11710
+
11711
+ $page_param = $this->_menu->get_slug( $page );
11712
+
11713
+ if ( empty( $page ) &&
11714
+ $this->is_theme() &&
11715
+ // Show the opt-in as an overlay for free wp.org themes or themes without any settings page.
11716
+ ( $this->is_free_wp_org_theme() || ! $this->has_settings_menu() )
11717
+ ) {
11718
+ $params[ $this->get_unique_affix() . '_show_optin' ] = 'true';
11719
+
11720
+ return add_query_arg(
11721
+ $params,
11722
+ $this->admin_url( 'themes.php', 'admin', $network )
11723
+ );
11724
+ }
11725
+
11726
+ if ( ! $this->has_settings_menu() ) {
11727
+ if ( ! empty( $page ) ) {
11728
+ // Module doesn't have a setting page, but since the request is for
11729
+ // a specific Freemius page, use the admin.php path.
11730
+ return add_query_arg( array_merge( $params, array(
11731
+ 'page' => $page_param,
11732
+ ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
11733
+ } else {
11734
+ if ( $this->is_activation_mode() ) {
11735
+ /**
11736
+ * @author Vova Feldman
11737
+ * @since 1.2.1.6
11738
+ *
11739
+ * If plugin doesn't have a settings page, create one for the opt-in screen.
11740
+ */
11741
+ return add_query_arg( array_merge( $params, array(
11742
+ 'page' => $this->_slug,
11743
+ ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
11744
+ } else {
11745
+ // Plugin without a settings page.
11746
+ return add_query_arg(
11747
+ $params,
11748
+ $this->admin_url( 'plugins.php', 'admin', $network )
11749
+ );
11750
+ }
11751
+ }
11752
+ }
11753
+
11754
+ // Module has a submenu settings page.
11755
+ if ( ! $this->_menu->is_top_level() ) {
11756
+ $parent_slug = $this->_menu->get_parent_slug();
11757
+ $menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
11758
+ $parent_slug :
11759
+ 'admin.php';
11760
+
11761
+ return add_query_arg( array_merge( $params, array(
11762
+ 'page' => $page_param,
11763
+ ) ), $this->admin_url( $menu_file, 'admin', $network ) );
11764
+ }
11765
+
11766
+ // Module has a top level CPT settings page.
11767
+ if ( $this->_menu->is_cpt() ) {
11768
+ if ( empty( $page ) && $this->is_activation_mode() ) {
11769
+ return add_query_arg( array_merge( $params, array(
11770
+ 'page' => $page_param
11771
+ ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
11772
+ } else {
11773
+ if ( ! empty( $page ) ) {
11774
+ $params['page'] = $page_param;
11775
+ }
11776
+
11777
+ return add_query_arg(
11778
+ $params,
11779
+ $this->admin_url( $this->_menu->get_raw_slug(), 'admin', $network )
11780
+ );
11781
+ }
11782
+ }
11783
+
11784
+ // Module has a custom top level settings page.
11785
+ return add_query_arg( array_merge( $params, array(
11786
+ 'page' => $page_param,
11787
+ ) ), $this->admin_url( 'admin.php', 'admin', $network ) );
11788
+ }
11789
+
11790
+ #--------------------------------------------------------------------------------
11791
+ #region Multisite
11792
+ #--------------------------------------------------------------------------------
11793
+
11794
+ /**
11795
+ * @author Leo Fajardo (@leorw)
11796
+ * @since 2.0.0
11797
+ *
11798
+ * @return bool
11799
+ */
11800
+ function is_network_active() {
11801
+ return $this->_is_network_active;
11802
+ }
11803
+
11804
+ /**
11805
+ * Delegate activation for the given sites in the network (or all sites if `null`) to site admins.
11806
+ *
11807
+ * @author Leo Fajardo (@leorw)
11808
+ * @since 2.0.0
11809
+ *
11810
+ * @param array|null $sites
11811
+ */
11812
+ private function delegate_connection( $sites = null ) {
11813
+ $this->_logger->entrance();
11814
+
11815
+ $this->_admin_notices->remove_sticky( 'connect_account' );
11816
+
11817
+ if ( is_null( $sites ) ) {
11818
+ // All sites delegation.
11819
+ $this->_storage->store( 'is_delegated_connection', true, true, true );
11820
+ } else {
11821
+ // Specified sites delegation.
11822
+ foreach ( $sites as $site ) {
11823
+ $this->delegate_site_connection( $site['blog_id'] );
11824
+ }
11825
+ }
11826
+
11827
+ $this->network_upgrade_mode_completed();
11828
+ }
11829
+
11830
+ /**
11831
+ * Delegate specific network site conncetion to the site admin.
11832
+ *
11833
+ * @author Vova Feldman (@svovaf)
11834
+ * @since 2.0.0
11835
+ *
11836
+ * @param int $blog_id
11837
+ */
11838
+ private function delegate_site_connection( $blog_id ) {
11839
+ $this->_storage->store( 'is_delegated_connection', true, $blog_id, true );
11840
+ }
11841
+
11842
+ /**
11843
+ * Check if super-admin delegated the connection of ALL sites to the site admins.
11844
+ *
11845
+ * @author Vova Feldman (@svovaf)
11846
+ * @since 2.0.0
11847
+ *
11848
+ * @return bool
11849
+ */
11850
+ function is_network_delegated_connection() {
11851
+ if ( ! $this->_is_network_active ) {
11852
+ return false;
11853
+ }
11854
+
11855
+ return $this->_storage->get( 'is_delegated_connection', false, true );
11856
+ }
11857
+
11858
+ /**
11859
+ * @author Leo Fajardo (@leorw)
11860
+ * @since 2.0.0
11861
+ *
11862
+ * @param int $blog_id
11863
+ *
11864
+ * @return bool
11865
+ */
11866
+ function is_site_delegated_connection( $blog_id = 0 ) {
11867
+ if ( ! $this->_is_network_active ) {
11868
+ return false;
11869
+ }
11870
+
11871
+ if ( 0 == $blog_id ) {
11872
+ $blog_id = get_current_blog_id();
11873
+ }
11874
+
11875
+ return $this->_storage->get( 'is_delegated_connection', false, $blog_id );
11876
+ }
11877
+
11878
+ /**
11879
+ * Check if delegated the connection. When running within the the network admin,
11880
+ * and haven't specified the blog ID, checks if network level delegated. If running
11881
+ * within a site admin or specified a blog ID, check if delegated the connection for
11882
+ * the current context site.
11883
+ *
11884
+ * If executed outside the the admin, check if delegated the connection
11885
+ * for the current context site OR the whole network.
11886
+ *
11887
+ * @author Vova Feldman (@svovaf)
11888
+ * @since 2.0.0
11889
+ *
11890
+ * @param int $blog_id If set, checks if network delegated or blog specific delegated.
11891
+ *
11892
+ * @return bool
11893
+ */
11894
+ function is_delegated_connection( $blog_id = 0 ) {
11895
+ if ( ! $this->_is_network_active ) {
11896
+ return false;
11897
+ }
11898
+
11899
+ if ( fs_is_network_admin() && 0 == $blog_id ) {
11900
+ return $this->is_network_delegated_connection();
11901
+ }
11902
+
11903
+ return (
11904
+ $this->is_network_delegated_connection() ||
11905
+ $this->is_site_delegated_connection( $blog_id )
11906
+ );
11907
+ }
11908
+
11909
+ /**
11910
+ * Check if the current module is active for the site.
11911
+ *
11912
+ * @author Vova Feldman (@svovaf)
11913
+ * @since 2.0.0
11914
+ *
11915
+ * @param int $blog_id
11916
+ *
11917
+ * @return bool
11918
+ */
11919
+ function is_active_for_site( $blog_id ) {
11920
+ if ( ! is_multisite() ) {
11921
+ // Not a multisite and this code is executed, means that the plugin is active.
11922
+ return true;
11923
+ }
11924
+
11925
+ if ( $this->is_theme() ) {
11926
+ // All themes are site level activated.
11927
+ return true;
11928
+ }
11929
+
11930
+ if ( $this->_is_network_active ) {
11931
+ // Plugin was network activated so it's active.
11932
+ return true;
11933
+ }
11934
+
11935
+ return in_array( $this->_plugin_basename, (array) get_blog_option( $blog_id, 'active_plugins', array() ) );
11936
+ }
11937
+
11938
+ /**
11939
+ * @author Leo Fajardo (@leorw)
11940
+ * @since 2.0.0
11941
+ *
11942
+ * @return array Active & public sites collection.
11943
+ */
11944
+ static function get_sites() {
11945
+ /**
11946
+ * For consistency with get_blog_list() which only return active public sites.
11947
+ *
11948
+ * @author Vova Feldman (@svovaf)
11949
+ */
11950
+ $args = array(
11951
+ 'public' => 1,
11952
+ 'archived' => 0,
11953
+ 'mature' => 0,
11954
+ 'spam' => 0,
11955
+ 'deleted' => 0,
11956
+ );
11957
+
11958
+ if ( function_exists( 'get_sites' ) ) {
11959
+ // For WP 4.6 and above.
11960
+ return get_sites( $args );
11961
+ } else if ( function_exists( 'wp_get_sites' ) ) {
11962
+ // For WP 3.7 to WP 4.5.
11963
+ return wp_get_sites( $args );
11964
+ } else {
11965
+ // For WP 3.6 and below.
11966
+ return get_blog_list( 0, 'all' );
11967
+ }
11968
+ }
11969
+
11970
+ /**
11971
+ * Checks if a given blog is active.
11972
+ *
11973
+ * @author Vova Feldman (@svovaf)
11974
+ * @since 2.0.0
11975
+ *
11976
+ * @param $blog_id
11977
+ *
11978
+ * @return bool
11979
+ */
11980
+ private static function is_site_active( $blog_id ) {
11981
+ global $wpdb;
11982
+
11983
+ $blog_info = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d", $blog_id ) );
11984
+
11985
+ if ( ! is_object( $blog_info ) ) {
11986
+ return false;
11987
+ }
11988
+
11989
+ return (
11990
+ true == $blog_info->public &&
11991
+ false == $blog_info->archived &&
11992
+ false == $blog_info->mature &&
11993
+ false == $blog_info->spam &&
11994
+ false == $blog_info->deleted
11995
+ );
11996
+ }
11997
+
11998
+ /**
11999
+ * Get a mapping between the site addresses to their blog IDs.
12000
+ *
12001
+ * @author Vova Feldman (@svovaf)
12002
+ * @since 2.0.0
12003
+ *
12004
+ * @return array {
12005
+ * @key string Site address without protocol with a trailing slash.
12006
+ * @value int Site's blog ID.
12007
+ * }
12008
+ */
12009
+ private function get_address_to_blog_map() {
12010
+ $sites = self::get_sites();
12011
+
12012
+ // Map site addresses to their blog IDs.
12013
+ $address_to_blog_map = array();
12014
+ foreach ( $sites as $site ) {
12015
+ $blog_id = self::get_site_blog_id( $site );
12016
+ $address = trailingslashit( fs_strip_url_protocol( get_site_url( $blog_id ) ) );
12017
+ $address_to_blog_map[ $address ] = $blog_id;
12018
+ }
12019
+
12020
+ return $address_to_blog_map;
12021
+ }
12022
+
12023
+ /**
12024
+ * Get a mapping between the site addresses to their blog IDs.
12025
+ *
12026
+ * @author Vova Feldman (@svovaf)
12027
+ * @since 2.0.0
12028
+ *
12029
+ * @return array {
12030
+ * @key int Site's blog ID.
12031
+ * @value FS_Site Associated install.
12032
+ * }
12033
+ */
12034
+ function get_blog_install_map() {
12035
+ $sites = self::get_sites();
12036
+
12037
+ // Map site blog ID to its install.
12038
+ $install_map = array();
12039
+
12040
+ foreach ( $sites as $site ) {
12041
+ $blog_id = self::get_site_blog_id( $site );
12042
+ $install = $this->get_install_by_blog_id( $blog_id );
12043
+
12044
+ if ( is_object( $install ) ) {
12045
+ $install_map[ $blog_id ] = $install;
12046
+ }
12047
+ }
12048
+
12049
+ return $install_map;
12050
+ }
12051
+
12052
+ /**
12053
+ * Gets a map of module IDs that the given user has opted-in to.
12054
+ *
12055
+ * @author Leo Fajardo (@leorw)
12056
+ * @since 2.1.0
12057
+ *
12058
+ * @param number $fs_user_id
12059
+ *
12060
+ * @return array {
12061
+ * @key number $plugin_id
12062
+ * @value bool Always true.
12063
+ * }
12064
+ */
12065
+ private static function get_user_opted_in_module_ids_map( $fs_user_id ) {
12066
+ self::$_static_logger->entrance();
12067
+
12068
+ if ( ! is_multisite() ) {
12069
+ $installs = array_merge(
12070
+ self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN ),
12071
+ self::get_all_sites( WP_FS__MODULE_TYPE_THEME )
12072
+ );
12073
+ } else {
12074
+ $sites = self::get_sites();
12075
+
12076
+ $installs = array();
12077
+ foreach ( $sites as $site ) {
12078
+ $blog_id = self::get_site_blog_id( $site );
12079
+
12080
+ $installs = array_merge(
12081
+ $installs,
12082
+ self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id ),
12083
+ self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id )
12084
+ );
12085
+ }
12086
+ }
12087
+
12088
+ $module_ids_map = array();
12089
+ foreach ( $installs as $install ) {
12090
+ if ( is_object( $install ) &&
12091
+ FS_Site::is_valid_id( $install->id ) &&
12092
+ FS_User::is_valid_id( $install->user_id ) &&
12093
+ ( $install->user_id == $fs_user_id )
12094
+ ) {
12095
+ $module_ids_map[ $install->plugin_id ] = true;
12096
+ }
12097
+ }
12098
+
12099
+ return $module_ids_map;
12100
+ }
12101
+
12102
+ /**
12103
+ * @author Leo Fajardo (@leorw)
12104
+ *
12105
+ * @return null|array {
12106
+ * 'install' => FS_Site Module's install,
12107
+ * 'blog_id' => string The associated blog ID.
12108
+ * }
12109
+ */
12110
+ private function find_first_install() {
12111
+ $sites = self::get_sites();
12112
+
12113
+ foreach ( $sites as $site ) {
12114
+ $blog_id = self::get_site_blog_id( $site );
12115
+ $install = $this->get_install_by_blog_id( $blog_id );
12116
+
12117
+ if ( is_object( $install ) ) {
12118
+ return array(
12119
+ 'install' => $install,
12120
+ 'blog_id' => $blog_id
12121
+ );
12122
+ }
12123
+ }
12124
+
12125
+ return null;
12126
+ }
12127
+
12128
+ /**
12129
+ * Switches the Freemius site level context to a specified blog.
12130
+ *
12131
+ * @author Vova Feldman (@svovaf)
12132
+ * @since 2.0.0
12133
+ *
12134
+ * @param int $blog_id
12135
+ * @param FS_Site $install
12136
+ */
12137
+ function switch_to_blog( $blog_id, FS_Site $install = null ) {
12138
+ if ( $blog_id == $this->_context_is_network_or_blog_id ) {
12139
+ return;
12140
+ }
12141
+
12142
+ switch_to_blog( $blog_id );
12143
+ $this->_context_is_network_or_blog_id = $blog_id;
12144
+
12145
+ self::$_accounts->set_site_blog_context( $blog_id );
12146
+ $this->_storage->set_site_blog_context( $blog_id );
12147
+ $this->_storage->set_network_active( true, $this->is_delegated_connection( $blog_id ) );
12148
+
12149
+ $this->_site = is_object( $install ) ?
12150
+ $install :
12151
+ $this->get_install_by_blog_id( $blog_id );
12152
+
12153
+ $this->_user = false;
12154
+ $this->_licenses = false;
12155
+ $this->_license = null;
12156
+
12157
+ if ( is_object( $this->_site ) ) {
12158
+ // Try to fetch user from install.
12159
+ $this->_user = self::_get_user_by_id( $this->_site->user_id );
12160
+
12161
+ if ( ! is_object( $this->_user ) &&
12162
+ FS_User::is_valid_id( $this->_storage->prev_user_id )
12163
+ ) {
12164
+ // Try to fetch previously saved user.
12165
+ $this->_user = self::_get_user_by_id( $this->_storage->prev_user_id );
12166
+
12167
+ if ( ! is_object( $this->_user ) ) {
12168
+ // Fallback to network's user.
12169
+ $this->_user = $this->get_network_user();
12170
+ }
12171
+ }
12172
+
12173
+ $all_plugin_licenses = self::get_all_licenses( $this->_module_id );
12174
+
12175
+ if ( ! empty( $all_plugin_licenses ) ) {
12176
+ if ( ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) {
12177
+ $this->_license = null;
12178
+ } else {
12179
+ $license_found = false;
12180
+ foreach ( $all_plugin_licenses as $license ) {
12181
+ if ( $license->id == $this->_site->license_id ) {
12182
+ // License found.
12183
+ $this->_license = $license;
12184
+ $license_found = true;
12185
+ break;
12186
+ }
12187
+ }
12188
+
12189
+ if ( $license_found ) {
12190
+ $this->link_license_2_user( $this->_license->id, $this->_user->id );
12191
+ }
12192
+ }
12193
+
12194
+ $this->_licenses = $this->get_user_licenses( $this->_user->id );
12195
+ }
12196
+ }
12197
+
12198
+ unset( $this->_site_api );
12199
+ unset( $this->_user_api );
12200
+ }
12201
+
12202
+ /**
12203
+ * Restore the blog context to the blog that originally loaded the module.
12204
+ *
12205
+ * @author Vova Feldman (@svovaf)
12206
+ * @since 2.0.0
12207
+ */
12208
+ function restore_current_blog() {
12209
+ $this->switch_to_blog( $this->_blog_id );
12210
+ }
12211
+
12212
+ /**
12213
+ * @author Vova Feldman (@svovaf)
12214
+ * @since 2.0.0
12215
+ *
12216
+ * @param array|WP_Site $site
12217
+ *
12218
+ * @return int
12219
+ */
12220
+ static function get_site_blog_id( &$site ) {
12221
+ return ( $site instanceof WP_Site ) ?
12222
+ $site->blog_id :
12223
+ ( is_object( $site ) && isset( $site->userblog_id ) ?
12224
+ $site->userblog_id :
12225
+ $site['blog_id'] );
12226
+ }
12227
+
12228
+ /**
12229
+ * @author Leo Fajardo (@leorw)
12230
+ * @since 2.0.0
12231
+ *
12232
+ * @param array|WP_Site|null $site
12233
+ *
12234
+ * @return array
12235
+ */
12236
+ function get_site_info( $site = null ) {
12237
+ $this->_logger->entrance();
12238
+
12239
+ $switched = false;
12240
+
12241
+ if ( is_null( $site ) ) {
12242
+ $url = get_site_url();
12243
+ $name = get_bloginfo( 'name' );
12244
+ $blog_id = null;
12245
+ } else {
12246
+ $blog_id = self::get_site_blog_id( $site );
12247
+
12248
+ if ( get_current_blog_id() != $blog_id ) {
12249
+ switch_to_blog( $blog_id );
12250
+ $switched = true;
12251
+ }
12252
+
12253
+ if ( $site instanceof WP_Site ) {
12254
+ $url = $site->siteurl;
12255
+ $name = $site->blogname;
12256
+ } else {
12257
+ $url = get_site_url( $blog_id );
12258
+ $name = get_bloginfo( 'name' );
12259
+ }
12260
+ }
12261
+
12262
+ $info = array(
12263
+ 'uid' => $this->get_anonymous_id( $blog_id ),
12264
+ 'url' => $url,
12265
+ 'title' => $name,
12266
+ 'language' => get_bloginfo( 'language' ),
12267
+ 'charset' => get_bloginfo( 'charset' ),
12268
+ );
12269
+
12270
+ if ( is_numeric( $blog_id ) ) {
12271
+ $info['blog_id'] = $blog_id;
12272
+ }
12273
+
12274
+ if ( $switched ) {
12275
+ restore_current_blog();
12276
+ }
12277
+
12278
+ return $info;
12279
+ }
12280
+
12281
+ /**
12282
+ * Load the module's install based on the blog ID.
12283
+ *
12284
+ * @author Vova Feldman (@svovaf)
12285
+ * @since 2.0.0
12286
+ *
12287
+ * @param int|null $blog_id
12288
+ *
12289
+ * @return FS_Site
12290
+ */
12291
+ function get_install_by_blog_id( $blog_id = null ) {
12292
+ $installs = self::get_all_sites( $this->_module_type, $blog_id );
12293
+ $install = isset( $installs[ $this->_slug ] ) ? $installs[ $this->_slug ] : null;
12294
+
12295
+ if ( is_object( $install ) &&
12296
+ is_numeric( $install->id ) &&
12297
+ is_numeric( $install->user_id ) &&
12298
+ FS_Plugin_Plan::is_valid_id( $install->plan_id )
12299
+ ) {
12300
+ // Load site.
12301
+ $install = clone $install;
12302
+ }
12303
+
12304
+ return $install;
12305
+ }
12306
+
12307
+ /**
12308
+ * Check if module is installed on a specified site.
12309
+ *
12310
+ * @author Vova Feldman (@svovaf)
12311
+ * @since 2.0.0
12312
+ *
12313
+ * @param int|null $blog_id
12314
+ *
12315
+ * @return bool
12316
+ */
12317
+ function is_installed_on_site( $blog_id = null ) {
12318
+ $installs = self::get_all_sites( $this->_module_type, $blog_id );
12319
+ $install = isset( $installs[ $this->_slug ] ) ? $installs[ $this->_slug ] : null;
12320
+
12321
+ return (
12322
+ is_object( $install ) &&
12323
+ is_numeric( $install->id ) &&
12324
+ is_numeric( $install->user_id ) &&
12325
+ FS_Plugin_Plan::is_valid_id( $install->plan_id )
12326
+ );
12327
+ }
12328
+
12329
+ /**
12330
+ * Check if super-admin connected at least one site via the network opt-in.
12331
+ *
12332
+ * @author Vova Feldman (@svovaf)
12333
+ * @since 2.0.0
12334
+ *
12335
+ * @return bool
12336
+ */
12337
+ function is_network_registered() {
12338
+ if ( ! $this->_is_network_active ) {
12339
+ return false;
12340
+ }
12341
+
12342
+ return FS_User::is_valid_id( $this->_storage->network_user_id );
12343
+ }
12344
+
12345
+ /**
12346
+ * Returns the main user associated with the network.
12347
+ *
12348
+ * @author Vova Feldman (@svovaf)
12349
+ * @since 2.0.0
12350
+ *
12351
+ * @return FS_User
12352
+ */
12353
+ function get_network_user() {
12354
+ if ( ! $this->_is_network_active ) {
12355
+ return null;
12356
+ }
12357
+
12358
+ return FS_User::is_valid_id( $this->_storage->network_user_id ) ?
12359
+ self::_get_user_by_id( $this->_storage->network_user_id ) :
12360
+ null;
12361
+ }
12362
+
12363
+ /**
12364
+ * Returns the current context user or the network's main user.
12365
+ *
12366
+ * @author Vova Feldman (@svovaf)
12367
+ * @since 2.0.0
12368
+ *
12369
+ * @return FS_User
12370
+ */
12371
+ function get_current_or_network_user() {
12372
+ return ( $this->_user instanceof FS_User ) ?
12373
+ $this->_user :
12374
+ $this->get_network_user();
12375
+ }
12376
+
12377
+ /**
12378
+ * Returns the main install associated with the network.
12379
+ *
12380
+ * @author Vova Feldman (@svovaf)
12381
+ * @since 2.0.0
12382
+ *
12383
+ * @return FS_Site
12384
+ */
12385
+ function get_network_install() {
12386
+ if ( ! $this->_is_network_active ) {
12387
+ return null;
12388
+ }
12389
+
12390
+ return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ?
12391
+ $this->get_install_by_blog_id( $this->_storage->network_install_blog_id ) :
12392
+ null;
12393
+ }
12394
+
12395
+ /**
12396
+ * Returns the blog ID that is associated with the main install.
12397
+ *
12398
+ * @author Leo Fajardo (@leorw)
12399
+ * @since 2.0.0
12400
+ *
12401
+ * @return int|null
12402
+ */
12403
+ function get_network_install_blog_id() {
12404
+ if ( ! $this->_is_network_active ) {
12405
+ return null;
12406
+ }
12407
+
12408
+ return FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ?
12409
+ $this->_storage->network_install_blog_id :
12410
+ null;
12411
+ }
12412
+
12413
+ /**
12414
+ * Returns the current context install or the network's main install.
12415
+ *
12416
+ * @author Vova Feldman (@svovaf)
12417
+ * @since 2.0.0
12418
+ *
12419
+ * @return FS_Site
12420
+ */
12421
+ function get_current_or_network_install() {
12422
+ return ( $this->_site instanceof FS_Site ) ?
12423
+ $this->_site :
12424
+ $this->get_network_install();
12425
+ }
12426
+
12427
+ /**
12428
+ * Check if executing a site level action from the network level admin.
12429
+ *
12430
+ * @author Vova Feldman (@svovaf)
12431
+ * @since 2.0.0
12432
+ *
12433
+ * @return false|int If yes, return the requested blog ID.
12434
+ */
12435
+ private function is_network_level_site_specific_action() {
12436
+ if ( ! $this->_is_network_active ) {
12437
+ return false;
12438
+ }
12439
+
12440
+ if ( ! fs_is_network_admin() ) {
12441
+ return false;
12442
+ }
12443
+
12444
+ $blog_id = fs_request_get( 'blog_id', '' );
12445
+
12446
+ return is_numeric( $blog_id ) ? $blog_id : false;
12447
+ }
12448
+
12449
+ /**
12450
+ * Check if executing an action from the network level admin.
12451
+ *
12452
+ * @author Vova Feldman (@svovaf)
12453
+ * @since 2.0.0
12454
+ *
12455
+ * @return bool
12456
+ */
12457
+ private function is_network_level_action() {
12458
+ return ( $this->_is_network_active && fs_is_network_admin() );
12459
+ }
12460
+
12461
+ /**
12462
+ * Needs to be executed after site deactivation, archive, deletion, or flag as spam.
12463
+ * The logic updates the network level user and blog, and reschedule the crons if the cron executing site matching the site that is no longer publicly active.
12464
+ *
12465
+ * @author Vova Feldman (@svovaf)
12466
+ * @since 2.0.0
12467
+ *
12468
+ * @param int $context_blog_id
12469
+ */
12470
+ private function update_multisite_data_after_site_deactivation( $context_blog_id = 0 ) {
12471
+ $this->_logger->entrance();
12472
+
12473
+ if ( $this->_is_network_active ) {
12474
+ if ( $context_blog_id == $this->_storage->network_install_blog_id ) {
12475
+ $installs_map = $this->get_blog_install_map();
12476
+
12477
+ foreach ( $installs_map as $blog_id => $install ) {
12478
+ /**
12479
+ * @var FS_Site $install
12480
+ */
12481
+ if ( $context_blog_id == $blog_id ) {
12482
+ continue;
12483
+ }
12484
+
12485
+ if ( $install->user_id != $this->_storage->network_user_id ) {
12486
+ continue;
12487
+ }
12488
+
12489
+ // Switch reference to a blog that is opted-in and belong to the same super-admin.
12490
+ $this->_storage->network_install_blog_id = $blog_id;
12491
+ break;
12492
+ }
12493
+ }
12494
+ }
12495
+
12496
+ if ( $this->is_sync_cron_scheduled() &&
12497
+ $context_blog_id == $this->get_sync_cron_blog_id()
12498
+ ) {
12499
+ $this->schedule_sync_cron( WP_FS__SCRIPT_START_TIME, true, $context_blog_id );
12500
+ }
12501
+
12502
+ if ( $this->is_install_sync_scheduled() &&
12503
+ $context_blog_id == $this->get_install_sync_cron_blog_id()
12504
+ ) {
12505
+ $this->schedule_install_sync( $context_blog_id );
12506
+ }
12507
+ }
12508
+
12509
+ /**
12510
+ * Executed after site deactivation, archive, or flag as spam.
12511
+ *
12512
+ * @author Vova Feldman (@svovaf)
12513
+ * @since 2.0.0
12514
+ *
12515
+ * @param int $context_blog_id
12516
+ */
12517
+ public function _after_site_deactivated_callback( $context_blog_id = 0 ) {
12518
+ $this->_logger->entrance();
12519
+
12520
+ $install = $this->get_install_by_blog_id( $context_blog_id );
12521
+
12522
+ if ( ! is_object( $install ) ) {
12523
+ // Site not connected.
12524
+ return;
12525
+ }
12526
+
12527
+ $this->update_multisite_data_after_site_deactivation( $context_blog_id );
12528
+
12529
+ $current_blog_id = get_current_blog_id();
12530
+
12531
+ $this->switch_to_blog( $context_blog_id );
12532
+
12533
+ // Send deactivation event.
12534
+ $this->sync_install( array(
12535
+ 'is_active' => false,
12536
+ ) );
12537
+
12538
+ $this->switch_to_blog( $current_blog_id );
12539
+ }
12540
+
12541
+ /**
12542
+ * Executed after site deletion.
12543
+ *
12544
+ * @author Vova Feldman (@svovaf)
12545
+ * @since 2.0.0
12546
+ *
12547
+ * @param int $context_blog_id
12548
+ * @param bool $drop True if site's database tables should be dropped. Default is false.
12549
+ */
12550
+ public function _after_site_deleted_callback( $context_blog_id = 0, $drop = false ) {
12551
+ $this->_logger->entrance();
12552
+
12553
+ $install = $this->get_install_by_blog_id( $context_blog_id );
12554
+
12555
+ if ( ! is_object( $install ) ) {
12556
+ // Site not connected.
12557
+ return;
12558
+ }
12559
+
12560
+ $this->update_multisite_data_after_site_deactivation( $context_blog_id );
12561
+
12562
+ $current_blog_id = get_current_blog_id();
12563
+
12564
+ $this->switch_to_blog( $context_blog_id );
12565
+
12566
+ if ( $drop ) {
12567
+ // Delete install if dropping site DB.
12568
+ $this->delete_account_event();
12569
+ } else {
12570
+ // Send deactivation event.
12571
+ $this->sync_install( array(
12572
+ 'is_active' => false,
12573
+ ) );
12574
+ }
12575
+
12576
+ $this->switch_to_blog( $current_blog_id );
12577
+ }
12578
+
12579
+ /**
12580
+ * Executed after site re-activation.
12581
+ *
12582
+ * @author Vova Feldman (@svovaf)
12583
+ * @since 2.0.0
12584
+ *
12585
+ * @param int $context_blog_id
12586
+ */
12587
+ public function _after_site_reactivated_callback( $context_blog_id = 0 ) {
12588
+ $this->_logger->entrance();
12589
+
12590
+ $install = $this->get_install_by_blog_id( $context_blog_id );
12591
+
12592
+ if ( ! is_object( $install ) ) {
12593
+ // Site not connected.
12594
+ return;
12595
+ }
12596
+
12597
+ if ( ! self::is_site_active( $context_blog_id ) ) {
12598
+ // Site not yet active (can be in spam mode, archived, deleted...).
12599
+ return;
12600
+ }
12601
+
12602
+ $current_blog_id = get_current_blog_id();
12603
+
12604
+ $this->switch_to_blog( $context_blog_id );
12605
+
12606
+ // Send re-activation event.
12607
+ $this->sync_install( array(
12608
+ 'is_active' => true,
12609
+ ) );
12610
+
12611
+ $this->switch_to_blog( $current_blog_id );
12612
+ }
12613
+
12614
+ #endregion Multisite
12615
+
12616
+ /**
12617
+ * @author Leo Fajardo (@leorw)
12618
+ *
12619
+ * @param string $path
12620
+ * @param string $scheme
12621
+ * @param bool $network
12622
+ *
12623
+ * @return string
12624
+ */
12625
+ private function admin_url( $path = '', $scheme = 'admin', $network = true ) {
12626
+ return ( $this->_is_network_active && $network ) ?
12627
+ network_admin_url( $path, $scheme ) :
12628
+ admin_url( $path, $scheme );
12629
+ }
12630
+
12631
+ /**
12632
+ * Check if currently in a specified admin page.
12633
+ *
12634
+ * @author Vova Feldman (@svovaf)
12635
+ * @since 1.2.2.7
12636
+ *
12637
+ * @param string $page
12638
+ *
12639
+ * @return bool
12640
+ */
12641
+ function is_admin_page( $page ) {
12642
+ return ( $this->_menu->get_slug( $page ) === fs_request_get( 'page', '', 'get' ) );
12643
+ }
12644
+
12645
+ /**
12646
+ * Get module's main admin setting page URL.
12647
+ *
12648
+ * @author Vova Feldman (@svovaf)
12649
+ * @since 1.2.2.7
12650
+ *
12651
+ * @return string
12652
+ */
12653
+ function main_menu_url() {
12654
+ return $this->_menu->main_menu_url();
12655
+ }
12656
+
12657
+ /**
12658
+ * Check if currently on the theme's setting page or
12659
+ * on any of the Freemius added pages (via tabs).
12660
+ *
12661
+ * @author Vova Feldman (@svovaf)
12662
+ * @since 1.2.2.7
12663
+ *
12664
+ * @return bool
12665
+ */
12666
+ function is_theme_settings_page() {
12667
+ return fs_starts_with(
12668
+ fs_request_get( 'page', '', 'get' ),
12669
+ $this->_menu->get_slug()
12670
+ );
12671
+ }
12672
+
12673
+ /**
12674
+ * Plugin's account page + sync license URL.
12675
+ *
12676
+ * @author Vova Feldman (@svovaf)
12677
+ * @since 1.1.9.1
12678
+ *
12679
+ * @param bool|number $plugin_id
12680
+ * @param bool $add_action_nonce
12681
+ * @param array $params
12682
+ *
12683
+ * @return string
12684
+ */
12685
+ function _get_sync_license_url( $plugin_id = false, $add_action_nonce = true, $params = array() ) {
12686
+ if ( is_numeric( $plugin_id ) ) {
12687
+ $params['plugin_id'] = $plugin_id;
12688
+ }
12689
+
12690
+ return $this->get_account_url(
12691
+ $this->get_unique_affix() . '_sync_license',
12692
+ $params,
12693
+ $add_action_nonce
12694
+ );
12695
+ }
12696
+
12697
+ /**
12698
+ * Plugin's account URL.
12699
+ *
12700
+ * @author Vova Feldman (@svovaf)
12701
+ * @since 1.0.4
12702
+ *
12703
+ * @param bool|string $action
12704
+ * @param array $params
12705
+ *
12706
+ * @param bool $add_action_nonce
12707
+ *
12708
+ * @return string
12709
+ */
12710
+ function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
12711
+ if ( is_string( $action ) ) {
12712
+ $params['fs_action'] = $action;
12713
+ }
12714
+
12715
+ self::require_pluggable_essentials();
12716
+
12717
+ return ( $add_action_nonce && is_string( $action ) ) ?
12718
+ fs_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
12719
+ $this->_get_admin_page_url( 'account', $params );
12720
+ }
12721
+
12722
+ /**
12723
+ * @author Vova Feldman (@svovaf)
12724
+ * @since 1.2.0
12725
+ *
12726
+ * @param string $tab
12727
+ * @param bool $action
12728
+ * @param array $params
12729
+ * @param bool $add_action_nonce
12730
+ *
12731
+ * @return string
12732
+ *
12733
+ * @uses get_account_url()
12734
+ */
12735
+ function get_account_tab_url( $tab, $action = false, $params = array(), $add_action_nonce = true ) {
12736
+ $params['tab'] = $tab;
12737
+
12738
+ return $this->get_account_url( $action, $params, $add_action_nonce );
12739
+ }
12740
+
12741
+ /**
12742
+ * Plugin's account URL.
12743
+ *
12744
+ * @author Vova Feldman (@svovaf)
12745
+ * @since 1.0.4
12746
+ *
12747
+ * @param bool|string $topic
12748
+ * @param bool|string $message
12749
+ *
12750
+ * @return string
12751
+ */
12752
+ function contact_url( $topic = false, $message = false ) {
12753
+ $params = array();
12754
+ if ( is_string( $topic ) ) {
12755
+ $params['topic'] = $topic;
12756
+ }
12757
+ if ( is_string( $message ) ) {
12758
+ $params['message'] = $message;
12759
+ }
12760
+
12761
+ if ( $this->is_addon() ) {
12762
+ $params['addon_id'] = $this->get_id();
12763
+
12764
+ return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
12765
+ } else {
12766
+ return $this->_get_admin_page_url( 'contact', $params );
12767
+ }
12768
+ }
12769
+
12770
+ /**
12771
+ * Add-on direct info URL.
12772
+ *
12773
+ * @author Vova Feldman (@svovaf)
12774
+ * @since 1.1.0
12775
+ *
12776
+ * @param string $slug
12777
+ *
12778
+ * @return string
12779
+ */
12780
+ function addon_url( $slug ) {
12781
+ return $this->_get_admin_page_url( 'addons', array(
12782
+ 'slug' => $slug
12783
+ ) );
12784
+ }
12785
+
12786
+ /* Logger
12787
+ ------------------------------------------------------------------------------------------------------------------*/
12788
+ /**
12789
+ * @param string $id
12790
+ * @param bool $prefix_slug
12791
+ *
12792
+ * @return FS_Logger
12793
+ */
12794
+ function get_logger( $id = '', $prefix_slug = true ) {
12795
+ return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
12796
+ }
12797
+
12798
+ /**
12799
+ * Note: This method is used externally so don't delete it.
12800
+ *
12801
+ * @param $id
12802
+ * @param bool $load_options
12803
+ * @param bool $prefix_slug
12804
+ *
12805
+ * @return FS_Option_Manager
12806
+ */
12807
+ function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
12808
+ return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
12809
+ }
12810
+
12811
+ /* Security
12812
+ ------------------------------------------------------------------------------------------------------------------*/
12813
+ private static function _encrypt( $str ) {
12814
+ if ( is_null( $str ) ) {
12815
+ return null;
12816
+ }
12817
+
12818
+ /**
12819
+ * The encrypt/decrypt functions are used to protect
12820
+ * the user from messing up with some of the sensitive
12821
+ * data stored for the module as a JSON in the database.
12822
+ *
12823
+ * I used the same suggested hack by the theme review team.
12824
+ * For more details, look at the function `Base64UrlDecode()`
12825
+ * in `./sdk/FreemiusBase.php`.
12826
+ *
12827
+ * @todo Remove this hack once the base64 error is removed from the Theme Check.
12828
+ *
12829
+ * @author Vova Feldman (@svovaf)
12830
+ * @since 1.2.2
12831
+ */
12832
+ $fn = 'base64' . '_encode';
12833
+
12834
+ return $fn( $str );
12835
+ }
12836
+
12837
+ static function _decrypt( $str ) {
12838
+ if ( is_null( $str ) ) {
12839
+ return null;
12840
+ }
12841
+
12842
+ /**
12843
+ * The encrypt/decrypt functions are used to protect
12844
+ * the user from messing up with some of the sensitive
12845
+ * data stored for the module as a JSON in the database.
12846
+ *
12847
+ * I used the same suggested hack by the theme review team.
12848
+ * For more details, look at the function `Base64UrlDecode()`
12849
+ * in `./sdk/FreemiusBase.php`.
12850
+ *
12851
+ * @todo Remove this hack once the base64 error is removed from the Theme Check.
12852
+ *
12853
+ * @author Vova Feldman (@svovaf)
12854
+ * @since 1.2.2
12855
+ */
12856
+ $fn = 'base64' . '_decode';
12857
+
12858
+ return $fn( $str );
12859
+ }
12860
+
12861
+ /**
12862
+ * @author Vova Feldman (@svovaf)
12863
+ * @since 1.0.5
12864
+ *
12865
+ * @param FS_Entity $entity
12866
+ *
12867
+ * @return FS_Entity Return an encrypted clone entity.
12868
+ */
12869
+ private static function _encrypt_entity( FS_Entity $entity ) {
12870
+ $clone = clone $entity;
12871
+ $props = get_object_vars( $entity );
12872
+
12873
+ foreach ( $props as $key => $val ) {
12874
+ $clone->{$key} = self::_encrypt( $val );
12875
+ }
12876
+
12877
+ return $clone;
12878
+ }
12879
+
12880
+ /**
12881
+ * @author Vova Feldman (@svovaf)
12882
+ * @since 1.0.5
12883
+ *
12884
+ * @param FS_Entity $entity
12885
+ *
12886
+ * @return FS_Entity Return an decrypted clone entity.
12887
+ */
12888
+ private static function decrypt_entity( FS_Entity $entity ) {
12889
+ $clone = clone $entity;
12890
+ $props = get_object_vars( $entity );
12891
+
12892
+ foreach ( $props as $key => $val ) {
12893
+ $clone->{$key} = self::_decrypt( $val );
12894
+ }
12895
+
12896
+ return $clone;
12897
+ }
12898
+
12899
+ /**
12900
+ * Tries to activate account based on POST params.
12901
+ *
12902
+ * @author Vova Feldman (@svovaf)
12903
+ * @since 1.0.2
12904
+ *
12905
+ * @deprecated Not in use, outdated.
12906
+ */
12907
+ function _activate_account() {
12908
+ if ( $this->is_registered() ) {
12909
+ // Already activated.
12910
+ return;
12911
+ }
12912
+
12913
+ self::_clean_admin_content_section();
12914
+
12915
+ if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
12916
+ // check_admin_referer( 'activate_' . $this->_plugin->public_key );
12917
+
12918
+ // Verify matching plugin details.
12919
+ if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
12920
+ return;
12921
+ }
12922
+
12923
+ $user = new FS_User();
12924
+ $user->id = fs_request_get( 'user_id' );
12925
+ $user->public_key = fs_request_get( 'user_public_key' );
12926
+ $user->secret_key = fs_request_get( 'user_secret_key' );
12927
+ $user->email = fs_request_get( 'user_email' );
12928
+ $user->first = fs_request_get( 'user_first' );
12929
+ $user->last = fs_request_get( 'user_last' );
12930
+ $user->is_verified = fs_request_get_bool( 'user_is_verified' );
12931
+
12932
+ $site = new FS_Site();
12933
+ $site->id = fs_request_get( 'install_id' );
12934
+ $site->public_key = fs_request_get( 'install_public_key' );
12935
+ $site->secret_key = fs_request_get( 'install_secret_key' );
12936
+ $site->plan_id = fs_request_get( 'plan_id' );
12937
+
12938
+ $plans = array();
12939
+ $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
12940
+ foreach ( $plans_data as $p ) {
12941
+ $plan = new FS_Plugin_Plan( $p );
12942
+ if ( $site->plan_id == $plan->id ) {
12943
+ $plan->title = fs_request_get( 'plan_title' );
12944
+ $plan->name = fs_request_get( 'plan_name' );
12945
+ }
12946
+
12947
+ $plans[] = $plan;
12948
+ }
12949
+
12950
+ $this->_set_account( $user, $site, $plans );
12951
+
12952
+ // Reload the page with the keys.
12953
+ fs_redirect( $this->_get_admin_page_url() );
12954
+ }
12955
+ }
12956
+
12957
+ /**
12958
+ * @author Vova Feldman (@svovaf)
12959
+ * @since 1.0.7
12960
+ *
12961
+ * @param string $email
12962
+ *
12963
+ * @return FS_User|false
12964
+ */
12965
+ static function _get_user_by_email( $email ) {
12966
+ self::$_static_logger->entrance();
12967
+
12968
+ $email = trim( strtolower( $email ) );
12969
+
12970
+ $users = self::get_all_users();
12971
+
12972
+ if ( is_array( $users ) ) {
12973
+ foreach ( $users as $user ) {
12974
+ if ( $email === trim( strtolower( $user->email ) ) ) {
12975
+ return $user;
12976
+ }
12977
+ }
12978
+ }
12979
+
12980
+ return false;
12981
+ }
12982
+
12983
+ #----------------------------------------------------------------------------------
12984
+ #region Account (Loading, Updates & Activation)
12985
+ #----------------------------------------------------------------------------------
12986
+
12987
+ /***
12988
+ * Load account information (user + site).
12989
+ *
12990
+ * @author Vova Feldman (@svovaf)
12991
+ * @since 1.0.1
12992
+ */
12993
+ private function _load_account() {
12994
+ $this->_logger->entrance();
12995
+
12996
+ $this->do_action( 'before_account_load' );
12997
+
12998
+ $users = self::get_all_users();
12999
+ $plans = self::get_all_plans( $this->_module_type );
13000
+
13001
+ if ( $this->_logger->is_on() && is_admin() ) {
13002
+ $this->_logger->log( 'users = ' . var_export( $users, true ) );
13003
+ $this->_logger->log( 'plans = ' . var_export( $plans, true ) );
13004
+ }
13005
+
13006
+ $site = fs_is_network_admin() ?
13007
+ $this->get_network_install() :
13008
+ $this->get_install_by_blog_id();
13009
+
13010
+ if ( fs_is_network_admin() &&
13011
+ ! is_object( $site ) &&
13012
+ FS_Site::is_valid_id( $this->_storage->network_install_blog_id )
13013
+ ) {
13014
+ $first_install = $this->find_first_install();
13015
+
13016
+ if ( is_null( $first_install ) ) {
13017
+ unset( $this->_storage->network_install_blog_id );
13018
+ } else {
13019
+ $site = $first_install['install'];
13020
+ $this->_storage->network_install_blog_id = $first_install['blog_id'];
13021
+ }
13022
+ }
13023
+
13024
+ if ( is_object( $site ) &&
13025
+ is_numeric( $site->id ) &&
13026
+ is_numeric( $site->user_id ) &&
13027
+ FS_Plugin_Plan::is_valid_id( $site->plan_id )
13028
+ ) {
13029
+ // Load site.
13030
+ $this->_site = $site;
13031
+
13032
+ // Load plans.
13033
+ $this->_plans = $plans[ $this->_slug ];
13034
+ if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
13035
+ $this->_sync_plans();
13036
+ } else {
13037
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
13038
+ if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
13039
+ $this->_plans[ $i ] = self::decrypt_entity( $this->_plans[ $i ] );
13040
+ } else {
13041
+ unset( $this->_plans[ $i ] );
13042
+ }
13043
+ }
13044
+ }
13045
+ }
13046
+
13047
+ $user = null;
13048
+ if ( fs_is_network_admin() && $this->_is_network_active ) {
13049
+ $user = $this->get_network_user();
13050
+ }
13051
+
13052
+ if ( is_object( $user ) ) {
13053
+ $this->_user = clone $user;
13054
+ } else if ( $this->_site ) {
13055
+ $user = self::_get_user_by_id( $this->_site->user_id );
13056
+
13057
+ if ( ! is_object( $user ) && FS_User::is_valid_id( $this->_storage->prev_user_id ) ) {
13058
+ /**
13059
+ * Try to load the previous owner. This recovery is used for the following use-case:
13060
+ * 1. Opt-in
13061
+ * 2. Cloning site1 to site2
13062
+ * 3. Ownership switch in site1 (same applies for site2)
13063
+ * 4. Install data sync on site2
13064
+ * 5. Now site2's install is associated with the new owner which does not exists locally.
13065
+ */
13066
+ $user = self::_get_user_by_id( $this->_storage->prev_user_id );
13067
+ }
13068
+
13069
+ if ( ! is_object( $user ) ) {
13070
+ /**
13071
+ * This is a special fault tolerance mechanism to handle a scenario that the user data is missing.
13072
+ */
13073
+ $user = $this->fetch_user_by_install();
13074
+ }
13075
+
13076
+ $this->_user = ( $user instanceof FS_User ) ?
13077
+ clone $user :
13078
+ null;
13079
+ }
13080
+
13081
+ if ( is_object( $this->_user ) ) {
13082
+ // Load licenses.
13083
+ $this->_licenses = $this->get_user_licenses( $this->_user->id );
13084
+ }
13085
+
13086
+ if ( is_object( $this->_site ) ) {
13087
+ $this->_license = $this->_get_license_by_id( $this->_site->license_id );
13088
+
13089
+ if ( $this->_site->version != $this->get_plugin_version() ) {
13090
+ // If stored install version is different than current installed plugin version,
13091
+ // then update plugin version event.
13092
+ $this->update_plugin_version_event();
13093
+ }
13094
+ }
13095
+
13096
+ if ( $this->is_theme() ) {
13097
+ $this->_register_account_hooks();
13098
+ }
13099
+ }
13100
+
13101
+ /**
13102
+ * Special user recovery mechanism.
13103
+ *
13104
+ * @author Vova Feldman (@svovaf)
13105
+ * @since 2.0.0
13106
+ *
13107
+ * @return \FS_User|mixed
13108
+ */
13109
+ private function fetch_user_by_install() {
13110
+ $api = $this->get_api_site_scope();
13111
+
13112
+ $uid = $this->get_anonymous_id();
13113
+ $request_path = "/users/{$this->_site->user_id}.json?uid={$uid}";
13114
+
13115
+ $result = $api->get( $request_path, false, WP_FS__TIME_10_MIN_IN_SEC );
13116
+
13117
+ if ( $this->is_api_result_entity( $result ) ) {
13118
+ $user = new FS_User( $result );
13119
+ $this->_user = $user;
13120
+ $this->_store_user();
13121
+
13122
+ return $user;
13123
+ }
13124
+
13125
+ $error_code = FS_Api::get_error_code( $result );
13126
+
13127
+ if ( in_array( $error_code, array( 'invalid_unique_id', 'user_cannot_be_recovered' ) ) ) {
13128
+ /**
13129
+ * Those API errors will continue coming and are not recoverable with the
13130
+ * current site's data. Therefore, extend the API call's cached result to 7 days.
13131
+ */
13132
+ $api->update_cache_expiration( $request_path, WP_FS__TIME_WEEK_IN_SEC );
13133
+ }
13134
+
13135
+ return $result;
13136
+ }
13137
+
13138
+ /**
13139
+ * @author Vova Feldman (@svovaf)
13140
+ * @since 1.0.1
13141
+ *
13142
+ * @param FS_User $user
13143
+ * @param FS_Site $site
13144
+ * @param bool|array $plans
13145
+ */
13146
+ private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
13147
+ $site->user_id = $user->id;
13148
+
13149
+ $this->_site = $site;
13150
+ $this->_user = $user;
13151
+ if ( false !== $plans ) {
13152
+ $this->_plans = $plans;
13153
+ }
13154
+
13155
+ $this->send_install_update();
13156
+
13157
+ $this->_store_account();
13158
+
13159
+ }
13160
+
13161
+ /**
13162
+ * @author Vova Feldman (@svovaf)
13163
+ * @since 1.1.7.4
13164
+ *
13165
+ * @param array $override_with
13166
+ * @param bool|int|null $network_level_or_blog_id If true, return params for network level opt-in. If integer, get params for specified blog in the network.
13167
+ *
13168
+ * @return array
13169
+ */
13170
+ function get_opt_in_params( $override_with = array(), $network_level_or_blog_id = null ) {
13171
+ $this->_logger->entrance();
13172
+
13173
+ $current_user = self::_get_current_wp_user();
13174
+
13175
+ $activation_action = $this->get_unique_affix() . '_activate_new';
13176
+ $return_url = $this->is_anonymous() ?
13177
+ // If skipped already, then return to the account page.
13178
+ $this->get_account_url( $activation_action, array(), false ) :
13179
+ // Return to the module's main page.
13180
+ $this->get_after_activation_url( 'after_connect_url', array( 'fs_action' => $activation_action ) );
13181
+
13182
+ $params = array(
13183
+ 'user_firstname' => $current_user->user_firstname,
13184
+ 'user_lastname' => $current_user->user_lastname,
13185
+ 'user_nickname' => $current_user->user_nicename,
13186
+ 'user_email' => $current_user->user_email,
13187
+ 'user_ip' => WP_FS__REMOTE_ADDR,
13188
+ 'plugin_slug' => $this->_slug,
13189
+ 'plugin_id' => $this->get_id(),
13190
+ 'plugin_public_key' => $this->get_public_key(),
13191
+ 'plugin_version' => $this->get_plugin_version(),
13192
+ 'return_url' => fs_nonce_url( $return_url, $activation_action ),
13193
+ 'account_url' => fs_nonce_url( $this->_get_admin_page_url(
13194
+ 'account',
13195
+ array( 'fs_action' => 'sync_user' )
13196
+ ), 'sync_user' ),
13197
+ 'platform_version' => get_bloginfo( 'version' ),
13198
+ 'sdk_version' => $this->version,
13199
+ 'programming_language_version' => phpversion(),
13200
+ 'is_premium' => $this->is_premium(),
13201
+ 'is_active' => true,
13202
+ 'is_uninstalled' => false,
13203
+ );
13204
+
13205
+ if ( true === $network_level_or_blog_id ) {
13206
+ if ( ! isset( $override_with['sites'] ) ) {
13207
+ $params['sites'] = array();
13208
+
13209
+ $sites = self::get_sites();
13210
+
13211
+ foreach ( $sites as $site ) {
13212
+ $blog_id = self::get_site_blog_id( $site );
13213
+ if ( ! $this->is_site_delegated_connection( $blog_id ) &&
13214
+ ! $this->is_installed_on_site( $blog_id )
13215
+ ) {
13216
+ $params['sites'][] = $this->get_site_info( $site );
13217
+ }
13218
+ }
13219
+ }
13220
+ } else {
13221
+ $site = is_numeric( $network_level_or_blog_id ) ?
13222
+ array( 'blog_id' => $network_level_or_blog_id ) :
13223
+ null;
13224
+
13225
+ $site = $this->get_site_info( $site );
13226
+
13227
+ $params = array_merge( $params, array(
13228
+ 'site_uid' => $site['uid'],
13229
+ 'site_url' => $site['url'],
13230
+ 'site_name' => $site['title'],
13231
+ 'language' => $site['language'],
13232
+ 'charset' => $site['charset'],
13233
+ ) );
13234
+ }
13235
+
13236
+ if ( $this->is_pending_activation() &&
13237
+ ! empty( $this->_storage->pending_license_key )
13238
+ ) {
13239
+ $params['license_key'] = $this->_storage->pending_license_key;
13240
+ }
13241
+
13242
+ if ( WP_FS__SKIP_EMAIL_ACTIVATION && $this->has_secret_key() ) {
13243
+ // Even though rand() is known for its security issues,
13244
+ // the timestamp adds another layer of protection.
13245
+ // It would be very hard for an attacker to get the secret key form here.
13246
+ // Plus, this should never run in production since the secret should never
13247
+ // be included in the production version.
13248
+ $params['ts'] = WP_FS__SCRIPT_START_TIME;
13249
+ $params['salt'] = md5( uniqid( rand() ) );
13250
+ $params['secure'] = md5(
13251
+ $params['ts'] .
13252
+ $params['salt'] .
13253
+ $this->get_secret_key()
13254
+ );
13255
+ }
13256
+
13257
+ return array_merge( $params, $override_with );
13258
+ }
13259
+
13260
+ /**
13261
+ * 1. If successful opt-in or pending activation returns the next page that the user should be redirected to.
13262
+ * 2. If there was an API error, return the API result.
13263
+ *
13264
+ * @author Vova Feldman (@svovaf)
13265
+ * @since 1.1.7.4
13266
+ *
13267
+ * @param string|bool $email
13268
+ * @param string|bool $first
13269
+ * @param string|bool $last
13270
+ * @param string|bool $license_key
13271
+ * @param bool $is_uninstall If "true", this means that the module is currently being uninstalled.
13272
+ * In this case, the user and site info will be sent to the server but no
13273
+ * data will be saved to the WP installation's database.
13274
+ * @param number|bool $trial_plan_id
13275
+ * @param bool $is_disconnected Whether or not to opt in without tracking.
13276
+ * @param null|bool $is_marketing_allowed
13277
+ * @param array $sites If network-level opt-in, an array of containing details of sites.
13278
+ *
13279
+ * @return string|object
13280
+ * @use WP_Error
13281
+ */
13282
+ function opt_in(
13283
+ $email = false,
13284
+ $first = false,
13285
+ $last = false,
13286
+ $license_key = false,
13287
+ $is_uninstall = false,
13288
+ $trial_plan_id = false,
13289
+ $is_disconnected = false,
13290
+ $is_marketing_allowed = null,
13291
+ $sites = array()
13292
+ ) {
13293
+ $this->_logger->entrance();
13294
+
13295
+ if ( false === $email ) {
13296
+ $current_user = self::_get_current_wp_user();
13297
+ $email = $current_user->user_email;
13298
+ }
13299
+
13300
+ /**
13301
+ * @since 1.2.1 If activating with license key, ignore the context-user
13302
+ * since the user will be automatically loaded from the license.
13303
+ */
13304
+ if ( empty( $license_key ) ) {
13305
+ // Clean up pending license if opt-ing in again.
13306
+ $this->_storage->remove( 'pending_license_key' );
13307
+
13308
+ if ( ! $is_uninstall ) {
13309
+ $fs_user = Freemius::_get_user_by_email( $email );
13310
+ if ( is_object( $fs_user ) && ! $this->is_pending_activation() ) {
13311
+ return $this->install_with_current_user(
13312
+ false,
13313
+ $trial_plan_id,
13314
+ $sites
13315
+ );
13316
+ }
13317
+ }
13318
+ }
13319
+
13320
+ $user_info = array();
13321
+ if ( ! empty( $email ) ) {
13322
+ $user_info['user_email'] = $email;
13323
+ }
13324
+ if ( ! empty( $first ) ) {
13325
+ $user_info['user_firstname'] = $first;
13326
+ }
13327
+ if ( ! empty( $last ) ) {
13328
+ $user_info['user_lastname'] = $last;
13329
+ }
13330
+
13331
+ if ( ! empty( $sites ) ) {
13332
+ $is_network = true;
13333
+
13334
+ $user_info['sites'] = $sites;
13335
+ } else {
13336
+ $is_network = false;
13337
+ }
13338
+
13339
+ $params = $this->get_opt_in_params( $user_info, $is_network );
13340
+
13341
+ $filtered_license_key = false;
13342
+ if ( is_string( $license_key ) ) {
13343
+ $filtered_license_key = $this->apply_filters( 'license_key', $license_key );
13344
+ $params['license_key'] = $filtered_license_key;
13345
+ } else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) {
13346
+ $params['trial_plan_id'] = $trial_plan_id;
13347
+ }
13348
+
13349
+ if ( $is_uninstall ) {
13350
+ $params['uninstall_params'] = array(
13351
+ 'reason_id' => $this->_storage->uninstall_reason->id,
13352
+ 'reason_info' => $this->_storage->uninstall_reason->info
13353
+ );
13354
+ }
13355
+
13356
+ if ( isset( $params['license_key'] ) ) {
13357
+ $fs_user = Freemius::_get_user_by_email( $email );
13358
+
13359
+ if ( is_object( $fs_user ) ) {
13360
+ /**
13361
+ * If opting in with a context license and the context WP Admin user already opted in
13362
+ * before from the current site, add the user context security params to avoid the
13363
+ * unnecessary email activation when the context license is owned by the same context user.
13364
+ *
13365
+ * @author Leo Fajardo (@leorw)
13366
+ * @since 1.2.3
13367
+ */
13368
+ $params = array_merge( $params, FS_Security::instance()->get_context_params(
13369
+ $fs_user,
13370
+ false,
13371
+ 'install_with_existing_user'
13372
+ ) );
13373
+ }
13374
+ }
13375
+
13376
+ if ( is_bool( $is_marketing_allowed ) ) {
13377
+ $params['is_marketing_allowed'] = $is_marketing_allowed;
13378
+ }
13379
+
13380
+ $params['is_disconnected'] = $is_disconnected;
13381
+ $params['format'] = 'json';
13382
+
13383
+ $request = array(
13384
+ 'method' => 'POST',
13385
+ 'body' => $params,
13386
+ 'timeout' => WP_FS__DEBUG_SDK ? 60 : 30,
13387
+ );
13388
+
13389
+ $url = WP_FS__ADDRESS . '/action/service/user/install/';
13390
+ $response = self::safe_remote_post( $url, $request );
13391
+
13392
+ if ( is_wp_error( $response ) ) {
13393
+ /**
13394
+ * @var WP_Error $response
13395
+ */
13396
+ $result = new stdClass();
13397
+
13398
+ $error_code = $response->get_error_code();
13399
+ $error_type = str_replace( ' ', '', ucwords( str_replace( '_', ' ', $error_code ) ) );
13400
+
13401
+ $result->error = (object) array(
13402
+ 'type' => $error_type,
13403
+ 'message' => $response->get_error_message(),
13404
+ 'code' => $error_code,
13405
+ 'http' => 402
13406
+ );
13407
+
13408
+ return $result;
13409
+ }
13410
+
13411
+ // Module is being uninstalled, don't handle the returned data.
13412
+ if ( $is_uninstall ) {
13413
+ return true;
13414
+ }
13415
+
13416
+ /**
13417
+ * When json_decode() executed on PHP 5.2 with an invalid JSON, it will throw a PHP warning. Unfortunately, the new Theme Check doesn't allow PHP silencing and the theme review team isn't open to change that, therefore, instead of using `@json_decode()` we had to use the method without the `@` directive.
13418
+ *
13419
+ * @author Vova Feldman (@svovaf)
13420
+ * @since 1.2.3
13421
+ * @link https://themes.trac.wordpress.org/ticket/46134#comment:5
13422
+ * @link https://themes.trac.wordpress.org/ticket/46134#comment:9
13423
+ * @link https://themes.trac.wordpress.org/ticket/46134#comment:12
13424
+ * @link https://themes.trac.wordpress.org/ticket/46134#comment:14
13425
+ */
13426
+ $decoded = is_string( $response['body'] ) ?
13427
+ json_decode( $response['body'] ) :
13428
+ null;
13429
+
13430
+ if ( empty( $decoded ) ) {
13431
+ return false;
13432
+ }
13433
+
13434
+ if ( ! $this->is_api_result_object( $decoded ) ) {
13435
+ if ( ! empty( $params['license_key'] ) ) {
13436
+ // Pass the fully entered license key to the failure handler.
13437
+ $params['license_key'] = $license_key;
13438
+ }
13439
+
13440
+ return $is_uninstall ?
13441
+ $decoded :
13442
+ $this->apply_filters( 'after_install_failure', $decoded, $params );
13443
+ } else if ( isset( $decoded->pending_activation ) && $decoded->pending_activation ) {
13444
+ if ( $is_network ) {
13445
+ $site_ids = array();
13446
+ foreach ( $sites as $site ) {
13447
+ $site_ids[] = $site['blog_id'];
13448
+ }
13449
+
13450
+ /**
13451
+ * Store the sites so that they can be installed once the user has clicked on the activation link
13452
+ * in the email.
13453
+ *
13454
+ * @author Leo Fajardo (@leorw)
13455
+ */
13456
+ $this->_storage->pending_sites_info = array(
13457
+ 'blog_ids' => $site_ids,
13458
+ 'license_key' => $license_key,
13459
+ 'trial_plan_id' => $trial_plan_id
13460
+ );
13461
+ }
13462
+
13463
+ // Pending activation, add message.
13464
+ return $this->set_pending_confirmation(
13465
+ ( isset( $decoded->email ) ?
13466
+ $decoded->email :
13467
+ true ),
13468
+ false,
13469
+ $filtered_license_key,
13470
+ ! empty( $params['trial_plan_id'] )
13471
+ );
13472
+ } else if ( isset( $decoded->install_secret_key ) ) {
13473
+ return $this->install_with_new_user(
13474
+ $decoded->user_id,
13475
+ $decoded->user_public_key,
13476
+ $decoded->user_secret_key,
13477
+ ( isset( $decoded->is_marketing_allowed ) && ! is_null( $decoded->is_marketing_allowed ) ?
13478
+ $decoded->is_marketing_allowed :
13479
+ null ),
13480
+ $decoded->install_id,
13481
+ $decoded->install_public_key,
13482
+ $decoded->install_secret_key,
13483
+ false
13484
+ );
13485
+ } else if ( is_array( $decoded->installs ) ) {
13486
+ return $this->install_many_with_new_user(
13487
+ $decoded->user_id,
13488
+ $decoded->user_public_key,
13489
+ $decoded->user_secret_key,
13490
+ ( isset( $decoded->is_marketing_allowed ) && ! is_null( $decoded->is_marketing_allowed ) ?
13491
+ $decoded->is_marketing_allowed :
13492
+ null ),
13493
+ $decoded->installs,
13494
+ false
13495
+ );
13496
+ }
13497
+
13498
+ return $decoded;
13499
+ }
13500
+
13501
+ /**
13502
+ * Set user and site identities.
13503
+ *
13504
+ * @author Vova Feldman (@svovaf)
13505
+ * @since 1.0.9
13506
+ *
13507
+ * @param FS_User $user
13508
+ * @param FS_Site $site
13509
+ * @param bool $redirect
13510
+ * @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
13511
+ * redirect (or return a URL) to the account page with a special parameter to
13512
+ * trigger the auto installation processes.
13513
+ *
13514
+ * @return string If redirect is `false`, returns the next page the user should be redirected to.
13515
+ */
13516
+ function setup_account(
13517
+ FS_User $user,
13518
+ FS_Site $site,
13519
+ $redirect = true,
13520
+ $auto_install = false
13521
+ ) {
13522
+ return $this->setup_network_account(
13523
+ $user,
13524
+ array( $site ),
13525
+ $redirect,
13526
+ $auto_install,
13527
+ false
13528
+ );
13529
+ }
13530
+
13531
+ /**
13532
+ * Set user and site identities.
13533
+ *
13534
+ * @author Vova Feldman (@svovaf)
13535
+ * @since 2.0.0
13536
+ *
13537
+ * @param FS_User $user
13538
+ * @param FS_Site[] $installs
13539
+ * @param bool $redirect
13540
+ * @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will redirect (or return a URL) to the account page with a special parameter to trigger the auto installation processes.
13541
+ * @param bool $is_network_level_opt_in
13542
+ *
13543
+ * @return string If redirect is `false`, returns the next page the user should be redirected to.
13544
+ */
13545
+ function setup_network_account(
13546
+ FS_User $user,
13547
+ array $installs,
13548
+ $redirect = true,
13549
+ $auto_install = false,
13550
+ $is_network_level_opt_in = true
13551
+ ) {
13552
+ $first_install = $installs[0];
13553
+
13554
+ $this->_user = $user;
13555
+ $this->_site = $first_install;
13556
+
13557
+ $this->_sync_plans();
13558
+
13559
+ if ( $this->_storage->handle_gdpr_admin_notice &&
13560
+ $this->should_handle_gdpr_admin_notice() &&
13561
+ FS_GDPR_Manager::instance()->should_show_opt_in_notice()
13562
+ ) {
13563
+ /**
13564
+ * Clear user lock after an opt-in.
13565
+ */
13566
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-user-lock.php';
13567
+ FS_User_Lock::instance()->unlock();
13568
+ }
13569
+
13570
+ if ( 1 < count( $installs ) ) {
13571
+ // Only network level opt-in can have more than one install.
13572
+ $is_network_level_opt_in = true;
13573
+ }
13574
+ // $is_network_level_opt_in = self::is_ajax_action_static( 'network_activate', $this->_module_id );
13575
+ // If Freemius was OFF before, turn it on.
13576
+ $this->turn_on();
13577
+
13578
+ if ( ! $this->_is_network_active || ! $is_network_level_opt_in ) {
13579
+ $this->_set_account( $user, $first_install );
13580
+
13581
+ $this->do_action( 'after_account_connection', $user, $first_install );
13582
+ } else {
13583
+ $this->_store_user();
13584
+
13585
+ // Map site addresses to their blog IDs.
13586
+ $address_to_blog_map = $this->get_address_to_blog_map();
13587
+
13588
+ $first_blog_id = null;
13589
+ $blog_2_install_map = array();
13590
+ foreach ( $installs as $install ) {
13591
+ $address = trailingslashit( fs_strip_url_protocol( $install->url ) );
13592
+ $blog_id = $address_to_blog_map[ $address ];
13593
+
13594
+ $this->_store_site( true, $blog_id, $install );
13595
+
13596
+ if ( is_null( $first_blog_id ) ) {
13597
+ $first_blog_id = $blog_id;
13598
+ }
13599
+
13600
+ $blog_2_install_map[ $blog_id ] = $install;
13601
+ }
13602
+
13603
+ if ( ! FS_User::is_valid_id( $this->_storage->network_user_id ) ||
13604
+ ! is_object( self::_get_user_by_id( $this->_storage->network_user_id ) )
13605
+ ) {
13606
+ // Store network user.
13607
+ $this->_storage->network_user_id = $this->_user->id;
13608
+ }
13609
+
13610
+ if ( ! FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ) {
13611
+ $this->_storage->network_install_blog_id = $first_blog_id;
13612
+ }
13613
+
13614
+ if ( count( $installs ) === count( $address_to_blog_map ) ) {
13615
+ // Super-admin opted-in for all sites in the network.
13616
+ $this->_storage->is_network_connected = true;
13617
+ }
13618
+
13619
+ $this->_store_licenses( false );
13620
+
13621
+ self::$_accounts->store();
13622
+
13623
+ // Don't sync the installs data on network upgrade
13624
+ if ( ! $this->network_upgrade_mode_completed() ) {
13625
+ $this->send_installs_update();
13626
+ }
13627
+
13628
+ // Switch install context back to the first install.
13629
+ $this->_site = $first_install;
13630
+
13631
+ $current_blog = get_current_blog_id();
13632
+
13633
+ foreach ( $blog_2_install_map a