Gutenberg Blocks – Ultimate Addons for Gutenberg - Version 0.0.1

Version Description

  • Initial release
Download this release

Release Info

Developer Nikschavan
Plugin Icon Gutenberg Blocks – Ultimate Addons for Gutenberg
Version 0.0.1
Comparing to
See all releases

Version 0.0.1

classes/class-uagb-core-plugin.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * UAGB Core Plugin.
4
+ *
5
+ * @package UAGB
6
+ */
7
+
8
+ namespace UltimateGutenberg;
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * UAGB_Core_Plugin.
16
+ *
17
+ * @package UAGB
18
+ */
19
+ class UAGB_Core_Plugin {
20
+
21
+ /**
22
+ * Member Variable
23
+ *
24
+ * @var instance
25
+ */
26
+ private static $instance;
27
+
28
+ /**
29
+ * Initiator
30
+ */
31
+ public static function get_instance() {
32
+ if ( ! isset( self::$instance ) ) {
33
+ self::$instance = new self;
34
+ }
35
+ return self::$instance;
36
+ }
37
+
38
+ /**
39
+ * Constructor
40
+ */
41
+ public function __construct() {
42
+
43
+ $this->includes();
44
+ }
45
+
46
+ /**
47
+ * Includes.
48
+ *
49
+ * @since 1.0.0
50
+ */
51
+ private function includes() {
52
+ require( UAGB_DIR . 'classes/class-uagb-init-blocks.php' );
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Prepare if class 'UAGB_Core_Plugin' exist.
58
+ * Kicking this off by calling 'get_instance()' method
59
+ */
60
+ UAGB_Core_Plugin::get_instance();
classes/class-uagb-init-blocks.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * UAGB Blocks Initializer
4
+ *
5
+ * Enqueue CSS/JS of all the blocks.
6
+ *
7
+ * @since 1.0.0
8
+ * @package UAGB
9
+ */
10
+
11
+ namespace UltimateGutenberg;
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit; // Exit if accessed directly.
15
+ }
16
+
17
+ /**
18
+ * UAGB_Init_Blocks.
19
+ *
20
+ * @package UAGB
21
+ */
22
+ class UAGB_Init_Blocks {
23
+
24
+ /**
25
+ * Member Variable
26
+ *
27
+ * @var instance
28
+ */
29
+ private static $instance;
30
+
31
+ /**
32
+ * Initiator
33
+ */
34
+ public static function get_instance() {
35
+ if ( ! isset( self::$instance ) ) {
36
+ self::$instance = new self;
37
+ }
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ */
44
+ public function __construct() {
45
+
46
+ // Hook: Frontend assets.
47
+ add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) );
48
+
49
+ // Hook: Editor assets.
50
+ add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ) );
51
+ }
52
+
53
+ /**
54
+ * Enqueue Gutenberg block assets for both frontend + backend.
55
+ *
56
+ * @since 1.0.0
57
+ */
58
+ function block_assets() {
59
+ // Styles.
60
+ wp_enqueue_style(
61
+ 'uabg-block-css', // Handle.
62
+ UAGB_URL . 'dist/blocks.style.build.css', // Block style CSS.
63
+ array( 'wp-blocks' ), // Dependency to include the CSS after it.
64
+ UAGB_VER
65
+ );
66
+ } // End function editor_assets().
67
+
68
+ /**
69
+ * Enqueue Gutenberg block assets for backend editor.
70
+ *
71
+ * @since 1.0.0
72
+ */
73
+ function editor_assets() {
74
+ // Scripts.
75
+ wp_enqueue_script(
76
+ 'uabg-block-editor-js', // Handle.
77
+ UAGB_URL . 'dist/blocks.build.js',
78
+ array( 'wp-blocks', 'wp-i18n', 'wp-element' ), // Dependencies, defined above.
79
+ UAGB_VER,
80
+ true // Enqueue the script in the footer.
81
+ );
82
+
83
+ // Styles.
84
+ wp_enqueue_style(
85
+ 'uabg-block-editor-css', // Handle.
86
+ UAGB_URL . 'dist/blocks.editor.build.css', // Block editor CSS.
87
+ array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
88
+ UAGB_VER
89
+ );
90
+ } // End function editor_assets().
91
+
92
+ }
93
+
94
+ /**
95
+ * Prepare if class 'UAGB_Init_Blocks' exist.
96
+ * Kicking this off by calling 'get_instance()' method
97
+ */
98
+ UAGB_Init_Blocks::get_instance();
classes/class-uagb-loader.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * UAGB Loader.
4
+ *
5
+ * @package UAGB
6
+ */
7
+
8
+ if ( ! class_exists( 'UAGB_Loader' ) ) {
9
+
10
+ /**
11
+ * Class UAGB_Loader.
12
+ */
13
+ final class UAGB_Loader {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var instance
19
+ */
20
+ private static $instance;
21
+
22
+ /**
23
+ * Initiator
24
+ */
25
+ public static function get_instance() {
26
+ if ( ! isset( self::$instance ) ) {
27
+ self::$instance = new self;
28
+ }
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Constructor
34
+ */
35
+ public function __construct() {
36
+
37
+ // Activation hook.
38
+ register_activation_hook( UAGB_FILE, array( $this, 'activation_reset' ) );
39
+
40
+ // deActivation hook.
41
+ register_deactivation_hook( UAGB_FILE, array( $this, 'deactivation_reset' ) );
42
+
43
+ $this->define_constants();
44
+
45
+ add_action( 'plugins_loaded', array( $this, 'load_plugin' ) );
46
+ }
47
+
48
+ /**
49
+ * Defines all constants
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ public function define_constants() {
54
+ define( 'UAGB_BASE', plugin_basename( UAGB_FILE ) );
55
+ define( 'UAGB_DIR', plugin_dir_path( UAGB_FILE ) );
56
+ define( 'UAGB_URL', plugins_url( '/', UAGB_FILE ) );
57
+ define( 'UAGB_VER', '0.0.1' );
58
+ define( 'UAGB_MODULES_DIR', UAGB_DIR . 'modules/' );
59
+ define( 'UAGB_MODULES_URL', UAGB_URL . 'modules/' );
60
+ define( 'UAGB_SLUG', 'uagb' );
61
+ define( 'UAGB_CATEGORY', 'Ultimate Addons' );
62
+ }
63
+
64
+ /**
65
+ * Loads plugin files.
66
+ *
67
+ * @since 1.0.0
68
+ *
69
+ * @return void
70
+ */
71
+ function load_plugin() {
72
+
73
+ if ( ! function_exists( 'gutenberg_init' ) ) {
74
+ /* TO DO */
75
+ add_action( 'admin_notices', array( $this, 'uagb_fails_to_load' ) );
76
+ return;
77
+ }
78
+
79
+ $this->load_textdomain();
80
+
81
+ require( UAGB_DIR . 'classes/class-uagb-core-plugin.php' );
82
+ }
83
+
84
+ /**
85
+ * Load Ultimate Gutenberg Text Domain.
86
+ * This will load the translation textdomain depending on the file priorities.
87
+ * 1. Global Languages /wp-content/languages/ultimate-addons-for-gutenberg/ folder
88
+ * 2. Local dorectory /wp-content/plugins/ultimate-addons-for-gutenberg/languages/ folder
89
+ *
90
+ * @since 1.0.0
91
+ * @return void
92
+ */
93
+ public function load_textdomain() {
94
+ // Default languages directory for "ultimate-addons-for-gutenberg".
95
+ $lang_dir = UAGB_DIR . 'languages/';
96
+
97
+ /**
98
+ * Filters the languages directory path to use for AffiliateWP.
99
+ *
100
+ * @param string $lang_dir The languages directory path.
101
+ */
102
+ $lang_dir = apply_filters( 'uagb_languages_directory', $lang_dir );
103
+
104
+ // Traditional WordPress plugin locale filter.
105
+ global $wp_version;
106
+
107
+ $get_locale = get_locale();
108
+
109
+ if ( $wp_version >= 4.7 ) {
110
+ $get_locale = get_user_locale();
111
+ }
112
+
113
+ /**
114
+ * Language Locale for Ultimate Gutenberg
115
+ *
116
+ * @var $get_locale The locale to use. Uses get_user_locale()` in WordPress 4.7 or greater,
117
+ * otherwise uses `get_locale()`.
118
+ */
119
+ $locale = apply_filters( 'plugin_locale', $get_locale, 'ultimate-addons-for-gutenberg' );
120
+ $mofile = sprintf( '%1$s-%2$s.mo', 'ultimate-addons-for-gutenberg', $locale );
121
+
122
+ // Setup paths to current locale file.
123
+ $mofile_local = $lang_dir . $mofile;
124
+ $mofile_global = WP_LANG_DIR . '/ultimate-addons-for-gutenberg/' . $mofile;
125
+
126
+ if ( file_exists( $mofile_global ) ) {
127
+ // Look in global /wp-content/languages/ultimate-addons-for-gutenberg/ folder.
128
+ load_textdomain( 'ultimate-addons-for-gutenberg', $mofile_global );
129
+ } elseif ( file_exists( $mofile_local ) ) {
130
+ // Look in local /wp-content/plugins/ultimate-addons-for-gutenberg/languages/ folder.
131
+ load_textdomain( 'ultimate-addons-for-gutenberg', $mofile_local );
132
+ } else {
133
+ // Load the default language files.
134
+ load_plugin_textdomain( 'ultimate-addons-for-gutenberg', false, $lang_dir );
135
+ }
136
+ }
137
+ /**
138
+ * Fires admin notice when Gutenberg is not installed and activated.
139
+ *
140
+ * @since 1.0.0
141
+ *
142
+ * @return void
143
+ */
144
+ public function uagb_fails_to_load() {
145
+ $class = 'notice notice-error';
146
+ /* translators: %s: html tags */
147
+ $message = sprintf( __( 'The %1$sUltimate Addon for Gutenberg%2$s plugin requires %1$sGutenberg%2$s plugin installed & activated.', 'ultimate-addons-for-gutenberg' ), '<strong>', '</strong>' );
148
+
149
+ $plugin = 'gutenberg/gutenberg.php';
150
+
151
+ if ( _is_gutenberg_installed( $plugin ) ) {
152
+ if ( ! current_user_can( 'activate_plugins' ) ) {
153
+ return;
154
+ }
155
+
156
+ $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
157
+ $button_label = __( 'Activate Gutenberg', 'ultimate-addons-for-gutenberg' );
158
+
159
+ } else {
160
+ if ( ! current_user_can( 'install_plugins' ) ) {
161
+ return;
162
+ }
163
+
164
+ $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=gutenberg' ), 'install-plugin_gutenberg' );
165
+ $button_label = __( 'Install Gutenberg', 'ultimate-addons-for-gutenberg' );
166
+ }
167
+
168
+ $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
169
+
170
+ printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
171
+ }
172
+
173
+ /**
174
+ * Activation Reset
175
+ */
176
+ function activation_reset() {
177
+ }
178
+
179
+ /**
180
+ * Deactivation Reset
181
+ */
182
+ function deactivation_reset() {
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Prepare if class 'UAGB_Loader' exist.
188
+ * Kicking this off by calling 'get_instance()' method
189
+ */
190
+ UAGB_Loader::get_instance();
191
+ }
192
+
193
+ /**
194
+ * Is Gutenberg plugin installed.
195
+ */
196
+ if ( ! function_exists( '_is_gutenberg_installed' ) ) {
197
+
198
+ /**
199
+ * Check if Gutenberg Pro is installed
200
+ *
201
+ * @since 1.0.0
202
+ *
203
+ * @param string $plugin_path Plugin path.
204
+ * @return boolean true | false
205
+ * @access public
206
+ */
207
+ function _is_gutenberg_installed( $plugin_path ) {
208
+ $plugins = get_plugins();
209
+
210
+ return isset( $plugins[ $plugin_path ] );
211
+ }
212
+ }
dist/blocks.build.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){function t(a){if(n[a])return n[a].exports;var r=n[a]={i:a,l:!1,exports:{}};return e[a].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,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},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";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function l(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i,c=n(2),p=(n.n(c),n(3)),u=(n.n(p),n(4)),s=(n.n(u),function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}()),m=wp.i18n.__,d=wp.blocks.registerBlockType,g=wp.editor,b=g.AlignmentToolbar,f=g.BlockControls,h=g.ColorPalette,w=g.InspectorControls,y=g.RichText,v=wp.components,x=v.PanelBody,C=v.PanelColor,S=v.SelectControl,E=v.RangeControl,H=wp.element.Component,O=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),s(t,[{key:"render",value:function(){var e=this.props,t=e.isSelected,n=e.className,a=e.setAttributes,r=e.attributes,o=r.headingTitle,l=r.headingDesc,i=r.headingAlign,c=r.headingColor,p=r.subHeadingColor,u=r.separatorColor,s=r.headingTag,d=r.headFontSize,g=r.subHeadFontSize,v=r.separatorWidth,H=r.separatorHeight,O=r.headSpace,A=r.separatorSpace,T=r.subHeadSpace;return[t&&wp.element.createElement(f,{key:"controls"},wp.element.createElement(b,{value:i,onChange:function(e){return a({headingAlign:e})}})),t&&wp.element.createElement(w,null,wp.element.createElement(x,{title:m("Typography"),initialOpen:!1},wp.element.createElement(S,{label:m("Tag"),value:s,onChange:function(e){return a({headingTag:e})},options:[{value:"h1",label:m("H1")},{value:"h2",label:m("H2")},{value:"h3",label:m("H3")},{value:"h4",label:m("H4")},{value:"h5",label:m("H5")},{value:"h6",label:m("H6")}]}),wp.element.createElement(E,{label:m("Heading Font Size"),value:d,onChange:function(e){return a({headFontSize:e})},min:10,max:200,beforeIcon:"editor-textcolor",allowReset:!0}),wp.element.createElement(E,{label:m("Sub-Heading Font Size"),value:g,onChange:function(e){return a({subHeadFontSize:e})},min:10,max:200,beforeIcon:"editor-textcolor",allowReset:!0})),wp.element.createElement(x,{title:m("Colors"),initialOpen:!1},wp.element.createElement(C,{title:m("Heading Color"),colorValue:c,initialOpen:!1},wp.element.createElement(h,{value:c,onChange:function(e){return a({headingColor:e})},allowReset:!0})),wp.element.createElement(C,{title:m("Sub-Heading Color"),colorValue:p,initialOpen:!1},wp.element.createElement(h,{value:p,onChange:function(e){return a({subHeadingColor:e})},allowReset:!0})),wp.element.createElement(C,{title:m("Separator Color"),colorValue:u,initialOpen:!1},wp.element.createElement(h,{value:u,onChange:function(e){return a({separatorColor:e})},allowReset:!0}))),wp.element.createElement(x,{title:m("Additional Options"),initialOpen:!1},wp.element.createElement(E,{label:m("Separator Height"),value:H,onChange:function(e){return a({separatorHeight:e})},min:0,max:50,beforeIcon:"editor-textcolor",allowReset:!0}),wp.element.createElement(E,{label:m("Separator Width"),value:v,onChange:function(e){return a({separatorWidth:e})},min:0,max:100,beforeIcon:"editor-textcolor",allowReset:!0}),wp.element.createElement(E,{label:m("Heading Spacing"),value:O,onChange:function(e){return a({headSpace:e})},min:0,max:50,beforeIcon:"editor-textcolor",allowReset:!0}),wp.element.createElement(E,{label:m("Separator Spacing"),value:A,onChange:function(e){return a({separatorSpace:e})},min:0,max:50,beforeIcon:"editor-textcolor",allowReset:!0}),wp.element.createElement(E,{label:m("Sub-Heading Spacing"),value:T,onChange:function(e){return a({subHeadSpace:e})},min:0,max:50,beforeIcon:"editor-textcolor",allowReset:!0}))),wp.element.createElement("div",{className:n},wp.element.createElement(y,{tagName:s,placeholder:m("Write a Heading"),value:o,className:"uagb-heading-text",onChange:function(e){return a({headingTitle:e})},style:{textAlign:i,fontSize:d+"px",color:c,marginBottom:O+"px"}}),wp.element.createElement("div",{className:"uagb-separator-wrap",style:{textAlign:i}},wp.element.createElement("div",{className:"uagb-separator",style:{borderTopWidth:H+"px",width:v+"%",borderColor:u,marginBottom:A+"px"}})),wp.element.createElement(y,{tagName:"p",placeholder:m("Write a Description"),value:l,className:"uagb-desc-text",onChange:function(e){return a({headingDesc:e})},style:{textAlign:i,fontSize:g+"px",color:p,marginBottom:T+"px"}}))]}}]),t}(H);d("uagb/advanced-heading",(i={title:m("Advanced Heading - UAGB"),description:m("Add Advanced Heading block."),icon:"editor-textcolor",category:"common",keywords:[m("advanced heading"),m("uagb")]},a(i,"category","formatting"),a(i,"attributes",{headingTitle:{type:"string"},headingDesc:{type:"string"},headingAlign:{type:"string",default:"center"},headingColor:{type:"string"},subHeadingColor:{type:"string"},separatorColor:{type:"string"},headingTag:{type:"string",default:"h1"},separatorHeight:{type:"number"},separatorWidth:{type:"number"},headFontSize:{type:"number"},subHeadFontSize:{type:"number"},headSpace:{type:"number"},separatorSpace:{type:"number"},subHeadSpace:{type:"number"}}),a(i,"edit",O),a(i,"save",function(e){console.log("Save props"),console.log(e);var t=e.attributes,n=t.headingTitle,a=t.headingDesc,r=t.headingAlign,o=t.headingColor,l=t.subHeadingColor,i=t.separatorColor,c=t.headingTag,p=t.separatorWidth,u=t.separatorHeight,s=t.headFontSize,m=t.subHeadFontSize,d=t.headSpace,g=t.separatorSpace,b=t.subHeadSpace;return wp.element.createElement("div",{className:e.className},wp.element.createElement(y.Content,{tagName:c,value:n,className:"uagb-heading-text",style:{textAlign:r,fontSize:s+"px",color:o,marginBottom:d+"px"}}),wp.element.createElement("div",{className:"uagb-separator-wrap",style:{textAlign:r}},wp.element.createElement("div",{className:"uagb-separator",style:{borderTopWidth:u+"px",width:p+"%",borderColor:i,marginBottom:g+"px"}})),wp.element.createElement("p",{className:"uagb-desc-text",style:{textAlign:r,fontSize:m+"px",color:l,marginBottom:b+"px"}},a))}),i))},function(e,t,n){var a,r;!function(){"use strict";function n(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var r=typeof a;if("string"===r||"number"===r)e.push(a);else if(Array.isArray(a))e.push(n.apply(null,a));else if("object"===r)for(var l in a)o.call(a,l)&&a[l]&&e.push(l)}}return e.join(" ")}var o={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?e.exports=n:(a=[],void 0!==(r=function(){return n}.apply(t,a))&&(e.exports=r))}()},function(e,t){},function(e,t){}]);
dist/blocks.editor.build.css ADDED
File without changes
dist/blocks.style.build.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-block-uagb-advanced-heading{padding:0;color:#000000;margin:0 auto}.wp-block-uagb-advanced-heading .uagb-heading-text{margin:0}.wp-block-uagb-advanced-heading .uagb-separator-wrap{font-size:0}.wp-block-uagb-advanced-heading .uagb-separator{border-top-style:solid;display:inline-block;border-top-width:2px;width:5%;margin:0px 0px 10px 0px}.wp-block-uagb-advanced-heading .uagb-desc-text{margin:0}
languages/ultimate-addons-for-gutenberg.pot ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2018 Brainstorm Force
2
+ # This file is distributed under the same license as the Ultimate Addons for Gutenberg package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Ultimate Addons for Gutenberg 0.0.1\n"
6
+ "Report-Msgid-Bugs-To: "
7
+ "https://wordpress.org/support/plugin/ultimate-addons-for-gutenberg\n"
8
+ "POT-Creation-Date: 2018-06-08 10:12:43+00:00\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=utf-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: en\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "X-Poedit-Country: United States\n"
18
+ "X-Poedit-SourceCharset: UTF-8\n"
19
+ "X-Poedit-KeywordsList: "
20
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
21
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
22
+ "X-Poedit-Basepath: ../\n"
23
+ "X-Poedit-SearchPath-0: .\n"
24
+ "X-Poedit-Bookmarks: \n"
25
+ "X-Textdomain-Support: yes\n"
26
+ "X-Generator: grunt-wp-i18n1.0.2\n"
27
+
28
+ #: classes/class-uagb-loader.php:147
29
+ #. translators: %s: html tags
30
+ msgid ""
31
+ "The %1$sUltimate Addon for Gutenberg%2$s plugin requires %1$sGutenberg%2$s "
32
+ "plugin installed & activated."
33
+ msgstr ""
34
+
35
+ #: classes/class-uagb-loader.php:157
36
+ msgid "Activate Gutenberg"
37
+ msgstr ""
38
+
39
+ #: classes/class-uagb-loader.php:165
40
+ msgid "Install Gutenberg"
41
+ msgstr ""
42
+
43
+ #. Plugin Name of the plugin/theme
44
+ msgid "Ultimate Addons for Gutenberg"
45
+ msgstr ""
46
+
47
+ #. Plugin URI of the plugin/theme
48
+ msgid "https://ultimategutenberg.com/"
49
+ msgstr ""
50
+
51
+ #. Description of the plugin/theme
52
+ msgid ""
53
+ "Ultimate Addons is a premium extension for Gutenberg that adds 5 modules "
54
+ "and works on top of Gutenberg. You can use it with any WordPress theme."
55
+ msgstr ""
56
+
57
+ #. Author of the plugin/theme
58
+ msgid "Brainstorm Force"
59
+ msgstr ""
60
+
61
+ #. Author URI of the plugin/theme
62
+ msgid "https://www.brainstormforce.com"
63
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Ultimate Addons for Gutenberg ===
2
+ Contributors: brainstormforce
3
+ Donate link: https://www.paypal.me/BrainstormForce
4
+ Tags: gutenberg, gutenberg free blocks, gutenberg addons, gutenberg addon, gutenberg addons, beaver builder lite, gutenberg blocks
5
+ Requires at least: 4.6
6
+ Requires PHP: 5.6
7
+ Tested up to: 4.9.6
8
+ Stable tag: 0.0.1
9
+ License: GPLv2 or later
10
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ The Ultimate Addons for Gutenberg extends the Gutenberg functionality with several unique custom blocks.
13
+
14
+ == Description ==
15
+
16
+ <strong>The Ultimate Addons for Gutenberg</strong>
17
+
18
+ Supercharge Gutenberg with custom blocks. We have Advanced Heading Block as a start. We will add more blocks soon.
19
+
20
+ Note: Gutenberg is in an early stage of development so the Ultimate Addons for Gutenberg is also in early stage and may not be suitable for production sites. The breaking changes could be expected.
21
+
22
+ Feel free to contribute to the Gutenberg development.
23
+
24
+ == Installation ==
25
+
26
+ 1. Install Ultimate Addon for Gutenberg either via the WordPress plugin directory or by uploading the files to your server at wp-content/plugins.
27
+
28
+ == Frequently Asked Questions ==
29
+
30
+ = Can I use Ultimate Addons for Gutenberg without Gutenberg? =
31
+
32
+ No.
33
+ The Ultimate Addons for Gutenberg is an addon for Gutenberg. You need Gutenberg to be activated.
34
+
35
+ == Screenshots ==
36
+
37
+ 1. /assets/screenshots/1.png
38
+
39
+ == Changelog ==
40
+
41
+ = 0.0.1 =
42
+ * Initial release
src/blocks.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Gutenberg Blocks
3
+ *
4
+ * All blocks related JavaScript files should be imported here.
5
+ * You can create a new block folder in this dir and include code
6
+ * for that block here as well.
7
+ *
8
+ * All blocks should be included here since this is the file that
9
+ * Webpack is compiling as the input file.
10
+ */
11
+
12
+ import './blocks/advanced-heading/block.js';
src/blocks/advanced-heading/block.js ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * BLOCK: advanced-heading
3
+ */
4
+
5
+ // Import block dependencies and components.
6
+ import classnames from 'classnames';
7
+
8
+ // Import CSS.
9
+ import './style.scss'
10
+ import './editor.scss';
11
+
12
+ // Import __() from wp.i18n
13
+ const { __ } = wp.i18n;
14
+
15
+ // Import registerBlockType() from wp.blocks
16
+ const {
17
+ registerBlockType,
18
+ } = wp.blocks;
19
+
20
+ const {
21
+ AlignmentToolbar,
22
+ BlockControls,
23
+ ColorPalette,
24
+ InspectorControls,
25
+ RichText,
26
+ } = wp.editor
27
+
28
+ const {
29
+ PanelBody,
30
+ PanelColor,
31
+ SelectControl,
32
+ RangeControl,
33
+ } = wp.components;
34
+
35
+ // Extend component
36
+ const { Component } = wp.element;
37
+
38
+ class UAGBAdvancedHeading extends Component {
39
+ render() {
40
+
41
+ // Setup the attributes
42
+ const {
43
+ isSelected,
44
+ className,
45
+ setAttributes,
46
+ attributes: {
47
+ headingTitle,
48
+ headingDesc,
49
+ headingAlign,
50
+ headingColor,
51
+ subHeadingColor,
52
+ separatorColor,
53
+ headingTag,
54
+ headFontSize,
55
+ subHeadFontSize,
56
+ separatorWidth,
57
+ separatorHeight,
58
+ headSpace,
59
+ separatorSpace,
60
+ subHeadSpace,
61
+ },
62
+ } = this.props;
63
+
64
+ return [
65
+
66
+ isSelected && (
67
+ <BlockControls key='controls'>
68
+ <AlignmentToolbar
69
+ value={ headingAlign }
70
+ onChange={ ( value ) => setAttributes( { headingAlign: value } ) }
71
+ />
72
+ </BlockControls>
73
+ ),
74
+
75
+ isSelected && (
76
+ <InspectorControls>
77
+ <PanelBody
78
+ title={ __( 'Typography' ) }
79
+ initialOpen={ false }
80
+ >
81
+ <SelectControl
82
+ label={ __( 'Tag' ) }
83
+ value={ headingTag }
84
+ onChange={ ( value ) => setAttributes( { headingTag: value } ) }
85
+ options={ [
86
+ { value: 'h1', label: __( 'H1' ) },
87
+ { value: 'h2', label: __( 'H2' ) },
88
+ { value: 'h3', label: __( 'H3' ) },
89
+ { value: 'h4', label: __( 'H4' ) },
90
+ { value: 'h5', label: __( 'H5' ) },
91
+ { value: 'h6', label: __( 'H6' ) },
92
+ ] }
93
+ />
94
+ <RangeControl
95
+ label={ __( 'Heading Font Size' ) }
96
+ value={ headFontSize }
97
+ onChange={ ( value ) => setAttributes( { headFontSize: value } ) }
98
+ min={ 10 }
99
+ max={ 200 }
100
+ beforeIcon="editor-textcolor"
101
+ allowReset
102
+ />
103
+ <RangeControl
104
+ label={ __( 'Sub-Heading Font Size' ) }
105
+ value={ subHeadFontSize }
106
+ onChange={ ( value ) => setAttributes( { subHeadFontSize: value } ) }
107
+ min={ 10 }
108
+ max={ 200 }
109
+ beforeIcon="editor-textcolor"
110
+ allowReset
111
+ />
112
+ </PanelBody>
113
+ <PanelBody
114
+ title={ __( 'Colors' ) }
115
+ initialOpen={ false }
116
+ >
117
+ <PanelColor
118
+ title={ __( 'Heading Color' ) }
119
+ colorValue={ headingColor }
120
+ initialOpen={ false }
121
+ >
122
+ <ColorPalette
123
+ value={ headingColor }
124
+ onChange={ ( colorValue ) => setAttributes( { headingColor: colorValue } ) }
125
+ allowReset
126
+ />
127
+ </PanelColor>
128
+ <PanelColor
129
+ title={ __( 'Sub-Heading Color' ) }
130
+ colorValue={ subHeadingColor }
131
+ initialOpen={ false }
132
+ >
133
+ <ColorPalette
134
+ value={ subHeadingColor }
135
+ onChange={ ( colorValue ) => setAttributes( { subHeadingColor: colorValue } ) }
136
+ allowReset
137
+ />
138
+ </PanelColor>
139
+ <PanelColor
140
+ title={ __( 'Separator Color' ) }
141
+ colorValue={ separatorColor }
142
+ initialOpen={ false }
143
+ >
144
+ <ColorPalette
145
+ value={ separatorColor }
146
+ onChange={ ( colorValue ) => setAttributes( { separatorColor: colorValue } ) }
147
+ allowReset
148
+ />
149
+ </PanelColor>
150
+ </PanelBody>
151
+ <PanelBody
152
+ title={ __( 'Additional Options' ) }
153
+ initialOpen={ false }
154
+ >
155
+ <RangeControl
156
+ label={ __( 'Separator Height' ) }
157
+ value={ separatorHeight }
158
+ onChange={ ( value ) => setAttributes( { separatorHeight: value } ) }
159
+ min={ 0 }
160
+ max={ 50 }
161
+ beforeIcon="editor-textcolor"
162
+ allowReset
163
+ />
164
+ <RangeControl
165
+ label={ __( 'Separator Width' ) }
166
+ value={ separatorWidth }
167
+ onChange={ ( value ) => setAttributes( { separatorWidth: value } ) }
168
+ min={ 0 }
169
+ max={ 100 }
170
+ beforeIcon="editor-textcolor"
171
+ allowReset
172
+ />
173
+ <RangeControl
174
+ label={ __( 'Heading Spacing' ) }
175
+ value={ headSpace }
176
+ onChange={ ( value ) => setAttributes( { headSpace: value } ) }
177
+ min={ 0 }
178
+ max={ 50 }
179
+ beforeIcon="editor-textcolor"
180
+ allowReset
181
+ />
182
+ <RangeControl
183
+ label={ __( 'Separator Spacing' ) }
184
+ value={ separatorSpace }
185
+ onChange={ ( value ) => setAttributes( { separatorSpace: value } ) }
186
+ min={ 0 }
187
+ max={ 50 }
188
+ beforeIcon="editor-textcolor"
189
+ allowReset
190
+ />
191
+ <RangeControl
192
+ label={ __( 'Sub-Heading Spacing' ) }
193
+ value={ subHeadSpace }
194
+ onChange={ ( value ) => setAttributes( { subHeadSpace: value } ) }
195
+ min={ 0 }
196
+ max={ 50 }
197
+ beforeIcon="editor-textcolor"
198
+ allowReset
199
+ />
200
+ </PanelBody>
201
+ </InspectorControls>
202
+ ),
203
+
204
+ <div className={ className }>
205
+ <RichText
206
+ tagName={ headingTag }
207
+ placeholder={ __( 'Write a Heading' ) }
208
+ value={ headingTitle }
209
+ className='uagb-heading-text'
210
+ onChange={ ( value ) => setAttributes( { headingTitle: value } ) }
211
+ style={{
212
+ textAlign: headingAlign,
213
+ fontSize: headFontSize + 'px',
214
+ color: headingColor,
215
+ marginBottom: headSpace + 'px',
216
+ }}
217
+ />
218
+ <div
219
+ className="uagb-separator-wrap"
220
+ style={{ textAlign: headingAlign }}
221
+ ><div className="uagb-separator" style={{ borderTopWidth: separatorHeight + 'px', width: separatorWidth + '%', borderColor: separatorColor, marginBottom: separatorSpace + 'px', }}></div></div>
222
+ <RichText
223
+ tagName="p"
224
+ placeholder={ __( 'Write a Description' ) }
225
+ value={ headingDesc }
226
+ className='uagb-desc-text'
227
+ onChange={ ( value ) => setAttributes( { headingDesc: value } ) }
228
+ style={{
229
+ textAlign: headingAlign,
230
+ fontSize: subHeadFontSize + 'px',
231
+ color: subHeadingColor,
232
+ marginBottom: subHeadSpace + 'px',
233
+ }}
234
+ />
235
+ </div>
236
+ ];
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Register: as Gutenberg Block.
242
+ *
243
+ * Registers a new block provided a unique name and an object defining its
244
+ * behavior.
245
+ *
246
+ * @link https://wordpress.org/gutenberg/handbook/block-api/
247
+ * @param {string} name Block name.
248
+ * @param {Object} settings Block settings.
249
+ * @return {?WPBlock} The block, if it has been successfully
250
+ * registered; otherwise `undefined`.
251
+ */
252
+ registerBlockType( 'uagb/advanced-heading', {
253
+
254
+ // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
255
+ title: __( 'Advanced Heading - UAGB' ), // Block title.
256
+ description: __( 'Add Advanced Heading block.' ), // Block description.
257
+ icon: 'editor-textcolor', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
258
+ category: 'common', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
259
+ keywords: [
260
+ __( 'advanced heading' ),
261
+ __( 'uagb' ),
262
+ ],
263
+ category: 'formatting',
264
+
265
+ attributes: {
266
+ headingTitle: {
267
+ type: 'string',
268
+ },
269
+ headingDesc: {
270
+ type: 'string',
271
+ },
272
+ headingAlign: {
273
+ type: 'string',
274
+ default: 'center',
275
+ },
276
+ headingColor: {
277
+ type: 'string',
278
+ },
279
+ subHeadingColor: {
280
+ type: 'string',
281
+ },
282
+ separatorColor: {
283
+ type: 'string',
284
+ },
285
+ headingTag: {
286
+ type: 'string',
287
+ default: 'h1'
288
+ },
289
+ separatorHeight: {
290
+ type: 'number'
291
+ },
292
+ separatorWidth: {
293
+ type: 'number'
294
+ },
295
+ headFontSize: {
296
+ type: 'number',
297
+ },
298
+ subHeadFontSize: {
299
+ type: 'number',
300
+ },
301
+ headSpace: {
302
+ type: 'number',
303
+ },
304
+ separatorSpace: {
305
+ type: 'number',
306
+ },
307
+ subHeadSpace: {
308
+ type: 'number',
309
+ },
310
+ },
311
+ /**
312
+ * The edit function describes the structure of your block in the context of the editor.
313
+ * This represents what the editor will render when the block is used.
314
+ *
315
+ * The "edit" property must be a valid function.
316
+ *
317
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
318
+ */
319
+ edit: UAGBAdvancedHeading,
320
+
321
+ /*function( props ) {
322
+
323
+ console.log( 'Edit props' );
324
+ console.log( props );
325
+
326
+ const { headingTitle } = props.attributes;
327
+
328
+ return (
329
+ <div className={ props.className }>
330
+ <p>Ultimate Addons For Gutenberg!</p>
331
+ </div>
332
+ );
333
+ },*/
334
+
335
+ /**
336
+ * The save function defines the way in which the different attributes should be combined
337
+ * into the final markup, which is then serialized by Gutenberg into post_content.
338
+ *
339
+ * The "save" property must be specified and must be a valid function.
340
+ *
341
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
342
+ */
343
+ save: function( props ) {
344
+
345
+ console.log( 'Save props' );
346
+ console.log( props );
347
+
348
+ const {
349
+ headingTitle,
350
+ headingDesc,
351
+ headingAlign,
352
+ headingColor,
353
+ subHeadingColor,
354
+ separatorColor,
355
+ headingTag,
356
+ separatorWidth,
357
+ separatorHeight,
358
+ headFontSize,
359
+ subHeadFontSize,
360
+ headSpace,
361
+ separatorSpace,
362
+ subHeadSpace,
363
+ } = props.attributes;
364
+
365
+ return (
366
+ <div className={ props.className }>
367
+ <RichText.Content
368
+ tagName={ headingTag }
369
+ value={ headingTitle }
370
+ className='uagb-heading-text'
371
+ style={{
372
+ textAlign: headingAlign,
373
+ fontSize: headFontSize + 'px',
374
+ color: headingColor,
375
+ marginBottom: headSpace + 'px',
376
+ }}
377
+ />
378
+ <div className="uagb-separator-wrap" style={{ textAlign: headingAlign }}><div className="uagb-separator" style={{ borderTopWidth: separatorHeight + 'px', width: separatorWidth + '%', borderColor: separatorColor, marginBottom: separatorSpace + 'px', }}></div></div>
379
+ <p className="uagb-desc-text" style={{ textAlign: headingAlign, fontSize: subHeadFontSize + 'px', color: subHeadingColor, marginBottom: subHeadSpace + 'px', }}>{ headingDesc }</p>
380
+ </div>
381
+ );
382
+ }
383
+ } );
src/blocks/advanced-heading/editor.scss ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /**
2
+ * #.# Editor Styles
3
+ *
4
+ * CSS for just Backend enqueued after style.scss
5
+ * which makes it higher in priority.
6
+ */
src/blocks/advanced-heading/style.scss ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * #.# Styles
3
+ *
4
+ * CSS for both Frontend+Backend.
5
+ */
6
+
7
+ .wp-block-uagb-advanced-heading {
8
+ padding: 0;
9
+ color: #000000;
10
+ margin: 0 auto;
11
+
12
+ .uagb-heading-text {
13
+ margin: 0;
14
+ }
15
+
16
+ .uagb-separator-wrap {
17
+ font-size: 0;
18
+ }
19
+
20
+ .uagb-separator {
21
+ border-top-style: solid;
22
+ display: inline-block;
23
+ border-top-width: 2px;
24
+ width: 5%;
25
+ margin: 0px 0px 10px 0px;
26
+ }
27
+
28
+ .uagb-desc-text {
29
+ margin: 0;
30
+ }
31
+ }
src/common.scss ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /**
2
+ * #.# Common SCSS
3
+ *
4
+ * Can include things like variables and mixins
5
+ * that are used across the project.
6
+ */
ultimate-addons-for-gutenberg.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Ultimate Addons for Gutenberg
4
+ * Plugin URI: https://ultimategutenberg.com/
5
+ * Author: Brainstorm Force
6
+ * Author URI: https://www.brainstormforce.com
7
+ * Version: 0.0.1
8
+ * Description: Ultimate Addons is a premium extension for Gutenberg that adds 5 modules and works on top of Gutenberg. You can use it with any WordPress theme.
9
+ * Text Domain: ultimate-addons-for-gutenberg
10
+ *
11
+ * @package UAGB
12
+ */
13
+
14
+ define( 'UAGB_FILE', __FILE__ );
15
+
16
+ require_once 'classes/class-uagb-loader.php';