Version Description
[ Add function ] CSS Optimize(Tree shaking)
Download this release
Release Info
Developer | kurudrive |
Plugin | VK All in One Expansion Unit |
Version | 9.31.0.0 |
Comparing to | |
See all releases |
Code changes from version 9.30.2.0 to 9.31.0.0
- admin/customizer.php +14 -8
- inc/vk-css-optimize/package/class-css-tree-shaking.php +225 -0
- inc/vk-css-optimize/package/class-vk-css-optimize.php +74 -0
- inc/vk-css-optimize/vk-css-optimize-config.php +49 -0
- initialize.php +6 -26
- readme.txt +4 -1
- vkExUnit.php +1 -1
admin/customizer.php
CHANGED
@@ -113,25 +113,31 @@ function veu_customize_register_pagespeed( $wp_customize ) {
|
|
113 |
|
114 |
// CSS Footer Setting.
|
115 |
$wp_customize->add_setting(
|
116 |
-
'vkExUnit_pagespeeding[
|
117 |
array(
|
118 |
-
'default' =>
|
119 |
'type' => 'option',
|
120 |
'capability' => 'edit_theme_options',
|
121 |
-
'sanitize_callback' => '
|
122 |
)
|
123 |
);
|
124 |
$wp_customize->add_control(
|
125 |
-
'vkExUnit_pagespeeding[
|
126 |
array(
|
127 |
-
'label' => __( '
|
128 |
'section' => 'veu_speeding_setting',
|
129 |
-
'settings' => 'vkExUnit_pagespeeding[
|
130 |
-
'
|
131 |
-
'
|
|
|
|
|
|
|
|
|
|
|
132 |
)
|
133 |
);
|
134 |
|
|
|
135 |
// JS Footer Setting.
|
136 |
$wp_customize->add_setting(
|
137 |
'vkExUnit_pagespeeding[js_footer]',
|
113 |
|
114 |
// CSS Footer Setting.
|
115 |
$wp_customize->add_setting(
|
116 |
+
'vkExUnit_pagespeeding[css_optimize]',
|
117 |
array(
|
118 |
+
'default' => 'tree-shaking',
|
119 |
'type' => 'option',
|
120 |
'capability' => 'edit_theme_options',
|
121 |
+
'sanitize_callback' => 'veu_sanitize_radio',
|
122 |
)
|
123 |
);
|
124 |
$wp_customize->add_control(
|
125 |
+
'vkExUnit_pagespeeding[css_optimize]',
|
126 |
array(
|
127 |
+
'label' => __( 'Optimize CSS', 'vk-all-in-one-expansion-unit' ),
|
128 |
'section' => 'veu_speeding_setting',
|
129 |
+
'settings' => 'vkExUnit_pagespeeding[css_optimize]',
|
130 |
+
'description' => __( 'If you enable this setting that css file will be minified.', 'vk-all-in-one-expansion-unit' ),
|
131 |
+
'type' => 'select',
|
132 |
+
'choices' => array(
|
133 |
+
'default' => __( 'Nothing to do', 'vk-all-in-one-expansion-unit' ),
|
134 |
+
'tree-shaking' => __( 'Optimize All CSS ( Tree Shaking ) ( Beta )', 'vk-all-in-one-expansion-unit' ),
|
135 |
+
'optomize-all-css' => __( 'Optimize All CSS ( Tree Shaking + Preload ) ( Beta )', 'vk-all-in-one-expansion-unit' ),
|
136 |
+
),
|
137 |
)
|
138 |
);
|
139 |
|
140 |
+
|
141 |
// JS Footer Setting.
|
142 |
$wp_customize->add_setting(
|
143 |
'vkExUnit_pagespeeding[js_footer]',
|
inc/vk-css-optimize/package/class-css-tree-shaking.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CSS Simple Tree Shaking
|
4 |
+
*
|
5 |
+
* Description: CSS 定義データから未使用の id, class, tag に関する定義を取り除き縮小化します
|
6 |
+
*
|
7 |
+
* Version: 1.0.2
|
8 |
+
* Author: enomoto@celtislab
|
9 |
+
* Author URI: https://celtislab.net/
|
10 |
+
* License: GPLv2
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
namespace celtislab;
|
14 |
+
|
15 |
+
defined( 'ABSPATH' ) || exit;
|
16 |
+
|
17 |
+
class CSS_tree_shaking {
|
18 |
+
|
19 |
+
private static $cmplist;
|
20 |
+
private static $varlist;
|
21 |
+
private static $jsaddlist;
|
22 |
+
private static $atrule_data;
|
23 |
+
function __construct() {}
|
24 |
+
|
25 |
+
// アットルール一時退避( @{md5key} に置き換えておく)
|
26 |
+
private static function atrule_store($css){
|
27 |
+
$pattern = array( '|(@(\-[\w]+\-)?keyframes.+?\{)(.+?\})\}|',
|
28 |
+
'|(@(\-[\w]+\-)?supports.+?\{)(.+?\})\}|',
|
29 |
+
'|(@(\-[\w]+\-)?media.+?\{)(.+?\})\}|',
|
30 |
+
'|@[^;\{]+?;|',
|
31 |
+
'|@[^;\{]+?\{(.+?)\}|'
|
32 |
+
);
|
33 |
+
foreach ( $pattern as $atrule ) {
|
34 |
+
$css = preg_replace_callback( $atrule, function($matches) {
|
35 |
+
$key = 'AR_' . md5($matches[0]);
|
36 |
+
$data = $matches[0];
|
37 |
+
if(!empty($matches[3])){
|
38 |
+
$incss = self::atrule_store( $matches[3] );
|
39 |
+
$incss = self::tree_shaking( $incss );
|
40 |
+
$data = (!empty($incss))? $matches[1] . $incss . '}' : '';
|
41 |
+
}
|
42 |
+
self::$atrule_data[ $key ] = $data;
|
43 |
+
return '@{' . $key . '}';
|
44 |
+
}, $css);
|
45 |
+
}
|
46 |
+
return $css;
|
47 |
+
}
|
48 |
+
|
49 |
+
//アットルール復元
|
50 |
+
private static function atrule_restore($css){
|
51 |
+
$css = preg_replace_callback('|@\{(.+?)\}|', function($matches) {
|
52 |
+
$data = $matches[0];
|
53 |
+
$key = $matches[1];
|
54 |
+
if(strpos($key, 'AR_') !== false){
|
55 |
+
$data = (!empty(self::$atrule_data[ $key ]))? self::atrule_restore( self::$atrule_data[ $key ] ) : '';
|
56 |
+
}
|
57 |
+
return $data;
|
58 |
+
}, $css);
|
59 |
+
return $css;
|
60 |
+
}
|
61 |
+
|
62 |
+
//CSS から未使用の id, class, tag を含む定義を削除
|
63 |
+
private static function tree_shaking($css) {
|
64 |
+
$ncss = preg_replace_callback("|(.+?)(\{.+?\})|u", function($matches) {
|
65 |
+
$data = $matches[0];
|
66 |
+
$sel = $matches[1];
|
67 |
+
if($sel !== '@'){
|
68 |
+
$pattern = array( 'id' => '|(#)([\w\-\\%]+)|u',
|
69 |
+
'class' => '|(\.)([\w\-\\%]+)|u',
|
70 |
+
'tag' => '/(^|[,\s>\+~\(\)\]\|])([\w\-]+)/iu'
|
71 |
+
);
|
72 |
+
|
73 |
+
$slist = array_map("trim", explode(',', $sel));
|
74 |
+
foreach ($slist as $s) {
|
75 |
+
//selector の判定条件から :not(...) を除外 ($_s で判定して削除時は $s で行う)
|
76 |
+
$_s = $s;
|
77 |
+
if(preg_match('/:not\(.+?\)/', $s)){
|
78 |
+
$_s = preg_replace( '/:not\(.+?\)/', '', $s );
|
79 |
+
}
|
80 |
+
foreach (array('id','class','tag') as $item) {
|
81 |
+
if(!empty($_s) && preg_match_all( $pattern[$item], $_s, $match)){
|
82 |
+
foreach ($match[2] as $val) {
|
83 |
+
//$jsaddlist 登録名が一部でも含まれていれば削除しない(処理を簡略化するため上位層のセレクタのみで判定)
|
84 |
+
if(in_array($val, self::$jsaddlist))
|
85 |
+
break;
|
86 |
+
|
87 |
+
//$cmplist 登録名に含まれていないものが一つでもあれば削除
|
88 |
+
if(!preg_match('/^[0-9]+/', $val) && !in_array($val, self::$cmplist[$item])){
|
89 |
+
$sel = preg_replace( '/(' . preg_quote($s) . ')(,|$)/u', '$2', $sel, 1 );
|
90 |
+
$s = '';
|
91 |
+
break;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
$sel = preg_replace('/,+/su', ',', $sel);
|
98 |
+
$sel = preg_replace('/\s+/su', ' ', $sel);
|
99 |
+
$sel = trim($sel);
|
100 |
+
$sel = trim($sel, ',');
|
101 |
+
$data = (!empty($sel))? $sel . $matches[2] : '';
|
102 |
+
}
|
103 |
+
return $data;
|
104 |
+
}, $css);
|
105 |
+
return $ncss;
|
106 |
+
}
|
107 |
+
|
108 |
+
//未使用変数定義の削除(tree_shaking 実行後に実施する必要あり)
|
109 |
+
public static function tree_shaking4var($css) {
|
110 |
+
$ncss = $css;
|
111 |
+
self::$varlist = array();
|
112 |
+
if(preg_match_all( '/var\((\-\-.+?)\)/iu', $css, $vmatchs)){
|
113 |
+
foreach ($vmatchs[1] as $v) {
|
114 |
+
$v = trim($v);
|
115 |
+
if(!in_array($v, self::$varlist)){
|
116 |
+
self::$varlist[] = $v;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
//url() 定義時は文字列中に ; がそのまま含まれている場合があるの分けて処理
|
121 |
+
$ncss = preg_replace_callback( '|(\-\-[\w\-]+?):url\(.+?\);?|u', function($matches) {
|
122 |
+
$data = $matches[0];
|
123 |
+
if(!in_array(trim($matches[1]), self::$varlist)){
|
124 |
+
$data = '';
|
125 |
+
}
|
126 |
+
return $data;
|
127 |
+
}, $ncss);
|
128 |
+
$ncss = preg_replace_callback( '|(\-\-[\w\-]+?):(.+?)([;\}])|u', function($matches) {
|
129 |
+
$data = $matches[0];
|
130 |
+
if(!preg_match('|url\(|u', $matches[2]) && !in_array(trim($matches[1]), self::$varlist)){
|
131 |
+
$data = ($matches[3] === '}')? '}' : '';
|
132 |
+
}
|
133 |
+
return $data;
|
134 |
+
}, $ncss);
|
135 |
+
|
136 |
+
return $ncss;
|
137 |
+
}
|
138 |
+
|
139 |
+
/*=============================================================
|
140 |
+
* CSS 内のコメント、改行、空白等を削除するだけのシンプルな縮小化
|
141 |
+
*/
|
142 |
+
public static function simple_minify( $css ) {
|
143 |
+
$res = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
|
144 |
+
if(!empty($res)){
|
145 |
+
$css = $res;
|
146 |
+
$css = str_replace(array("\r", "\n"), '', $css);
|
147 |
+
$css = str_replace("\t", ' ', $css);
|
148 |
+
$css = preg_replace('/\s+/su', ' ', $css);
|
149 |
+
$css = preg_replace('/\s([\{\}:=,\)*\/;>])/', '$1', $css);
|
150 |
+
$css = preg_replace('/([\{\}:=,\(*\/!;>])\s/', '$1', $css);
|
151 |
+
}
|
152 |
+
return $css;
|
153 |
+
}
|
154 |
+
|
155 |
+
/*=============================================================
|
156 |
+
* CSS 内の未使用 id, class, tag に関する定義を取り除く縮小化
|
157 |
+
*/
|
158 |
+
public static function extended_minify($css, $html, $jsaddlist=array()) {
|
159 |
+
self::$atrule_data = array();
|
160 |
+
self::$jsaddlist = $jsaddlist; //JS によりDOMロード後に追加される ID や class 等が除外されなくするための名前の事前登録用
|
161 |
+
$inidata = array(
|
162 |
+
'id' => array(),
|
163 |
+
'class' => array(
|
164 |
+
'device-mobile',
|
165 |
+
'header_scrolled',
|
166 |
+
'active',
|
167 |
+
'menu-open',
|
168 |
+
'vk-mobile-nav-menu-btn',
|
169 |
+
'vk-mobile-nav-open',
|
170 |
+
'vk-menu-acc-active',
|
171 |
+
'acc-parent-open',
|
172 |
+
'acc-btn',
|
173 |
+
'acc-btn-open',
|
174 |
+
'acc-btn-close',
|
175 |
+
'acc-child-open',
|
176 |
+
'carousel-item-left',
|
177 |
+
'carousel-item-next',
|
178 |
+
'carousel-item-right',
|
179 |
+
'carousel-item-prev',
|
180 |
+
'form-control',
|
181 |
+
'btn',
|
182 |
+
'btn-primary',
|
183 |
+
'.vk_post_imgOuter a:hover .card-img-overlay::after'
|
184 |
+
),
|
185 |
+
'tag' => array(
|
186 |
+
'html',
|
187 |
+
'head',
|
188 |
+
'body',
|
189 |
+
'title',
|
190 |
+
'style',
|
191 |
+
'meta',
|
192 |
+
'link',
|
193 |
+
'script',
|
194 |
+
'noscript'
|
195 |
+
)
|
196 |
+
);
|
197 |
+
$inidata = apply_filters( 'css_tree_shaking_exclude', $inidata );
|
198 |
+
$pattern = array( 'id' => '|[\s\t\'"]id\s?=\s?[\'"](.+?)[\'"]|u',
|
199 |
+
'class' => '|[\s\t\'"]class\s?=\s?[\'"](.+?)[\'"]|u',
|
200 |
+
'tag' => '|<([\w\-]+)|iu'
|
201 |
+
);
|
202 |
+
|
203 |
+
if(empty(self::$cmplist['parse'])){
|
204 |
+
self::$cmplist['parse'] = true;
|
205 |
+
foreach (array('id','class','tag') as $item) {
|
206 |
+
self::$cmplist[$item] = $inidata[$item];
|
207 |
+
if(preg_match_all( $pattern[$item], $html, $matches)){
|
208 |
+
foreach ($matches[1] as $val) {
|
209 |
+
$arr = array_map("trim", explode(' ', $val));
|
210 |
+
foreach($arr as $dt){
|
211 |
+
if(!empty($dt) && !in_array($dt, self::$cmplist[$item]))
|
212 |
+
self::$cmplist[$item][] = $dt;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
$css = self::simple_minify( $css );
|
219 |
+
$css = self::atrule_store( $css );
|
220 |
+
$css = self::tree_shaking( $css );
|
221 |
+
$css = self::atrule_restore( $css );
|
222 |
+
$css = self::tree_shaking4var( $css );
|
223 |
+
return $css;
|
224 |
+
}
|
225 |
+
}
|
inc/vk-css-optimize/package/class-vk-css-optimize.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* VK CSS Optimize
|
4 |
+
*
|
5 |
+
* @package Lightning
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* VK CSS Tree Shaking Class
|
10 |
+
*/
|
11 |
+
if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
|
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() {
|
24 |
+
if ( ob_get_length() ) {
|
25 |
+
ob_end_flush();
|
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;
|
38 |
+
|
39 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
40 |
+
$path_name = $vk_css_array['path'];
|
41 |
+
if ( WP_Filesystem() ) {
|
42 |
+
global $wp_filesystem;
|
43 |
+
$css = $wp_filesystem->get_contents( $path_name );
|
44 |
+
}
|
45 |
+
|
46 |
+
$css = celtislab\CSS_tree_shaking::extended_minify( $css, $buffer );
|
47 |
+
$buffer = str_replace(
|
48 |
+
'<link rel=\'stylesheet\' id=\'' . $vk_css_array['id'] . '-css\' href=\'' . $vk_css_array['url'] . '?ver=' . $vk_css_array['version'] . '\' type=\'text/css\' media=\'all\' />',
|
49 |
+
'<style id=\'' . $vk_css_array['id'] . '-css\' type=\'text/css\'>' . $css . '</style>',
|
50 |
+
$buffer
|
51 |
+
);
|
52 |
+
$buffer = str_replace(
|
53 |
+
'<link rel=\'stylesheet\' id=\'' . $vk_css_array['id'] . '-css\' href=\'' . $vk_css_array['url'] . '\' type=\'text/css\' media=\'all\' />',
|
54 |
+
'<style id=\'' . $vk_css_array['id'] . '-css\' type=\'text/css\'>' . $css . '</style>',
|
55 |
+
$buffer
|
56 |
+
);
|
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
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* VK CSS Tree Shaking Config
|
4 |
+
*
|
5 |
+
* @package Lightning
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Optimize CSS.
|
10 |
+
*/
|
11 |
+
function veu_optimize_css() {
|
12 |
+
$options = get_option( 'vkExUnit_pagespeeding' );
|
13 |
+
|
14 |
+
if ( ! isset( $options['css_optimize'] ) ) {
|
15 |
+
$options['css_optimize'] = 'tree-shaking';
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( ! empty( $options['css_optimize'] ) && ( 'optomize-all-css' === $options['css_optimize'] || 'tree-shaking' === $options['css_optimize'] ) ) {
|
19 |
+
|
20 |
+
// 表示位置の配列.
|
21 |
+
global $vk_css_tree_shaking_array;
|
22 |
+
global $vkExUnit_version;
|
23 |
+
|
24 |
+
if ( empty( $vk_css_tree_shaking_array ) ) {
|
25 |
+
$vk_css_tree_shaking_array = array(
|
26 |
+
array(
|
27 |
+
'id' => 'vkExUnit_common_style',
|
28 |
+
'url' => veu_get_directory_uri( '/assets/css/vkExUnit_style.css' ),
|
29 |
+
'path' => veu_get_directory( '/assets/css/vkExUnit_style.css' ),
|
30 |
+
'version' => $vkExUnit_version,
|
31 |
+
),
|
32 |
+
);
|
33 |
+
} else {
|
34 |
+
$add_array = array(
|
35 |
+
'id' => 'vkExUnit_common_style',
|
36 |
+
'url' => veu_get_directory_uri( '/assets/css/vkExUnit_style.css' ),
|
37 |
+
'path' => veu_get_directory( '/assets/css/vkExUnit_style.css' ),
|
38 |
+
'version' => $vkExUnit_version,
|
39 |
+
);
|
40 |
+
array_push( $vk_css_tree_shaking_array, $add_array );
|
41 |
+
}
|
42 |
+
|
43 |
+
$vk_css_tree_shaking_array = apply_filters( 'vk_css_tree_shaking_array', $vk_css_tree_shaking_array );
|
44 |
+
if ( ! class_exists( 'VK_CSS_Optimize' ) ) {
|
45 |
+
require_once dirname( __FILE__ ) . '/package/class-vk-css-optimize.php';
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
add_action( 'after_setup_theme', 'veu_optimize_css' );
|
initialize.php
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
require veu_get_directory() . '/veu-package-manager.php';
|
12 |
// template-tags-veuでpackageの関数を使うので package-managerを先に読み込んでいる
|
13 |
require_once veu_get_directory() . '/inc/template-tags/template-tags-config.php';
|
|
|
14 |
|
15 |
require_once veu_get_directory() . '/admin/admin.php';
|
16 |
require veu_get_directory() . '/inc/footer-copyright-change.php';
|
@@ -94,34 +95,13 @@ function change_old_options() {
|
|
94 |
unset( $option['common'] );
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
add_action( 'after_setup_theme', 'veu_change_enqueue_point_run_filter', 5 );
|
101 |
-
function veu_change_enqueue_point_run_filter() {
|
102 |
-
$default = array(
|
103 |
-
'css_exunit' => false,
|
104 |
-
'js_footer' => false,
|
105 |
-
);
|
106 |
-
$option = get_option( 'vkExUnit_pagespeeding', $default );
|
107 |
-
$option = wp_parse_args( $option, $default );
|
108 |
-
if ( $option['css_exunit'] ) {
|
109 |
-
|
110 |
-
// font awesome.
|
111 |
-
add_filter( 'vkfa_enqueue_point', 'veu_change_enqueue_point_to_footer' );
|
112 |
-
|
113 |
-
// vk blocks css.
|
114 |
-
add_filter( 'vkblocks_enqueue_point', 'veu_change_enqueue_point_to_footer' );
|
115 |
-
|
116 |
-
// common css.
|
117 |
-
add_filter( 'veu_enqueue_point_common_css', 'veu_change_enqueue_point_to_footer' );
|
118 |
-
|
119 |
-
// css customize.
|
120 |
-
add_filter( 'veu_enqueue_point_css_customize_common', 'veu_change_enqueue_point_to_footer' );
|
121 |
-
add_filter( 'veu_enqueue_point_css_customize_single', 'veu_change_enqueue_point_to_footer' );
|
122 |
-
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
|
126 |
/**
|
127 |
* Move JavaScripts To Footer
|
11 |
require veu_get_directory() . '/veu-package-manager.php';
|
12 |
// template-tags-veuでpackageの関数を使うので package-managerを先に読み込んでいる
|
13 |
require_once veu_get_directory() . '/inc/template-tags/template-tags-config.php';
|
14 |
+
require_once veu_get_directory() . '/inc/vk-css-optimize/vk-css-optimize-config.php';
|
15 |
|
16 |
require_once veu_get_directory() . '/admin/admin.php';
|
17 |
require veu_get_directory() . '/inc/footer-copyright-change.php';
|
95 |
unset( $option['common'] );
|
96 |
}
|
97 |
|
98 |
+
if ( isset( $option['css_exunit'] ) ) {
|
99 |
+
$option['css_optimize'] = 'tree-shaking';
|
100 |
+
unset( $option['css_exunit'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
+
|
103 |
}
|
104 |
+
add_action( 'after_setup_theme', 'change_old_options', 4 );
|
105 |
|
106 |
/**
|
107 |
* Move JavaScripts To Footer
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:
|
|
4 |
Tags: Google Analytics, New posts, Related Posts, sitemap, sns, twitter card, Facebook Page Plugin, OG tags,
|
5 |
Requires at least: 5.0.0
|
6 |
Tested up to: 5.5.0
|
7 |
-
Stable tag: 9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -99,6 +99,9 @@ e.g.
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
102 |
= 9.30.2.0 =
|
103 |
[ bug fix ] WP5.5 API Alert
|
104 |
|
4 |
Tags: Google Analytics, New posts, Related Posts, sitemap, sns, twitter card, Facebook Page Plugin, OG tags,
|
5 |
Requires at least: 5.0.0
|
6 |
Tested up to: 5.5.0
|
7 |
+
Stable tag: 9.31.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
99 |
|
100 |
== Changelog ==
|
101 |
|
102 |
+
= 9.31.0.0 =
|
103 |
+
[ Add function ] CSS Optimize(Tree shaking)
|
104 |
+
|
105 |
= 9.30.2.0 =
|
106 |
[ bug fix ] WP5.5 API Alert
|
107 |
|
vkExUnit.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: VK All in One Expansion Unit
|
4 |
* Plugin URI: https://ex-unit.nagoya
|
5 |
* Description: This plug-in is an integrated plug-in with a variety of features that make it powerful your web site. Many features can be stopped individually. Example Facebook Page Plugin,Social Bookmarks,Print OG Tags,Print Twitter Card Tags,Print Google Analytics tag,New post widget,Insert Related Posts and more!
|
6 |
-
* Version: 9.
|
7 |
* Author: Vektor,Inc.
|
8 |
* Text Domain: vk-all-in-one-expansion-unit
|
9 |
* Domain Path: /languages
|
3 |
* Plugin Name: VK All in One Expansion Unit
|
4 |
* Plugin URI: https://ex-unit.nagoya
|
5 |
* Description: This plug-in is an integrated plug-in with a variety of features that make it powerful your web site. Many features can be stopped individually. Example Facebook Page Plugin,Social Bookmarks,Print OG Tags,Print Twitter Card Tags,Print Google Analytics tag,New post widget,Insert Related Posts and more!
|
6 |
+
* Version: 9.31.0.0
|
7 |
* Author: Vektor,Inc.
|
8 |
* Text Domain: vk-all-in-one-expansion-unit
|
9 |
* Domain Path: /languages
|