Changeset 2954638
- Timestamp:
- 08/17/2023 02:36:16 AM (2 years ago)
- Location:
- yasakani-cache/trunk
- Files:
-
- 6 edited
-
magatama_lv1.php (modified) (1 diff)
-
minify/css-tree-shaking.php (modified) (6 diffs)
-
minify/minify-utils.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
yasakani-cache.php (modified) (3 diffs)
-
yasakani_option_page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yasakani-cache/trunk/magatama_lv1.php
r2890915 r2954638 3 3 Module Name: yasakani cache magatama_lv1 module (auto_prepend_file or advanced-cache) 4 4 Description: Simple, Easy, Ultra-high-speed Page Cache Powered by SQLite 5 Version: 3.7. 05 Version: 3.7.1 6 6 Author: enomoto@celtislab 7 7 License: GPLv2 -
yasakani-cache/trunk/minify/css-tree-shaking.php
r2890915 r2954638 4 4 * 5 5 * Description: CSS tree shaking minify library 6 * Version: 3. 0.06 * Version: 3.1.0 7 7 * Author: enomoto@celtislab 8 8 * Author URI: https://celtislab.net/ 9 9 * License: GPLv2 10 10 */ 11 namespace celtislab\v3_ 0;11 namespace celtislab\v3_1; 12 12 13 13 class CSS_tree_shaking { … … 19 19 private static $style; 20 20 private static $type; 21 private static $role; 21 22 private static $attrlist; 22 23 private static $jsaddlist; … … 53 54 $offset = 0; 54 55 $maxlen = strlen($_s); 55 while($offset < $maxlen && preg_match( '`(?<id>#)(?<iname>[\w\-\\%]+)|(?<class>\.)(?<cname>[\w\-\\%]+)|(?<attr>\[)(?<atype>class|id|style|type )(?<mark>\^|\$|\*)?=(?<astr>.+?)\]|^(?<tag1>[\w\-\\%]+)|[,\s>\+~\(\)\]\|](?<tag2>[\w\-\\%]+)`u', $_s, $item, PREG_OFFSET_CAPTURE, $offset)){56 while($offset < $maxlen && preg_match( '`(?<id>#)(?<iname>[\w\-\\%]+)|(?<class>\.)(?<cname>[\w\-\\%]+)|(?<attr>\[)(?<atype>class|id|style|type|role)(?<mark>\^|\$|\*)?=(?<astr>.+?)\]|^(?<tag1>[\w\-\\%]+)|[,\s>\+~\(\)\]\|](?<tag2>[\w\-\\%]+)`u', $_s, $item, PREG_OFFSET_CAPTURE, $offset)){ 56 57 if(!empty($item['id'][0])){ 57 58 $name = $item['iname'][0]; … … 160 161 self::$style = array(); 161 162 self::$type = array(); 163 self::$role = array(); 162 164 self::$tag = array_flip( array('html','head','body','title','style','meta','link','script','noscript') ); 163 165 … … 173 175 } 174 176 if(!empty($atrb)){ 175 preg_replace_callback( '`(id|class|style|type )\s?=\s?([\'"])(.+?)\2`u', function($_atrb){177 preg_replace_callback( '`(id|class|style|type|role)\s?=\s?([\'"])(.+?)\2`u', function($_atrb){ 176 178 $sep = ($_atrb[1] === 'style')? ';' : ' '; 177 179 array_map( function($_s) use($_atrb) { self::${$_atrb[1]}[trim($_s)] = 1; }, explode($sep, trim($_atrb[3], ' ;'))); … … 181 183 return $item[0]; 182 184 }, $html ); 183 //for id / css / inline style / type attribute selector matching185 //for id / css / inline style / type /role attribute selector matching 184 186 self::$attrlist['id'] = '^' . implode("$^", array_keys(self::$id)) . '$'; 185 187 self::$attrlist['class'] = '^' . implode("$^", array_keys(self::$class)) . '$'; 186 188 self::$attrlist['style'] = '^' . implode("$^", array_keys(self::$style)) . '$'; 187 189 self::$attrlist['type'] = '^' . implode("$^", array_keys(self::$type)) . '$'; 190 self::$attrlist['role'] = '^' . implode("$^", array_keys(self::$role)) . '$'; 188 191 } 189 192 -
yasakani-cache/trunk/minify/minify-utils.php
r2890915 r2954638 5 5 * Description: JS, CSS 最適化/縮小ユーティリティ 6 6 * 7 * Version: 3.7. 07 * Version: 3.7.1 8 8 * Author: enomoto@celtislab 9 9 * Author URI: https://celtislab.net/ … … 19 19 use celtislab\v1_1\Str_utils; 20 20 21 if(!class_exists('\celtislab\v3_ 0\CSS_tree_shaking')){21 if(!class_exists('\celtislab\v3_1\CSS_tree_shaking')){ 22 22 require_once( __DIR__ . '/css-tree-shaking.php'); 23 23 } 24 use celtislab\v3_ 0\CSS_tree_shaking;24 use celtislab\v3_1\CSS_tree_shaking; 25 25 26 26 class YC_minfy { … … 89 89 $exclid = in_array($postid, array_map("trim", explode(',', $option['exclude_tree_shaking_postid']))); 90 90 $minify_css = (!empty($option['embed_css']) && !$exclid)? true : false; 91 $ampcss = (!empty($option['minify_ampcss']) && !$exclid)? true : false;92 91 $exclid = in_array($postid, array_map("trim", explode(',', $option['exclude_defer_js_postid']))); 93 92 $defer_js = (!empty($option['defer_js']) && !$exclid)? true : false; 94 93 } else { 95 94 $minify_css = $option['embed_css']; 96 $ampcss = $option['minify_ampcss'];97 95 $defer_js = $option['defer_js']; 98 96 } … … 158 156 159 157 $nbase_html = $base_html; 160 $nbase_html = preg_replace_callback( $pattern, function($matches) use(&$exclude_js, &$exclude_css, &$core_css, &$ ampcss, &$base_html, &$base_head, &$includes_url, &$content_url, &$inline_id4shaking) {158 $nbase_html = preg_replace_callback( $pattern, function($matches) use(&$exclude_js, &$exclude_css, &$core_css, &$base_html, &$base_head, &$includes_url, &$content_url, &$inline_id4shaking) { 161 159 if(!empty($matches['script'])){ 162 160 //JSファイルに defer を付ける … … 182 180 $atrb = $matches['style']; 183 181 $code = $matches['inlinecss']; 184 if ($ampcss && strpos($atrb, 'amp-custom' ) !== false) { 185 //amp css tree shaking 186 $code = CSS_tree_shaking::extended_minify(CSS_tree_shaking::simple_minify($code), $base_html, $exclude_css, true); 187 } elseif( $core_css && preg_match('#id=[\'"](wp\-block\-[\w-]+inline\-css)[\'"]#', $atrb, $idcore)){ 182 if( $core_css && preg_match('#id=[\'"](wp\-block\-[\w-]+inline\-css)[\'"]#', $atrb, $idcore)){ 188 183 //wp core block inline css 189 184 $code = CSS_tree_shaking::extended_minify(CSS_tree_shaking::simple_minify($code), $base_html, $exclude_css, false); -
yasakani-cache/trunk/readme.txt
r2890915 r2954638 3 3 Tags: cache, performance, SQLite, CSS minify(tree shaking), auto_prepend_file, bot block, IP block, security, Brute Force, statistics 4 4 Requires at least: 5.3 5 Tested up to: 6. 25 Tested up to: 6.3 6 6 Requires PHP: 7.4 7 Stable tag: 3.7. 07 Stable tag: 3.7.1 8 8 Donate link: https://celtislab.net/en/wp-yasakani-file-diff-detect-restore/ 9 9 License: GPLv2 … … 88 88 89 89 == Changelog == 90 91 = 3.7.1 = 92 * 2023-8-17 93 * WordPress6.3 tested 94 * css tree shaking updated (amp-custom style unsuported) 95 90 96 91 97 = 3.7.0 = -
yasakani-cache/trunk/yasakani-cache.php
r2890915 r2954638 3 3 Plugin Name: Yasakani Cache 4 4 Description: Simple, Easy, Ultra-high-speed Page Cache Powered by SQLite 5 Version: 3.7. 05 Version: 3.7.1 6 6 Plugin URI: https://celtislab.net/en/wp-yasakani-cache/ 7 7 Author: enomoto@celtislab 8 8 Author URI: https://celtislab.net/ 9 9 Requires at least: 5.3 10 Tested up to: 6. 210 Tested up to: 6.3 11 11 Requires PHP: 7.4 12 12 License: GPLv2 … … 1122 1122 $oopt['embed_css'] = self::$option['embed_css']; 1123 1123 $oopt['minify_core_block_css'] = self::$option['minify_core_block_css']; 1124 $oopt['minify_ampcss'] = self::$option['minify_ampcss'];1124 //$oopt['minify_ampcss'] = self::$option['minify_ampcss']; 1125 1125 //$oopt['minify_varcss'] = self::$option['minify_varcss']; 1126 1126 $oopt['dis_block_separate_css'] = self::$option['dis_block_separate_css']; … … 1131 1131 self::$option['embed_css'] = (!empty($_POST['yasakani']['embed_css'])) ? (int) $_POST['yasakani']['embed_css'] : 0; 1132 1132 self::$option['minify_core_block_css'] = (!empty($_POST['yasakani']['minify_core_block_css'])) ? (int) $_POST['yasakani']['minify_core_block_css'] : 0; 1133 self::$option['minify_ampcss'] = (!empty($_POST['yasakani']['minify_ampcss'])) ? (int) $_POST['yasakani']['minify_ampcss'] : 0;1133 //self::$option['minify_ampcss'] = (!empty($_POST['yasakani']['minify_ampcss'])) ? (int) $_POST['yasakani']['minify_ampcss'] : 0; 1134 1134 //self::$option['minify_varcss'] = (!empty($_POST['yasakani']['minify_varcss'])) ? (int) $_POST['yasakani']['minify_varcss'] : 0; 1135 1135 self::$option['dis_block_separate_css'] = (!empty($_POST['yasakani']['dis_block_separate_css'])) ? (int) $_POST['yasakani']['dis_block_separate_css'] : 0; -
yasakani-cache/trunk/yasakani_option_page.php
r2890915 r2954638 352 352 <div><textarea name="yasakani[tree_shaking_css]" rows="5" cols="50" id="tree_shaking_css" class="large-text code"><?php echo esc_textarea(self::$option['tree_shaking_css']); ?></textarea></div> 353 353 <p> 354 <?php echo self::checkbox('yasakani[minify_core_block_css]', self::$option['minify_core_block_css'], __('Shrink CSS for all WP core blocks(id=wp-block-xxxx) and embed inline in head', 'yasakani')); ?><br/> 355 <?php echo self::checkbox('yasakani[minify_ampcss]', self::$option['minify_ampcss'], __('amp-custom style (For AMP page)', 'yasakani')); ?> 354 <?php echo self::checkbox('yasakani[minify_core_block_css]', self::$option['minify_core_block_css'], __('Shrink CSS for all WP core blocks(id=wp-block-xxxx) and embed inline in head', 'yasakani')); ?> 356 355 </p> 357 356 <p><?php _e('Names such as registered ID and Class are excluded from CSS Tree Shaking. (Names separated by line feed)', 'yasakani'); ?></p>
Note: See TracChangeset
for help on using the changeset viewer.