Plugin Directory

Changeset 1949156


Ignore:
Timestamp:
09/29/2018 06:57:25 PM (8 years ago)
Author:
wallrio
Message:

version 0.1.0

Location:
cache-seo-speed/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • cache-seo-speed/trunk/CssWallRioMain.php

    r1935231 r1949156  
    44Plugin URI: http://wallrio.com/wordpress/plugins/cache-seo-speed/
    55Description: Tool for optimization, caching and minification, accelerates the loading of pages with focus on performance analyzers.
    6 Version: 0.0.2
     6Version: 0.0.1
    77Author: Wallace Rio
    88Author URI: http://wallrio.com
  • cache-seo-speed/trunk/package.json

    r1935231 r1949156  
    11{
    22    "name": "cache-seo-speed",
    3     "version":"0.0.2",
     3    "version":"0.1.0",
    44    "description": "Ferramenta para optimização, cache e minificação, acelera o carregamento de páginas com foco em analisadores de performance",
    55    "homepage": "http://wallrio.com/wordpress/plugins/cache-seo-speed/",
  • cache-seo-speed/trunk/readme-ptbr.txt

    r1935231 r1949156  
    77Requires at least: 4.3
    88Tested up to: 4.9
    9 Stable tag: 0.0.2
     9Stable tag: 0.1.0
     10Require PHP: 5.2 or higher
    1011
    1112Ferramenta para otimização, cache e minificação, acelera o carregamento de páginas com
     
    55562. Tela principal (Português)
    5657
     58== Changelog ==
     59
     60= 0.0.2 =
     61* corrigido falha na chamada para o cache de conteúdo
     62
     63= 0.1.0 =
     64* adicionado método de concatenação em @import no css
     65* implementado sistema para otimização de imagens
     66* corrigido incompatibilidade com PHP 5.2
     67
    5768== Frequently Asked Questions ==
    5869
  • cache-seo-speed/trunk/readme.txt

    r1935231 r1949156  
    77Requires at least: 4.3
    88Tested up to: 4.9
    9 Stable tag: 0.0.2
     9Stable tag: 0.1.0
     10Require PHP: 5.2 or higher
     11
    1012
    1113Tool for optimization, caching and minification, accelerates the loading of pages with
     
    6163* fixed call failed for content cache.
    6264
     65= 0.1.0 =
     66* Added concatenation method in @import in css
     67* Implemented system for optimization of images
     68* Fixed incompatibility with PHP 5.2
    6369
    6470== Frequently Asked Questions ==
  • cache-seo-speed/trunk/src/CssWallRio_filter.php

    r1932100 r1949156  
    55 */
    66
     7error_reporting(E_ALL);
     8ini_set("display_errors", true);
     9ini_set("display_startup_erros",true);
     10
    711
    812class CssWallRio_filter{
    913   
    1014    public static function init($filters,$content = ''){
     15
    1116        if($filters == true){
    1217            $filters = array(
     
    1924        if(is_array($filters))
    2025        foreach ($filters as $key => $value) {
    21             if($value == 'GoogleAnalyticsRemoveOnPageSpeed')
    22                 $content = CssWallRio_filter::GoogleAnalyticsRemoveOnPageSpeed($content);
     26            // if($value == 'GoogleAnalyticsRemoveOnPageSpeed')
     27                // $content = CssWallRio_filter::GoogleAnalyticsRemoveOnPageSpeed($content);
    2328
    2429            if($value == 'GtmRemoveOnPageSpeed')
     
    2732        return $content;
    2833    }
    29 
     34/*
    3035    public static  function GoogleAnalyticsRemoveOnPageSpeed($content = ''){   
    3136        $sourceReplaceAnalit= '#\(function\(i,s,o,g,r,a,m\)\{i\[\'GoogleAnalyticsObject#ism';
     
    3944
    4045    public static  function GtmRemoveOnPageSpeed($content = ''){       
    41         $sourceReplaceAnalit= '#\(function\(w,d,s,l,i\)\{#ism';
     46        $sourceReplaceAnalit = '#\(function\(w,d,s,l,i\)\{#ism';
    4247        $targetReplaceAnalit = 'if(navigator.userAgent.indexOf("Speed Insights") == -1) { (function(w,d,s,l,i){';           
     48
    4349        $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content);
     50
    4451        $sourceReplaceAnalit= '#dataLayer\',\'(.*)\'\);\<#ism';
    4552        $targetReplaceAnalit = 'dataLayer\',\'$1\');}<';         
     53        $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content);
     54
     55        return $content;
     56    }*/
     57
     58    public static  function GoogleAnalyticsRemoveOnPageSpeed($content = ''){
     59        // set GoogleAnalytics Remove On PageSpeed
     60            $sourceReplaceAnalit= '#\(function\(i,s,o,g,r,a,m\)\{i\[\'GoogleAnalyticsObject#im';
     61            // $targetReplaceAnalit = 'if(navigator.userAgent.indexOf("Speed Insights") == -1) { (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject';           
     62            $targetReplaceAnalit = 'window.addEventListener(\'mousemove\', function()  { (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject';           
     63            $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content);
     64            $sourceReplaceAnalit= '#ga\(\'send\'\, \'pageview\'\)\;#im';
     65            // $targetReplaceAnalit = 'ga(\'send\', \'pageview\');}';         
     66            $targetReplaceAnalit = 'ga(\'send\', \'pageview\');});';         
     67            $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content);
     68
     69        return $content;
     70    }
     71
     72    public static  function GtmRemoveOnPageSpeed($content = ''){       
     73        $sourceReplaceAnalit= '#\(function\(w,d,s,l,i\)\{#im';
     74        // $targetReplaceAnalit = 'if(navigator.userAgent.indexOf("Speed Insights") == -1) { (function(w,d,s,l,i){';           
     75        $targetReplaceAnalit = 'window.addEventListener("mousemove",function(){ (function(w,d,s,l,i){';           
     76        $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content,-1,$count);
     77
     78
     79        $sourceReplaceAnalit= '#dataLayer\',\'(.*)\'\);\<#im';
     80        // $targetReplaceAnalit = 'dataLayer\',\'$1\');}<';         
     81        $targetReplaceAnalit = 'dataLayer\',\'$1\');});<';         
    4682        $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content);
    4783        return $content;
  • cache-seo-speed/trunk/src/CssWallRio_init.php

    r1932100 r1949156  
    1717            $theme,
    1818            $timeToUpdate,
    19             $activatekey,$initialDate,$statusUpdate,
     19            $initialDate,$statusUpdate,
    2020            $version,$statusUpdateForce = false;
    2121    private static $pluginDir,$pluginName,$wpContentDir,$rootDir;   
     
    232232            $this->optimizegzip = isset($config->optimizegzip)?$config->optimizegzip:false;
    233233            $this->mobileusage = isset($config->mobileusage)?$config->mobileusage:false;           
    234             $this->mobile_css_noload_external = isset($config->mobile_css_noload_external)?$config->mobile_css_noload_external:false;           
     234            $this->mobile_css_noload_external = isset($config->mobile_css_noload_external)?$config->mobile_css_noload_external:false;     
     235           
     236            $this->includeimports = isset($config->includeimports)?$config->includeimports:false;     
     237
    235238            $this->desktopusage = isset($config->desktopusage)?$config->desktopusage:false;
    236239            $this->timeToUpdate = isset($config->timeToUpdate)?$config->timeToUpdate:5;
    237             $this->activatekey = isset($config->activatekey)?$config->activatekey:'';           
     240               
    238241            $this->useragent_allow = isset($config->useragent_allow)?$config->useragent_allow:'';
    239242            $this->useragent_deny = isset($config->useragent_deny)?$config->useragent_deny:'';       
    240             $this->pageListBlock = isset($config->pagesblock)?$config->pagesblock:[];
     243            $this->pageListBlock = isset($config->pagesblock)?$config->pagesblock:array();
    241244            $this->filters = isset($config->filters)?$config->filters:null;
    242245            $this->singlecache = isset($config->singlecache)?$config->singlecache:false;
    243             $this->key = isset($config->singlecache)?$config->key:false;
     246         
    244247        }
    245248       
     
    251254    public function run($content,$existCache){
    252255        if(!isset($this->desktopusage)) $this->desktopusage = true;
    253         if(!isset($this->pageListBlock)) $this->pageListBlock = [];
     256        if(!isset($this->pageListBlock)) $this->pageListBlock = array();
    254257        if(!isset($this->mobileusage)) $this->mobileusage = true;
    255258
  • cache-seo-speed/trunk/src/CssWallRio_spider.php

    r1935231 r1949156  
    99class CssWallRio_spider{
    1010
    11     private $url,$minifyCss,$minifyJs;
     11    private static $dirTheme;
     12    private static $url,$minifyCss,$minifyJs,$mobile_css_noload_external,$includeimports;
    1213
    1314    function __construct($config){
    14         $this->minifyCss = $config->minifyCss;
    15         $this->minifyJs = $config->minifyJs;
    16         $this->mobile_css_noload_external = $config->mobile_css_noload_external;
     15        self::$minifyCss = $config->minifyCss;
     16        self::$minifyJs = $config->minifyJs;
     17        self::$mobile_css_noload_external = $config->mobile_css_noload_external;
     18        self::$includeimports = $config->includeimports;
    1719    }
    1820
    1921    public function run($content){
    2022
    21         $callbackRep = function($match){
    22             $value = $match[0];
    23             $attrStringsPre = preg_replace('/href=["|\'](.*?)["|\']/is','',$value);
    24             $attrStrings = str_replace(array('<link','/>','>'),'',$attrStringsPre);
    25             $valueNew = preg_match_all('/href=["|\'](.*?)["|\']/is',$value,$newMatch);
     23        if(function_exists('create_function')){
     24            $callbackRep = create_function('$match', 'return CssWallRio_spider::linkAdjust($match);');
     25        }else{
     26            eval('$callbackRep = function($match){
     27                return CssWallRio_spider::linkAdjust($match);           
     28            };');
     29
     30
     31        }
     32        $content = preg_replace_callback('/<link[^>]*?rel=["|\']stylesheet["|\']*?[^>]*>/is', $callbackRep, $content);
     33
     34
     35        if(function_exists('create_function')){
     36            $callbackRep = create_function('$match', 'return CssWallRio_spider::styleAdjust($match);');
     37        }else{
     38            eval('$callbackRep = function($match){
     39                return CssWallRio_spider::styleAdjust($match);
     40            };');
     41        }
     42        $content = preg_replace_callback('#<script[^<]+?>(.*?)</script>#is', $callbackRep, $content);
     43
     44        return $content;
     45
     46    }
     47   
     48   
     49
     50
     51    public static function styleAdjust($match){
     52        $value = $match[0];
     53        $valueNew = preg_match_all('/src=["|\'](.*?)["|\']/is',$value,$newMatch);
     54        $attrStringsPre = preg_replace('/src=["|\'](.*?)["|\']/is','',$value);
     55        $valueNew = preg_match_all('/<script\b(.*?)*>/is',$attrStringsPre,$newMatch2);
     56        $attrStrings = str_replace(array('<script','/>','>'),'',$newMatch2[0][0]);
     57
     58        if(count($newMatch[0]) > 0 ){
    2659            $url = $newMatch[1][0];
    2760
    2861            $resultRequest = wp_remote_get($url);
    29 
    3062            if(is_array($resultRequest))
    31             $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
     63                $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
    3264            else if(is_object($resultRequest))
    33             $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
    34 
     65                $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
     66
     67                        $type = 'js-link';
     68        }else{
     69            $url = '';
     70            $type = 'js-inline';
     71            $contentFile = $match[1];
     72        }
     73
     74        $contentFile = str_replace('<iframe','&lt;iframe',$contentFile);
     75        $contentFile = str_replace('</script','&lt;/',$contentFile);
     76       
     77        $ifMinify = '';
     78        if(self::$minifyJs === true){
     79            $ifMinify = 'data-minify="true"';
     80            $contentFile = CssWallRio_minify::js($contentFile);
     81        }
     82
     83        if(strpos($attrStrings, 'data-nowpcss')!== false)return $value;
     84       
     85
     86        $valueResult = '<script '.$attrStrings .' '.$ifMinify.' data-css-type="'.$type.'" data-url="'.$url.'" >';
     87        $valueResult .= $contentFile;
     88        $valueResult .= '</script>';
     89
     90        return $valueResult;
     91    }
     92
     93    public static function linkAdjust($match){
     94        $value = $match[0];
     95        $attrStringsPre = preg_replace('/href=["|\'](.*?)["|\']/is','',$value);
     96        $attrStrings = str_replace(array('<link','/>','>'),'',$attrStringsPre);
     97        $valueNew = preg_match_all('/href=["|\'](.*?)["|\']/is',$value,$newMatch);
     98        $url = $newMatch[1][0];
     99
     100        $resultRequest = wp_remote_get($url);
     101
     102        if(is_array($resultRequest))
     103        $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
     104        else if(is_object($resultRequest))
     105        $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
     106
     107       
     108        $urlAdjust = $url;
     109        $urlAdjust = explode('?', $urlAdjust);
     110        $urlAdjust = $urlAdjust[0];
     111        $urlAdjust = dirname($urlAdjust);
     112   
     113   
     114        self::$dirTheme = $urlAdjust;
     115
     116        if(function_exists('create_function')){
     117            $callbackRep = create_function('$match', 'return CssWallRio_spider::changeUrlOnStyle($match,"'.$urlAdjust.'");');
     118        }else{
     119            eval('$callbackRep = function($match){
     120                return self::changeUrlOnStyle($match,"'.$urlAdjust.'");
     121            };');
     122        }
     123        $contentFile  = preg_replace_callback('/url\((.*?)\)/is',$callbackRep,$contentFile);
     124
     125
     126        // replace @import-----------------------------
     127        if(function_exists('create_function')){
     128            $callbackRep = create_function('$match', 'return CssWallRio_spider::changeImportStyle($match,"'.$urlAdjust.'");');
     129        }else{
     130            eval('$callbackRep = function($match){
     131                return self::changeImportStyle($match,"'.$urlAdjust.'");
     132            };');
     133        }
     134
     135        $contentFile  = preg_replace_callback('/@import [\'|"](.*?)[\'|"];/is',$callbackRep,$contentFile);
     136       
     137        if(function_exists('create_function')){
     138            $callbackRep = create_function('$match', 'return CssWallRio_spider::changeImportStyle($match,"'.$urlAdjust.'",true);');
     139        }else{
     140            eval('$callbackRep = function($match){
     141                return self::changeImportStyle($match,"'.$urlAdjust.'",true);
     142            };');
     143        }
     144        $contentFile  = preg_replace_callback('/@import url\([\'|"]?(.*?)[\'|"]?\);/is',$callbackRep,$contentFile);
     145
     146
     147
     148
     149
     150            $ifMinify = '';
     151        if(self::$minifyCss === true){
     152            $ifMinify = 'data-minify="true"';
     153            $contentFile = CssWallRio_minify::css($contentFile);
     154        }
     155       
     156        if(strpos($attrStrings, 'data-nowpcss')!== false)return $value;
     157       
     158        $html_style = '<style '.$attrStrings .' '.$ifMinify.' data-css-type="css-link" data-url="'.$url.'" >';
     159        $html_style .= $contentFile;
     160        $html_style .= '</style>';
     161
     162       
     163
     164        return $html_style;
     165    }
     166   
     167    public static function changeImportStyle($matches,$url,$modeUrl = null){
     168       
     169        $attach_start = '"';
     170        $attach_end = '"';
     171
     172        if($modeUrl == true){
     173            $attach_start = 'url(';
     174            $attach_end = ')';
     175        }
     176
     177        $val = $matches[1];
     178            if(strpos($val, 'http://') !== false || strpos($val, 'https://') !== false || strpos($val, 'data:') !== false){
     179               
     180                if(self::$mobile_css_noload_external === true)
     181                    return '';
     182
     183                if(self::$includeimports === true){
     184                    $resultRequest = wp_remote_get($val);
     185                    if(is_array($resultRequest))
     186                    $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
     187                    else if(is_object($resultRequest))
     188                    $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
     189
     190                    return "\n\n".$contentFile."\n\n";
     191                }
     192               
     193                return '@import '.$attach_start.''.$val.''.$attach_end.';';
     194            }
     195
     196        $urlAdjust = $url;
     197        $urlAdjust = explode('?', $urlAdjust);
     198        $urlAdjust = $urlAdjust[0];
     199   
     200        $dirThemeNew = $urlAdjust;
     201       
     202        $val = str_replace(array('"','\''), '', $val);
     203        $val = $dirThemeNew.'/'.$val;
     204
     205        if(self::$includeimports === true){
     206            $resultRequest = wp_remote_get($val);
     207            if(is_array($resultRequest))
     208            $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
     209            else if(is_object($resultRequest))
     210            $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
     211
     212            return "\n\n".$contentFile."\n\n";
     213        }
     214
     215       
     216        return '@import '.$attach_start.''.$val.''.$attach_end.';';
     217    }
     218
     219    public static function changeUrlOnStyle($matches,$url){
     220        $val = $matches[1];
     221        if(strpos($val, 'http://') !== false || strpos($val, 'https://') !== false || strpos($val, 'data:') !== false){
    35222           
    36             $urlAdjust = $url;
    37             $urlAdjust = explode('?', $urlAdjust);
    38             $urlAdjust = $urlAdjust[0];
    39             $urlAdjust = dirname($urlAdjust);
    40        
    41        
    42             $dirTheme = $urlAdjust;
    43             $contentFile  = preg_replace_callback('/url\((.*?)\)/is',function($matches) use ($dirTheme){
    44                     $val = $matches[1];
    45                     if(strpos($val, 'http://') !== false || strpos($val, 'https://') !== false || strpos($val, 'data:') !== false){
    46                        
    47                         if($this->mobile_css_noload_external === true)
    48                             $val = '';
    49 
    50                         return 'url('.$val.')';
    51                     }
    52                     if(substr($val, 0,1)=='"'){
    53                         $signal = '"';
    54                     }else if(substr($val, 0,1)=='\''){
    55                         $signal = '\'';
    56                     }else{
    57                         $signal = '';
    58                     }
    59                     $val = str_replace(array('"','\''), '', $val);
    60                     $val = $dirTheme.'/'.$val;
    61                     return 'url('.$signal.$val.$signal.')';
    62                 },$contentFile);
    63 
    64                 $ifMinify = '';
    65             if($this->minifyCss === true){
    66                 $ifMinify = 'data-minify="true"';
    67                 $contentFile = CssWallRio_minify::css($contentFile);
    68             }
    69            
    70             if(strpos($attrStrings, 'data-nowpcss')!== false)return $value;
    71            
    72             $html_style = '<style '.$attrStrings .' '.$ifMinify.' data-css-type="css-link" data-url="'.$url.'" >';
    73             $html_style .= $contentFile;
    74             $html_style .= '</style>';
    75    
    76            
    77 
    78             return $html_style;
    79         };
    80 
    81         $content = preg_replace_callback('/<link[^>]*?rel=["|\']stylesheet["|\']*?[^>]*>/is', $callbackRep, $content);
    82 
    83         $callbackRep = function($match){
    84             $value = $match[0];
    85             $valueNew = preg_match_all('/src=["|\'](.*?)["|\']/is',$value,$newMatch);
    86             $attrStringsPre = preg_replace('/src=["|\'](.*?)["|\']/is','',$value);
    87             $valueNew = preg_match_all('/<script\b(.*?)*>/is',$attrStringsPre,$newMatch2);
    88             $attrStrings = str_replace(array('<script','/>','>'),'',$newMatch2[0][0]);
    89 
    90             if(count($newMatch[0]) > 0 ){
    91                 $url = $newMatch[1][0];
    92 
    93                 $resultRequest = wp_remote_get($url);
    94                 if(is_array($resultRequest))
    95                     $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';
    96                 else if(is_object($resultRequest))
    97                     $contentFile = isset($resultRequest->body)?$resultRequest->body:'';
    98 
    99                             $type = 'js-link';
    100             }else{
    101                 $url = '';
    102                 $type = 'js-inline';
    103                 $contentFile = $match[1];
    104             }
    105 
    106             $contentFile = str_replace('<iframe','&lt;iframe',$contentFile);
    107             $contentFile = str_replace('</script','&lt;/',$contentFile);
    108            
    109             $ifMinify = '';
    110             if($this->minifyJs === true){
    111                 $ifMinify = 'data-minify="true"';
    112                 $contentFile = CssWallRio_minify::js($contentFile);
    113             }
    114 
    115             if(strpos($attrStrings, 'data-nowpcss')!== false)return $value;
    116            
    117 
    118             $valueResult = '<script '.$attrStrings .' '.$ifMinify.' data-css-type="'.$type.'" data-url="'.$url.'" >';
    119             $valueResult .= $contentFile;
    120             $valueResult .= '</script>';
    121 
    122             return $valueResult;
    123         };
    124 
    125         $content = preg_replace_callback('#<script[^<]+?>(.*?)</script>#is', $callbackRep, $content);
    126 
    127         return $content;
    128     }
    129 
    130    
    131 
     223            if(self::$mobile_css_noload_external === true)
     224                $val = '';
     225
     226            return 'url('.$val.')';
     227        }
     228        if(substr($val, 0,1)=='"'){
     229            $signal = '"';
     230        }else if(substr($val, 0,1)=='\''){
     231            $signal = '\'';
     232        }else{
     233            $signal = '';
     234        }
     235        $val = str_replace(array('"','\''), '', $val);
     236        $val = $url.'/'.$val;
     237        return 'url('.$signal.$val.$signal.')';
     238    }
    132239}
  • cache-seo-speed/trunk/views/CssWallRioTranslation.php

    r1932100 r1949156  
    6868            'alert-permission-directory'=>'Set permission 755 to directory',
    6969           
     70            'include-imports-css'=>'Concatenate @import',
     71            'image-optimization-title'=>'Image optimization',
     72            'optimizate-image'=>'Optimize Now',
     73            'optimization-image-finish'=>'Image optimized with success',
     74            'optimization-restore-button'=>'Restore images not optimized',
     75            'optimization-restored'=>'Images restored',
     76            'image-optimization-alert'=>'does not work on localhost'
     77           
    7078        );
    7179
     
    123131            'alert-saved-success'=>'Salvo com sucesso',
    124132            'alert-permission-directory'=>'Altere para 755 a permissão do diretório',
     133
     134            'include-imports-css'=>'Concatenar @import',
     135            'image-optimization-title'=>'Otimização de imagens',
     136            'optimizate-image'=>'Otimizar agora',
     137            'optimization-image-finish'=>'Image optimized with success',
     138            'optimization-restore-button'=>'Restaurar imagens não otimizadas',
     139            'optimization-restored'=>'Imagens restauradas',
     140            'image-optimization-alert'=>'Não funciona no localhost'
    125141        );
    126142
  • cache-seo-speed/trunk/views/CssWallRioView.php

    r1932100 r1949156  
    208208        else
    209209            $mobile_css_noload_external = false;
     210       
     211        if(isset($request['includeimports']))
     212            $includeimports = true;
     213        else
     214            $includeimports = false;
    210215
    211216        if(isset($request['desktopusage']))
     
    258263            'mobileusage'=>$mobileusage,
    259264            'mobile_css_noload_external'=>$mobile_css_noload_external,
     265            'includeimports'=>$includeimports,
    260266            'showloading'=>$showloading,
    261267            'desktopusage'=>$desktopusage,
     
    265271            'useragent_deny'=>$useragent_deny,
    266272            'filters'=>$filters,
    267             'pagesblock'=>$pagesblockArray,
    268             'key'=>$precontent->key,
     273            'pagesblock'=>$pagesblockArray
    269274        );
    270275
  • cache-seo-speed/trunk/views/settings/index.php

    r1932100 r1949156  
    55 */
    66
     7
     8
    79$configPath = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'cache-seo-speed'.DIRECTORY_SEPARATOR.'.css-config.dat';
    810$dirCache = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'cache/cache-seo-speed'.DIRECTORY_SEPARATOR;
     
    1214$dirRoot = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))).DIRECTORY_SEPARATOR;
    1315$urlPlugin = plugins_url().'/';
     16// $domain = str_replace('wp-content/plugins/', '', $urlPlugin);
    1417
    1518$pluginUrlArray = explode('/', $dirPlugin);
     
    2326require_once $dirPlugin.'src'.DIRECTORY_SEPARATOR."CssWallRio_wpload.php";
    2427require_once $dirPlugin.'views'.DIRECTORY_SEPARATOR.'CssWallRioView.php';
     28
    2529
    2630CssWallRioView::$dirPlugin = $dirPlugin;
     
    4751$objectsDir_size = number_format($objectsDir_size / 1048576, 1) . ' MB';
    4852$server = json_encode($_SERVER);
    49 $domain = urlencode( get_site_url() );
    50 
     53$domain = get_site_url() ;
     54$domainUrl = urlencode( $domain );
     55
     56    require_once $dirPlugin.'src'.DIRECTORY_SEPARATOR."CssWallRio_optimage.php";
     57 
     58if(isset($_POST['restoreoptimage'])){
     59    // require_once $dirPlugin.'src'.DIRECTORY_SEPARATOR."CssWallRio_optimage.php";
     60     CssWallRio_optimage::restoreImages(
     61        $dirCache.DIRECTORY_SEPARATOR."backup",
     62        $wpcontentDir,
     63        $domain.'/wp-content/'     
     64    );
     65
     66    if(file_exists($dirCache.DIRECTORY_SEPARATOR."opt.zip")){
     67        unlink($dirCache.DIRECTORY_SEPARATOR."opt.zip");
     68    }
     69
     70    CssWallRio_optimage::deleteExtractDir($dirCache.DIRECTORY_SEPARATOR."extract");
     71
     72    $messageAction = '<div style="display:table;margin-top:10px;margin-bottom:10px;background:#fff;color:green;padding:20px 40px">'.CssWallRioTranslation::text('optimization-restored').'!</div>';
     73
     74}
     75
     76$pageOpt = '';
     77if(isset($_POST['optimizeimage'])){
     78    // require_once $dirPlugin.'src'.DIRECTORY_SEPARATOR."CssWallRio_optimage.php";
     79    if(file_exists($objectsDir)){
     80        CssWallRio_misc::rrmdir($objectsDir);
     81       
     82    }
     83
     84       
     85
     86 
     87    $optimizeimage_page = isset($_POST['optimizeimage_page'])?$_POST['optimizeimage_page']:'';
     88    if($optimizeimage_page == 'home'){
     89        $pageOpt = $domain;
     90    }else{
     91        if(substr($optimizeimage_page, 0,1) == '/') $optimizeimage_page = substr($optimizeimage_page, 1);
     92
     93        if(substr($domain, strlen($domain)-1) == '/')
     94            $domain = substr($domain, $domain,strlen($domain)-1);
     95
     96        $pageOpt = $domain.'/'.$optimizeimage_page;
     97    }
     98
     99    CssWallRio_optimage::deleteExtractDir($dirCache.DIRECTORY_SEPARATOR."extract");
    51100   
     101    if(file_exists($dirCache.DIRECTORY_SEPARATOR."opt.zip")){
     102        unlink($dirCache.DIRECTORY_SEPARATOR."opt.zip");
     103    }
     104
     105    CssWallRio_optimage::download(
     106        'https://www.googleapis.com/pagespeedonline/v3beta1/optimizeContents?url='.$pageOpt.'?strategy=desktop',
     107        $dirCache.DIRECTORY_SEPARATOR."opt.zip",
     108        $domain
     109    );
     110
     111    CssWallRio_optimage::extract(
     112        $dirCache.DIRECTORY_SEPARATOR."opt.zip",
     113        $dirCache.DIRECTORY_SEPARATOR."extract".DIRECTORY_SEPARATOR
     114    );
     115
     116    CssWallRio_optimage::createFileWithDirectory(
     117        $dirCache.DIRECTORY_SEPARATOR."extract",
     118        $wpcontentDir,
     119        $domain.'/wp-content/'     
     120    );
     121
     122
     123
     124    // CssWallRio_optimage::deleteExtractDir($dirCache.DIRECTORY_SEPARATOR."extract");
     125
     126    $messageAction = '<div style="display:table;margin-top:10px;margin-bottom:10px;background:#fff;color:green;padding:20px 40px">'.CssWallRioTranslation::text('optimization-image-finish').'!</div>';   
     127
     128}
     129$restoreoptimage_visible = ''; 
     130if(!file_exists($dirCache.DIRECTORY_SEPARATOR."backup"))
     131$restoreoptimage_visible = ' style="display:none" '; 
     132
     133
     134$optimizeimage_disabled = '';
     135if( $_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1' ){
     136    $optimizeimage_disabled = 'disabled';
     137}
     138
     139
     140$optimizedImage = false;
     141if(file_exists($dirCache.DIRECTORY_SEPARATOR."opt.zip") === true){
     142    $optimizedImage = true;
     143}
     144
     145
     146
    52147if(isset($_POST['save'])){
    53148
     
    82177$showloading = isset($config['showloading'])?$config['showloading']:false;       
    83178$mobile_css_noload_external = isset($config['mobile_css_noload_external'])?$config['mobile_css_noload_external']:false;       
     179$includeimports = isset($config['includeimports'])?$config['includeimports']:false;       
    84180$timeToUpdate = isset($config['timeToUpdate'])?$config['timeToUpdate']:5;
    85181$activatekey = isset($config['activatekey'])?$config['activatekey']:'';       
     
    92188$useragent_allow = isset($config['useragent_allow'])?$config['useragent_allow']:'';
    93189$useragent_deny = isset($config['useragent_deny'])?$config['useragent_deny']:'';       
    94 $pagesblock = isset($config['pagesblock'])?$config['pagesblock']:[];
     190$pagesblock = isset($config['pagesblock'])?$config['pagesblock']:array();
    95191$pagesblockShow = implode(',', $pagesblock);
    96192$filters = isset($config['filters'])?$config['filters']:false;
     
    120216$mobileusage_checked = '';
    121217$mobile_css_noload_external_checked = '';
     218$includeimports_checked = '';
    122219$desktopusage_checked = '';
    123220$showloading_checked = '';
     
    155252    $mobileusage_checked = ' checked ';
    156253}
    157 if($mobile_css_noload_external === true){
    158     $mobile_css_noload_external_checked = ' checked ';
     254if($includeimports === true){
     255    $includeimports_checked = ' checked ';
    159256}
    160257
     
    202299}
    203300
    204 $localIP = getHostByName(getHostName());
     301$localIP = getHostByName(php_uname('n'));
    205302
    206303
     
    230327
    231328<style media="screen">
     329
     330.CssWallrio_success{
     331    color: green;
     332}
    232333@media (min-width:600px){
    233334    .line{
     
    278379    font-weight: normal;
    279380    color:#444;
     381}
     382
     383.link{
     384    background-color: transparent;
     385    padding: 10px 0px;
     386    margin: 0px;
     387    border:0px;
     388    color:blue;
     389    text-decoration: underline;
     390    cursor: pointer;
     391}.link:hover{
     392    text-decoration: underline;
    280393}
    281394</style>
     
    330443
    331444                    <tr>
    332                         <th scope="row"><?php echo CssWallRioTranslation::text('to-minify-css'); ?></th>
    333                         <td>
    334                             <fieldset>
    335                                 <legend class="screen-reader-text"><span><?php echo CssWallRioTranslation::text('to-minify-css'); ?></span></legend><label for="">
     445                        <th scope="row">CSS</th>
     446                        <td>
     447                            <fieldset>
     448                                <legend class="screen-reader-text"><span>CSS</span></legend><label for="">
    336449                                <input name="minifyCss" id="minifyCss"  type="checkbox" <?php echo $minifyCss_checked; ?> <?php echo $disabled_all; ?> >
    337                                 </label>
    338                             </fieldset>
     450                                <?php echo CssWallRioTranslation::text('to-minify-css'); ?>
     451                                </label>
     452                            </fieldset>
     453
     454                            <input name="includeimports" id="includeimports"  type="checkbox" <?php echo $includeimports_checked; ?> <?php echo $disabled_all; ?>> <?php echo CssWallRioTranslation::text('include-imports-css'); ?>
     455                                </label>
     456
    339457                        </td>
    340458                    </tr>
     
    383501                    </tr>
    384502
     503
     504
     505                    <tr>
     506                        <th scope="row"><?php echo CssWallRioTranslation::text('image-optimization-title'); ?>
     507                            <br>
     508                            <small style="font-weight: normal !important;"><?php echo CssWallRioTranslation::text('image-optimization-alert'); ?>
     509                                </small>
     510                        </th>
     511                        <td>
     512                            <fieldset>
     513                                <legend class="screen-reader-text"><span><?php echo CssWallRioTranslation::text('image-optimization-title'); ?></span></legend>
     514                                <label for="">
     515                                   
     516                                    <input name="optimizeimage" id="optimizeimage" class="button button-primary " value="<?php echo CssWallRioTranslation::text('optimizate-image'); ?>" type="submit" <?php echo $optimizeimage_disabled; ?> <?php echo $disabled_all; ?>>
     517                                    <br>
     518
     519                                    <button type="submit" name="restoreoptimage" id="restoreoptimage" class="link" <?php echo $restoreoptimage_visible; ?> <?php echo $disabled_all; ?> ><?php echo CssWallRioTranslation::text('optimization-restore-button'); ?></button>
     520
     521                                    <p class="description" >
     522                                        <?php
     523
     524                                            if($optimizedImage === true){
     525                                                echo '<span class="CssWallrio_success">Optimized</span>';
     526                                            }
     527
     528                                        ?>
     529                                        <?php echo $pageOpt; ?>
     530                                    </p>
     531
     532                                </label>
     533
     534                                <br>
     535                                <br>
     536                                <i>Página</i>
     537                                <input type="text" name="optimizeimage_page" value="home" >
     538                               
     539                            </fieldset>
     540                        </td>
     541                    </tr>
     542
     543
     544
     545
    385546                    <tr>
    386547                        <th scope="row"><?php echo CssWallRioTranslation::text('optimize-cache'); ?></th>
     
    461622                                <input name="mobile_css_noload_external" id="mobile_css_noload_external"  type="checkbox" <?php echo $mobile_css_noload_external_checked; ?> <?php echo $disabled_all; ?>> <?php echo CssWallRioTranslation::text('mobile-no-load-external-css'); ?>
    462623                                </label>
     624                             
     625
     626                               
    463627                             
    464628
Note: See TracChangeset for help on using the changeset viewer.