Changeset 2418510
- Timestamp:
- 11/14/2020 11:41:19 AM (5 years ago)
- Location:
- static-optimizer/trunk
- Files:
-
- 3 edited
-
lib/opt.php (modified) (7 diffs)
-
readme.txt (modified) (5 diffs)
-
static-optimizer.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
static-optimizer/trunk/lib/opt.php
r2414860 r2418510 219 219 . $host_prefix_regex 220 220 . $host_q 221 . '[\w\-/.] +)[\w\s:\-/.%]+?)\.(' . $supported_ext . ')'221 . '[\w\-/.]*)[\w\s:\-/.%]+?)\.(' . $supported_ext . ')' 222 222 . '(?:[?&](?:hash|sha\d+|md5|ts?|version|ver|v|m|_)=([\w\-.]+))?([\'")]*)#si', 223 223 [ $this, 'appendQSAssetVerReplaceCallback' ], … … 462 462 $img_html = $matches[0]; 463 463 464 // local or external link 465 if (!$this->isInternalSiteLink($img_html)) { 466 return $img_html; 467 } 468 464 469 $append_txt = ' onerror="javascript:static_optimizer_handle_broken_image(this);" '; 465 470 … … 489 494 . $host_prefix_regex 490 495 . $host_q 491 . '[\w\-/.] +)[:\w\-/.\s%]+?)'496 . '[\w\-/.]*)[:\w\-/.\s%]+?)' 492 497 . '\.(svg|png|jpe?g|gif)(?:\?(?:hash|sha\d+|md5|ts?|version|ver|v|m|_)=([\w\-.]+))?([\'"\s]+)#si', 493 498 [ $this, 'appendQSAssetVerReplaceCallback' ], … … 548 553 if (stripos($first_match, '.statopt_ver') !== false) { // the link already has version 549 554 return $matches[0]; 555 } elseif (stripos($first_match, '.qs_ver') !== false) { // the link already has version 556 return $matches[0]; 550 557 } 551 558 … … 555 562 556 563 $ver = empty($matches[3]) ? '' : $matches[3]; 564 $prev_suffix = $matches[4]; // quotes, parenthesis 565 557 566 $is_ts = strlen($ver) >= 8 && is_numeric($ver) && preg_match('#^\d+$#si', $ver); 558 567 $local_file_regex = '#(/wp-[\w\-]+/.+)#si'; … … 593 602 // @todo use https://www.jsdelivr.com/?docs=wp for known wp plugins & themes assets ? 594 603 // ='https://1mapps.qsandbox0.staging.com/statopt/test/site/wp-includes/css/dist/block-library/style.min.statopt_ver.1603969031.css' 595 $str = $matches[1] . '.statopt_ver.' . $ver . '.'. $matches[2] . $matches[4];604 $str = $matches[1] . '.statopt_ver.' . $ver . '.'. $matches[2];// . $matches[4]; 596 605 597 606 $ctx = [ … … 628 637 } 629 638 639 $str .= $prev_suffix; // let's append it here so it doesn't confuse the optimized url 640 630 641 return $str; 631 642 } -
static-optimizer/trunk/readme.txt
r2414860 r2418510 2 2 Contributors: lordspace,statopt,orbisius 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A 4 Tags: wp,static,optimization,smush,ewww,autoptimize,cache,minify,caching,speed,performance,supercacher,wp-super-cache,wp-fastest-cache,image,asset,js,css, font,optimisation4 Tags: wp,static,optimization,smush,ewww,autoptimize,cache,minify,caching,speed,performance,supercacher,wp-super-cache,wp-fastest-cache,image,asset,js,css,optimisation 5 5 Requires at least: 4.0 6 6 Tested up to: 5.5 7 7 Requires PHP: 5.6 8 Stable tag: 1.0. 28 Stable tag: 1.0.3 9 9 License: GPLv2 or later 10 10 11 Optimizes your assets (images, css, js , fonts) for faster site loading so they are loaded by StaticOptimizer Optimization servers.11 Optimizes your assets (images, css, js) for faster site loading so they are loaded by StaticOptimizer Optimization servers. 12 12 13 13 == Description == … … 19 19 20 20 = Features / Benefits = 21 * Simple, efficient and free to use 21 22 * Easy to set up. Just get your API key and you're good to go. 22 23 * Automatic js and css minification & compression 23 24 * Automatic image optimization (gif, jpeg, png) 24 25 * Files are reloaded only when they are changed on your server (or deleted from ours). 25 * Our servers check and if the visitor's browser support webp that's what we'll serve. 26 * Automatic conversion to webp 27 * Our servers check and if the visitor's browser supports webp we'll serve that file otherwise the optimized version. 26 28 * Responsive Images (from srcset) are also processed 29 * Background images url() are also processed 27 30 * We've put extra efforts to make this plugin as efficient as possible. 28 * Simple to use 31 * The code in script blocks is preserved 32 33 == Demo == 34 https://www.youtube.com/watch?v=1KC_JJOcu1s 29 35 30 36 = How it works = … … 32 38 After you get your API key the plugin will install as a system (mu-plugin) and will correct the location where the selected files are loaded from. 33 39 During the plugin configuration you can tell the plugin which file types you'd like to be optimized. 34 By default only images are selected for optimization. You can also select js, css & fontfiles to be optimized as well.40 By default only images are selected for optimization. You can also select js, & css files to be optimized as well. 35 41 The first time our servers get a file it will be downloaded and optimized. Because this operation can take several seconds 36 42 your users will be redirected back to the original file that was requested. Any subsequent requests will be served from our servers. 37 43 38 44 = Who is this plugin for? = 39 People who have lots of images on their site such online stores, photographers .45 People who have lots of images on their site such online stores, photographers, real estate agents. 40 46 41 47 = Thanks = 42 48 43 49 I'd like to express my gratitude to the people who have taken the time to test the plugin & make suggestions and/or has provided access to troubleshoot glitches. 44 * Ryan Chaffe - https://site123.ca 45 * Michel Veenstra - https://www.adventis.nl 50 * Phil Ryan - <a href="https://site123.ca" title="" target="_blank">https://site123.ca</a> 51 * Michel Veenstra - <a href="https://www.adventis.nl" title="" target="_blank">https://www.adventis.nl</a> 52 46 53 * and to many more. 47 48 == Demo ==49 https://www.youtube.com/watch?v=1KC_JJOcu1s50 54 51 55 == Support == … … 75 79 == Frequently Asked Questions == 76 80 77 = How to use this plugin?=81 = For the most up-to-date FAQ see the site = 78 82 79 Check out https://statopt.com83 Check out <a href="https://statopt.com" target="_blank" title="[new window]">https://statopt.com</a> 80 84 81 85 = Bug Report / Feature Requests = 82 Please submit any bug report or feature requests to our github issue tracking system.83 86 84 <a href="https://github.com/statopt/static-optimizer-wp/issues" 85 target="_blank" title="[new window]">Report Bugs / Features</a>87 Please submit any bug report or feature requests in our github issue tracking system. 88 <a href="https://github.com/statopt/static-optimizer-wp/issues" target="_blank" title="[new window]">Report Bugs / Features</a> 86 89 87 90 = Does it work with WordPress multisite? = … … 89 92 90 93 == Changelog == 94 95 = 1.0.3 = 96 * moved demo up 97 * readme changes 98 * removed the fonts from the selected list as they may not load all the time usually those with relative paths 99 * added a check so the api form expands after the user submits the form to get a key 100 * added notes about fonts referenced/loaded via relative paths 101 * fixed the notice that's shown on localhost installs 102 * improved image parser to skip external images. 103 * added a fix for the parser that deals with backgrounds with url() ... it was capturing the last closing parenthesis 91 104 92 105 = 1.0.2 = -
static-optimizer/trunk/static-optimizer.php
r2414860 r2418510 4 4 Plugin URI: https://statopt.com 5 5 Description: Makes your images, js, css load faster by optimizing them and loading them from StaticOptimizer Optimization servers 6 Version: 1.0. 26 Version: 1.0.3 7 7 Author: StaticOptimizer & Orbisius 8 8 Author URI: https://orbisius.com … … 435 435 return false; 436 436 }); 437 438 // When the user submits the form to sign up for the API key, it will wait for him/her expanded. 439 jQuery('.static_optimizer_get_api_key_form').on('submit', function (e) { 440 setTimeout(function () { 441 jQuery('.static_optimizer_admin_options_fields_reveal_btn').trigger('click'); 442 }, 100); 443 444 return true; 445 }); 437 446 }); 438 447 })(jQuery); … … 463 472 echo "<br/>"; 464 473 echo "<div class='static_optimizer_admin_options_fields_reveal_btn_wrapper'>"; 465 echo __( "Use the form below to get your API key | <a href='javascript:void(0);' class='static_optimizer_admin_options_fields_reveal_btn'>I already have an API key</a>", 'statopt' ); 474 echo __( "Use the form below to get your API key " 475 . " | <a href='javascript:void(0);' class='static_optimizer_admin_options_fields_reveal_btn'>I already have an API key</a>", 'statopt' ); 466 476 echo "</div>"; 467 468 477 } 469 478 } … … 868 877 type='checkbox' value='1' $checked /> $file_type </label><br/>"; 869 878 } 879 880 $note_on_fonts =<<<NOTE_EOF 881 <br/> 882 <div> 883 Note: If you have fonts that are loaded/referenced in CSS via relative paths they may not properly load from our 884 servers. 885 </div> 886 NOTE_EOF; 887 888 if (isset($file_types['fonts'])) { 889 echo $note_on_fonts; 890 } 870 891 } 871 892 … … 914 935 915 936 <form id="static_optimizer_get_api_key_form" name="static_optimizer_get_api_key_form" 937 class="static_optimizer_get_api_key_form" 916 938 target="_blank" 917 939 method="post"> … … 922 944 923 945 Site: <input type="url" id="static_optimizer_site_url" name="site_url" 924 style="width: 45%"946 style="width: 35%" 925 947 value="<?php esc_attr_e( $site_url ); ?>"/> 926 948 … … 963 985 964 986 function static_optimizer_maybe_render_localhost_notice( $ctx ) { 965 $local_ips = [ '::1', '127.0.0.1', ];966 967 987 if ( empty( $_SERVER['REMOTE_ADDR'] ) ) { 968 988 return; 969 989 } 970 990 991 $ip = empty( $_SERVER['REMOTE_ADDR'] ) ? '' : $_SERVER['REMOTE_ADDR']; 992 $local_ips = [ '::1', '127.0.0.1', ]; 993 $server_name = empty( $_SERVER['SERVER_NAME'] ) ? '' : $_SERVER['SERVER_NAME']; 994 $show_localhost_notice = false; 995 971 996 // Let's check LAN IPs 972 if ( ! preg_match( '#^(::1|127\.0\.|10\.0\.[0-2]|192\.168.[0-2]\.|172\.[1-3]\d*\.0)#si', $_SERVER['REMOTE_ADDR'] ) ) { // internal req or dev machine 973 return; 974 } 975 976 $server_name = empty( $_SERVER['SERVER_NAME'] ) ? '' : $_SERVER['SERVER_NAME']; 977 978 if ( ! preg_match( '#^(localhost|\.local)#si', $server_name ) ) { // internal req or dev machine 979 return; 980 } 997 if ( in_array($ip, $local_ips) 998 || preg_match( '#^(::1|127\.0\.|10\.0\.[0-2]|192\.168.[0-2]\.|172\.[1-3]\d*\.0)#si', $_SERVER['REMOTE_ADDR'] ) 999 ) { 1000 $show_localhost_notice = true; 1001 } elseif ( $server_name == 'localhost' 1002 || preg_match( '#^(localhost|\.local)#si', $server_name ) ) { // internal req or dev machine 1003 $show_localhost_notice = true; 1004 } 1005 1006 if (!$show_localhost_notice) { 1007 return; 1008 } 981 1009 982 1010 ?> 983 1011 <div class="alert" style="background:red;color: #fff;padding: 3px;"> 984 This plugin doesn't work on localhost because our servers need to be able to access your site.1012 <p>Warning: This plugin doesn't work on localhost because our servers need to be able to access your site.</p> 985 1013 </div> 986 1014 <?php
Note: See TracChangeset
for help on using the changeset viewer.