Plugin Directory

Changeset 2418510


Ignore:
Timestamp:
11/14/2020 11:41:19 AM (5 years ago)
Author:
statopt
Message:
  • moved demo up
  • readme changes
  • removed the fonts from the selected list as they may not load all the time usually those with relative paths
  • added a check so the api form expands after the user submits the form to get a key
  • added notes about fonts referenced/loaded via relative paths
  • fixed the notice that's shown on localhost installs
  • improved image parser to skip external images.
  • added a fix for the parser that deals with backgrounds with url() ... it was capturing the last closing parenthesis
Location:
static-optimizer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • static-optimizer/trunk/lib/opt.php

    r2414860 r2418510  
    219219            . $host_prefix_regex
    220220            . $host_q
    221             . '[\w\-/.]+)[\w\s:\-/.%]+?)\.(' . $supported_ext . ')'
     221            . '[\w\-/.]*)[\w\s:\-/.%]+?)\.(' . $supported_ext . ')'
    222222            . '(?:[?&](?:hash|sha\d+|md5|ts?|version|ver|v|m|_)=([\w\-.]+))?([\'")]*)#si',
    223223            [ $this, 'appendQSAssetVerReplaceCallback' ],
     
    462462        $img_html = $matches[0];
    463463
     464        // local or external link
     465        if (!$this->isInternalSiteLink($img_html)) {
     466            return $img_html;
     467        }
     468
    464469        $append_txt = ' onerror="javascript:static_optimizer_handle_broken_image(this);" ';
    465470
     
    489494            . $host_prefix_regex
    490495            . $host_q
    491             . '[\w\-/.]+)[:\w\-/.\s%]+?)'
     496            . '[\w\-/.]*)[:\w\-/.\s%]+?)'
    492497            . '\.(svg|png|jpe?g|gif)(?:\?(?:hash|sha\d+|md5|ts?|version|ver|v|m|_)=([\w\-.]+))?([\'"\s]+)#si',
    493498            [ $this, 'appendQSAssetVerReplaceCallback' ],
     
    548553        if (stripos($first_match, '.statopt_ver') !== false) { // the link already has version
    549554            return $matches[0];
     555        } elseif (stripos($first_match, '.qs_ver') !== false) { // the link already has version
     556            return $matches[0];
    550557        }
    551558
     
    555562
    556563        $ver = empty($matches[3]) ? '' : $matches[3];
     564        $prev_suffix = $matches[4]; // quotes, parenthesis
     565
    557566        $is_ts = strlen($ver) >= 8 && is_numeric($ver) && preg_match('#^\d+$#si', $ver);
    558567        $local_file_regex = '#(/wp-[\w\-]+/.+)#si';
     
    593602        // @todo use https://www.jsdelivr.com/?docs=wp for known wp plugins & themes assets ?
    594603        // ='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];
    596605
    597606        $ctx = [
     
    628637        }
    629638
     639        $str .= $prev_suffix; // let's append it here so it doesn't confuse the optimized url
     640
    630641        return $str;
    631642    }
  • static-optimizer/trunk/readme.txt

    r2414860 r2418510  
    22Contributors: lordspace,statopt,orbisius
    33Donate 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,optimisation
     4Tags: wp,static,optimization,smush,ewww,autoptimize,cache,minify,caching,speed,performance,supercacher,wp-super-cache,wp-fastest-cache,image,asset,js,css,optimisation
    55Requires at least: 4.0
    66Tested up to: 5.5
    77Requires PHP: 5.6
    8 Stable tag: 1.0.2
     8Stable tag: 1.0.3
    99License: GPLv2 or later
    1010
    11 Optimizes your assets (images, css, js, fonts) for faster site loading so they are loaded by StaticOptimizer Optimization servers.
     11Optimizes your assets (images, css, js) for faster site loading so they are loaded by StaticOptimizer Optimization servers.
    1212
    1313== Description ==
     
    1919
    2020= Features / Benefits =
     21* Simple, efficient and free to use
    2122* Easy to set up. Just get your API key and you're good to go.
    2223* Automatic js and css minification & compression
    2324* Automatic image optimization (gif, jpeg, png)
    2425* 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.
    2628* Responsive Images (from srcset) are also processed
     29* Background images url() are also processed
    2730* 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 ==
     34https://www.youtube.com/watch?v=1KC_JJOcu1s
    2935
    3036= How it works =
     
    3238After 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.
    3339During 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 & font files to be optimized as well.
     40By default only images are selected for optimization. You can also select js, & css files to be optimized as well.
    3541The first time our servers get a file it will be downloaded and optimized. Because this operation can take several seconds
    3642your users will be redirected back to the original file that was requested. Any subsequent requests will be served from our servers.
    3743
    3844= Who is this plugin for? =
    39 People who have lots of images on their site such online stores, photographers.
     45People who have lots of images on their site such online stores, photographers, real estate agents.
    4046
    4147= Thanks =
    4248
    4349I'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
    4653* and to many more.
    47 
    48 == Demo ==
    49 https://www.youtube.com/watch?v=1KC_JJOcu1s
    5054
    5155== Support ==
     
    7579== Frequently Asked Questions ==
    7680
    77 = How to use this plugin? =
     81= For the most up-to-date FAQ see the site =
    7882
    79 Check out https://statopt.com
     83Check out <a href="https://statopt.com" target="_blank" title="[new window]">https://statopt.com</a>
    8084
    8185= Bug Report / Feature Requests =
    82 Please submit any bug report or feature requests to our github issue tracking system.
    8386
    84 <a href="https://github.com/statopt/static-optimizer-wp/issues"
    85                                     target="_blank" title="[new window]">Report Bugs / Features</a>
     87Please 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>
    8689
    8790= Does it work with WordPress multisite? =
     
    8992
    9093== 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
    91104
    92105= 1.0.2 =
  • static-optimizer/trunk/static-optimizer.php

    r2414860 r2418510  
    44Plugin URI: https://statopt.com
    55Description: Makes your images, js, css load faster by optimizing them and loading them from StaticOptimizer Optimization servers
    6 Version: 1.0.2
     6Version: 1.0.3
    77Author: StaticOptimizer & Orbisius
    88Author URI: https://orbisius.com
     
    435435                                                return false;
    436436                                            });
     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                                            });
    437446                                        });
    438447                                    })(jQuery);
     
    463472                                            echo "<br/>";
    464473                                            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' );
    466476                                            echo "</div>";
    467 
    468477                                        }
    469478                                    }
     
    868877            type='checkbox' value='1' $checked /> $file_type </label><br/>";
    869878    }
     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>
     886NOTE_EOF;
     887
     888    if (isset($file_types['fonts'])) {
     889        echo $note_on_fonts;
     890    }
    870891}
    871892
     
    914935
    915936        <form id="static_optimizer_get_api_key_form" name="static_optimizer_get_api_key_form"
     937              class="static_optimizer_get_api_key_form"
    916938              target="_blank"
    917939              method="post">
     
    922944
    923945            Site: <input type="url" id="static_optimizer_site_url" name="site_url"
    924                          style="width: 45%"
     946                         style="width: 35%"
    925947                         value="<?php esc_attr_e( $site_url ); ?>"/>
    926948
     
    963985
    964986function static_optimizer_maybe_render_localhost_notice( $ctx ) {
    965     $local_ips = [ '::1', '127.0.0.1', ];
    966 
    967987    if ( empty( $_SERVER['REMOTE_ADDR'] ) ) {
    968988        return;
    969989    }
    970990
     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
    971996    // 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    }
    9811009
    9821010    ?>
    9831011    <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>
    9851013    </div>
    9861014    <?php
Note: See TracChangeset for help on using the changeset viewer.