Changeset 1949156
- Timestamp:
- 09/29/2018 06:57:25 PM (8 years ago)
- Location:
- cache-seo-speed/trunk
- Files:
-
- 10 edited
-
CssWallRioMain.php (modified) (1 diff)
-
package.json (modified) (1 diff)
-
readme-ptbr.txt (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
src/CssWallRio_filter.php (modified) (4 diffs)
-
src/CssWallRio_init.php (modified) (3 diffs)
-
src/CssWallRio_spider.php (modified) (1 diff)
-
views/CssWallRioTranslation.php (modified) (2 diffs)
-
views/CssWallRioView.php (modified) (3 diffs)
-
views/settings/index.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cache-seo-speed/trunk/CssWallRioMain.php
r1935231 r1949156 4 4 Plugin URI: http://wallrio.com/wordpress/plugins/cache-seo-speed/ 5 5 Description: Tool for optimization, caching and minification, accelerates the loading of pages with focus on performance analyzers. 6 Version: 0.0. 26 Version: 0.0.1 7 7 Author: Wallace Rio 8 8 Author URI: http://wallrio.com -
cache-seo-speed/trunk/package.json
r1935231 r1949156 1 1 { 2 2 "name": "cache-seo-speed", 3 "version":"0. 0.2",3 "version":"0.1.0", 4 4 "description": "Ferramenta para optimização, cache e minificação, acelera o carregamento de páginas com foco em analisadores de performance", 5 5 "homepage": "http://wallrio.com/wordpress/plugins/cache-seo-speed/", -
cache-seo-speed/trunk/readme-ptbr.txt
r1935231 r1949156 7 7 Requires at least: 4.3 8 8 Tested up to: 4.9 9 Stable tag: 0.0.2 9 Stable tag: 0.1.0 10 Require PHP: 5.2 or higher 10 11 11 12 Ferramenta para otimização, cache e minificação, acelera o carregamento de páginas com … … 55 56 2. Tela principal (Português) 56 57 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 57 68 == Frequently Asked Questions == 58 69 -
cache-seo-speed/trunk/readme.txt
r1935231 r1949156 7 7 Requires at least: 4.3 8 8 Tested up to: 4.9 9 Stable tag: 0.0.2 9 Stable tag: 0.1.0 10 Require PHP: 5.2 or higher 11 10 12 11 13 Tool for optimization, caching and minification, accelerates the loading of pages with … … 61 63 * fixed call failed for content cache. 62 64 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 63 69 64 70 == Frequently Asked Questions == -
cache-seo-speed/trunk/src/CssWallRio_filter.php
r1932100 r1949156 5 5 */ 6 6 7 error_reporting(E_ALL); 8 ini_set("display_errors", true); 9 ini_set("display_startup_erros",true); 10 7 11 8 12 class CssWallRio_filter{ 9 13 10 14 public static function init($filters,$content = ''){ 15 11 16 if($filters == true){ 12 17 $filters = array( … … 19 24 if(is_array($filters)) 20 25 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); 23 28 24 29 if($value == 'GtmRemoveOnPageSpeed') … … 27 32 return $content; 28 33 } 29 34 /* 30 35 public static function GoogleAnalyticsRemoveOnPageSpeed($content = ''){ 31 36 $sourceReplaceAnalit= '#\(function\(i,s,o,g,r,a,m\)\{i\[\'GoogleAnalyticsObject#ism'; … … 39 44 40 45 public static function GtmRemoveOnPageSpeed($content = ''){ 41 $sourceReplaceAnalit = '#\(function\(w,d,s,l,i\)\{#ism';46 $sourceReplaceAnalit = '#\(function\(w,d,s,l,i\)\{#ism'; 42 47 $targetReplaceAnalit = 'if(navigator.userAgent.indexOf("Speed Insights") == -1) { (function(w,d,s,l,i){'; 48 43 49 $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content); 50 44 51 $sourceReplaceAnalit= '#dataLayer\',\'(.*)\'\);\<#ism'; 45 52 $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\');});<'; 46 82 $content = preg_replace($sourceReplaceAnalit, $targetReplaceAnalit, $content); 47 83 return $content; -
cache-seo-speed/trunk/src/CssWallRio_init.php
r1932100 r1949156 17 17 $theme, 18 18 $timeToUpdate, 19 $ activatekey,$initialDate,$statusUpdate,19 $initialDate,$statusUpdate, 20 20 $version,$statusUpdateForce = false; 21 21 private static $pluginDir,$pluginName,$wpContentDir,$rootDir; … … 232 232 $this->optimizegzip = isset($config->optimizegzip)?$config->optimizegzip:false; 233 233 $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 235 238 $this->desktopusage = isset($config->desktopusage)?$config->desktopusage:false; 236 239 $this->timeToUpdate = isset($config->timeToUpdate)?$config->timeToUpdate:5; 237 $this->activatekey = isset($config->activatekey)?$config->activatekey:'';240 238 241 $this->useragent_allow = isset($config->useragent_allow)?$config->useragent_allow:''; 239 242 $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(); 241 244 $this->filters = isset($config->filters)?$config->filters:null; 242 245 $this->singlecache = isset($config->singlecache)?$config->singlecache:false; 243 $this->key = isset($config->singlecache)?$config->key:false;246 244 247 } 245 248 … … 251 254 public function run($content,$existCache){ 252 255 if(!isset($this->desktopusage)) $this->desktopusage = true; 253 if(!isset($this->pageListBlock)) $this->pageListBlock = [];256 if(!isset($this->pageListBlock)) $this->pageListBlock = array(); 254 257 if(!isset($this->mobileusage)) $this->mobileusage = true; 255 258 -
cache-seo-speed/trunk/src/CssWallRio_spider.php
r1935231 r1949156 9 9 class CssWallRio_spider{ 10 10 11 private $url,$minifyCss,$minifyJs; 11 private static $dirTheme; 12 private static $url,$minifyCss,$minifyJs,$mobile_css_noload_external,$includeimports; 12 13 13 14 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; 17 19 } 18 20 19 21 public function run($content){ 20 22 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 ){ 26 59 $url = $newMatch[1][0]; 27 60 28 61 $resultRequest = wp_remote_get($url); 29 30 62 if(is_array($resultRequest)) 31 $contentFile = isset($resultRequest['body'])?$resultRequest['body']:'';63 $contentFile = isset($resultRequest['body'])?$resultRequest['body']:''; 32 64 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','<iframe',$contentFile); 75 $contentFile = str_replace('</script','</',$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){ 35 222 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','<iframe',$contentFile); 107 $contentFile = str_replace('</script','</',$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 } 132 239 } -
cache-seo-speed/trunk/views/CssWallRioTranslation.php
r1932100 r1949156 68 68 'alert-permission-directory'=>'Set permission 755 to directory', 69 69 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 70 78 ); 71 79 … … 123 131 'alert-saved-success'=>'Salvo com sucesso', 124 132 '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' 125 141 ); 126 142 -
cache-seo-speed/trunk/views/CssWallRioView.php
r1932100 r1949156 208 208 else 209 209 $mobile_css_noload_external = false; 210 211 if(isset($request['includeimports'])) 212 $includeimports = true; 213 else 214 $includeimports = false; 210 215 211 216 if(isset($request['desktopusage'])) … … 258 263 'mobileusage'=>$mobileusage, 259 264 'mobile_css_noload_external'=>$mobile_css_noload_external, 265 'includeimports'=>$includeimports, 260 266 'showloading'=>$showloading, 261 267 'desktopusage'=>$desktopusage, … … 265 271 'useragent_deny'=>$useragent_deny, 266 272 'filters'=>$filters, 267 'pagesblock'=>$pagesblockArray, 268 'key'=>$precontent->key, 273 'pagesblock'=>$pagesblockArray 269 274 ); 270 275 -
cache-seo-speed/trunk/views/settings/index.php
r1932100 r1949156 5 5 */ 6 6 7 8 7 9 $configPath = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'cache-seo-speed'.DIRECTORY_SEPARATOR.'.css-config.dat'; 8 10 $dirCache = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.'cache/cache-seo-speed'.DIRECTORY_SEPARATOR; … … 12 14 $dirRoot = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))).DIRECTORY_SEPARATOR; 13 15 $urlPlugin = plugins_url().'/'; 16 // $domain = str_replace('wp-content/plugins/', '', $urlPlugin); 14 17 15 18 $pluginUrlArray = explode('/', $dirPlugin); … … 23 26 require_once $dirPlugin.'src'.DIRECTORY_SEPARATOR."CssWallRio_wpload.php"; 24 27 require_once $dirPlugin.'views'.DIRECTORY_SEPARATOR.'CssWallRioView.php'; 28 25 29 26 30 CssWallRioView::$dirPlugin = $dirPlugin; … … 47 51 $objectsDir_size = number_format($objectsDir_size / 1048576, 1) . ' MB'; 48 52 $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 58 if(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 = ''; 77 if(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"); 51 100 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 = ''; 130 if(!file_exists($dirCache.DIRECTORY_SEPARATOR."backup")) 131 $restoreoptimage_visible = ' style="display:none" '; 132 133 134 $optimizeimage_disabled = ''; 135 if( $_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1' ){ 136 $optimizeimage_disabled = 'disabled'; 137 } 138 139 140 $optimizedImage = false; 141 if(file_exists($dirCache.DIRECTORY_SEPARATOR."opt.zip") === true){ 142 $optimizedImage = true; 143 } 144 145 146 52 147 if(isset($_POST['save'])){ 53 148 … … 82 177 $showloading = isset($config['showloading'])?$config['showloading']:false; 83 178 $mobile_css_noload_external = isset($config['mobile_css_noload_external'])?$config['mobile_css_noload_external']:false; 179 $includeimports = isset($config['includeimports'])?$config['includeimports']:false; 84 180 $timeToUpdate = isset($config['timeToUpdate'])?$config['timeToUpdate']:5; 85 181 $activatekey = isset($config['activatekey'])?$config['activatekey']:''; … … 92 188 $useragent_allow = isset($config['useragent_allow'])?$config['useragent_allow']:''; 93 189 $useragent_deny = isset($config['useragent_deny'])?$config['useragent_deny']:''; 94 $pagesblock = isset($config['pagesblock'])?$config['pagesblock']: [];190 $pagesblock = isset($config['pagesblock'])?$config['pagesblock']:array(); 95 191 $pagesblockShow = implode(',', $pagesblock); 96 192 $filters = isset($config['filters'])?$config['filters']:false; … … 120 216 $mobileusage_checked = ''; 121 217 $mobile_css_noload_external_checked = ''; 218 $includeimports_checked = ''; 122 219 $desktopusage_checked = ''; 123 220 $showloading_checked = ''; … … 155 252 $mobileusage_checked = ' checked '; 156 253 } 157 if($ mobile_css_noload_external=== true){158 $ mobile_css_noload_external_checked = ' checked ';254 if($includeimports === true){ 255 $includeimports_checked = ' checked '; 159 256 } 160 257 … … 202 299 } 203 300 204 $localIP = getHostByName( getHostName());301 $localIP = getHostByName(php_uname('n')); 205 302 206 303 … … 230 327 231 328 <style media="screen"> 329 330 .CssWallrio_success{ 331 color: green; 332 } 232 333 @media (min-width:600px){ 233 334 .line{ … … 278 379 font-weight: normal; 279 380 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; 280 393 } 281 394 </style> … … 330 443 331 444 <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=""> 336 449 <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 339 457 </td> 340 458 </tr> … … 383 501 </tr> 384 502 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 385 546 <tr> 386 547 <th scope="row"><?php echo CssWallRioTranslation::text('optimize-cache'); ?></th> … … 461 622 <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'); ?> 462 623 </label> 624 625 626 463 627 464 628
Note: See TracChangeset
for help on using the changeset viewer.