VK Blocks - Version 0.52.2

Version Description

[ Other ] version only

Download this release

Release Info

Developer vektor-inc
Plugin Icon 128x128 VK Blocks
Version 0.52.2
Comparing to
See all releases

Code changes from version 0.51.0 to 0.52.2

README.md CHANGED
@@ -86,3 +86,5 @@ gulp dist して zip に圧縮してそのzipファイルをvwsのパッケー
86
  ```
87
  bin/dist_kuru.sh
88
  ```
 
 
86
  ```
87
  bin/dist_kuru.sh
88
  ```
89
+
90
+ naoki!
example.png ADDED
Binary file
inc/vk-css-optimize/package/class-css-tree-shaking.php CHANGED
@@ -1,9 +1,4 @@
1
  <?php
2
- /*
3
- The original of this file is located at:
4
- https://github.com/vektor-inc/vektor-wp-libraries
5
- If you want to change this file, please change the original file.
6
- */
7
  /**
8
  * CSS Simple Tree Shaking
9
  *
1
  <?php
 
 
 
 
 
2
  /**
3
  * CSS Simple Tree Shaking
4
  *
inc/vk-css-optimize/package/class-vk-css-optimize.php CHANGED
@@ -1,13 +1,8 @@
1
  <?php
2
- /*
3
- The original of this file is located at:
4
- https://github.com/vektor-inc/vektor-wp-libraries
5
- If you want to change this file, please change the original file.
6
- */
7
-
8
  /**
9
  * VK CSS Optimize
10
  *
 
11
  */
12
 
13
  /**
@@ -17,210 +12,12 @@ if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
17
  class VK_CSS_Optimize {
18
 
19
  public function __construct() {
20
- add_action( 'customize_register', array( __CLASS__, 'customize_register' ) );
21
- add_filter( 'css_tree_shaking_exclude', array( __CLASS__, 'tree_shaking_exclude' ) );
22
-
23
- $options = VK_CSS_Optimize::get_css_optimize_options();
24
-
25
- if ( ! empty( $options['tree_shaking'] ) ) {
26
- add_action( 'get_header', array( __CLASS__, 'get_html_start' ), 2147483647 );
27
- add_action( 'shutdown', array( __CLASS__, 'get_html_end' ), 0 );
28
- }
29
-
30
- if ( ! empty( $options['preload'] ) ) {
31
- add_filter( 'style_loader_tag', array( __CLASS__, 'css_preload' ), 10, 4 );
32
- }
33
- }
34
-
35
- public static function customize_register( $wp_customize ){
36
- global $prefix_customize_panel;
37
- $wp_customize->add_section(
38
- 'css_optimize', array(
39
- 'title' => $prefix_customize_panel . __( 'CSS Optimize ( Speed up ) Settings', 'vk-blocks' ),
40
- 'priority' => 450,
41
- )
42
- );
43
-
44
- // Tree shaking
45
- ////////////////////////////////////////////////////////////////
46
-
47
- $wp_customize->add_setting(
48
- 'tree_shaking_title',
49
- array(
50
- 'sanitize_callback' => 'sanitize_text_field',
51
- )
52
- );
53
- $wp_customize->add_control(
54
- new Custom_Html_Control(
55
- $wp_customize,
56
- 'tree_shaking_title',
57
- array(
58
- 'label' => __( 'Tree shaking', 'vk-blocks' ),
59
- 'section' => 'css_optimize',
60
- 'type' => 'text',
61
- 'custom_title_sub' => '',
62
- // 'custom_html' => __( 'Move part of CSS and JS to the footer to improve display speed.', 'vk-blocks' ),
63
- )
64
- )
65
- );
66
-
67
- $wp_customize->add_setting(
68
- 'vk_css_optimize_options[tree_shaking]',
69
- array(
70
- 'default' => '',
71
- 'type' => 'option',
72
- 'capability' => 'edit_theme_options',
73
- 'sanitize_callback' => array( 'VK_Helpers', 'sanitize_choice' ),
74
- )
75
- );
76
- $wp_customize->add_control(
77
- 'vk_css_optimize_options[tree_shaking]',
78
- array(
79
- 'label' => __( 'Tree shaking activation settings', 'vk-blocks' ),
80
- 'section' => 'css_optimize',
81
- 'settings' => 'vk_css_optimize_options[tree_shaking]',
82
- 'type' => 'select',
83
- 'description' => __( 'Output only the main CSS of the page inline', 'vk-blocks' ),
84
- 'choices' => array(
85
- '' => __( 'Nothing to do', 'vk-blocks' ),
86
- 'active' => __( 'Active Tree shaking (Recomend)', 'vk-blocks' ),
87
- ),
88
- )
89
- );
90
-
91
- $wp_customize->add_setting(
92
- 'vk_css_optimize_options[tree_shaking_class_exclude]',
93
- array(
94
- 'default' => '',
95
- 'type' => 'option',
96
- 'capability' => 'edit_theme_options',
97
- 'sanitize_callback' => 'sanitize_text_field',
98
- )
99
- );
100
- $wp_customize->add_control(
101
- 'vk_css_optimize_options[tree_shaking_class_exclude]',
102
- array(
103
- 'label' => __( 'Exclude class of tree shaking', 'vk-blocks' ),
104
- 'section' => 'css_optimize',
105
- 'settings' => 'vk_css_optimize_options[tree_shaking_class_exclude]',
106
- 'type' => 'textarea',
107
- 'description' => __( 'If you choose "Active Tree shaking" that delete the useless css.If you using active css class that please fill in class name. Ex) btn-active,slide-active,scrolled', 'vk-blocks' ),
108
- )
109
- );
110
-
111
- // Preload
112
- ////////////////////////////////////////////////////////////////
113
- $wp_customize->add_setting(
114
- 'css_preload_title',
115
- array(
116
- 'sanitize_callback' => 'sanitize_text_field',
117
- )
118
- );
119
- $wp_customize->add_control(
120
- new Custom_Html_Control(
121
- $wp_customize,
122
- 'css_preload_title',
123
- array(
124
- 'label' => __( 'Preload CSS', 'vk-blocks' ),
125
- 'section' => 'css_optimize',
126
- 'type' => 'text',
127
- 'custom_title_sub' => '',
128
- // 'custom_html' => __( 'Move part of CSS and JS to the footer to improve display speed.', 'vk-blocks' ),
129
- )
130
- )
131
- );
132
-
133
- $wp_customize->add_setting(
134
- 'vk_css_optimize_options[preload]',
135
- array(
136
- 'default' => '',
137
- 'type' => 'option',
138
- 'capability' => 'edit_theme_options',
139
- 'sanitize_callback' => 'sanitize_text_field',
140
- )
141
- );
142
- $wp_customize->add_control(
143
- 'vk_css_optimize_options[preload]',
144
- array(
145
- 'label' => __( 'Preload CSS activation settings', 'vk-blocks' ),
146
- 'section' => 'css_optimize',
147
- 'settings' => 'vk_css_optimize_options[preload]',
148
- 'description' => __( 'Preload css except for critical css', 'vk-blocks' ),
149
- 'type' => 'select',
150
- 'choices' => array(
151
- '' => __( 'Nothing to do', 'vk-blocks' ),
152
- 'active' => __( 'Active Preload CSS (Recomend)', 'vk-blocks' ),
153
- ),
154
- )
155
- );
156
-
157
- }
158
-
159
- /**
160
- *
161
- */
162
- public static function get_css_optimize_options(){
163
-
164
- $theme_textdomain = wp_get_theme()->get( 'TextDomain' );
165
- if ( 'lightning' === $theme_textdomain || 'lightning-pro' === $theme_textdomain ){
166
- $old_options = get_option( 'lightning_theme_options' );
167
- } else if ( 'katawara' === $theme_textdomain ){
168
- $old_options = get_option( 'katawara_theme_options' );
169
- } else {
170
- $old_options = get_option( 'vk_blocks_options' );
171
- }
172
-
173
- $vk_css_optimize_options = get_option( 'vk_css_optimize_options' );
174
- $vk_css_optimize_options_default = array(
175
- 'tree_shaking' => 'active',
176
- 'preload' => 'active',
177
- );
178
-
179
- // fall back function
180
- // Actualy other array exist but optimize_css is most important
181
- if ( ! isset( $vk_css_optimize_options['tree_shaking'] ) ) {
182
-
183
- if ( isset( $old_options['optimize_css'] ) ){
184
- if ( $old_options['optimize_css'] === 'optomize-all-css' || $old_options['optimize_css'] === 'tree-shaking' ){
185
- $vk_css_optimize_options['tree_shaking'] = 'active';
186
- } else {
187
- $vk_css_optimize_options['tree_shaking'] = '';
188
- }
189
- }
190
- }
191
-
192
- if ( ! isset( $vk_css_optimize_options['tree_shaking_class_exclude'] ) ) {
193
- if ( ! empty( $old_options['tree_shaking_class_exclude'] ) ){
194
- $vk_css_optimize_options['tree_shaking_class_exclude'] = esc_html( $old_options['tree_shaking_class_exclude'] );
195
- }
196
- }
197
-
198
- if ( ! isset( $vk_css_optimize_options['preload'] ) ) {
199
-
200
- if ( isset( $old_options['optimize_css'] ) ){
201
- if ( $old_options['optimize_css'] === 'optomize-all-css'){
202
- $vk_css_optimize_options['preload'] ='active';
203
- } else {
204
- $vk_css_optimize_options['preload'] = '';
205
- }
206
-
207
- }
208
-
209
- }
210
- $vk_css_optimize_options = wp_parse_args( $vk_css_optimize_options, $vk_css_optimize_options_default );
211
- if (
212
- ! isset( $vk_css_optimize_options['tree_shaking'] ) ||
213
- ! isset( $vk_css_optimize_options['tree_shaking_class_exclude'] ) ||
214
- ! isset( $vk_css_optimize_options['preload'] )
215
- ){
216
- update_option( 'vk_css_optimize_options', $vk_css_optimize_options );
217
- }
218
-
219
- return $vk_css_optimize_options;
220
  }
221
 
222
  public static function get_html_start() {
223
- ob_start( 'VK_CSS_Optimize::css_tree_shaking_buffer' );
224
  }
225
 
226
  public static function get_html_end() {
@@ -229,20 +26,12 @@ if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
229
  }
230
  }
231
 
232
- public static function css_tree_shaking_array() {
233
- $vk_css_tree_shaking_array = array();
234
- $vk_css_tree_shaking_array = apply_filters( 'vk_css_tree_shaking_array', $vk_css_tree_shaking_array );
235
- return $vk_css_tree_shaking_array;
236
- }
237
-
238
- public static function css_tree_shaking_buffer( $buffer ) {
239
-
240
- $options = VK_CSS_Optimize::get_css_optimize_options();
241
 
242
  // CSS Tree Shaking.
243
  require_once dirname( __FILE__ ) . '/class-css-tree-shaking.php';
244
- $vk_css_tree_shaking_array = VK_CSS_Optimize::css_tree_shaking_array();
245
-
246
  foreach ( $vk_css_tree_shaking_array as $vk_css_array ) {
247
  $options['ssl']['verify_peer'] = false;
248
  $options['ssl']['verify_peer_name'] = false;
@@ -268,63 +57,18 @@ if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
268
 
269
  }
270
 
271
- return $buffer;
272
- }
273
-
274
- public static function css_preload( $tag, $handle, $href, $media ) {
275
-
276
- $vk_css_tree_shaking_array = VK_CSS_Optimize::css_tree_shaking_array();
277
-
278
- $tree_shaking_handles = array();
279
-
280
- $options = VK_CSS_Optimize::get_css_optimize_options();
281
-
282
- // tree shaking がかかっているものはpreloadから除外する
283
- // でないと表示時に一瞬崩れて結局実用性に問題があるため
284
- foreach ( $vk_css_tree_shaking_array as $vk_css_array ) {
285
- $tree_shaking_handles[] = $vk_css_array['id'];
286
- }
287
- // クリティカルじゃないCSS(tree shakingにかけているもの以外)をpreload
288
- if ( ! in_array( $handle, $tree_shaking_handles ) ){
289
- $tag = "<link rel='preload' id='".$handle."-css' href='".$href."' as='style' onload=\"this.onload=null;this.rel='stylesheet'\"/>\n";
290
- $tag .= "<link rel='stylesheet' id='".$handle."-css' href='".$href."' media='print' onload=\"this.media='all'; this.onload=null;\">\n";
291
  }
292
 
293
- return $tag;
294
  }
295
 
296
-
297
- /**
298
- * Exclude CSS.
299
- *
300
- * @param string $inidata exclude css class.
301
- */
302
- public static function tree_shaking_exclude( $inidata ) {
303
- $options = VK_CSS_Optimize::get_css_optimize_options();
304
-
305
- $exclude_classes_array = array();
306
-
307
- if ( ! empty( $options['tree_shaking_class_exclude'] ) ) {
308
-
309
- // delete before after space.
310
- $exclude_clssses = trim( $options['tree_shaking_class_exclude'] );
311
-
312
- // convert tab and br to space.
313
- $exclude_clssses = preg_replace( '/[\n\r\t]/', '', $exclude_clssses );
314
-
315
- // Change multiple spaces to single space.
316
- $exclude_clssses = preg_replace( '/\s/', '', $exclude_clssses );
317
- $exclude_clssses = str_replace( ',', ',', $exclude_clssses );
318
- $exclude_clssses = str_replace( '、', ',', $exclude_clssses );
319
- $exclude_classes_array = explode( ',', $exclude_clssses );
320
-
321
- }
322
-
323
- $inidata['class'] = array_merge( $inidata['class'], $exclude_classes_array );
324
-
325
- return $inidata;
326
- }
327
-
328
  }
329
  new VK_CSS_Optimize();
330
  }
1
  <?php
 
 
 
 
 
 
2
  /**
3
  * VK CSS Optimize
4
  *
5
+ * @package Lightning
6
  */
7
 
8
  /**
12
  class VK_CSS_Optimize {
13
 
14
  public function __construct() {
15
+ add_action( 'get_header', array( __CLASS__, 'get_html_start' ), 2147483647 );
16
+ add_action( 'shutdown', array( __CLASS__, 'get_html_end' ), 0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
  public static function get_html_start() {
20
+ ob_start( 'VK_CSS_Optimize::css_optimize' );
21
  }
22
 
23
  public static function get_html_end() {
26
  }
27
  }
28
 
29
+ public static function css_optimize( $buffer ) {
30
+ $options = get_option( 'lightning_theme_options' );
 
 
 
 
 
 
 
31
 
32
  // CSS Tree Shaking.
33
  require_once dirname( __FILE__ ) . '/class-css-tree-shaking.php';
34
+ global $vk_css_tree_shaking_array;
 
35
  foreach ( $vk_css_tree_shaking_array as $vk_css_array ) {
36
  $options['ssl']['verify_peer'] = false;
37
  $options['ssl']['verify_peer_name'] = false;
57
 
58
  }
59
 
60
+ if ( ! empty( $options['optimize_css'] ) && 'optomize-all-css' === $options['optimize_css'] ) {
61
+ // CSS Preload.
62
+ $buffer = str_replace(
63
+ 'link rel=\'stylesheet\'',
64
+ 'link rel="preload" as="style" onload="this.onload=null;this.rel=\'stylesheet\'"',
65
+ $buffer
66
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
 
69
+ return $buffer;
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  new VK_CSS_Optimize();
74
  }
inc/vk-css-optimize/vk-css-optimize-config.php CHANGED
@@ -4,21 +4,11 @@
4
  *
5
  * @package VK Blocks
6
  */
7
-
8
- function vkblocks_load_css_optimize(){
9
- $theme_textdomain = wp_get_theme()->get( 'TextDomain' );
10
- // VK Blocks は翻訳作るのが面倒なのでテーマ側が翻訳してある場合はそちらを使う
11
- if (
12
- 'lightning' != $theme_textdomain &&
13
- 'lightning-pro' != $theme_textdomain &&
14
- 'katawara' != $theme_textdomain
15
- ){
16
- if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
17
- require_once dirname( __FILE__ ) . '/package/class-vk-css-optimize.php';
18
- }
19
- }
20
- }
21
- add_action( 'after_setup_theme', 'vkblocks_load_css_optimize',11 );
22
 
23
  function vkblocks_css_tree_shaking_array( $vk_css_tree_shaking_array ){
24
  $vk_css_tree_shaking_array[] = array(
4
  *
5
  * @package VK Blocks
6
  */
7
+
8
+ /*
9
+ VK CSS Optimize 本体はExUnitなどで読み込むのでここでは読み込まない
10
+ 追加したいファイルのみフックで投げる
11
+ */
 
 
 
 
 
 
 
 
 
 
12
 
13
  function vkblocks_css_tree_shaking_array( $vk_css_tree_shaking_array ){
14
  $vk_css_tree_shaking_array[] = array(
package-lock.json CHANGED
@@ -9935,9 +9935,9 @@
9935
  }
9936
  },
9937
  "buffer": {
9938
- "version": "5.6.1",
9939
- "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.1.tgz",
9940
- "integrity": "sha512-2z15UUHpS9/3tk9mY/q+Rl3rydOi7yMp5XWNQnRvoz+mJwiv8brqYwp9a+nOCtma6dwuEIxljD8W3ysVBZ05Vg==",
9941
  "dev": true,
9942
  "requires": {
9943
  "base64-js": "^1.3.1",
9935
  }
9936
  },
9937
  "buffer": {
9938
+ "version": "5.7.0",
9939
+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.0.tgz",
9940
+ "integrity": "sha512-cd+5r1VLBwUqTrmnzW+D7ABkJUM6mr7uv1dv+6jRw4Rcl7tFIFHDqHPL98LhpGFn3dbAt3gtLxtrWp4m1kFrqg==",
9941
  "dev": true,
9942
  "requires": {
9943
  "base64-js": "^1.3.1",
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
  Tags: Gutenberg,FAQ,alert
5
  Requires at least: 5.0
6
  Tested up to: 5.5.1
7
- Stable tag: 0.50.3
8
  Requires PHP: 5.6.0
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -62,6 +62,21 @@ e.g.
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  = 0.50.3 =
66
  * [ Other ] version only
67
 
4
  Tags: Gutenberg,FAQ,alert
5
  Requires at least: 5.0
6
  Tested up to: 5.5.1
7
+ Stable tag: 0.52.2
8
  Requires PHP: 5.6.0
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
62
 
63
  == Changelog ==
64
 
65
+ = 0.52.2 =
66
+ [ Other ] version only
67
+
68
+ = 0.52.1 =
69
+ [ Bug fix ][ Grid Column(Pro) ] Fixed a bug that the hidden specification is removed when re-editing
70
+ [ Bug fix ][ Slider(Pro) ] Fix Can not stop loop
71
+ [ Bug fix ][ Outer(Pro) ] Fix cant edit outer block(cant save style tag) on Editor role user
72
+
73
+ = 0.52.0 =
74
+ [ Specification Change ][ CSS Optimize ] Delete package
75
+
76
+ = 0.51.0 =
77
+ [ Specification Change ][ CSS Optimize ] default off / exclude wooCommerce preload
78
+ [ Add function ][ CSS Optimize ] Add exclude handles
79
+
80
  = 0.50.3 =
81
  * [ Other ] version only
82
 
vk-blocks.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: VK Blocks
4
  * Plugin URI: https://github.com/vektor-inc/vk-blocks
5
  * Description: This is a plugin that extends Gutenberg's blocks.
6
- * Version: 0.50.3
7
  * Author: Vektor,Inc.
8
  * Author URI: https://vektor-inc.co.jp
9
  * Text Domain: vk-blocks
3
  * Plugin Name: VK Blocks
4
  * Plugin URI: https://github.com/vektor-inc/vk-blocks
5
  * Description: This is a plugin that extends Gutenberg's blocks.
6
+ * Version: 0.52.2
7
  * Author: Vektor,Inc.
8
  * Author URI: https://vektor-inc.co.jp
9
  * Text Domain: vk-blocks