Plugin Directory

Changeset 2693063


Ignore:
Timestamp:
03/12/2022 10:25:31 PM (4 years ago)
Author:
hexydec
Message:

Updated dependencies to latest versions to fix issues with PHP 8.0/8.1.
Updated minimum version of Wordpress to 5.9.
Updated version number to 0.6.0.

Location:
torque/trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • torque/trunk/packages.php

    r2658197 r2693063  
    1717     * @var string VERSION The version number of the application, this is used in the cache key for CSS/Javascript that is minified
    1818     */
    19     public const VERSION = '0.5.8';
     19    public const VERSION = '0.6.0';
    2020
    2121    /**
  • torque/trunk/packages/cssdoc/cssdoc.php

    r2639345 r2693063  
    99     * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML
    1010     */
    11     protected static $tokens = [
     11    protected static array $tokens = [
    1212       'whitespace' => '\s++',
    1313       'comment' => '\\/\\*[\d\D]*?\\*\\/',
     
    3333     * @var array $config Object configuration array
    3434     */
    35     protected $config = [
     35    protected array $config = [
    3636        'nested' => ['@media', '@supports', '@keyframes', '@-webkit-keyframes', '@-moz-keyframes', '@-o-keyframes', '@document', '@-moz-document', '@container'], // directive that can have nested rules
    3737        'spaced' => ['calc'], // values where spaces between operators must be retained
     
    204204     * @var document $document The root document
    205205     */
    206     protected $document;
     206    protected document $document;
    207207
    208208    /**
    209209     * @var int $pointer The current pointer position for the array iterator
    210210     */
    211     protected $pointer = 0;
     211    protected int $pointer = 0;
    212212
    213213    /**
     
    253253     */
    254254    public function offsetSet($i, $value) : void {
    255         if (\is_null($i)) $this->document->rules[] = $value;
    256         else $this->document->rules[$i] = $value;
     255        if (\is_null($i)) {
     256            $this->document->rules[] = $value;
     257        } else {
     258            $this->document->rules[$i] = $value;
     259        }
    257260    }
    258261
     
    282285     * @return mixed The requested value or null if the key doesn't exist
    283286     */
    284     public function offsetGet($i) { // return reference so you can set it like an array
     287    public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array
    285288        return $this->document->rules[$i] ?? null;
    286289    }
     
    291294     * @return document|rule The child node at the current pointer position
    292295     */
    293     public function current() {
     296    public function current() : mixed {
    294297        return $this->document->rules[$this->pointer] ?? null;
    295298    }
  • torque/trunk/packages/cssdoc/tokens/directive.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var string The name of the directive
    1515     */
    16     protected $directive;
     16    protected string $directive;
    1717
    1818    /**
    19      * @var string The value of the directive
     19     * @var array The contents of the directive, split into parts
    2020     */
    21     public $content = [];
     21    public array $content = [];
    2222
    2323    /**
    2424     * @var array An array of properties
    2525     */
    26     public $properties = [];
     26    public array $properties = [];
    2727
    2828    /**
    2929     * @var document A document object
    3030     */
    31     public $document = null;
     31    public ?document $document = null;
    3232
    3333    /**
  • torque/trunk/packages/cssdoc/tokens/document.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var array An array of child token objects
    1515     */
    16     public $rules = [];
     16    public array $rules = [];
    1717
    1818    /**
  • torque/trunk/packages/cssdoc/tokens/property.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var string The name of the property
    1515     */
    16     protected $name;
     16    protected string $name;
    1717
    1818    /**
    1919     * @var array The values of the property
    2020     */
    21     protected $value = [];
     21    protected array $value = [];
    2222
    2323    /**
    2424     * @var bool Whether the property is important
    2525     */
    26     protected $important = false;
     26    protected bool $important = false;
    2727
    2828    /**
    2929     * @var bool Whether the property has a semi-colon to close it
    3030     */
    31     public $semicolon = false;
     31    public bool $semicolon = false;
    3232
    3333    /**
    3434     * @var string Any comment specified with the property
    3535     */
    36     protected $comment = null;
     36    protected ?string $comment = null;
    3737
    3838    /**
  • torque/trunk/packages/cssdoc/tokens/rule.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var array An array of selectors
    1515     */
    16     protected $selectors = [];
     16    protected array $selectors = [];
    1717
    1818    /**
    1919     * @var array An array of properties
    2020     */
    21     public $properties = [];
     21    public array $properties = [];
    2222
    2323    /**
    2424     * @var string A comment
    2525     */
    26     protected $comment = null;
     26    protected ?string $comment = null;
    2727
    2828    /**
     
    9797            $item->minify($minify);
    9898        }
     99
     100        // remove last semi-colon
    99101        if ($this->properties && $minify['semicolons']) {
    100102            \end($this->properties)->semicolon = false;
  • torque/trunk/packages/cssdoc/tokens/selector.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var array An array of selectors
    1515     */
    16     protected $selectors = [];
     16    protected array $selectors = [];
    1717
    1818    /**
  • torque/trunk/packages/cssdoc/tokens/value.php

    r2592945 r2693063  
    99     * @var cssdoc The parent CSSdoc object
    1010     */
    11     protected $root;
     11    protected cssdoc $root;
    1212
    1313    /**
    1414     * @var string The name of the parent property
    1515     */
    16     protected $name = null;
     16    protected ?string $name = null;
    1717
    1818    /**
    1919     * @var bool Whether the value is within brackets
    2020     */
    21     protected $brackets = false;
    22 
    23     /**
    24      * @var value Properties
     21    protected bool $brackets = false;
     22
     23    /**
     24     * @var array Properties
    2525     */
    2626    protected $properties = [];
  • torque/trunk/packages/htmldoc/htmldoc.php

    r2615373 r2693063  
    99     * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML
    1010     */
    11     protected static $tokens = [
     11    protected static array $tokens = [
    1212        'textnode' => '(?<=>|^)[^<]++(?=<|$)',
    1313        'attributevalue' => '\\s*+=\\s*+(?:"[^"]*+"++|\'[^\']*+\'++|[^\\s>]*+)',
     
    2727     * @var array $selectors Regexp components keyed by their corresponding codename for tokenising CSS selectors
    2828     */
    29     protected static $selectors = [
     29    protected static array $selectors = [
    3030        'quotes' => '(?<!\\\\)"(?:[^"\\\\]++|\\\\.)*+"',
    3131        'join' => '\\s*[>+~]\\s*',
     
    4646     * @var array $children Stores the regexp components keyed by their corresponding codename for tokenising CSS selectors
    4747     */
    48     protected $children = [];
     48    protected array $children = [];
    4949
    5050    /**
    5151     * @var int $pointer The current pointer position for the array iterator
    5252     */
    53     protected $pointer = 0;
     53    protected int $pointer = 0;
    5454
    5555    /**
    5656     * @var array A cache of attribute and class names for sorting
    5757     */
    58     protected $cache = [];
     58    protected array $cache = [];
    5959
    6060    /**
     
    8989     */
    9090    public function offsetSet($i, $value) : void {
    91         if (\is_null($i)) $this->children[] = $value;
    92         else $this->children[$i] = $value;
     91        if (\is_null($i)) {
     92            $this->children[] = $value;
     93        } else {
     94            $this->children[$i] = $value;
     95        }
    9396    }
    9497
     
    118121     * @return mixed The requested value or null if the key doesn't exist
    119122     */
    120     public function offsetGet($i) { // return reference so you can set it like an array
     123    public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array
    121124        return $this->children[$i] ?? null;
    122125    }
     
    127130     * @return tag|text|comment|doctype The child node at the current pointer position
    128131     */
    129     public function current() {
     132    public function current() : mixed {
    130133        return $this->children[$this->pointer] ?? null;
    131134    }
     
    342345
    343346                    case 'squareopen':
    344                         $item = ['join' => $join];
     347                        $item = ['join' => $join, 'sensitive' => true];
    345348                        while (($token = $tokens->next()) !== null) {
    346349                            if ($token['type'] === 'squareclose') {
     
    350353                                    $token['value'] = \stripslashes(\mb_substr($token['value'], 1, -1));
    351354                                }
    352                                 $item[isset($item['attribute']) ? 'value' : 'attribute'] = $token['value'];
     355                                if (!isset($item['attribute'])) {
     356                                    $item['attribute'] = $token['value'];
     357                                } elseif (!isset($item['value'])) {
     358                                    $item['value'] = $token['value'];
     359                                } elseif ($token['value'] === 'i') {
     360                                    $item['sensitive'] = false;
     361                                }
    353362                            } elseif ($token['type'] === 'comparison') {
    354363                                $item['comparison'] = $token['value'];
  • torque/trunk/packages/htmldoc/tokens/comment.php

    r2592945 r2693063  
    99     * @var string The text content of this object
    1010     */
    11     protected $content = null;
     11    protected ?string $content = null;
    1212
    1313    /**
  • torque/trunk/packages/htmldoc/tokens/custom.php

    r2592945 r2693063  
    99     * @var array The custom configuration
    1010     */
    11     protected $config = [];
     11    protected array $config = [];
    1212
    1313    /**
    14      * @var array The name of the tag
     14     * @var string The name of the tag
    1515     */
    16     protected $tagName;
     16    protected string $tagName;
    1717
    1818    /**
    1919     * @var string A string containing javascript
    2020     */
    21     protected $content = '';
     21    protected string $content = '';
    2222
    2323    /**
  • torque/trunk/packages/htmldoc/tokens/doctype.php

    r2592945 r2693063  
    99     * @var array The text content of this object
    1010     */
    11     protected $content = [];
     11    protected array $content = [];
    1212
    1313    /**
  • torque/trunk/packages/htmldoc/tokens/tag.php

    r2639345 r2693063  
    99     * @var htmldoc The parent htmldoc object
    1010     */
    11     protected $root;
     11    protected htmldoc $root;
    1212
    1313    /**
    1414     * @var array The object configuration
    1515     */
    16     protected $config = [];
     16    protected array $config = [];
    1717
    1818    /**
    1919     * @var tag The parent tag object
    2020     */
    21     protected $parent = null;
     21    protected ?tag $parent = null;
    2222
    2323    /**
    2424     * @var array Cache for the list of parent tags
    2525     */
    26     protected $parenttags = null;
     26    protected ?array $parenttags = null;
    2727
    2828    /**
    2929     * @var string The type of tag
    3030     */
    31     protected $tagName = null;
     31    protected ?string $tagName = null;
    3232
    3333    /**
    3434     * @var array An array of attributes where the key is the name of the attribute and the value is the value
    3535     */
    36     protected $attributes = [];
     36    protected array $attributes = [];
    3737
    3838    /**
    3939     * @var string If the tag is a singleton, this defines the closing string
    4040     */
    41     protected $singleton = null;
     41    protected ?string $singleton = null;
    4242
    4343    /**
    4444     * @var array An array of child token objects
    4545     */
    46     protected $children = [];
     46    protected array $children = [];
    4747
    4848    /**
    4949     * @var bool Whether to close the tag when rendering as HTML
    5050     */
    51     public $close = true;
     51    public bool $close = true;
    5252
    5353    /**
     
    330330    }
    331331
     332    /**
     333     * Retrieve the index position of the current element in the parent
     334     *
     335     * @return int|null The index of the current element with the parent, or null if there is no parent
     336     */
    332337    protected function getIndex() : ?int {
    333338        foreach ($this->parent->children() AS $key => $item) {
     
    429434                // remove host for own domain
    430435                if ($minify['urls']['host'] && isset($_SERVER['HTTP_HOST'])) {
    431                     if (!isset($host)) {
    432                         $host = ['//'.$_SERVER['HTTP_HOST'], $scheme.$_SERVER['HTTP_HOST']];
    433                     }
     436                    $host ??= ['//'.$_SERVER['HTTP_HOST'], $scheme.$_SERVER['HTTP_HOST']];
    434437                    foreach ($host AS $item) {
    435438
     
    665668                    break;
    666669                } elseif (!empty($item['value'])) {
     670                    $current = $this->attributes[$item['attribute']];
    667671                    switch ($item['comparison']) {
    668672
    669673                        // exact match
    670674                        case '=':
    671                             if ($this->attributes[$item['attribute']] !== $item['value']) {
     675                            if ($item['sensitive']) {
     676                                if ($current !== $item['value']) {
     677                                    $match = false;
     678                                    break;
     679                                }
     680                            } elseif (\mb_strtolower($current) !== \mb_strtolower($item['value'])) {
    672681                                $match = false;
    673682                                break;
     
    677686                        // match start
    678687                        case '^=':
    679                             if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) !== 0) {
     688                            if ($item['sensitive']) {
     689                                if (\mb_strpos($current, $item['value']) !== 0) {
     690                                    $match = false;
     691                                    break;
     692                                }
     693                            } elseif (\mb_stripos($current, $item['value']) !== 0) {
    680694                                $match = false;
    681695                                break;
     
    685699                        // match within
    686700                        case '*=':
    687                             if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) === false) {
     701                            if ($item['sensitive']) {
     702                                if (\mb_strpos($current, $item['value']) === false) {
     703                                    $match = false;
     704                                    break;
     705                                }
     706                            } elseif (\mb_stripos($current, $item['value']) === false) {
    688707                                $match = false;
    689708                                break;
     
    693712                        // match end
    694713                        case '$=':
    695                             if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) !== \mb_strlen($this->attributes[$item['attribute']]) - \mb_strlen($item['value'])) {
     714                            if ($item['sensitive']) {
     715                                if (\mb_strpos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) {
     716                                    $match = false;
     717                                    break;
     718                                }
     719                            } elseif (\mb_stripos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) {
    696720                                $match = false;
    697721                                break;
  • torque/trunk/packages/htmldoc/tokens/text.php

    r2592945 r2693063  
    99     * @var htmldoc The parent htmldoc object
    1010     */
    11     protected $root;
     11    protected htmldoc $root;
    1212
    1313    /**
    1414     * @var tag The parent tag object
    1515     */
    16     protected $parent;
     16    protected tag $parent;
    1717
    1818    /**
    1919     * @var string The text content of this object
    2020     */
    21     protected $content = '';
     21    protected string $content = '';
    2222
    2323    /**
  • torque/trunk/packages/jslite/jslite.php

    r2639345 r2693063  
    99     * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML
    1010     */
    11     protected static $tokens = [
     11    protected static array $tokens = [
    1212
    1313        // capture the easy stuff first
     
    4848    ];
    4949
    50     protected $config = [
     50    protected array $config = [
    5151        'minify' => [
    5252            'whitespace' => true, // strip whitespace around javascript
     
    5959        ]
    6060    ];
    61     protected $expressions = null;
     61    protected ?array $expressions = null;
    6262
    6363    public function __construct(array $config = []) {
  • torque/trunk/packages/jslite/tokens/brackets.php

    r2615373 r2693063  
    77
    88    public const significant = true;
    9     protected $root;
    10     protected $expressions = [];
    11     public $bracket = 'bracket'; // square or bracket or curly
     9    protected expression $root;
     10    protected array $expressions = [];
     11    public string $bracket = 'bracket'; // square or bracket or curly
    1212
    1313    /**
  • torque/trunk/packages/jslite/tokens/comment.php

    r2592945 r2693063  
    1010     * @var string The text content of this object
    1111     */
    12     protected $content = null;
    13     protected $multi = false;
     12    protected ?string $content = null;
     13    protected bool $multi = false;
    1414
    1515    /**
  • torque/trunk/packages/jslite/tokens/expression.php

    r2639345 r2693063  
    77
    88    public const significant = true;
    9     public $commands = [];
    10     public $eol;
    11     public $bracket = null;
     9    public array $commands = [];
     10    public ?string $eol = null;
     11    public ?string $bracket = null;
    1212
    1313    public function __construct(?string $bracket = null) {
  • torque/trunk/packages/jslite/tokens/keyword.php

    r2639345 r2693063  
    77
    88    public const significant = true;
    9     public $content = '';
     9    public string $content = '';
    1010
    1111    /**
  • torque/trunk/packages/jslite/tokens/number.php

    r2592945 r2693063  
    77
    88    public const significant = true;
    9     protected $content = '';
     9    protected string $content = '';
    1010
    1111    /**
  • torque/trunk/packages/jslite/tokens/operator.php

    r2592945 r2693063  
    1010     * @var string The text content of this object
    1111     */
    12     public $content = '';
     12    public string $content = '';
    1313
    1414    /**
  • torque/trunk/packages/jslite/tokens/regexp.php

    r2592945 r2693063  
    77
    88    public const significant = true;
    9     protected $content = '';
     9    protected string $content = '';
    1010
    1111    /**
  • torque/trunk/packages/jslite/tokens/string.php

    r2592945 r2693063  
    77
    88    public const significant = true;
    9     public $content = '';
    10     protected $quote = '"';
    11     protected $process = false;
     9    public string $content = '';
     10    protected string $quote = '"';
     11    protected bool $process = false;
    1212
    1313    /**
  • torque/trunk/packages/jslite/tokens/variable.php

    r2592945 r2693063  
    77
    88    public const significant = true;
    9     public $content = '';
     9    public string $content = '';
    1010
    1111    /**
  • torque/trunk/packages/jslite/tokens/whitespace.php

    r2615373 r2693063  
    77
    88    public const significant = false;
    9     protected $parent;
    10     protected $content;
     9    protected expression $parent;
     10    protected string $content;
    1111
    1212    /**
  • torque/trunk/packages/tokenise/tokenise.php

    r2592945 r2693063  
    88     * @var string $value Stores the subject value to be tokenised
    99     */
    10     protected $value = '';
     10    protected string $value = '';
    1111
    1212    /**
    1313     * @var string $pattern Stores the regexp pattern to tokenise the string with
    1414     */
    15     protected $pattern = '';
     15    protected string $pattern = '';
    1616
    1717    /**
    1818     * @var array $keys An array to map the regexp output with the token type
    1919     */
    20     protected $keys = [];
     20    protected array $keys = [];
    2121
    2222    /**
    2323     * @var int $pos The position within $value to retrieve the next token from
    2424     */
    25     protected $pos = 0;
     25    protected int $pos = 0;
    2626
    2727    /**
    2828     * @var int $pointer The current token position
    2929     */
    30     protected $pointer = -1;
     30    protected int $pointer = -1;
    3131
    3232    /**
    3333     * @var array $tokens An array of captured tokens
    3434     */
    35     protected $tokens = [];
     35    protected array $tokens = [];
    3636
    3737    /**
  • torque/trunk/readme.txt

    r2658197 r2693063  
    22Contributors: hexydec
    33Tags: minify,minification,performance,security,optimization
    4 Requires at least: 5.7
    5 Tested up to: 5.8
    6 Requires PHP: 7.3
    7 Stable tag: 0.5.8
     4Requires at least: 5.9
     5Tested up to: 5.9
     6Requires PHP: 8.0
     7Stable tag: 0.6.0
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    137137== Changelog ==
    138138
     139= Version 0.6.0 =
     140
     141* Updated dependencies to fix PHP 8.0/8.1 issues
     142
    139143= Version 0.5.8 =
    140144
  • torque/trunk/torque.php

    r2658197 r2693063  
    1010Plugin URI:     https://github.com/hexydec/torque
    1111Description:    Make your Wordpress website noticably faster by optimising how it is delivered. Analyse your website's performance and security, minify and combine your assets, and configure an array of performance and security settings quickly and easily with this comprehensive plugin. Achieves the best compression of any minification plugin.
    12 Version:        0.5.8
    13 Requires PHP:   7.3
     12Version:        0.6.0
     13Requires PHP:   8.0
    1414Author:         Hexydec
    1515Author URI:     https://github.com/hexydec/
Note: See TracChangeset for help on using the changeset viewer.