Plugin Directory

Changeset 1814154


Ignore:
Timestamp:
02/02/2018 02:29:26 PM (8 years ago)
Author:
GatorDog
Message:

PHP 7.0 compat and minor updates

Location:
gator-cache
Files:
18 edited
8 copied

Legend:

Unmodified
Added
Removed
  • gator-cache/tags/2.1.6/gator-cache.php

    r1553194 r1814154  
    22/**
    33 * @package Gator Cache
    4  * @version 2.1.5
     4 * @version 2.1.6
    55 */
    66/*
     
    1212Text Domain: gator-cache
    1313Domain Path: /lang
    14 Version: 2.1.5
     14Version: 2.1.6
    1515*/
    1616class WpGatorCache
     
    2727        'app_support' => array(),
    2828        'roles' => array(),
     29        'only_user' => false,
    2930        'refresh' => array('home' => true, 'archive' => true, 'all' => false),
    3031        'pingback' => false,
     
    4849    protected static $multiSiteData;
    4950    const PREFIX = 'gtr_cache';
    50     const VERSION = '2.1.5';
     51    const VERSION = '2.1.6';
    5152    const JP_MOBILE_MOD = 'minileven'; // JetPack mobile module slug
    5253    const SUPPORT_LINK = 'https://wordpress.org/support/plugin/gator-cache';
     
    6970          || ('post' !== $post->post_type && 'page' !== $post->post_type && !in_array($post->post_type, self::getCacheTypes()))
    7071          || (defined('DOING_AJAX') && DOING_AJAX) || is_admin()
    71           || (is_user_logged_in() && (!$options['enable_hooks'] || !self::cacheUserContent()))
     72          || (($loggedIn = is_user_logged_in()) && (!$options['enable_hooks'] || !self::cacheUserContent()))
     73          || !$loggedIn && $options['only_user']
    7274          || '' === get_option('permalink_structure')
    7375          || self::hasPathExclusion($path)
     
    693695    {
    694696        $groups = array($opts['group']);
    695         if ($isJetPackMobile = $opts['jp_mobile_cache']) {
     697        if ($isJetPackMobile = isset($opts['jp_mobile_cache']) && $opts['jp_mobile_cache']) {
    696698            $groups[] = $opts['group'] . '-jpmobile';
    697699        }
    698         if (!$opts['skip_ssl']) {
     700        if (empty($opts['skip_ssl'])) {
    699701            $groups[] = 'ssl@' . $opts['group'];
    700702            if ($isJetPackMobile) {
  • gator-cache/tags/2.1.6/lib/GatorCacheAdminSettings.php

    r1515890 r1814154  
    176176                    }
    177177                }
    178                 if ($roles !== $this->options['roles']) {
     178                $onlyUser = isset($_POST['only_user']) && '1' === $_POST['only_user'];
     179                var_dump($onlyUser, $_POST);
     180                if ($roles !== $this->options['roles'] || $onlyUser !== $this->options['only_user']) {
    179181                    $update = true;
    180182                    $this->options['roles'] = $roles;
    181183                    $cache['skip_user'] = !empty($roles);
     184                    $this->options['only_user'] = $cache['only_user'] = $cache['skip_user'] && $onlyUser;
    182185                }
    183186            break;
  • gator-cache/tags/2.1.6/lib/GatorCachePlugin.php

    r1553194 r1814154  
    7474                }
    7575            }
     76            $config = GatorCache::getConfig($this->configPath);
     77            if (empty($this->options['roles']) && $config->get('skip_user')) {//
     78                $config->save('skip_user', false);
     79            }
    7680            //upgrades done or nothing to upgrade, update the version
    7781            $wpConfig->set('version', $this->options['version'] = WpGatorCache::VERSION);
     
    211215        }
    212216        $this->setContentTypes($config);
     217        $config = GatorCache::getConfig($this->configPath);
     218        if (empty($this->options['roles']) && $config->get('skip_user')) {
     219            $config->save('skip_user', false);
     220        }
    213221        return true;
    214222    }
  • gator-cache/tags/2.1.6/lib/Reo/Classic/CacheLite.php

    r1355383 r1814154  
    677677            clearstatcache();
    678678            $length = @filesize($this->_file);
     679/*@depricated function get_magic_quotes_runtime
    679680            $mqr = get_magic_quotes_runtime();
    680681            if ($mqr) {
    681682                set_magic_quotes_runtime(0);
    682             }
     683            }*/
    683684            if ($this->readControl) {
    684685                if ('none' === $this->readControlType) {
     
    698699                $data = '';
    699700            }
    700             if ($mqr) {
     701/*            if ($mqr) {
    701702                set_magic_quotes_runtime($mqr);
    702             }
     703            }*/
    703704            if ($this->_fileLocking) {
    704705                @flock($fp, LOCK_UN);
     
    731732                @flock($fp, LOCK_EX);
    732733            }
    733 
     734/*@depricated function get_magic_quotes_runtime
    734735            if ($mqr = get_magic_quotes_runtime()) {
    735736                set_magic_quotes_runtime(0);
    736             }
     737            }*/
    737738            if ($this->readControl) {
    738739                @fwrite($fp, $prefix = (0 === $this->lifeTime ? '0000000000' : time() + $this->lifeTime) . $this->_hash($data, $this->readControlType) . $data);
     
    740741                @fwrite($fp, $data);
    741742            }
    742             if ($mqr) {
     743            /*if ($mqr) {
    743744                set_magic_quotes_runtime($mqr);
    744             }
     745            }*/
    745746            if ($this->_fileLocking) {
    746747                @flock($fp, LOCK_UN);
  • gator-cache/tags/2.1.6/lib/advanced-cache.php

    r1520541 r1814154  
    6464        }
    6565    }
     66    // not logged in
     67    if ($config->get('skip_user') && $config->get('only_user')) {
     68        return; // do not serve cache to non-logged in user a rare use case
     69    }
    6670}
    6771$request = GatorCache::getRequest();
    68 if ('GET' !== $request->getMethod() || $request->hasQueryString() || '.php' === substr($request->getRequestUri(), -4)
     72if ('GET' !== $request->getMethod() || ($request->hasQueryString() && !$config->get('serve_qs')) || '.php' === substr($request->getRequestUri(), -4)
    6973  || ($request->isSecure() && $config->get('skip_ssl'))
    7074  || false === ($host = $config->get($request->isSecure() && $config->has('secure_host') ? 'secure_host' : 'host'))
  • gator-cache/tags/2.1.6/lib/config.ini.php

    r1355383 r1814154  
    77oc_enabled = 0
    88gzip = 1
    9 skip_user = 1
     9skip_user = 0
     10only_user = 0
    1011last_modified = 0
    1112cache_warm = 0
  • gator-cache/tags/2.1.6/readme.txt

    r1553202 r1814154  
    44Tags: cache, performance, optimize, bbpress, woocommerce, multisite, jetpack mobile
    55Requires at least: 3.8
    6 Tested up to: 4.7
    7 Stable tag: 2.1.5
     6Tested up to: 4.9.2
     7Stable tag: 2.1.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57= 2.1.6 =
     58* WordPress 4.9.2 compatiblity verified
     59* PHP 7.x compatibilty, fix warning errors
     60* Fix warning error with JetPack mobile compatiblity
    5761= 2.1.5 =
    5862* Redis Object Cache plugin compatiblity, fix issue with object-cache deletion.
  • gator-cache/tags/2.1.6/tpl/options.php

    r1520541 r1814154  
    228228      </select>
    229229    </p>
     230    <p>
     231      <input type="checkbox" name="gci_only_user" id="gci_only_user" value="1"<?php if($options['only_user']){echo ' checked="checked"';}?>/>
     232      <label for="gci_only_user"><?php _e('Only serve cache to logged in users', 'gator-cache');?></label>
     233    </p>
    230234    <p><button class="button-primary"><?php _e('Update', 'gator-cache');?></button></p>
    231235    <p><i class="fa fa-lightbulb-o"></i> <?php _e('Unless your theme displays user specific content via ajax, caching logged-in user content is usually not a good idea.', 'gator-cache');?></p>
     
    330334        if(1 === sel.length){
    331335            var form = [{'name':sel.attr('id'),'value': sel.val()}];
     336            if ('gci_roles' === form[0].name) {
     337                form.push({'name':'only_user','value':$('#gci_only_user').prop('checked') ? 1 : 0});
     338            }
    332339        }
    333340        else{
  • gator-cache/tags/2.1.6/trunk/gator-cache.php

    r1553194 r1814154  
    22/**
    33 * @package Gator Cache
    4  * @version 2.1.5
     4 * @version 2.1.6
    55 */
    66/*
     
    1212Text Domain: gator-cache
    1313Domain Path: /lang
    14 Version: 2.1.5
     14Version: 2.1.6
    1515*/
    1616class WpGatorCache
     
    2727        'app_support' => array(),
    2828        'roles' => array(),
     29        'only_user' => false,
    2930        'refresh' => array('home' => true, 'archive' => true, 'all' => false),
    3031        'pingback' => false,
     
    4849    protected static $multiSiteData;
    4950    const PREFIX = 'gtr_cache';
    50     const VERSION = '2.1.5';
     51    const VERSION = '2.1.6';
    5152    const JP_MOBILE_MOD = 'minileven'; // JetPack mobile module slug
    5253    const SUPPORT_LINK = 'https://wordpress.org/support/plugin/gator-cache';
     
    6970          || ('post' !== $post->post_type && 'page' !== $post->post_type && !in_array($post->post_type, self::getCacheTypes()))
    7071          || (defined('DOING_AJAX') && DOING_AJAX) || is_admin()
    71           || (is_user_logged_in() && (!$options['enable_hooks'] || !self::cacheUserContent()))
     72          || (($loggedIn = is_user_logged_in()) && (!$options['enable_hooks'] || !self::cacheUserContent()))
     73          || !$loggedIn && $options['only_user']
    7274          || '' === get_option('permalink_structure')
    7375          || self::hasPathExclusion($path)
     
    693695    {
    694696        $groups = array($opts['group']);
    695         if ($isJetPackMobile = $opts['jp_mobile_cache']) {
     697        if ($isJetPackMobile = isset($opts['jp_mobile_cache']) && $opts['jp_mobile_cache']) {
    696698            $groups[] = $opts['group'] . '-jpmobile';
    697699        }
    698         if (!$opts['skip_ssl']) {
     700        if (empty($opts['skip_ssl'])) {
    699701            $groups[] = 'ssl@' . $opts['group'];
    700702            if ($isJetPackMobile) {
  • gator-cache/tags/2.1.6/trunk/lib/GatorCacheAdminSettings.php

    r1515890 r1814154  
    176176                    }
    177177                }
    178                 if ($roles !== $this->options['roles']) {
     178                $onlyUser = isset($_POST['only_user']) && '1' === $_POST['only_user'];
     179                var_dump($onlyUser, $_POST);
     180                if ($roles !== $this->options['roles'] || $onlyUser !== $this->options['only_user']) {
    179181                    $update = true;
    180182                    $this->options['roles'] = $roles;
    181183                    $cache['skip_user'] = !empty($roles);
     184                    $this->options['only_user'] = $cache['only_user'] = $cache['skip_user'] && $onlyUser;
    182185                }
    183186            break;
  • gator-cache/tags/2.1.6/trunk/lib/GatorCachePlugin.php

    r1553194 r1814154  
    7474                }
    7575            }
     76            $config = GatorCache::getConfig($this->configPath);
     77            if (empty($this->options['roles']) && $config->get('skip_user')) {//
     78                $config->save('skip_user', false);
     79            }
    7680            //upgrades done or nothing to upgrade, update the version
    7781            $wpConfig->set('version', $this->options['version'] = WpGatorCache::VERSION);
     
    211215        }
    212216        $this->setContentTypes($config);
     217        $config = GatorCache::getConfig($this->configPath);
     218        if (empty($this->options['roles']) && $config->get('skip_user')) {
     219            $config->save('skip_user', false);
     220        }
    213221        return true;
    214222    }
  • gator-cache/tags/2.1.6/trunk/lib/Reo/Classic/CacheLite.php

    r1355383 r1814154  
    677677            clearstatcache();
    678678            $length = @filesize($this->_file);
     679/*@depricated function get_magic_quotes_runtime
    679680            $mqr = get_magic_quotes_runtime();
    680681            if ($mqr) {
    681682                set_magic_quotes_runtime(0);
    682             }
     683            }*/
    683684            if ($this->readControl) {
    684685                if ('none' === $this->readControlType) {
     
    698699                $data = '';
    699700            }
    700             if ($mqr) {
     701/*            if ($mqr) {
    701702                set_magic_quotes_runtime($mqr);
    702             }
     703            }*/
    703704            if ($this->_fileLocking) {
    704705                @flock($fp, LOCK_UN);
     
    731732                @flock($fp, LOCK_EX);
    732733            }
    733 
     734/*@depricated function get_magic_quotes_runtime
    734735            if ($mqr = get_magic_quotes_runtime()) {
    735736                set_magic_quotes_runtime(0);
    736             }
     737            }*/
    737738            if ($this->readControl) {
    738739                @fwrite($fp, $prefix = (0 === $this->lifeTime ? '0000000000' : time() + $this->lifeTime) . $this->_hash($data, $this->readControlType) . $data);
     
    740741                @fwrite($fp, $data);
    741742            }
    742             if ($mqr) {
     743            /*if ($mqr) {
    743744                set_magic_quotes_runtime($mqr);
    744             }
     745            }*/
    745746            if ($this->_fileLocking) {
    746747                @flock($fp, LOCK_UN);
  • gator-cache/tags/2.1.6/trunk/lib/advanced-cache.php

    r1520541 r1814154  
    6464        }
    6565    }
     66    // not logged in
     67    if ($config->get('skip_user') && $config->get('only_user')) {
     68        return; // do not serve cache to non-logged in user a rare use case
     69    }
    6670}
    6771$request = GatorCache::getRequest();
    68 if ('GET' !== $request->getMethod() || $request->hasQueryString() || '.php' === substr($request->getRequestUri(), -4)
     72if ('GET' !== $request->getMethod() || ($request->hasQueryString() && !$config->get('serve_qs')) || '.php' === substr($request->getRequestUri(), -4)
    6973  || ($request->isSecure() && $config->get('skip_ssl'))
    7074  || false === ($host = $config->get($request->isSecure() && $config->has('secure_host') ? 'secure_host' : 'host'))
  • gator-cache/tags/2.1.6/trunk/lib/config.ini.php

    r1355383 r1814154  
    77oc_enabled = 0
    88gzip = 1
    9 skip_user = 1
     9skip_user = 0
     10only_user = 0
    1011last_modified = 0
    1112cache_warm = 0
  • gator-cache/tags/2.1.6/trunk/readme.txt

    r1553202 r1814154  
    44Tags: cache, performance, optimize, bbpress, woocommerce, multisite, jetpack mobile
    55Requires at least: 3.8
    6 Tested up to: 4.7
    7 Stable tag: 2.1.5
     6Tested up to: 4.9.2
     7Stable tag: 2.1.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57= 2.1.6 =
     58* WordPress 4.9.2 compatiblity verified
     59* PHP 7.x compatibilty, fix warning errors
     60* Fix warning error with JetPack mobile compatiblity
    5761= 2.1.5 =
    5862* Redis Object Cache plugin compatiblity, fix issue with object-cache deletion.
  • gator-cache/tags/2.1.6/trunk/tpl/options.php

    r1520541 r1814154  
    228228      </select>
    229229    </p>
     230    <p>
     231      <input type="checkbox" name="gci_only_user" id="gci_only_user" value="1"<?php if($options['only_user']){echo ' checked="checked"';}?>/>
     232      <label for="gci_only_user"><?php _e('Only serve cache to logged in users', 'gator-cache');?></label>
     233    </p>
    230234    <p><button class="button-primary"><?php _e('Update', 'gator-cache');?></button></p>
    231235    <p><i class="fa fa-lightbulb-o"></i> <?php _e('Unless your theme displays user specific content via ajax, caching logged-in user content is usually not a good idea.', 'gator-cache');?></p>
     
    330334        if(1 === sel.length){
    331335            var form = [{'name':sel.attr('id'),'value': sel.val()}];
     336            if ('gci_roles' === form[0].name) {
     337                form.push({'name':'only_user','value':$('#gci_only_user').prop('checked') ? 1 : 0});
     338            }
    332339        }
    333340        else{
  • gator-cache/trunk/gator-cache.php

    r1553194 r1814154  
    22/**
    33 * @package Gator Cache
    4  * @version 2.1.5
     4 * @version 2.1.6
    55 */
    66/*
     
    1212Text Domain: gator-cache
    1313Domain Path: /lang
    14 Version: 2.1.5
     14Version: 2.1.6
    1515*/
    1616class WpGatorCache
     
    2727        'app_support' => array(),
    2828        'roles' => array(),
     29        'only_user' => false,
    2930        'refresh' => array('home' => true, 'archive' => true, 'all' => false),
    3031        'pingback' => false,
     
    4849    protected static $multiSiteData;
    4950    const PREFIX = 'gtr_cache';
    50     const VERSION = '2.1.5';
     51    const VERSION = '2.1.6';
    5152    const JP_MOBILE_MOD = 'minileven'; // JetPack mobile module slug
    5253    const SUPPORT_LINK = 'https://wordpress.org/support/plugin/gator-cache';
     
    6970          || ('post' !== $post->post_type && 'page' !== $post->post_type && !in_array($post->post_type, self::getCacheTypes()))
    7071          || (defined('DOING_AJAX') && DOING_AJAX) || is_admin()
    71           || (is_user_logged_in() && (!$options['enable_hooks'] || !self::cacheUserContent()))
     72          || (($loggedIn = is_user_logged_in()) && (!$options['enable_hooks'] || !self::cacheUserContent()))
     73          || !$loggedIn && $options['only_user']
    7274          || '' === get_option('permalink_structure')
    7375          || self::hasPathExclusion($path)
     
    693695    {
    694696        $groups = array($opts['group']);
    695         if ($isJetPackMobile = $opts['jp_mobile_cache']) {
     697        if ($isJetPackMobile = isset($opts['jp_mobile_cache']) && $opts['jp_mobile_cache']) {
    696698            $groups[] = $opts['group'] . '-jpmobile';
    697699        }
    698         if (!$opts['skip_ssl']) {
     700        if (empty($opts['skip_ssl'])) {
    699701            $groups[] = 'ssl@' . $opts['group'];
    700702            if ($isJetPackMobile) {
  • gator-cache/trunk/lib/GatorCacheAdminSettings.php

    r1515890 r1814154  
    176176                    }
    177177                }
    178                 if ($roles !== $this->options['roles']) {
     178                $onlyUser = isset($_POST['only_user']) && '1' === $_POST['only_user'];
     179                var_dump($onlyUser, $_POST);
     180                if ($roles !== $this->options['roles'] || $onlyUser !== $this->options['only_user']) {
    179181                    $update = true;
    180182                    $this->options['roles'] = $roles;
    181183                    $cache['skip_user'] = !empty($roles);
     184                    $this->options['only_user'] = $cache['only_user'] = $cache['skip_user'] && $onlyUser;
    182185                }
    183186            break;
  • gator-cache/trunk/lib/GatorCachePlugin.php

    r1553194 r1814154  
    7474                }
    7575            }
     76            $config = GatorCache::getConfig($this->configPath);
     77            if (empty($this->options['roles']) && $config->get('skip_user')) {//
     78                $config->save('skip_user', false);
     79            }
    7680            //upgrades done or nothing to upgrade, update the version
    7781            $wpConfig->set('version', $this->options['version'] = WpGatorCache::VERSION);
     
    211215        }
    212216        $this->setContentTypes($config);
     217        $config = GatorCache::getConfig($this->configPath);
     218        if (empty($this->options['roles']) && $config->get('skip_user')) {
     219            $config->save('skip_user', false);
     220        }
    213221        return true;
    214222    }
  • gator-cache/trunk/lib/Reo/Classic/CacheLite.php

    r1355383 r1814154  
    677677            clearstatcache();
    678678            $length = @filesize($this->_file);
     679/*@depricated function get_magic_quotes_runtime
    679680            $mqr = get_magic_quotes_runtime();
    680681            if ($mqr) {
    681682                set_magic_quotes_runtime(0);
    682             }
     683            }*/
    683684            if ($this->readControl) {
    684685                if ('none' === $this->readControlType) {
     
    698699                $data = '';
    699700            }
    700             if ($mqr) {
     701/*            if ($mqr) {
    701702                set_magic_quotes_runtime($mqr);
    702             }
     703            }*/
    703704            if ($this->_fileLocking) {
    704705                @flock($fp, LOCK_UN);
     
    731732                @flock($fp, LOCK_EX);
    732733            }
    733 
     734/*@depricated function get_magic_quotes_runtime
    734735            if ($mqr = get_magic_quotes_runtime()) {
    735736                set_magic_quotes_runtime(0);
    736             }
     737            }*/
    737738            if ($this->readControl) {
    738739                @fwrite($fp, $prefix = (0 === $this->lifeTime ? '0000000000' : time() + $this->lifeTime) . $this->_hash($data, $this->readControlType) . $data);
     
    740741                @fwrite($fp, $data);
    741742            }
    742             if ($mqr) {
     743            /*if ($mqr) {
    743744                set_magic_quotes_runtime($mqr);
    744             }
     745            }*/
    745746            if ($this->_fileLocking) {
    746747                @flock($fp, LOCK_UN);
  • gator-cache/trunk/lib/advanced-cache.php

    r1520541 r1814154  
    6464        }
    6565    }
     66    // not logged in
     67    if ($config->get('skip_user') && $config->get('only_user')) {
     68        return; // do not serve cache to non-logged in user a rare use case
     69    }
    6670}
    6771$request = GatorCache::getRequest();
    68 if ('GET' !== $request->getMethod() || $request->hasQueryString() || '.php' === substr($request->getRequestUri(), -4)
     72if ('GET' !== $request->getMethod() || ($request->hasQueryString() && !$config->get('serve_qs')) || '.php' === substr($request->getRequestUri(), -4)
    6973  || ($request->isSecure() && $config->get('skip_ssl'))
    7074  || false === ($host = $config->get($request->isSecure() && $config->has('secure_host') ? 'secure_host' : 'host'))
  • gator-cache/trunk/lib/config.ini.php

    r1355383 r1814154  
    77oc_enabled = 0
    88gzip = 1
    9 skip_user = 1
     9skip_user = 0
     10only_user = 0
    1011last_modified = 0
    1112cache_warm = 0
  • gator-cache/trunk/readme.txt

    r1553202 r1814154  
    44Tags: cache, performance, optimize, bbpress, woocommerce, multisite, jetpack mobile
    55Requires at least: 3.8
    6 Tested up to: 4.7
    7 Stable tag: 2.1.5
     6Tested up to: 4.9.2
     7Stable tag: 2.1.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57= 2.1.6 =
     58* WordPress 4.9.2 compatiblity verified
     59* PHP 7.x compatibilty, fix warning errors
     60* Fix warning error with JetPack mobile compatiblity
    5761= 2.1.5 =
    5862* Redis Object Cache plugin compatiblity, fix issue with object-cache deletion.
  • gator-cache/trunk/tpl/options.php

    r1520541 r1814154  
    228228      </select>
    229229    </p>
     230    <p>
     231      <input type="checkbox" name="gci_only_user" id="gci_only_user" value="1"<?php if($options['only_user']){echo ' checked="checked"';}?>/>
     232      <label for="gci_only_user"><?php _e('Only serve cache to logged in users', 'gator-cache');?></label>
     233    </p>
    230234    <p><button class="button-primary"><?php _e('Update', 'gator-cache');?></button></p>
    231235    <p><i class="fa fa-lightbulb-o"></i> <?php _e('Unless your theme displays user specific content via ajax, caching logged-in user content is usually not a good idea.', 'gator-cache');?></p>
     
    330334        if(1 === sel.length){
    331335            var form = [{'name':sel.attr('id'),'value': sel.val()}];
     336            if ('gci_roles' === form[0].name) {
     337                form.push({'name':'only_user','value':$('#gci_only_user').prop('checked') ? 1 : 0});
     338            }
    332339        }
    333340        else{
Note: See TracChangeset for help on using the changeset viewer.