Gutenberg Blocks – ACF Blocks Suite - Version 2.5.0

Version Description

  • Added Random Image Block (Free)
  • Bug Fixes
Download this release

Release Info

Developer munirkamal
Plugin Icon 128x128 Gutenberg Blocks – ACF Blocks Suite
Version 2.5.0
Comparing to
See all releases

Code changes from version 2.4.0 to 2.5.0

acf-blocks.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: ACF Blocks Suite
5
  * Plugin URI: https://acfblocks.com/
6
  * Description: Supercharge your Gutenberg editor with high quality beautiful WordPress blocks. Ready-to-use ACF Blocks!
7
- * Version: 2.4.0
8
  * Author: munirkamal
9
  * Author URI: https://munirkamal.wordpress.com
10
  * License: GPL2
@@ -491,7 +491,7 @@ if ( function_exists( 'acfb_fs' ) ) {
491
  $defaults = get_field_object( $field_id );
492
  $v = array();
493
  foreach ( $fields as $field ) {
494
- $v[$field] = $defaults[$field];
495
  }
496
  return $v;
497
  } else {
4
  * Plugin Name: ACF Blocks Suite
5
  * Plugin URI: https://acfblocks.com/
6
  * Description: Supercharge your Gutenberg editor with high quality beautiful WordPress blocks. Ready-to-use ACF Blocks!
7
+ * Version: 2.5.0
8
  * Author: munirkamal
9
  * Author URI: https://munirkamal.wordpress.com
10
  * License: GPL2
491
  $defaults = get_field_object( $field_id );
492
  $v = array();
493
  foreach ( $fields as $field ) {
494
+ $v[$field] = $defaults[$field] ?? "";
495
  }
496
  return $v;
497
  } else {
acf-json/group_5f8833a2c19d0.json ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "key": "group_5f8833a2c19d0",
3
+ "title": "Random Image",
4
+ "fields": [
5
+ {
6
+ "key": "field_5f8834a6177ff",
7
+ "label": "Content",
8
+ "name": "",
9
+ "type": "tab",
10
+ "instructions": "",
11
+ "required": 0,
12
+ "conditional_logic": 0,
13
+ "wrapper": {
14
+ "width": "",
15
+ "class": "",
16
+ "id": ""
17
+ },
18
+ "placement": "top",
19
+ "endpoint": 0
20
+ },
21
+ {
22
+ "key": "field_5f8834bd17801",
23
+ "label": "Select Images",
24
+ "name": "acfb_random_images",
25
+ "type": "gallery",
26
+ "instructions": "",
27
+ "required": 0,
28
+ "conditional_logic": 0,
29
+ "wrapper": {
30
+ "width": "",
31
+ "class": "",
32
+ "id": ""
33
+ },
34
+ "return_format": "url",
35
+ "preview_size": "medium",
36
+ "insert": "append",
37
+ "library": "all",
38
+ "min": "",
39
+ "max": "",
40
+ "min_width": "",
41
+ "min_height": "",
42
+ "min_size": "",
43
+ "max_width": "",
44
+ "max_height": "",
45
+ "max_size": "",
46
+ "mime_types": ""
47
+ },
48
+ {
49
+ "key": "field_5f897c9843aa6",
50
+ "label": "Alignment",
51
+ "name": "acfb_random_image_alignment",
52
+ "type": "button_group",
53
+ "instructions": "",
54
+ "required": 0,
55
+ "conditional_logic": 0,
56
+ "wrapper": {
57
+ "width": "",
58
+ "class": "",
59
+ "id": ""
60
+ },
61
+ "choices": {
62
+ "flex-start": "<span class=\"dashicons dashicons-editor-alignleft\"><\/span>",
63
+ "center": "<span class=\"dashicons dashicons-editor-aligncenter\"><\/span>",
64
+ "flex-end": "<span class=\"dashicons dashicons-editor-alignright\"><\/span>"
65
+ },
66
+ "allow_null": 0,
67
+ "default_value": "flex-start",
68
+ "layout": "horizontal",
69
+ "return_format": "value"
70
+ },
71
+ {
72
+ "key": "field_5f8834b217800",
73
+ "label": "Design",
74
+ "name": "",
75
+ "type": "tab",
76
+ "instructions": "",
77
+ "required": 0,
78
+ "conditional_logic": 0,
79
+ "wrapper": {
80
+ "width": "",
81
+ "class": "",
82
+ "id": ""
83
+ },
84
+ "placement": "top",
85
+ "endpoint": 0
86
+ },
87
+ {
88
+ "key": "field_5f883d323370a",
89
+ "label": "Sizing",
90
+ "name": "",
91
+ "type": "accordion",
92
+ "instructions": "",
93
+ "required": 0,
94
+ "conditional_logic": 0,
95
+ "wrapper": {
96
+ "width": "",
97
+ "class": "",
98
+ "id": ""
99
+ },
100
+ "open": 0,
101
+ "multi_expand": 0,
102
+ "endpoint": 0
103
+ },
104
+ {
105
+ "key": "field_5f883d483370c",
106
+ "label": "Width",
107
+ "name": "acfb_random_image_width",
108
+ "type": "range",
109
+ "instructions": "",
110
+ "required": 0,
111
+ "conditional_logic": 0,
112
+ "wrapper": {
113
+ "width": "",
114
+ "class": "",
115
+ "id": ""
116
+ },
117
+ "default_value": 100,
118
+ "min": "",
119
+ "max": "",
120
+ "step": "",
121
+ "prepend": "",
122
+ "append": "%"
123
+ },
124
+ {
125
+ "key": "field_5f883d3e3370b",
126
+ "label": "Spacing",
127
+ "name": "",
128
+ "type": "accordion",
129
+ "instructions": "",
130
+ "required": 0,
131
+ "conditional_logic": 0,
132
+ "wrapper": {
133
+ "width": "",
134
+ "class": "",
135
+ "id": ""
136
+ },
137
+ "open": 0,
138
+ "multi_expand": 0,
139
+ "endpoint": 0
140
+ },
141
+ {
142
+ "key": "field_5f883d983370e",
143
+ "label": "Margin",
144
+ "name": "acfb_random_image_margin",
145
+ "type": "margin",
146
+ "instructions": "",
147
+ "required": 0,
148
+ "conditional_logic": 0,
149
+ "wrapper": {
150
+ "width": "",
151
+ "class": "",
152
+ "id": ""
153
+ },
154
+ "margin_enable": 0,
155
+ "margin_top": "",
156
+ "margin_right": "",
157
+ "margin_bottom": "",
158
+ "margin_left": ""
159
+ },
160
+ {
161
+ "key": "field_5f883dae3370f",
162
+ "label": "Padding",
163
+ "name": "acfb_random_image_padding",
164
+ "type": "padding",
165
+ "instructions": "",
166
+ "required": 0,
167
+ "conditional_logic": 0,
168
+ "wrapper": {
169
+ "width": "",
170
+ "class": "",
171
+ "id": ""
172
+ },
173
+ "padding_enable": 0,
174
+ "padding_top": "",
175
+ "padding_right": "",
176
+ "padding_bottom": "",
177
+ "padding_left": ""
178
+ }
179
+ ],
180
+ "location": [
181
+ [
182
+ {
183
+ "param": "block",
184
+ "operator": "==",
185
+ "value": "acf\/acfb-random-image"
186
+ }
187
+ ]
188
+ ],
189
+ "menu_order": 0,
190
+ "position": "normal",
191
+ "style": "default",
192
+ "label_placement": "top",
193
+ "instruction_placement": "label",
194
+ "hide_on_screen": "",
195
+ "active": true,
196
+ "description": "",
197
+ "modified": 1602845880
198
+ }
block-templates/free/acfb-accordion.php CHANGED
@@ -8,7 +8,6 @@ echo parse_link(
8
  )
9
  );
10
 
11
-
12
  $acfb_accordion_padding = acfb_padding_name('acfb_accordion_padding');
13
  $acfb_accordion_margin = acfb_margin_name('acfb_accordion_margin');
14
  $acfb_accordion_title_typo = acfb_ffaimly_name('acfb_accordion_title_typo');
8
  )
9
  );
10
 
 
11
  $acfb_accordion_padding = acfb_padding_name('acfb_accordion_padding');
12
  $acfb_accordion_margin = acfb_margin_name('acfb_accordion_margin');
13
  $acfb_accordion_title_typo = acfb_ffaimly_name('acfb_accordion_title_typo');
block-templates/free/acfb-random-image.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $uid = $block['id'];
3
+
4
+ $className = 'acfb_random_image_block';
5
+ if( !empty($block['className']) ) {
6
+ $className .= ' ' . $block['className'];
7
+ }
8
+ if( !empty($block['align']) ) {
9
+ $className .= ' align' . $block['align'];
10
+ }
11
+
12
+ $placeholders = [
13
+ 'https://p111.p2.n0.cdn.getcloudapp.com/items/RBuWl6Bk/Image%202020-10-16%20at%205.07.13%20PM.jpg',
14
+ 'https://p111.p2.n0.cdn.getcloudapp.com/items/2Nujq1bx/Image%202020-10-16%20at%205.07.37%20PM.jpg',
15
+ 'https://p111.p2.n0.cdn.getcloudapp.com/items/JrugDAyd/Image%202020-10-16%20at%205.07.31%20PM.jpg',
16
+ 'https://p111.p2.n0.cdn.getcloudapp.com/items/ApuLz6eb/Image%202020-10-16%20at%205.07.23%20PM.jpgg',
17
+ ];
18
+
19
+ $acfb_random_image_margin = acfb_padding_name('acfb_random_image_margin');
20
+ $acfb_random_image_padding = acfb_margin_name('acfb_random_image_padding');
21
+ $acfb_random_image_gallery = get_field('acfb_random_images');
22
+
23
+ $final_random_image_gallery = is_array($acfb_random_image_gallery) ? $acfb_random_image_gallery : $placeholders;
24
+
25
+
26
+
27
+ ?>
28
+ <div class="<?php echo $uid; ?> <?php echo esc_attr($className); ?>">
29
+ <style type="text/css">
30
+ .<?php echo $uid; ?>{
31
+ <?php echo get_padding_field($acfb_random_image_padding); ?>
32
+ <?php echo get_margin_field($acfb_random_image_margin); ?>
33
+ }
34
+
35
+ .<?php echo $uid; ?> .acfb_random_image{
36
+ display: flex;
37
+ justify-content: <?php the_field('acfb_random_image_alignment'); ?>;
38
+ }
39
+
40
+ .<?php echo $uid; ?> .acfb_random_image img{
41
+ width: <?php the_field("acfb_random_image_width"); ?>%;
42
+ }
43
+
44
+ </style>
45
+
46
+ <div class="acfb_random_image">
47
+ <img src="" class="acfb_ri" data-random-image="<?php echo implode(',', $final_random_image_gallery); ?>" />
48
+ </div>
49
+
50
+ </div><!-- Uid -->
free-acf-blocks.php CHANGED
@@ -416,7 +416,20 @@ function acfb_blocks_free() {
416
  },
417
  ));
418
 
419
-
 
 
 
 
 
 
 
 
 
 
 
 
 
420
 
421
  }
422
 
416
  },
417
  ));
418
 
419
+ // register a Random Image
420
+ acf_register_block(array(
421
+ 'name' => 'acfb-random-image',
422
+ 'mode' => 'preview',
423
+ 'title' => __('Random Image'),
424
+ 'description' => __('Add Random Image in your pages/posts.'),
425
+ 'render_callback' => 'acf_blocks_template',
426
+ 'category' => 'acfb-blocks',
427
+ 'icon' => '<svg viewBox="0 -21 511.98744 511" xmlns="http://www.w3.org/2000/svg"><path d="m377.652344 469.828125c-4.03125 0-8.148438-.511719-12.226563-1.578125l-329.898437-88.34375c-25.449219-7.019531-40.617188-33.34375-33.960938-58.773438l36.265625-139.070312c2.21875-8.535156 10.945313-13.71875 19.519531-11.433594 8.535157 2.21875 13.675782 10.964844 11.4375 19.519532l-36.269531 139.09375c-2.238281 8.574218 2.859375 17.425781 11.394531 19.773437l329.707032 88.300781c8.46875 2.238282 17.214844-2.796875 19.433594-11.222656l11.261718-45.441406c2.136719-8.574219 10.796875-13.78125 19.371094-11.6875 8.578125 2.132812 13.804688 10.792968 11.691406 19.367187l-11.304687 45.65625c-5.699219 21.609375-25.152344 35.839844-46.421875 35.839844zm0 0"/><path d="m463.988281 341.828125h-330.667969c-26.472656 0-48-21.527344-48-48v-245.335937c0-26.472657 21.527344-48 48-48h330.667969c26.472657 0 48 21.527343 48 48v245.335937c0 26.472656-21.527343 48-48 48zm-330.667969-309.335937c-8.832031 0-16 7.167968-16 16v245.335937c0 8.832031 7.167969 16 16 16h330.667969c8.832031 0 16-7.167969 16-16v-245.335937c0-8.832032-7.167969-16-16-16zm0 0"/><path d="m191.988281 149.828125c-23.53125 0-42.667969-19.136719-42.667969-42.667969s19.136719-42.667968 42.667969-42.667968 42.664063 19.136718 42.664063 42.667968-19.132813 42.667969-42.664063 42.667969zm0-53.335937c-5.890625 0-10.667969 4.78125-10.667969 10.667968 0 5.886719 4.777344 10.667969 10.667969 10.667969 5.886719 0 10.664063-4.78125 10.664063-10.667969 0-5.886718-4.777344-10.667968-10.664063-10.667968zm0 0"/><path d="m101.746094 320.066406c-4.09375 0-8.191406-1.558594-11.304688-4.691406-6.25-6.25-6.25-16.386719 0-22.636719l96.425782-96.425781c14.59375-14.59375 38.335937-14.59375 52.90625 0l25.792968 25.792969 79.230469-95.105469c7.082031-8.492188 17.472656-13.398438 28.503906-13.460938 11.859375-.660156 21.460938 4.734376 28.605469 13.121094l106.199219 123.902344c5.757812 6.699219 4.96875 16.8125-1.730469 22.570312-6.71875 5.761719-16.808594 4.972657-22.570312-1.726562l-106.238282-123.945312c-1.410156-1.6875-3.136718-1.601563-4.097656-1.902344-.914062 0-2.6875.277344-4.09375 1.941406l-90.453125 108.589844c-2.882813 3.453125-7.082031 5.546875-11.5625 5.738281-4.566406.253906-8.875-1.496094-12.035156-4.671875l-38.183594-38.1875c-2.710937-2.710938-4.949219-2.710938-7.660156 0l-96.425781 96.40625c-3.117188 3.132812-7.210938 4.691406-11.308594 4.691406zm0 0"/></svg>',
428
+ 'enqueue_assets' => function(){
429
+ wp_enqueue_style( 'acfb-blocks-css', plugin_dir_url( __FILE__ ) . 'css/acfblocks.css' );
430
+ wp_enqueue_script( 'acfb-random-image-js', plugin_dir_url( __FILE__ ) . 'js/random-image.js', array('jquery'), '', true );
431
+ },
432
+ ));
433
 
434
  }
435
 
js/random-image.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ var initializeBlock = function( $block ) {
4
+
5
+ var randomImage = $($block).find('.acfb_ri').data('random-image');
6
+ var description = typeof randomImage !== 'undefined' ? randomImage.split(",") : [];
7
+
8
+ var size = description.length;
9
+ $($block).find('.acfb_random_image img').each(function() {
10
+ var x = Math.floor(size * Math.random()); //move random inside loop
11
+ if ($(this).hasClass("acfb_ri")) { //replace "img" with "this"
12
+ $(this).attr("src", description[x]);
13
+ }
14
+ });
15
+
16
+ // var size = description.length
17
+ // var x = Math.floor(size*Math.random())
18
+ // document.getElementById('random_image').src=description[x];
19
+
20
+ }
21
+
22
+ $(document).ready(function(){
23
+ $('.acfb_random_image_block').each(function(){
24
+ initializeBlock( $(this) );
25
+ });
26
+ });
27
+
28
+ if( window.acf ) {
29
+ window.acf.addAction( 'render_block_preview/type=acfb-random-image', initializeBlock );
30
+ }
31
+
32
+ })(jQuery);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: munirkamal, freemius
3
  Tags: block, gutenberg block, acf block, gutenberg, acf, editor
4
  Requires at least: 5.0
5
  Requires PHP: 5.6
6
- Tested up to: 5.5
7
- Stable tag: 2.4.0
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -42,6 +42,7 @@ ACF Blocks Suite is a collection of ready-to-use Gutenberg Blocks for WordPress.
42
  <li>Acf Meta Display Block</li>
43
  <li>Facebook Like Button Block</li>
44
  <li>Divider Block</li>
 
45
  </ol>
46
 
47
  == ACF Blocks Suite Pro Brings More Power ==
@@ -143,6 +144,10 @@ Absolutely! You can definitely use the ACF Blocks on yours as well as your clien
143
 
144
  == Changelog ==
145
 
 
 
 
 
146
  = 2.4.0 =
147
  * Added Divider Block (Free)
148
 
3
  Tags: block, gutenberg block, acf block, gutenberg, acf, editor
4
  Requires at least: 5.0
5
  Requires PHP: 5.6
6
+ Tested up to: 5.5.1
7
+ Stable tag: 2.5.0
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
42
  <li>Acf Meta Display Block</li>
43
  <li>Facebook Like Button Block</li>
44
  <li>Divider Block</li>
45
+ <li>Random Image Block</li>
46
  </ol>
47
 
48
  == ACF Blocks Suite Pro Brings More Power ==
144
 
145
  == Changelog ==
146
 
147
+ = 2.5.0 =
148
+ * Added Random Image Block (Free)
149
+ * Bug Fixes
150
+
151
  = 2.4.0 =
152
  * Added Divider Block (Free)
153