Plugin Directory

Changeset 2954638


Ignore:
Timestamp:
08/17/2023 02:36:16 AM (2 years ago)
Author:
enomoto celtislab
Message:

WordPress 6.3 support and css tree shaking update

Location:
yasakani-cache/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • yasakani-cache/trunk/magatama_lv1.php

    r2890915 r2954638  
    33  Module Name: yasakani cache magatama_lv1 module (auto_prepend_file or advanced-cache)
    44  Description: Simple, Easy, Ultra-high-speed Page Cache Powered by SQLite
    5   Version: 3.7.0
     5  Version: 3.7.1
    66  Author: enomoto@celtislab
    77  License: GPLv2
  • yasakani-cache/trunk/minify/css-tree-shaking.php

    r2890915 r2954638  
    44 *
    55 * Description: CSS tree shaking minify library
    6  * Version: 3.0.0
     6 * Version: 3.1.0
    77 * Author: enomoto@celtislab
    88 * Author URI: https://celtislab.net/
    99 * License: GPLv2
    1010 */
    11 namespace celtislab\v3_0;
     11namespace celtislab\v3_1;
    1212
    1313class CSS_tree_shaking {
     
    1919    private static $style;
    2020    private static $type;
     21    private static $role;
    2122    private static $attrlist;
    2223    private static $jsaddlist;
     
    5354                    $offset = 0;
    5455                    $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)){
    5657                        if(!empty($item['id'][0])){
    5758                            $name = $item['iname'][0];
     
    160161            self::$style = array();
    161162            self::$type  = array();
     163            self::$role  = array();
    162164            self::$tag   = array_flip( array('html','head','body','title','style','meta','link','script','noscript') );       
    163165           
     
    173175                }
    174176                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){
    176178                        $sep = ($_atrb[1] === 'style')? ';' : ' ';
    177179                        array_map( function($_s) use($_atrb) { self::${$_atrb[1]}[trim($_s)] = 1; }, explode($sep, trim($_atrb[3], ' ;')));
     
    181183                return $item[0];               
    182184            }, $html );
    183             //for id / css / inline style / type attribute selector matching
     185            //for id / css / inline style / type /role attribute selector matching
    184186            self::$attrlist['id']    = '^' . implode("$^", array_keys(self::$id)) . '$';
    185187            self::$attrlist['class'] = '^' . implode("$^", array_keys(self::$class)) . '$';           
    186188            self::$attrlist['style'] = '^' . implode("$^", array_keys(self::$style)) . '$';           
    187189            self::$attrlist['type']  = '^' . implode("$^", array_keys(self::$type)) . '$';           
     190            self::$attrlist['role']  = '^' . implode("$^", array_keys(self::$role)) . '$';           
    188191        }
    189192       
  • yasakani-cache/trunk/minify/minify-utils.php

    r2890915 r2954638  
    55 * Description: JS, CSS 最適化/縮小ユーティリティ
    66 *
    7  * Version: 3.7.0
     7 * Version: 3.7.1
    88 * Author: enomoto@celtislab
    99 * Author URI: https://celtislab.net/
     
    1919use celtislab\v1_1\Str_utils;
    2020
    21 if(!class_exists('\celtislab\v3_0\CSS_tree_shaking')){
     21if(!class_exists('\celtislab\v3_1\CSS_tree_shaking')){
    2222    require_once( __DIR__ . '/css-tree-shaking.php');
    2323}
    24 use celtislab\v3_0\CSS_tree_shaking;
     24use celtislab\v3_1\CSS_tree_shaking;
    2525
    2626class YC_minfy {
     
    8989            $exclid     = in_array($postid, array_map("trim", explode(',', $option['exclude_tree_shaking_postid'])));
    9090            $minify_css = (!empty($option['embed_css']) && !$exclid)? true : false;
    91             $ampcss     = (!empty($option['minify_ampcss']) && !$exclid)? true : false;
    9291            $exclid     = in_array($postid, array_map("trim", explode(',', $option['exclude_defer_js_postid'])));
    9392            $defer_js   = (!empty($option['defer_js']) && !$exclid)? true : false;           
    9493        } else {
    9594            $minify_css  = $option['embed_css'];
    96             $ampcss      = $option['minify_ampcss'];
    9795            $defer_js    = $option['defer_js'];           
    9896        }
     
    158156           
    159157            $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) {
    161159                if(!empty($matches['script'])){
    162160                    //JSファイルに defer を付ける
     
    182180                    $atrb = $matches['style'];
    183181                    $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)){
    188183                        //wp core block inline css
    189184                        $code = CSS_tree_shaking::extended_minify(CSS_tree_shaking::simple_minify($code), $base_html, $exclude_css, false);
  • yasakani-cache/trunk/readme.txt

    r2890915 r2954638  
    33Tags: cache, performance, SQLite, CSS minify(tree shaking), auto_prepend_file, bot block, IP block, security, Brute Force, statistics
    44Requires at least: 5.3
    5 Tested up to: 6.2
     5Tested up to: 6.3
    66Requires PHP: 7.4
    7 Stable tag: 3.7.0
     7Stable tag: 3.7.1
    88Donate link: https://celtislab.net/en/wp-yasakani-file-diff-detect-restore/
    99License: GPLv2
     
    8888
    8989== Changelog ==
     90
     91= 3.7.1 =
     92* 2023-8-17
     93* WordPress6.3 tested
     94* css tree shaking updated (amp-custom style unsuported)
     95
    9096
    9197= 3.7.0 =
  • yasakani-cache/trunk/yasakani-cache.php

    r2890915 r2954638  
    33  Plugin Name: Yasakani Cache
    44  Description: Simple, Easy, Ultra-high-speed Page Cache Powered by SQLite
    5   Version: 3.7.0
     5  Version: 3.7.1
    66  Plugin URI: https://celtislab.net/en/wp-yasakani-cache/
    77  Author: enomoto@celtislab
    88  Author URI: https://celtislab.net/
    99  Requires at least: 5.3
    10   Tested up to: 6.2
     10  Tested up to: 6.3
    1111  Requires PHP: 7.4
    1212  License: GPLv2
     
    11221122                    $oopt['embed_css'] = self::$option['embed_css'];
    11231123                    $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'];                   
    11251125                    //$oopt['minify_varcss'] = self::$option['minify_varcss'];                   
    11261126                    $oopt['dis_block_separate_css'] = self::$option['dis_block_separate_css'];                   
     
    11311131                    self::$option['embed_css'] = (!empty($_POST['yasakani']['embed_css'])) ? (int) $_POST['yasakani']['embed_css'] : 0;
    11321132                    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;
    11341134                    //self::$option['minify_varcss'] = (!empty($_POST['yasakani']['minify_varcss'])) ? (int) $_POST['yasakani']['minify_varcss'] : 0;
    11351135                    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  
    352352                            <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>
    353353                            <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')); ?>
    356355                            </p>                           
    357356                            <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.