Section Block - Version 1.0.0

Version Description

  • Initial release.
Download this release

Release Info

Developer wedoplugins
Plugin Icon 128x128 Section Block
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/banner-1544x500.jpg ADDED
Binary file
assets/banner-772x250.jpg ADDED
Binary file
assets/icon-128x128.png ADDED
Binary file
assets/icon-256x256.png ADDED
Binary file
build/background-position-events.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}n.d(t,"a",function(){return o});var o=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,o;return t=e,(n=[{key:"getOffsetLeft",value:function(e){var t=0;do{isNaN(e.offsetLeft)||(t+=e.offsetLeft)}while(e=e.offsetParent);return t}},{key:"update",value:function(e){var t,n=document.getElementById("adminmenuback"),r=0,o=this;null!==n&&(t="none"!==getComputedStyle(n,null).display,r=t?document.body.classList.contains("folded")?36:160:0),Array.from(document.querySelectorAll(".wp-block-wdp-section-block__background")).forEach(function(e){var t;e.style.marginLeft=null,t=o.getOffsetLeft(e),e.style.marginLeft=-1*(t-r)+"px"}),!0===e&&setTimeout(function(){o.update()})}}])&&r(t.prototype,n),o&&r(t,o),e}())},,function(e,t,n){"use strict";n.r(t);var r=n(0);jQuery(document).ready(function(){jQuery(window).on("load",function(){var e;r.a.update(),null!==(e=document.getElementById("editor"))&&new MutationObserver(function(e,t){var n=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done);n=!0)a.value.target.classList.contains("edit-post-layout")&&r.a.update()}catch(e){o=!0,u=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}}).observe(e,{attributes:!0,childList:!0,subtree:!0})}),jQuery(document).on("wp-collapse-menu",function(){r.a.update()}),jQuery(window).resize(function(){r.a.update()}),jQuery(window).on("orientationchange",function(){r.a.update()})})}]);
build/block-editor.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-block-wdp-section-block{padding:var(--wdpsb-padding) 0;position:relative}.wp-block-wdp-section-block>*{position:relative}.wp-block-wdp-section-block__background{position:absolute;top:0;left:0;height:100%;width:100vw;z-index:0;overflow:hidden;border:none;border-radius:0;box-shadow:var(--wdpsb-box-shadow-xoffset) var(--wdpsb-box-shadow-yoffset) var(--wdpsb-box-shadow-blurradius) var(--wdpsb-box-shadow-spreadradius) var(--wdpsb-box-shadow-color);background-image:var(--wdpsb-background-image);background-size:cover;background-position:var(--wdpsb-background-image-position-x) var(--wdpsb-background-image-position-y)}.wp-block-wdp-section-block__background::before{position:absolute;content:'';width:100%;height:100%;left:0;top:0;background-color:var(--wdpsb-overlay-background-color);opacity:var(--wdpsb-overlay-opacity);border:none;border-radius:0}.wp-block-wdp-section-block__background::after{position:absolute;content:'';width:100%;height:100%;left:0;top:0;opacity:1;border-width:var(--wdpsb-border-width);border-style:var(--wdpsb-border-style);border-color:var(--wdpsb-border-color);border-radius:0;border-left:none;border-right:none}@media (min-width:783px){body:not(.folded) .edit-post-layout:not(.is-sidebar-opened) .wp-block-wdp-section-block__background{width:calc(100vw - 160px)}body:not(.folded) .edit-post-layout.is-sidebar-opened .wp-block-wdp-section-block__background{width:calc(100vw - 440px)}body.folded .edit-post-layout:not(.is-sidebar-opened) .wp-block-wdp-section-block__background{width:calc(100vw - 36px)}body.folded .edit-post-layout.is-sidebar-opened .wp-block-wdp-section-block__background{width:calc(100vw - 316px)}}.block-editor-block-list__layout [data-type="wdp/section-block"].block-editor-block-list__block .block-editor-block-list__block-edit:before{z-index:1}
build/block.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-block-wdp-section-block{padding:var(--wdpsb-padding) 0;position:relative}.wp-block-wdp-section-block>*{position:relative}.wp-block-wdp-section-block__background{position:absolute;top:0;left:0;height:100%;width:100vw;z-index:0;overflow:hidden;border:none;border-radius:0;box-shadow:var(--wdpsb-box-shadow-xoffset) var(--wdpsb-box-shadow-yoffset) var(--wdpsb-box-shadow-blurradius) var(--wdpsb-box-shadow-spreadradius) var(--wdpsb-box-shadow-color);background-image:var(--wdpsb-background-image);background-size:cover;background-position:var(--wdpsb-background-image-position-x) var(--wdpsb-background-image-position-y)}.wp-block-wdp-section-block__background::before{position:absolute;content:'';width:100%;height:100%;left:0;top:0;background-color:var(--wdpsb-overlay-background-color);opacity:var(--wdpsb-overlay-opacity);border:none;border-radius:0}.wp-block-wdp-section-block__background::after{position:absolute;content:'';width:100%;height:100%;left:0;top:0;opacity:1;border-width:var(--wdpsb-border-width);border-style:var(--wdpsb-border-style);border-color:var(--wdpsb-border-color);border-radius:0;border-left:none;border-right:none}
build/block.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var o={};function t(a){if(o[a])return o[a].exports;var n=o[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=o,t.d=function(e,o,a){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)t.d(a,n,function(o){return e[o]}.bind(null,n));return a},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="",t(t.s=1)}([function(e,o,t){"use strict";function a(e,o){for(var t=0;t<o.length;t++){var a=o[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}t.d(o,"a",function(){return n});var n=new(function(){function e(){!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e)}var o,t,n;return o=e,(t=[{key:"getOffsetLeft",value:function(e){var o=0;do{isNaN(e.offsetLeft)||(o+=e.offsetLeft)}while(e=e.offsetParent);return o}},{key:"update",value:function(e){var o,t=document.getElementById("adminmenuback"),a=0,n=this;null!==t&&(o="none"!==getComputedStyle(t,null).display,a=o?document.body.classList.contains("folded")?36:160:0),Array.from(document.querySelectorAll(".wp-block-wdp-section-block__background")).forEach(function(e){var o;e.style.marginLeft=null,o=n.getOffsetLeft(e),e.style.marginLeft=-1*(o-a)+"px"}),!0===e&&setTimeout(function(){n.update()})}}])&&a(o.prototype,t),n&&a(o,n),e}())},function(e,o,t){"use strict";t.r(o);var a=t(0);function n(e,o){for(var t=0;t<o.length;t++){var a=o[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}var l=new(function(){function e(){!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e)}var o,t,a;return o=e,(t=[{key:"convert",value:function(e,o){var t;return e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,o,t,a){return o+o+t+t+a+a}),(t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e))?"rgba(".concat(parseInt(t[1],16),",").concat(parseInt(t[2],16),",").concat(parseInt(t[3],16),",").concat(parseFloat(o,10),")"):e}}])&&n(o.prototype,t),a&&n(o,a),e}()),r=wp.i18n.__,c=wp.blocks.registerBlockType,i=wp.editor,d=i.InnerBlocks,s=i.InspectorControls,u=i.MediaUpload,b=wp.element.Fragment,p=wp.components,f=p.PanelBody,m=p.RangeControl,g=p.SelectControl,y=p.ToggleControl,w=p.ColorPalette,k=p.FocalPointPicker;c("wdp/section-block",{title:r("Section Block (by We Do Plugins)","section-block"),description:r("Cool Section Block for new Block Editor.","section-block"),icon:"index-card",category:"widgets",supports:{align:["wide","full"]},attributes:{useCustomStyles:{type:"boolean",default:!1},padding:{type:"integer",default:parseInt(WDPSectionBlock.padding,10)},overlayBackgroundColor:{type:"string",default:WDPSectionBlock.overlayBackgroundColor},overlayOpacity:{type:"float",default:parseFloat(WDPSectionBlock.overlayOpacity,10)},borderColor:{type:"string",default:WDPSectionBlock.borderColor},borderStyle:{type:"string",default:WDPSectionBlock.borderStyle},borderWidth:{type:"integer",default:parseInt(WDPSectionBlock.borderWidth,10)},boxShadowXOffset:{type:"integer",default:parseInt(WDPSectionBlock.boxShadowXOffset,10)},boxShadowYOffset:{type:"integer",default:parseInt(WDPSectionBlock.boxShadowYOffset,10)},boxShadowBlurRadius:{type:"integer",default:parseInt(WDPSectionBlock.boxShadowBlurRadius,10)},boxShadowSpreadRadius:{type:"integer",default:parseInt(WDPSectionBlock.boxShadowSpreadRadius,10)},boxShadowColor:{type:"string",default:WDPSectionBlock.boxShadowColor},boxShadowOpacity:{type:"float",default:parseFloat(WDPSectionBlock.boxShadowOpacity,10)},backgroundImage:{type:"string",default:null},backgroundImageFocalPos:{type:"object",default:{x:.5,y:.5}}},edit:function(e){var o=e.attributes,t=e.setAttributes,n=e.className,c=o.useCustomStyles,i=o.padding,p=o.overlayBackgroundColor,h=o.overlayOpacity,x=o.borderColor,v=o.borderStyle,S=o.borderWidth,R=o.boxShadowXOffset,C=o.boxShadowYOffset,E=o.boxShadowBlurRadius,B=o.boxShadowSpreadRadius,O=o.boxShadowColor,P=o.boxShadowOpacity,I=o.backgroundImage,W=o.backgroundImageFocalPos,D={"--wdpsb-padding":i+"px","--wdpsb-overlay-background-color":p,"--wdpsb-overlay-opacity":h,"--wdpsb-border-color":x,"--wdpsb-border-style":v,"--wdpsb-border-width":S+"px","--wdpsb-box-shadow-xoffset":R+"px","--wdpsb-box-shadow-yoffset":C+"px","--wdpsb-box-shadow-blurradius":E+"px","--wdpsb-box-shadow-spreadradius":B+"px","--wdpsb-box-shadow-color":l.convert(O,P),"--wdpsb-background-image":null!==I?"url('".concat(I,"')"):"none","--wdpsb-background-image-position-x":100*W.x+"%","--wdpsb-background-image-position-y":100*W.y+"%"};return React.createElement(b,null,React.createElement(s,null,React.createElement(f,{title:r("Use custom styles?","section-block")},React.createElement(y,{label:r("Use custom styles?","section-block"),checked:c,onChange:function(e){t({useCustomStyles:e})}})),!0===c&&React.createElement("div",null,React.createElement(f,{title:r("Overlay","section-block"),initialOpen:!1},React.createElement(b,null,React.createElement("p",null,r("Overlay background color","section-block")),React.createElement(w,{label:r("Overlay background color","section-block"),value:p,colors:WDPSectionBlock.themeColors,onChange:function(e){t({overlayBackgroundColor:e})}})),React.createElement(m,{label:r("Overlay opacity","section-block"),value:h,onChange:function(e){t({overlayOpacity:e})},min:0,max:1,step:.01})),React.createElement(f,{title:r("Padding","section-block"),initialOpen:!1},React.createElement(m,{label:r("Padding","section-block"),value:i,onChange:function(e){t({padding:e})},min:0,max:120})),React.createElement(f,{title:r("Border","section-block"),initialOpen:!1},React.createElement(b,null,React.createElement("p",null,r("Border color","section-block")),React.createElement(w,{label:r("Border color","section-block"),value:x,colors:WDPSectionBlock.themeColors,onChange:function(e){t({borderColor:e})}})),React.createElement(g,{label:r("Border style","section-block"),value:v,onChange:function(e){t({borderStyle:e})},options:[{value:"solid",label:r("Solid","section-block")},{value:"dashed",label:r("Dashed","section-block")},{value:"dotted",label:r("Dotted","section-block")}]}),React.createElement(m,{label:r("Border width","section-block"),value:S,onChange:function(e){t({borderWidth:e})},min:0,max:30})),React.createElement(f,{title:r("Box shadow","section-block"),initialOpen:!1},React.createElement(m,{label:r("X offset","section-block"),value:R,onChange:function(e){t({boxShadowXOffset:e})},min:-100,max:100}),React.createElement(m,{label:r("Y offset","section-block"),value:C,onChange:function(e){t({boxShadowYOffset:e})},min:-100,max:100}),React.createElement(m,{label:r("Blur radius","section-block"),value:E,onChange:function(e){t({boxShadowBlurRadius:e})},min:0,max:100}),React.createElement(m,{label:r("Spread radius","section-block"),value:B,onChange:function(e){t({boxShadowSpreadRadius:e})},min:-100,max:100}),React.createElement(b,null,React.createElement("p",null,r("Box shadow color","section-block")),React.createElement(w,{label:r("Box shadow color","section-block"),value:O,colors:WDPSectionBlock.themeColors,onChange:function(e){t({boxShadowColor:e})}})),React.createElement(m,{label:r("Box shadow color opacity","section-block"),value:P,onChange:function(e){t({boxShadowOpacity:e})},min:0,max:1,step:.01})),React.createElement(f,{title:r("Background image","section-block"),initialOpen:!1},React.createElement(u,{onSelect:function(e){t({backgroundImage:e.sizes.full.url})},type:"image",value:I,render:function(e){var o=e.open;return React.createElement("button",{className:"button",onClick:o},r("Upload image","section-block"))}}),null!==I&&React.createElement(b,null,React.createElement("h4",null,r("Image focal point","section-block")),React.createElement(k,{url:I,value:W,onChange:function(e){t({backgroundImageFocalPos:e})}}))))),React.createElement("div",{className:n,style:!0===c?D:{}},React.createElement("div",{className:"wp-block-wdp-section-block__background"}),React.createElement(d,null)),a.a.update(!0))},save:function(e){var o=e.attributes,t=e.className,a=o.useCustomStyles,n=o.padding,r=o.overlayBackgroundColor,c=o.overlayOpacity,i=o.borderColor,s=o.borderStyle,u=o.borderWidth,b=o.boxShadowXOffset,p=o.boxShadowYOffset,f=o.boxShadowBlurRadius,m=o.boxShadowSpreadRadius,g=o.boxShadowColor,y=o.boxShadowOpacity,w=o.backgroundImage,k=o.backgroundImageFocalPos,h={"--wdpsb-padding":n+"px","--wdpsb-overlay-background-color":r,"--wdpsb-overlay-opacity":c.toString(),"--wdpsb-border-color":i,"--wdpsb-border-style":s,"--wdpsb-border-width":u+"px","--wdpsb-box-shadow-xoffset":b+"px","--wdpsb-box-shadow-yoffset":p+"px","--wdpsb-box-shadow-blurradius":f+"px","--wdpsb-box-shadow-spreadradius":m+"px","--wdpsb-box-shadow-color":l.convert(g,y),"--wdpsb-background-image":null!==w?"url('".concat(w,"')"):"none","--wdpsb-background-image-position-x":100*k.x+"%","--wdpsb-background-image-position-y":100*k.y+"%"};return React.createElement("div",{className:t,style:!0===a?h:{}},React.createElement("div",{className:"wp-block-wdp-section-block__background"}),React.createElement(d.Content,null))}})}]);
build/index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Directory listing protection
4
+ *
5
+ * @package section_block
6
+ */
7
+
8
+ // Silence is golden.
classes/class-wdpsb-config.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Configuration class
4
+ *
5
+ * @package section_block
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ /**
13
+ * Configuration class
14
+ */
15
+ class WDPSB_Config {
16
+
17
+ /**
18
+ * Return default configuration
19
+ */
20
+ public static function get_all() {
21
+
22
+ return array(
23
+ 'padding' => array(
24
+ 'name' => __( 'Padding', 'section-block' ),
25
+ 'value' => apply_filters( 'wdpsb_default_padding', 30 ),
26
+ 'type' => 'range',
27
+ 'min' => 0,
28
+ 'max' => 120,
29
+ 'step' => 1,
30
+ ),
31
+ 'overlay-background-color' => array(
32
+ 'name' => __( 'Overlay background color', 'section-block' ),
33
+ 'value' => apply_filters( 'wdpsb_default_overlay_background_color', '#fff' ),
34
+ 'type' => 'color',
35
+ ),
36
+ 'overlay-opacity' => array(
37
+ 'name' => __( 'Overlay opacity', 'section-block' ),
38
+ 'value' => apply_filters( 'wdpsb_default_overlay_opacity', 0.5 ),
39
+ 'type' => 'range',
40
+ 'min' => 0,
41
+ 'max' => 1,
42
+ 'step' => 0.01,
43
+ ),
44
+ 'border-width' => array(
45
+ 'name' => __( 'Border width', 'section-block' ),
46
+ 'value' => apply_filters( 'wdpsb_default_border_width', 1 ),
47
+ 'type' => 'range',
48
+ 'min' => 0,
49
+ 'max' => 30,
50
+ ),
51
+ 'border-style' => array(
52
+ 'name' => __( 'Border style', 'section-block' ),
53
+ 'value' => apply_filters( 'wdpsb_default_border_style', 'solid' ),
54
+ 'type' => 'select',
55
+ 'values' => array(
56
+ 'solid' => __( 'Solid', 'section-block' ),
57
+ 'dashed' => __( 'Dashed', 'section-block' ),
58
+ 'dotted' => __( 'Dotted', 'section-block' ),
59
+ ),
60
+ ),
61
+ 'border-color' => array(
62
+ 'name' => __( 'Border color', 'section-block' ),
63
+ 'value' => apply_filters( 'wdpsb_default_border_color', '#ddd' ),
64
+ 'type' => 'color',
65
+ ),
66
+ 'box-shadow-x-offset' => array(
67
+ 'name' => __( 'Box shadow X offset', 'section-block' ),
68
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_x_offset', 0 ),
69
+ 'type' => 'range',
70
+ 'min' => -100,
71
+ 'max' => 100,
72
+ 'step' => 1,
73
+ ),
74
+ 'box-shadow-y-offset' => array(
75
+ 'name' => __( 'Box shadow Y offset', 'section-block' ),
76
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_y_offset', 0 ),
77
+ 'type' => 'range',
78
+ 'min' => -100,
79
+ 'max' => 100,
80
+ 'step' => 1,
81
+ ),
82
+ 'box-shadow-blur-radius' => array(
83
+ 'name' => __( 'Box shadow blur radius', 'section-block' ),
84
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_blur_radius', 35 ),
85
+ 'type' => 'range',
86
+ 'min' => 0,
87
+ 'max' => 100,
88
+ 'step' => 1,
89
+ ),
90
+ 'box-shadow-spread-radius' => array(
91
+ 'name' => __( 'Box shadow spread radius', 'section-block' ),
92
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_spread_radius', 0 ),
93
+ 'type' => 'range',
94
+ 'min' => -100,
95
+ 'max' => 100,
96
+ 'step' => 1,
97
+ ),
98
+ 'box-shadow-color' => array(
99
+ 'name' => __( 'Box shadow color', 'section-block' ),
100
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_color', '#000' ),
101
+ 'type' => 'color',
102
+ ),
103
+ 'box-shadow-opacity' => array(
104
+ 'name' => __( 'Box shadow opacity', 'section-block' ),
105
+ 'value' => apply_filters( 'wdpsb_default_box_shadow_opacity', 0.2 ),
106
+ 'type' => 'range',
107
+ 'min' => 0,
108
+ 'max' => 1,
109
+ 'step' => 0.01,
110
+ ),
111
+ );
112
+ }
113
+
114
+ /**
115
+ * Get key-value of default config
116
+ */
117
+ public static function get_simplified() {
118
+
119
+ $result = array();
120
+
121
+ foreach ( self::get_all() as $key => $data ) {
122
+ $result[ $key ] = $data['value'];
123
+ }
124
+
125
+ return $result;
126
+ }
127
+ }
classes/class-wdpsb-enqueue.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Enqueue block scripts and styles
4
+ *
5
+ * @package section_block
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ add_action( 'enqueue_block_editor_assets', array( 'WDPSB_Enqueue', 'editor_enqueue' ) );
13
+ add_action( 'wp_enqueue_scripts', array( 'WDPSB_Enqueue', 'enqueue_block' ) );
14
+
15
+ /**
16
+ * Enqueue class
17
+ */
18
+ class WDPSB_Enqueue {
19
+
20
+ /**
21
+ * Enqueue scripts and styles on editor
22
+ */
23
+ public static function editor_enqueue() {
24
+
25
+ wp_enqueue_script(
26
+ 'wdp/section-block',
27
+ plugins_url( 'build/block.min.js', WDPSB_MAIN_FILE ),
28
+ array(
29
+ 'wp-i18n',
30
+ 'wp-blocks',
31
+ 'wp-editor',
32
+ 'wp-components',
33
+ 'wp-element',
34
+ ),
35
+ WDPSB_VERSION,
36
+ true
37
+ );
38
+
39
+ wp_localize_script(
40
+ 'wdp/section-block',
41
+ 'WDPSectionBlock',
42
+ array_merge(
43
+ self::get_default_block_styles(),
44
+ array(
45
+ 'themeColors' => current( (array) get_theme_support( 'editor-color-palette' ) ),
46
+ )
47
+ )
48
+ );
49
+
50
+ self::enqueue_block( true );
51
+ }
52
+
53
+ /**
54
+ * Enqueue section block styles on front-end
55
+ *
56
+ * @param bool $is_editor Are styles for editor or not.
57
+ */
58
+ public static function enqueue_block( $is_editor = false ) {
59
+
60
+ wp_enqueue_style(
61
+ 'wdp/section-block',
62
+ plugins_url( 'build/block' . esc_attr( true === $is_editor ? '-editor' : '' ) . '.css', WDPSB_MAIN_FILE ),
63
+ array(),
64
+ WDPSB_VERSION
65
+ );
66
+
67
+ wp_enqueue_script(
68
+ 'wdp-section-block-background-position-events',
69
+ plugins_url( 'build/background-position-events.min.js', WDPSB_MAIN_FILE ),
70
+ array(
71
+ 'jquery',
72
+ ),
73
+ WDPSB_VERSION,
74
+ true
75
+ );
76
+
77
+ wp_add_inline_style(
78
+ 'wdp/section-block',
79
+ self::generate_css()
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Get default block styles
85
+ */
86
+ public static function get_default_block_styles() {
87
+
88
+ $defaults = WDPSB_Config::get_simplified();
89
+ $result = array();
90
+
91
+ foreach ( $defaults as $key => $value ) {
92
+
93
+ $key = explode( '-', $key );
94
+ $key_parts_count = count( $key );
95
+
96
+ for ( $i = 1; $i < $key_parts_count; $i++ ) {
97
+ $key[ $i ] = ucfirst( $key[ $i ] );
98
+ }
99
+
100
+ $result[ implode( '', $key ) ] = $value;
101
+ }
102
+
103
+ return $result;
104
+ }
105
+
106
+ /**
107
+ * Generate CSS variables
108
+ */
109
+ public static function generate_css() {
110
+
111
+ $defaults = WDPSB_Config::get_simplified();
112
+ $css = '';
113
+ $vars = array(
114
+ '--wdpsb-padding' => esc_attr( $defaults['padding'] ) . 'px',
115
+ '--wdpsb-overlay-background-color' => esc_attr( $defaults['overlay-background-color'] ),
116
+ '--wdpsb-overlay-opacity' => esc_attr( $defaults['overlay-opacity'] ),
117
+ '--wdpsb-border-width' => esc_attr( $defaults['border-width'] ) . 'px',
118
+ '--wdpsb-border-style' => esc_attr( $defaults['border-style'] ),
119
+ '--wdpsb-border-color' => esc_attr( $defaults['border-color'] ),
120
+ '--wdpsb-box-shadow-xoffset' => esc_attr( $defaults['box-shadow-x-offset'] ) . 'px',
121
+ '--wdpsb-box-shadow-yoffset' => esc_attr( $defaults['box-shadow-y-offset'] ) . 'px',
122
+ '--wdpsb-box-shadow-blurradius' => esc_attr( $defaults['box-shadow-blur-radius'] ) . 'px',
123
+ '--wdpsb-box-shadow-spreadradius' => esc_attr( $defaults['box-shadow-spread-radius'] ) . 'px',
124
+ '--wdpsb-box-shadow-color' => esc_attr( self::hex2rgb( $defaults['box-shadow-color'], $defaults['box-shadow-opacity'] ) ),
125
+ '--wdpsb-background-image' => 'none',
126
+ '--wdpsb-background-image-position-x' => '50%',
127
+ '--wdpsb-background-image-position-y' => '50%',
128
+ );
129
+
130
+ foreach ( $vars as $var => $value ) {
131
+ $css .= $var . ':' . $value . ';';
132
+ }
133
+
134
+ return ':root { ' . esc_attr( $css ) . ' }';
135
+ }
136
+
137
+ /**
138
+ * Transform HEX to RGB
139
+ *
140
+ * @param string $hex HEX color.
141
+ * @param int $opacity Color opacity value.
142
+ */
143
+ public static function hex2rgb( $hex, $opacity ) {
144
+
145
+ ( strlen( $hex ) === 4 ) ? list( $r, $g, $b ) = sscanf( $hex, '#%1x%1x%1x' ) : list( $r, $g, $b ) = sscanf( $hex, '#%2x%2x%2x' );
146
+ return "rgba($r,$g,$b,$opacity)";
147
+ }
148
+ }
classes/index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Directory listing protection
4
+ *
5
+ * @package section_block
6
+ */
7
+
8
+ // Silence is golden.
index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Directory listing protection
4
+ *
5
+ * @package section_block
6
+ */
7
+
8
+ // Silence is golden.
readme.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Section Block ===
2
+ Contributors: wedoplugins
3
+ Tags: block, section, section block, gutenberg, block editor, block library, blocks
4
+ Requires at least: 5.1
5
+ Tested up to: 5.1
6
+ Requires PHP: 5.6
7
+ License: GPLv2 or later
8
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
+ Stable tag: 1.0.0
10
+
11
+ Section Block for new WordPress Block Editor allow you to add Sections to your website and customize it.
12
+
13
+ == Description ==
14
+
15
+ Section Block for new WordPress Block Editor allow you to add Sections to your website and customize it:
16
+
17
+ * customize section border,
18
+ * customize section background image, add or hide overlay,
19
+ * customize section padding,
20
+ * customize section box shadow,
21
+
22
+ You can use any other Blocks inside this Section Block so this can be used to build more advanced templates.
23
+
24
+ Blocks inside this Section Block can be wide- or full-aligned, but section itself is always full-aligned.
25
+
26
+ Please note that this plugin so far require [Gutenberg plugin](https://wordpress.org/plugins/gutenberg/) to be installed with 5.3 version at minimum as it uses FocalPointPicker component as a dependency (this component is not available in WordPress core yet, at least until WordPress 5.2).
27
+
28
+ == Installation ==
29
+
30
+ 1. Install the plugin through the WordPress plugins screen directly or upload the plugin files to the "/wp-content/plugins/section-block" directory.
31
+ 2. Activate the plugin through the "Plugins" screen in WordPress
32
+ 3. Go to Block Editor and type /section to use this block.
33
+
34
+ == Changelog ==
35
+
36
+ = 1.0.0 =
37
+ * Initial release.
section-block.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Section Block
4
+ * Plugin URI: http://wedoplugins.com/plugins/section-block/
5
+ * Description: Adds a Section Block to new WordPress Blocks editor.
6
+ * Author: We Do Plugins
7
+ * Author URI: http://wedoplugins.com/
8
+ * Version: 1.0.0
9
+ * License: GPL2+
10
+ * Text Domain: section-block
11
+ *
12
+ * @package section_block
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ define( 'WDPSB_MAIN_FILE', __FILE__ );
20
+ define( 'WDPSB_VERSION', '1.0.0' );
21
+
22
+ require_once dirname( WDPSB_MAIN_FILE ) . '/classes/class-wdpsb-config.php';
23
+ require_once dirname( WDPSB_MAIN_FILE ) . '/classes/class-wdpsb-enqueue.php';