Changeset 2822242
- Timestamp:
- 11/22/2022 03:11:35 PM (3 years ago)
- Location:
- embed-rentle
- Files:
-
- 8 edited
- 13 copied
-
tags/1.2 (copied) (copied from embed-rentle/trunk)
-
tags/1.2/dist (copied) (copied from embed-rentle/trunk/dist)
-
tags/1.2/dist/blocks.build.js (copied) (copied from embed-rentle/trunk/dist/blocks.build.js) (1 diff)
-
tags/1.2/library (copied) (copied from embed-rentle/trunk/library)
-
tags/1.2/library/embed-rentle-classes.php (copied) (copied from embed-rentle/trunk/library/embed-rentle-classes.php) (4 diffs)
-
tags/1.2/package-lock.json (copied) (copied from embed-rentle/trunk/package-lock.json)
-
tags/1.2/package.json (copied) (copied from embed-rentle/trunk/package.json)
-
tags/1.2/plugin.php (copied) (copied from embed-rentle/trunk/plugin.php) (1 diff)
-
tags/1.2/readme.md (copied) (copied from embed-rentle/trunk/readme.md) (1 diff)
-
tags/1.2/readme.txt (copied) (copied from embed-rentle/trunk/readme.txt) (2 diffs)
-
tags/1.2/src (copied) (copied from embed-rentle/trunk/src)
-
tags/1.2/src/embed-rentle/block.js (copied) (copied from embed-rentle/trunk/src/embed-rentle/block.js) (3 diffs)
-
tags/1.2/src/embed-rentle/lib (copied) (copied from embed-rentle/trunk/src/embed-rentle/lib)
-
tags/1.2/src/init.php (modified) (3 diffs)
-
trunk/dist/blocks.build.js (modified) (1 diff)
-
trunk/library/embed-rentle-classes.php (modified) (4 diffs)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/readme.md (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/embed-rentle/block.js (modified) (3 diffs)
-
trunk/src/init.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
embed-rentle/tags/1.2/dist/blocks.build.js
r2533135 r2822242 1 !function(e){function t(l){if(n[l])return n[l].exports;var r=n[l]={i:l,l:!1,exports:{}};return e[l].call(r.exports,r,r.exports,t),r.l=!0,r.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=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";var l=n(2),r=n.n(l),o=n(3),a=(n.n(o),n(4)),c=(n.n(a),n(5)),i=n(6),p=n(7),__=wp.i18n.__,u=wp.blocks.registerBlockType,d=wp.blockEditor.InspectorControls,s=wp.element,h=s.Fragment,m=(s.RawHTML,wp.components),g=m.TextControl,w=m.SelectControl,f=m.PanelBody,b=m.PanelRow;u("embed-rentle/shop-block",{title:__("Rentle shop block"),icon:Object(i.a)(),category:"widgets",keywords:[__("rentle")],supports:{html:!1,reusable:!0,align:["full","wide"]},attributes:{shopId:{type:"string"},locationId:{type:"string"},categoryId:{type:"string"},productId:{type:"string"},paddingSize:{type:"string"}},edit:function(e){var t=e.attributes,n=e.className,l=e.setAttributes;return wp.element.createElement(h,null,wp.element.createElement(d,null,wp.element.createElement(f,null,wp.element.createElement(b,null,wp.element.createElement(g,{value:t.shopId,type:"string",onChange:function(e){return l({shopId:e})},placeholder:"Shop ID",label:"Shop ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.locationId,type:"string",onChange:function(e){return l({locationId:e})},placeholder:"Location ID",label:"Location ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.categoryId,type:"string",onChange:function(e){return l({categoryId:e})},placeholder:"Category ID",label:"Category ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.productId,type:"string",onChange:function(e){return l({productId:e})},placeholder:"Product ID",label:"Product ID"})),wp.element.createElement(b,null,wp.element.createElement(w,{label:__("Padding"),value:t.paddingSize,options:[{label:"No padding",value:"no-padding"},{label:"Small padding",value:"small-padding"},{label:"Medium padding",value:"medium-padding"},{label:"Large padding",value:"large-padding"}],onChange:function(e){return l({paddingSize:e})}})))),wp.element.createElement("div",{className:r()(n,t.paddingSize)},Object(c.a)(),!t.shopId&&Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("You need to define shop id.")),t.shopId&&!Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("There is something wrong with the settings. Shop, location, category or product ID should include only letters or numbers.")),t.shopId&&Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",null,__("Your widget is ready. Just preview the page and see it in action."))))},save:function(e){return null}})},function(e,t,n){var l,r;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var l=arguments[t];if(l){var r=typeof l;if("string"===r||"number"===r)e.push(l);else if(Array.isArray(l)&&l.length){var a=n.apply(null,l);a&&e.push(a)}else if("object"===r)for(var c in l)o.call(l,c)&&l[c]&&e.push(c)}}return e.join(" ")}var o={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?(n.default=n,e.exports=n):(l=[],void 0!==(r=function(){return n}.apply(t,l))&&(e.exports=r))}()},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"306",height:"84",viewBox:"0 0 306 84"},wp.element.createElement("path",{d:"M40.126 41.833l20.49 41.833H23.164c-15.06 0-24.792-4.723-22.938-19.342 1.622-16.643 13.67-22.49 28.731-22.49h11.169zm122.6-10.143c7.375 0 16.612 4.845 16.612 16.704 0 2.242-.214 4.483-.787 6.942h-26.28c1.146 3.978 4.082 5.858 8.736 5.858 4.797 0 6.588-1.23 8.95-2.387l5.444 6.147c-3.582 3.471-8.022 5.712-15.252 5.712-8.952 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.339-21.332zm126.161 0c7.375 0 16.613 4.845 16.613 16.704 0 2.242-.214 4.483-.788 6.942h-26.28c1.147 3.978 4.082 5.858 8.736 5.858 4.798 0 6.589-1.23 8.952-2.387l5.442 6.147c-3.58 3.471-8.02 5.712-15.252 5.712-8.95 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.34-21.332zM123.236 19.381c11.236 0 18.178 7.037 16.962 17.879-.644 6.39-4.08 11.272-9.59 14.072l9.661 18.309h-11.88l-8.374-16.442h-6.442l-1.717 16.442h-11.522l5.295-50.26h17.606zM207.87 31.69c6.886 0 13.56 4.744 12.353 16.676l-2.272 21.275h-11.216l2.2-20.772c.71-5.895-2.13-7.332-5.184-7.332-5.252 0-8.305 4.959-8.66 6.541l-2.485 21.563H181.39l3.905-37.376h11.218l-.71 6.253c.852-1.797 5.04-6.828 12.07-6.828zm34.141-12.309l-.94 11.961h8.04l-.87 9.466h-8.04l-1.666 15.29c-.216 1.675-.144 3.495 2.535 3.495 2.029 0 3.405-.219 5.506-.51l-.797 9.32c-1.883.801-4.49 1.238-8.113 1.238-6.52 0-11.734-2.33-10.577-13.979l1.666-14.854h-5.286l.869-9.466h5.286l.944-8.884 11.444-3.077zm24.512 0l-5.284 50.26h-11.127l5.281-50.26h11.13zm-103.575 21.54c-3.904 0-7.302 1.9-9.254 6.155h16.412c-.868-4.407-3.47-6.155-7.157-6.155zm126.162 0c-3.904 0-7.301 1.9-9.253 6.155h16.41c-.866-4.407-3.47-6.155-7.156-6.155zM121.838 29.639h-5.773l-1.371 13.334h5.34c4.69 0 8.443-1.864 8.948-7.169.578-4.66-2.454-6.165-7.144-6.165zM60.503 0c15.06 0 24.791 4.723 22.938 19.342-1.622 16.643-13.67 22.491-28.731 22.491H40.126L19.636 0h40.867z"}))}t.a=l},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},wp.element.createElement("path",{fillRule:"evenodd",d:"M16.85 0c2.884 0 4.85.64 6.011 1.959.941 1.067 1.302 2.528 1.072 4.34-.429 4.402-3.479 6.833-8.587 6.833H13.37L18.695 24H7.15c-2.884 0-4.85-.64-6.011-1.959-.941-1.067-1.302-2.528-1.072-4.34.429-4.402 3.479-6.833 8.588-6.833h1.087L4.418 0h12.433zm-6 13.132H8.655c-3.95 0-6.023 1.577-6.339 4.821-.149 1.181.022 2.025.521 2.592.697.79 2.148 1.191 4.313 1.191h7.915l-4.215-8.604zm6-10.868H8.049l4.214 8.604h3.084c3.948 0 6.021-1.577 6.337-4.82.15-1.182-.02-2.026-.52-2.593-.697-.79-2.148-1.191-4.312-1.191z"}))}t.a=l},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var l=function(e){return e.match("^[A-Za-z0-9]+$")},r=function(e,t,n,r){return!(e&&!l(e))&&(!(t&&!l(t))&&(!(n&&!l(n))&&!(r&&!l(r))))}}]);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=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";var l=n(2),o=n.n(l),a=n(3),r=(n.n(a),n(4)),i=(n.n(r),n(5)),c=n(6),s=n(7),__=wp.i18n.__,u=wp.blocks.registerBlockType,p=wp.blockEditor.InspectorControls,d=wp.element,h=d.Fragment,m=(d.RawHTML,wp.components),g=m.TextControl,w=m.ToggleControl,b=m.SelectControl,f=m.PanelBody,y=m.PanelRow;u("embed-rentle/shop-block",{title:__("Rentle shop block"),icon:Object(c.a)(),category:"widgets",keywords:[__("rentle")],supports:{html:!1,reusable:!0,align:["full","wide"]},attributes:{shopId:{type:"string"},locationId:{type:"string"},categoryId:{type:"string"},productId:{type:"string"},paddingSize:{type:"string"},disableAutoScroll:{type:"boolean",default:!1},disableHeightAnimation:{type:"boolean",default:!1},locationsView:{type:"boolean",default:!1}},edit:function(e){var t=e.attributes,n=e.className,l=e.setAttributes;return wp.element.createElement(h,null,wp.element.createElement(p,null,wp.element.createElement(f,null,wp.element.createElement(y,null,wp.element.createElement(g,{value:t.shopId,type:"string",onChange:function(e){return l({shopId:e})},placeholder:"Shop ID",label:"Shop ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.locationId,type:"string",onChange:function(e){return l({locationId:e})},placeholder:"Location ID",label:"Location ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.categoryId,type:"string",onChange:function(e){return l({categoryId:e})},placeholder:"Category ID",label:"Category ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.productId,type:"string",onChange:function(e){return l({productId:e})},placeholder:"Product ID",label:"Product ID"})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Disable auto scroll"),checked:t.disableAutoScroll,help:"By default, your website user is automatically scrolled to the top of the embedded store when the page changes or a dialog is shown inside the embed. This improves user experience in most cases, but you can disable this by enabling this setting.",onChange:function(){return l({disableAutoScroll:!t.disableAutoScroll})}})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Disable height animation"),checked:t.disableHeightAnimation,help:"By default, when the height of the embedded store changes, the height is animated to its new value to prevent stutter. You can disable by enabling this setting.",onChange:function(){return l({disableHeightAnimation:!t.disableHeightAnimation})}})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Locations view"),checked:t.locationsView,help:"If you have multiple stores and want to display all the store options for the customer, enable this setting.",onChange:function(){return l({locationsView:!t.locationsView})}})),wp.element.createElement(y,null,wp.element.createElement(b,{label:__("Padding"),value:t.paddingSize,options:[{label:"No padding",value:"no-padding"},{label:"Small padding",value:"small-padding"},{label:"Medium padding",value:"medium-padding"},{label:"Large padding",value:"large-padding"}],onChange:function(e){return l({paddingSize:e})}})))),wp.element.createElement("div",{className:o()(n,t.paddingSize)},Object(i.a)(),!t.shopId&&Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("You need to define shop id.")),t.shopId&&!Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("There is something wrong with the settings. Shop, location, category or product ID should include only letters or numbers.")),t.shopId&&Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",null,__("Your widget is ready. Just preview the page and see it in action."))))},save:function(e){return null}})},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 r=n.apply(null,l);r&&e.push(r)}else if("object"===o)for(var i in l)a.call(l,i)&&l[i]&&e.push(i)}}return e.join(" ")}var a={}.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";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"306",height:"84",viewBox:"0 0 306 84"},wp.element.createElement("path",{d:"M40.126 41.833l20.49 41.833H23.164c-15.06 0-24.792-4.723-22.938-19.342 1.622-16.643 13.67-22.49 28.731-22.49h11.169zm122.6-10.143c7.375 0 16.612 4.845 16.612 16.704 0 2.242-.214 4.483-.787 6.942h-26.28c1.146 3.978 4.082 5.858 8.736 5.858 4.797 0 6.588-1.23 8.95-2.387l5.444 6.147c-3.582 3.471-8.022 5.712-15.252 5.712-8.952 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.339-21.332zm126.161 0c7.375 0 16.613 4.845 16.613 16.704 0 2.242-.214 4.483-.788 6.942h-26.28c1.147 3.978 4.082 5.858 8.736 5.858 4.798 0 6.589-1.23 8.952-2.387l5.442 6.147c-3.58 3.471-8.02 5.712-15.252 5.712-8.95 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.34-21.332zM123.236 19.381c11.236 0 18.178 7.037 16.962 17.879-.644 6.39-4.08 11.272-9.59 14.072l9.661 18.309h-11.88l-8.374-16.442h-6.442l-1.717 16.442h-11.522l5.295-50.26h17.606zM207.87 31.69c6.886 0 13.56 4.744 12.353 16.676l-2.272 21.275h-11.216l2.2-20.772c.71-5.895-2.13-7.332-5.184-7.332-5.252 0-8.305 4.959-8.66 6.541l-2.485 21.563H181.39l3.905-37.376h11.218l-.71 6.253c.852-1.797 5.04-6.828 12.07-6.828zm34.141-12.309l-.94 11.961h8.04l-.87 9.466h-8.04l-1.666 15.29c-.216 1.675-.144 3.495 2.535 3.495 2.029 0 3.405-.219 5.506-.51l-.797 9.32c-1.883.801-4.49 1.238-8.113 1.238-6.52 0-11.734-2.33-10.577-13.979l1.666-14.854h-5.286l.869-9.466h5.286l.944-8.884 11.444-3.077zm24.512 0l-5.284 50.26h-11.127l5.281-50.26h11.13zm-103.575 21.54c-3.904 0-7.302 1.9-9.254 6.155h16.412c-.868-4.407-3.47-6.155-7.157-6.155zm126.162 0c-3.904 0-7.301 1.9-9.253 6.155h16.41c-.866-4.407-3.47-6.155-7.156-6.155zM121.838 29.639h-5.773l-1.371 13.334h5.34c4.69 0 8.443-1.864 8.948-7.169.578-4.66-2.454-6.165-7.144-6.165zM60.503 0c15.06 0 24.791 4.723 22.938 19.342-1.622 16.643-13.67 22.491-28.731 22.491H40.126L19.636 0h40.867z"}))}t.a=l},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},wp.element.createElement("path",{fillRule:"evenodd",d:"M16.85 0c2.884 0 4.85.64 6.011 1.959.941 1.067 1.302 2.528 1.072 4.34-.429 4.402-3.479 6.833-8.587 6.833H13.37L18.695 24H7.15c-2.884 0-4.85-.64-6.011-1.959-.941-1.067-1.302-2.528-1.072-4.34.429-4.402 3.479-6.833 8.588-6.833h1.087L4.418 0h12.433zm-6 13.132H8.655c-3.95 0-6.023 1.577-6.339 4.821-.149 1.181.022 2.025.521 2.592.697.79 2.148 1.191 4.313 1.191h7.915l-4.215-8.604zm6-10.868H8.049l4.214 8.604h3.084c3.948 0 6.021-1.577 6.337-4.82.15-1.182-.02-2.026-.52-2.593-.697-.79-2.148-1.191-4.312-1.191z"}))}t.a=l},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var l=function(e){return e.match("^[A-Za-z0-9]+$")},o=function(e,t,n,o){return!(e&&!l(e))&&(!(t&&!l(t))&&(!(n&&!l(n))&&!(o&&!l(o))))}}]); -
embed-rentle/tags/1.2/library/embed-rentle-classes.php
r2467184 r2822242 11 11 } else { 12 12 ?> 13 < iframe width="100%" height="100%" src="<?php echo self::create_iframe_src( $attributes ); ?>"></iframe>13 <rentle-store <?php self::set_web_component_attributes( $attributes ); ?> /> 14 14 <?php 15 15 } … … 17 17 </div> 18 18 <?php 19 } 20 21 public static function set_web_component_attributes( $attributes ) { 22 if ( ! empty( $attributes['shopId'] ) ) { 23 echo ' shop="' . esc_attr( $attributes['shopId'] ) . '"'; 24 } 25 26 if ( ! empty( $attributes['locationId'] ) ) { 27 echo ' store="' . esc_attr( $attributes['locationId'] ) . '"'; 28 } 29 30 if ( ! empty( $attributes['categoryId'] ) ) { 31 echo ' category="' . esc_attr( $attributes['categoryId'] ) . '"'; 32 } 33 34 if ( ! empty( $attributes['productId'] ) ) { 35 echo ' product="' . esc_attr( $attributes['productId'] ) . '"'; 36 } 37 38 if ( isset( $attributes['disableAutoScroll'] ) && true === $attributes['disableAutoScroll'] ) { 39 echo ' disableautoscroll="true"'; 40 } 41 42 if ( isset( $attributes['disableHeightAnimation'] ) && true === $attributes['disableHeightAnimation'] ) { 43 echo ' disableheightanimation="true"'; 44 } 45 46 if ( isset( $attributes['locationsView'] ) && true === $attributes['locationsView'] ) { 47 echo ' locationsview="true"'; 48 } 49 50 // Add height:100% 51 echo ' height="100%"'; 52 53 // Add lang automatically 54 echo ' lang="' . esc_attr( self::get_locale() ) . '"'; 19 55 } 20 56 … … 42 78 } 43 79 44 public static function create_iframe_src( $attributes ) { 45 $base_url = "https://rentle.store/{$attributes['shopId']}"; 46 $category_request = false; 47 48 // Show by shop name 49 if ( empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 50 $url = $base_url; 80 private static function get_locale() { 81 // Look for polylang installation 82 if ( function_exists( 'pll_current_language' ) ) { 83 return pll_current_language(); 51 84 } 52 85 53 // Show by location 54 if ( ! empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 55 $url = "{$base_url}/l/{$attributes['locationId']}/"; 56 } 57 58 // Show by product 59 if ( ( empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) || ( empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) ) { 60 $url = "{$base_url}/product/{$attributes['productId']}/"; 61 } 62 63 // Show by product and location 64 if ( ! empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) { 65 $url = "{$base_url}/l/{$attributes['locationId']}/product/{$attributes['productId']}/"; 66 } 67 68 // Show by category 69 if ( empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 70 $url = "{$base_url}/shop?category={$attributes['categoryId']}"; 71 $category_request = true; 72 } 73 74 // Show by category and location 75 if ( ! empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 76 $url = "{$base_url}/l/{$attributes['locationId']}/shop?category={$attributes['categoryId']}"; 77 $category_request = true; 78 } 79 80 // all filled, show by product and location 81 if ( ! empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) { 82 $url = "{$base_url}/l/{$attributes['locationId']}/product/{$attributes['productId']}/"; 83 } 84 85 86 // Adding lang code 87 if ( $category_request ) { 88 $url .= self::setting_iframe_locale( '&' ); 89 } else { 90 $url .= self::setting_iframe_locale(); 91 } 92 93 return $url; 94 } 95 96 private static function setting_iframe_locale( $start_with = '?' ) { 97 $string = $start_with . 'lang=' . substr( get_locale(), 0, 2 ); // Need only first two letters of country code 98 99 // Look for polylang installation 100 if ( function_exists( 'pll_current_language' ) ) { 101 $string = '?lang=' . pll_current_language(); 102 } 103 104 return $string; 86 return substr( get_locale(), 0, 2 ); 105 87 } 106 88 … … 146 128 } 147 129 130 if ( isset( $atts['disableautoscroll'] ) ) { 131 $atts['disableAutoScroll'] = $atts['disableautoscroll']; 132 unset( $atts['disableautoscroll'] ); 133 } 134 135 if ( isset( $atts['disableheightanimation'] ) ) { 136 $atts['disableHeightAnimation'] = $atts['disableheightanimation']; 137 unset( $atts['disableheightanimation'] ); 138 } 139 140 if ( isset( $atts['locationsview'] ) ) { 141 $atts['locationsView'] = $atts['locationsview']; 142 unset( $atts['locationsview'] ); 143 } 144 148 145 if ( isset( $atts['padding'] ) ) { 149 146 $atts['paddingSize'] = $atts['padding']; -
embed-rentle/tags/1.2/plugin.php
r2533135 r2822242 6 6 * Author: rentle 7 7 * Author URI: https://www.rentle.io/ 8 * Version: 1. 1.18 * Version: 1.2 9 9 * License: GPL2+ 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt -
embed-rentle/tags/1.2/readme.md
r2467184 r2822242 27 27 - `product` ==> specific product you want to show 28 28 - `padding` ==> vertical padding of the shop block. Can be one of the following: `no-padding`, `small-padding`, `medium-padding`, `large-padding` 29 - `disableautoscroll` ==> set to true, if you want to disable auto scroll 30 - `disableheightanimation` ==> set to true, if you want to disable height animation 31 - `locationsview` => set to true, if you want to list all store options 29 32 - `class` ==> if you want to wrap the element to custom class 30 33 -
embed-rentle/tags/1.2/readme.txt
r2821953 r2822242 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1. 1.17 Stable tag: 1.2 8 8 License: GPLv2 9 9 … … 149 149 150 150 == Changelog == 151 1.2 Change to rentle web component 151 152 1.1.1 Add validation for shopID, locationID, categoryID and productID 152 153 1.1 Change iframe shop urls -
embed-rentle/tags/1.2/src/embed-rentle/block.js
r2533135 r2822242 15 15 const {InspectorControls} = wp.blockEditor; 16 16 const {Fragment, RawHTML} = wp.element; 17 const {TextControl, SelectControl, PanelBody, PanelRow} = wp.components;17 const {TextControl, ToggleControl, SelectControl, PanelBody, PanelRow} = wp.components; 18 18 19 19 //Import lib … … 54 54 paddingSize: { 55 55 type: 'string' 56 }, 57 disableAutoScroll: { 58 type: 'boolean', 59 default: false 60 }, 61 disableHeightAnimation: { 62 type: 'boolean', 63 default: false 64 }, 65 locationsView: { 66 type: 'boolean', 67 default: false 56 68 } 57 69 }, … … 102 114 </PanelRow> 103 115 <PanelRow> 116 <ToggleControl 117 label={__('Disable auto scroll')} 118 checked={ attributes.disableAutoScroll } 119 help={`By default, your website user is automatically scrolled to the top of the embedded store when the page changes or a dialog is shown inside the embed. This improves user experience in most cases, but you can disable this by enabling this setting.`} 120 onChange={ () => setAttributes( { disableAutoScroll: ! attributes.disableAutoScroll } ) } 121 /> 122 </PanelRow> 123 <PanelRow> 124 <ToggleControl 125 label={__('Disable height animation')} 126 checked={ attributes.disableHeightAnimation } 127 help={`By default, when the height of the embedded store changes, the height is animated to its new value to prevent stutter. You can disable by enabling this setting.`} 128 onChange={ () => setAttributes( { disableHeightAnimation: ! attributes.disableHeightAnimation } ) } 129 /> 130 </PanelRow> 131 <PanelRow> 132 <ToggleControl 133 label={__('Locations view')} 134 checked={ attributes.locationsView } 135 help={`If you have multiple stores and want to display all the store options for the customer, enable this setting.`} 136 onChange={ () => setAttributes( { locationsView: ! attributes.locationsView } ) } 137 /> 138 </PanelRow> 139 <PanelRow> 104 140 <SelectControl 105 141 label={__('Padding')} -
embed-rentle/tags/1.2/src/init.php
r2333955 r2822242 16 16 function __construct() { 17 17 add_action( 'init', [ $this, 'initialize_hooks' ] ); 18 add_action( 'wp_head', [ $this, 'hook_rentle_js' ] ); 18 19 } 19 20 … … 26 27 $this->register_assets(); 27 28 add_shortcode( 'rentle_shop', [ $this, 'rentle_output_render_callback' ] ); 29 } 30 31 public function hook_rentle_js() { 32 global $post; 33 if ( ! has_block( 'embed-rentle/shop-block', $post->ID ) && ! has_shortcode( $post->post_content, 'rentle_shop' ) ) { 34 return; 35 } 36 ?> 37 <script type="text/javascript" src="https://cdn.rentle.io/embed/bundle.js" defer></script> 38 <?php 28 39 } 29 40 … … 78 89 'embed-rentle/shop-block', array( 79 90 // Enqueue blocks.style.build.css on both frontend & backend. 80 'style' => 'embed_rentle-style-css',91 'style' => 'embed_rentle-style-css', 81 92 // Enqueue blocks.build.js in the editor only. 82 'editor_script' => 'embed_rentle-block-js',93 'editor_script' => 'embed_rentle-block-js', 83 94 // Enqueue blocks.editor.build.css in the editor only. 84 'editor_style' => 'embed_rentle-block-editor-css',95 'editor_style' => 'embed_rentle-block-editor-css', 85 96 // PHP rendering callback 86 97 'render_callback' => [ $this, 'rentle_output_render_callback' ], -
embed-rentle/trunk/dist/blocks.build.js
r2533135 r2822242 1 !function(e){function t(l){if(n[l])return n[l].exports;var r=n[l]={i:l,l:!1,exports:{}};return e[l].call(r.exports,r,r.exports,t),r.l=!0,r.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=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";var l=n(2),r=n.n(l),o=n(3),a=(n.n(o),n(4)),c=(n.n(a),n(5)),i=n(6),p=n(7),__=wp.i18n.__,u=wp.blocks.registerBlockType,d=wp.blockEditor.InspectorControls,s=wp.element,h=s.Fragment,m=(s.RawHTML,wp.components),g=m.TextControl,w=m.SelectControl,f=m.PanelBody,b=m.PanelRow;u("embed-rentle/shop-block",{title:__("Rentle shop block"),icon:Object(i.a)(),category:"widgets",keywords:[__("rentle")],supports:{html:!1,reusable:!0,align:["full","wide"]},attributes:{shopId:{type:"string"},locationId:{type:"string"},categoryId:{type:"string"},productId:{type:"string"},paddingSize:{type:"string"}},edit:function(e){var t=e.attributes,n=e.className,l=e.setAttributes;return wp.element.createElement(h,null,wp.element.createElement(d,null,wp.element.createElement(f,null,wp.element.createElement(b,null,wp.element.createElement(g,{value:t.shopId,type:"string",onChange:function(e){return l({shopId:e})},placeholder:"Shop ID",label:"Shop ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.locationId,type:"string",onChange:function(e){return l({locationId:e})},placeholder:"Location ID",label:"Location ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.categoryId,type:"string",onChange:function(e){return l({categoryId:e})},placeholder:"Category ID",label:"Category ID"})),wp.element.createElement(b,null,wp.element.createElement(g,{value:t.productId,type:"string",onChange:function(e){return l({productId:e})},placeholder:"Product ID",label:"Product ID"})),wp.element.createElement(b,null,wp.element.createElement(w,{label:__("Padding"),value:t.paddingSize,options:[{label:"No padding",value:"no-padding"},{label:"Small padding",value:"small-padding"},{label:"Medium padding",value:"medium-padding"},{label:"Large padding",value:"large-padding"}],onChange:function(e){return l({paddingSize:e})}})))),wp.element.createElement("div",{className:r()(n,t.paddingSize)},Object(c.a)(),!t.shopId&&Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("You need to define shop id.")),t.shopId&&!Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("There is something wrong with the settings. Shop, location, category or product ID should include only letters or numbers.")),t.shopId&&Object(p.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",null,__("Your widget is ready. Just preview the page and see it in action."))))},save:function(e){return null}})},function(e,t,n){var l,r;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var l=arguments[t];if(l){var r=typeof l;if("string"===r||"number"===r)e.push(l);else if(Array.isArray(l)&&l.length){var a=n.apply(null,l);a&&e.push(a)}else if("object"===r)for(var c in l)o.call(l,c)&&l[c]&&e.push(c)}}return e.join(" ")}var o={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?(n.default=n,e.exports=n):(l=[],void 0!==(r=function(){return n}.apply(t,l))&&(e.exports=r))}()},function(e,t){},function(e,t){},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"306",height:"84",viewBox:"0 0 306 84"},wp.element.createElement("path",{d:"M40.126 41.833l20.49 41.833H23.164c-15.06 0-24.792-4.723-22.938-19.342 1.622-16.643 13.67-22.49 28.731-22.49h11.169zm122.6-10.143c7.375 0 16.612 4.845 16.612 16.704 0 2.242-.214 4.483-.787 6.942h-26.28c1.146 3.978 4.082 5.858 8.736 5.858 4.797 0 6.588-1.23 8.95-2.387l5.444 6.147c-3.582 3.471-8.022 5.712-15.252 5.712-8.952 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.339-21.332zm126.161 0c7.375 0 16.613 4.845 16.613 16.704 0 2.242-.214 4.483-.788 6.942h-26.28c1.147 3.978 4.082 5.858 8.736 5.858 4.798 0 6.589-1.23 8.952-2.387l5.442 6.147c-3.58 3.471-8.02 5.712-15.252 5.712-8.95 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.34-21.332zM123.236 19.381c11.236 0 18.178 7.037 16.962 17.879-.644 6.39-4.08 11.272-9.59 14.072l9.661 18.309h-11.88l-8.374-16.442h-6.442l-1.717 16.442h-11.522l5.295-50.26h17.606zM207.87 31.69c6.886 0 13.56 4.744 12.353 16.676l-2.272 21.275h-11.216l2.2-20.772c.71-5.895-2.13-7.332-5.184-7.332-5.252 0-8.305 4.959-8.66 6.541l-2.485 21.563H181.39l3.905-37.376h11.218l-.71 6.253c.852-1.797 5.04-6.828 12.07-6.828zm34.141-12.309l-.94 11.961h8.04l-.87 9.466h-8.04l-1.666 15.29c-.216 1.675-.144 3.495 2.535 3.495 2.029 0 3.405-.219 5.506-.51l-.797 9.32c-1.883.801-4.49 1.238-8.113 1.238-6.52 0-11.734-2.33-10.577-13.979l1.666-14.854h-5.286l.869-9.466h5.286l.944-8.884 11.444-3.077zm24.512 0l-5.284 50.26h-11.127l5.281-50.26h11.13zm-103.575 21.54c-3.904 0-7.302 1.9-9.254 6.155h16.412c-.868-4.407-3.47-6.155-7.157-6.155zm126.162 0c-3.904 0-7.301 1.9-9.253 6.155h16.41c-.866-4.407-3.47-6.155-7.156-6.155zM121.838 29.639h-5.773l-1.371 13.334h5.34c4.69 0 8.443-1.864 8.948-7.169.578-4.66-2.454-6.165-7.144-6.165zM60.503 0c15.06 0 24.791 4.723 22.938 19.342-1.622 16.643-13.67 22.491-28.731 22.491H40.126L19.636 0h40.867z"}))}t.a=l},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},wp.element.createElement("path",{fillRule:"evenodd",d:"M16.85 0c2.884 0 4.85.64 6.011 1.959.941 1.067 1.302 2.528 1.072 4.34-.429 4.402-3.479 6.833-8.587 6.833H13.37L18.695 24H7.15c-2.884 0-4.85-.64-6.011-1.959-.941-1.067-1.302-2.528-1.072-4.34.429-4.402 3.479-6.833 8.588-6.833h1.087L4.418 0h12.433zm-6 13.132H8.655c-3.95 0-6.023 1.577-6.339 4.821-.149 1.181.022 2.025.521 2.592.697.79 2.148 1.191 4.313 1.191h7.915l-4.215-8.604zm6-10.868H8.049l4.214 8.604h3.084c3.948 0 6.021-1.577 6.337-4.82.15-1.182-.02-2.026-.52-2.593-.697-.79-2.148-1.191-4.312-1.191z"}))}t.a=l},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var l=function(e){return e.match("^[A-Za-z0-9]+$")},r=function(e,t,n,r){return!(e&&!l(e))&&(!(t&&!l(t))&&(!(n&&!l(n))&&!(r&&!l(r))))}}]);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=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(1)},function(e,t,n){"use strict";var l=n(2),o=n.n(l),a=n(3),r=(n.n(a),n(4)),i=(n.n(r),n(5)),c=n(6),s=n(7),__=wp.i18n.__,u=wp.blocks.registerBlockType,p=wp.blockEditor.InspectorControls,d=wp.element,h=d.Fragment,m=(d.RawHTML,wp.components),g=m.TextControl,w=m.ToggleControl,b=m.SelectControl,f=m.PanelBody,y=m.PanelRow;u("embed-rentle/shop-block",{title:__("Rentle shop block"),icon:Object(c.a)(),category:"widgets",keywords:[__("rentle")],supports:{html:!1,reusable:!0,align:["full","wide"]},attributes:{shopId:{type:"string"},locationId:{type:"string"},categoryId:{type:"string"},productId:{type:"string"},paddingSize:{type:"string"},disableAutoScroll:{type:"boolean",default:!1},disableHeightAnimation:{type:"boolean",default:!1},locationsView:{type:"boolean",default:!1}},edit:function(e){var t=e.attributes,n=e.className,l=e.setAttributes;return wp.element.createElement(h,null,wp.element.createElement(p,null,wp.element.createElement(f,null,wp.element.createElement(y,null,wp.element.createElement(g,{value:t.shopId,type:"string",onChange:function(e){return l({shopId:e})},placeholder:"Shop ID",label:"Shop ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.locationId,type:"string",onChange:function(e){return l({locationId:e})},placeholder:"Location ID",label:"Location ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.categoryId,type:"string",onChange:function(e){return l({categoryId:e})},placeholder:"Category ID",label:"Category ID"})),wp.element.createElement(y,null,wp.element.createElement(g,{value:t.productId,type:"string",onChange:function(e){return l({productId:e})},placeholder:"Product ID",label:"Product ID"})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Disable auto scroll"),checked:t.disableAutoScroll,help:"By default, your website user is automatically scrolled to the top of the embedded store when the page changes or a dialog is shown inside the embed. This improves user experience in most cases, but you can disable this by enabling this setting.",onChange:function(){return l({disableAutoScroll:!t.disableAutoScroll})}})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Disable height animation"),checked:t.disableHeightAnimation,help:"By default, when the height of the embedded store changes, the height is animated to its new value to prevent stutter. You can disable by enabling this setting.",onChange:function(){return l({disableHeightAnimation:!t.disableHeightAnimation})}})),wp.element.createElement(y,null,wp.element.createElement(w,{label:__("Locations view"),checked:t.locationsView,help:"If you have multiple stores and want to display all the store options for the customer, enable this setting.",onChange:function(){return l({locationsView:!t.locationsView})}})),wp.element.createElement(y,null,wp.element.createElement(b,{label:__("Padding"),value:t.paddingSize,options:[{label:"No padding",value:"no-padding"},{label:"Small padding",value:"small-padding"},{label:"Medium padding",value:"medium-padding"},{label:"Large padding",value:"large-padding"}],onChange:function(e){return l({paddingSize:e})}})))),wp.element.createElement("div",{className:o()(n,t.paddingSize)},Object(i.a)(),!t.shopId&&Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("You need to define shop id.")),t.shopId&&!Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",{className:"wp-block-embed-rentle-shop-block__warning"},__("There is something wrong with the settings. Shop, location, category or product ID should include only letters or numbers.")),t.shopId&&Object(s.a)(t.shopId,t.locationId,t.categoryId,t.productId)&&wp.element.createElement("p",null,__("Your widget is ready. Just preview the page and see it in action."))))},save:function(e){return null}})},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 r=n.apply(null,l);r&&e.push(r)}else if("object"===o)for(var i in l)a.call(l,i)&&l[i]&&e.push(i)}}return e.join(" ")}var a={}.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";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"306",height:"84",viewBox:"0 0 306 84"},wp.element.createElement("path",{d:"M40.126 41.833l20.49 41.833H23.164c-15.06 0-24.792-4.723-22.938-19.342 1.622-16.643 13.67-22.49 28.731-22.49h11.169zm122.6-10.143c7.375 0 16.612 4.845 16.612 16.704 0 2.242-.214 4.483-.787 6.942h-26.28c1.146 3.978 4.082 5.858 8.736 5.858 4.797 0 6.588-1.23 8.95-2.387l5.444 6.147c-3.582 3.471-8.022 5.712-15.252 5.712-8.952 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.339-21.332zm126.161 0c7.375 0 16.613 4.845 16.613 16.704 0 2.242-.214 4.483-.788 6.942h-26.28c1.147 3.978 4.082 5.858 8.736 5.858 4.798 0 6.589-1.23 8.952-2.387l5.442 6.147c-3.58 3.471-8.02 5.712-15.252 5.712-8.95 0-18.762-5.929-18.762-17.644 0-11.931 10.168-21.332 21.34-21.332zM123.236 19.381c11.236 0 18.178 7.037 16.962 17.879-.644 6.39-4.08 11.272-9.59 14.072l9.661 18.309h-11.88l-8.374-16.442h-6.442l-1.717 16.442h-11.522l5.295-50.26h17.606zM207.87 31.69c6.886 0 13.56 4.744 12.353 16.676l-2.272 21.275h-11.216l2.2-20.772c.71-5.895-2.13-7.332-5.184-7.332-5.252 0-8.305 4.959-8.66 6.541l-2.485 21.563H181.39l3.905-37.376h11.218l-.71 6.253c.852-1.797 5.04-6.828 12.07-6.828zm34.141-12.309l-.94 11.961h8.04l-.87 9.466h-8.04l-1.666 15.29c-.216 1.675-.144 3.495 2.535 3.495 2.029 0 3.405-.219 5.506-.51l-.797 9.32c-1.883.801-4.49 1.238-8.113 1.238-6.52 0-11.734-2.33-10.577-13.979l1.666-14.854h-5.286l.869-9.466h5.286l.944-8.884 11.444-3.077zm24.512 0l-5.284 50.26h-11.127l5.281-50.26h11.13zm-103.575 21.54c-3.904 0-7.302 1.9-9.254 6.155h16.412c-.868-4.407-3.47-6.155-7.157-6.155zm126.162 0c-3.904 0-7.301 1.9-9.253 6.155h16.41c-.866-4.407-3.47-6.155-7.156-6.155zM121.838 29.639h-5.773l-1.371 13.334h5.34c4.69 0 8.443-1.864 8.948-7.169.578-4.66-2.454-6.165-7.144-6.165zM60.503 0c15.06 0 24.791 4.723 22.938 19.342-1.622 16.643-13.67 22.491-28.731 22.491H40.126L19.636 0h40.867z"}))}t.a=l},function(e,t,n){"use strict";function l(){return wp.element.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},wp.element.createElement("path",{fillRule:"evenodd",d:"M16.85 0c2.884 0 4.85.64 6.011 1.959.941 1.067 1.302 2.528 1.072 4.34-.429 4.402-3.479 6.833-8.587 6.833H13.37L18.695 24H7.15c-2.884 0-4.85-.64-6.011-1.959-.941-1.067-1.302-2.528-1.072-4.34.429-4.402 3.479-6.833 8.588-6.833h1.087L4.418 0h12.433zm-6 13.132H8.655c-3.95 0-6.023 1.577-6.339 4.821-.149 1.181.022 2.025.521 2.592.697.79 2.148 1.191 4.313 1.191h7.915l-4.215-8.604zm6-10.868H8.049l4.214 8.604h3.084c3.948 0 6.021-1.577 6.337-4.82.15-1.182-.02-2.026-.52-2.593-.697-.79-2.148-1.191-4.312-1.191z"}))}t.a=l},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var l=function(e){return e.match("^[A-Za-z0-9]+$")},o=function(e,t,n,o){return!(e&&!l(e))&&(!(t&&!l(t))&&(!(n&&!l(n))&&!(o&&!l(o))))}}]); -
embed-rentle/trunk/library/embed-rentle-classes.php
r2467184 r2822242 11 11 } else { 12 12 ?> 13 < iframe width="100%" height="100%" src="<?php echo self::create_iframe_src( $attributes ); ?>"></iframe>13 <rentle-store <?php self::set_web_component_attributes( $attributes ); ?> /> 14 14 <?php 15 15 } … … 17 17 </div> 18 18 <?php 19 } 20 21 public static function set_web_component_attributes( $attributes ) { 22 if ( ! empty( $attributes['shopId'] ) ) { 23 echo ' shop="' . esc_attr( $attributes['shopId'] ) . '"'; 24 } 25 26 if ( ! empty( $attributes['locationId'] ) ) { 27 echo ' store="' . esc_attr( $attributes['locationId'] ) . '"'; 28 } 29 30 if ( ! empty( $attributes['categoryId'] ) ) { 31 echo ' category="' . esc_attr( $attributes['categoryId'] ) . '"'; 32 } 33 34 if ( ! empty( $attributes['productId'] ) ) { 35 echo ' product="' . esc_attr( $attributes['productId'] ) . '"'; 36 } 37 38 if ( isset( $attributes['disableAutoScroll'] ) && true === $attributes['disableAutoScroll'] ) { 39 echo ' disableautoscroll="true"'; 40 } 41 42 if ( isset( $attributes['disableHeightAnimation'] ) && true === $attributes['disableHeightAnimation'] ) { 43 echo ' disableheightanimation="true"'; 44 } 45 46 if ( isset( $attributes['locationsView'] ) && true === $attributes['locationsView'] ) { 47 echo ' locationsview="true"'; 48 } 49 50 // Add height:100% 51 echo ' height="100%"'; 52 53 // Add lang automatically 54 echo ' lang="' . esc_attr( self::get_locale() ) . '"'; 19 55 } 20 56 … … 42 78 } 43 79 44 public static function create_iframe_src( $attributes ) { 45 $base_url = "https://rentle.store/{$attributes['shopId']}"; 46 $category_request = false; 47 48 // Show by shop name 49 if ( empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 50 $url = $base_url; 80 private static function get_locale() { 81 // Look for polylang installation 82 if ( function_exists( 'pll_current_language' ) ) { 83 return pll_current_language(); 51 84 } 52 85 53 // Show by location 54 if ( ! empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 55 $url = "{$base_url}/l/{$attributes['locationId']}/"; 56 } 57 58 // Show by product 59 if ( ( empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) || ( empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) ) { 60 $url = "{$base_url}/product/{$attributes['productId']}/"; 61 } 62 63 // Show by product and location 64 if ( ! empty( $attributes['locationId'] ) && empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) { 65 $url = "{$base_url}/l/{$attributes['locationId']}/product/{$attributes['productId']}/"; 66 } 67 68 // Show by category 69 if ( empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 70 $url = "{$base_url}/shop?category={$attributes['categoryId']}"; 71 $category_request = true; 72 } 73 74 // Show by category and location 75 if ( ! empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && empty( $attributes['productId'] ) ) { 76 $url = "{$base_url}/l/{$attributes['locationId']}/shop?category={$attributes['categoryId']}"; 77 $category_request = true; 78 } 79 80 // all filled, show by product and location 81 if ( ! empty( $attributes['locationId'] ) && ! empty( $attributes['categoryId'] ) && ! empty( $attributes['productId'] ) ) { 82 $url = "{$base_url}/l/{$attributes['locationId']}/product/{$attributes['productId']}/"; 83 } 84 85 86 // Adding lang code 87 if ( $category_request ) { 88 $url .= self::setting_iframe_locale( '&' ); 89 } else { 90 $url .= self::setting_iframe_locale(); 91 } 92 93 return $url; 94 } 95 96 private static function setting_iframe_locale( $start_with = '?' ) { 97 $string = $start_with . 'lang=' . substr( get_locale(), 0, 2 ); // Need only first two letters of country code 98 99 // Look for polylang installation 100 if ( function_exists( 'pll_current_language' ) ) { 101 $string = '?lang=' . pll_current_language(); 102 } 103 104 return $string; 86 return substr( get_locale(), 0, 2 ); 105 87 } 106 88 … … 146 128 } 147 129 130 if ( isset( $atts['disableautoscroll'] ) ) { 131 $atts['disableAutoScroll'] = $atts['disableautoscroll']; 132 unset( $atts['disableautoscroll'] ); 133 } 134 135 if ( isset( $atts['disableheightanimation'] ) ) { 136 $atts['disableHeightAnimation'] = $atts['disableheightanimation']; 137 unset( $atts['disableheightanimation'] ); 138 } 139 140 if ( isset( $atts['locationsview'] ) ) { 141 $atts['locationsView'] = $atts['locationsview']; 142 unset( $atts['locationsview'] ); 143 } 144 148 145 if ( isset( $atts['padding'] ) ) { 149 146 $atts['paddingSize'] = $atts['padding']; -
embed-rentle/trunk/plugin.php
r2533135 r2822242 6 6 * Author: rentle 7 7 * Author URI: https://www.rentle.io/ 8 * Version: 1. 1.18 * Version: 1.2 9 9 * License: GPL2+ 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt -
embed-rentle/trunk/readme.md
r2467184 r2822242 27 27 - `product` ==> specific product you want to show 28 28 - `padding` ==> vertical padding of the shop block. Can be one of the following: `no-padding`, `small-padding`, `medium-padding`, `large-padding` 29 - `disableautoscroll` ==> set to true, if you want to disable auto scroll 30 - `disableheightanimation` ==> set to true, if you want to disable height animation 31 - `locationsview` => set to true, if you want to list all store options 29 32 - `class` ==> if you want to wrap the element to custom class 30 33 -
embed-rentle/trunk/readme.txt
r2821953 r2822242 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1. 1.17 Stable tag: 1.2 8 8 License: GPLv2 9 9 … … 149 149 150 150 == Changelog == 151 1.2 Change to rentle web component 151 152 1.1.1 Add validation for shopID, locationID, categoryID and productID 152 153 1.1 Change iframe shop urls -
embed-rentle/trunk/src/embed-rentle/block.js
r2533135 r2822242 15 15 const {InspectorControls} = wp.blockEditor; 16 16 const {Fragment, RawHTML} = wp.element; 17 const {TextControl, SelectControl, PanelBody, PanelRow} = wp.components;17 const {TextControl, ToggleControl, SelectControl, PanelBody, PanelRow} = wp.components; 18 18 19 19 //Import lib … … 54 54 paddingSize: { 55 55 type: 'string' 56 }, 57 disableAutoScroll: { 58 type: 'boolean', 59 default: false 60 }, 61 disableHeightAnimation: { 62 type: 'boolean', 63 default: false 64 }, 65 locationsView: { 66 type: 'boolean', 67 default: false 56 68 } 57 69 }, … … 102 114 </PanelRow> 103 115 <PanelRow> 116 <ToggleControl 117 label={__('Disable auto scroll')} 118 checked={ attributes.disableAutoScroll } 119 help={`By default, your website user is automatically scrolled to the top of the embedded store when the page changes or a dialog is shown inside the embed. This improves user experience in most cases, but you can disable this by enabling this setting.`} 120 onChange={ () => setAttributes( { disableAutoScroll: ! attributes.disableAutoScroll } ) } 121 /> 122 </PanelRow> 123 <PanelRow> 124 <ToggleControl 125 label={__('Disable height animation')} 126 checked={ attributes.disableHeightAnimation } 127 help={`By default, when the height of the embedded store changes, the height is animated to its new value to prevent stutter. You can disable by enabling this setting.`} 128 onChange={ () => setAttributes( { disableHeightAnimation: ! attributes.disableHeightAnimation } ) } 129 /> 130 </PanelRow> 131 <PanelRow> 132 <ToggleControl 133 label={__('Locations view')} 134 checked={ attributes.locationsView } 135 help={`If you have multiple stores and want to display all the store options for the customer, enable this setting.`} 136 onChange={ () => setAttributes( { locationsView: ! attributes.locationsView } ) } 137 /> 138 </PanelRow> 139 <PanelRow> 104 140 <SelectControl 105 141 label={__('Padding')} -
embed-rentle/trunk/src/init.php
r2333955 r2822242 16 16 function __construct() { 17 17 add_action( 'init', [ $this, 'initialize_hooks' ] ); 18 add_action( 'wp_head', [ $this, 'hook_rentle_js' ] ); 18 19 } 19 20 … … 26 27 $this->register_assets(); 27 28 add_shortcode( 'rentle_shop', [ $this, 'rentle_output_render_callback' ] ); 29 } 30 31 public function hook_rentle_js() { 32 global $post; 33 if ( ! has_block( 'embed-rentle/shop-block', $post->ID ) && ! has_shortcode( $post->post_content, 'rentle_shop' ) ) { 34 return; 35 } 36 ?> 37 <script type="text/javascript" src="https://cdn.rentle.io/embed/bundle.js" defer></script> 38 <?php 28 39 } 29 40 … … 78 89 'embed-rentle/shop-block', array( 79 90 // Enqueue blocks.style.build.css on both frontend & backend. 80 'style' => 'embed_rentle-style-css',91 'style' => 'embed_rentle-style-css', 81 92 // Enqueue blocks.build.js in the editor only. 82 'editor_script' => 'embed_rentle-block-js',93 'editor_script' => 'embed_rentle-block-js', 83 94 // Enqueue blocks.editor.build.css in the editor only. 84 'editor_style' => 'embed_rentle-block-editor-css',95 'editor_style' => 'embed_rentle-block-editor-css', 85 96 // PHP rendering callback 86 97 'render_callback' => [ $this, 'rentle_output_render_callback' ],
Note: See TracChangeset
for help on using the changeset viewer.