diff --git a/README.md b/README.md
index 768c272c81..b8f642f48e 100644
--- a/README.md
+++ b/README.md
@@ -34,10 +34,9 @@ Feel free to check out our [public roadmap](https://trello.com/b/CrUcz6Jy/wp-roc
Visit [wp-media.me](https://wp-media.me/?utm_source=github&utm_medium=wp_rocket_profile).
-We also make other plugins that help speed up and secure WordPress websites. Check out:
+We also make other plugins that help speed up WordPress websites. Check out:
* [Imagify](https://imagify.io): it's a great WordPress plugin to optimize your images and speed up your website.
-* [SecuPress](https://secupress.me): get peace of mind by securing your WordPress website against various security threats.
## Special thanks
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000000..0ac98013b9
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,41 @@
+{
+ "name": "wp-media/wp-rocket",
+ "description": "Performance optimization plugin for WordPress",
+ "keywords": [
+ "wordpress",
+ "cache",
+ "minification",
+ "lazyload"
+ ],
+ "homepage": "https://wp-rocket.me",
+ "license": "GPL-2.0+",
+ "authors": [
+ {
+ "name": "WP Media",
+ "email": "contact@wp-media.me",
+ "homepage": "https://wp-media.me"
+ }
+ ],
+ "type": "wordpress-plugin",
+ "support": {
+ "issues": "https://github.com/wp-media/wp-rocket/issues",
+ "source": "https://github.com/wp-media/wp-rocket"
+ },
+ "require": {
+ "matthiasmullie/minify": "1.3.*",
+ "jamesryanbell/cloudflare": "^1.11",
+ "a5hleyrich/wp-background-processing": "^1.0"
+ },
+ "autoload": {
+ "classmap": [
+ "inc/classes",
+ "inc/vendors/classes"
+ ]
+ },
+ "require-dev": {
+ "squizlabs/php_codesniffer": "^3.1",
+ "wimg/php-compatibility": "^8.0",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
+ "wp-coding-standards/wpcs": "^0.14.0"
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000000..cae9c608fa
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,416 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "9c5425cb6724e56c1e01188ca31b6f3e",
+ "packages": [
+ {
+ "name": "a5hleyrich/wp-background-processing",
+ "version": "1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/A5hleyRich/wp-background-processing.git",
+ "reference": "15a8a79130a15366d9d550d078f14232ed83d3ba"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/A5hleyRich/wp-background-processing/zipball/15a8a79130a15366d9d550d078f14232ed83d3ba",
+ "reference": "15a8a79130a15366d9d550d078f14232ed83d3ba",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "classes/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPLv2+"
+ ],
+ "authors": [
+ {
+ "name": "Ashley Rich",
+ "email": "hello@ashleyrich.com"
+ }
+ ],
+ "description": "WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.",
+ "time": "2016-08-07T10:26:07+00:00"
+ },
+ {
+ "name": "jamesryanbell/cloudflare",
+ "version": "1.11.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/jamesryanbell/cloudflare.git",
+ "reference": "75e93bb822619d8ddb8b1843588caa2fad739491"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/jamesryanbell/cloudflare/zipball/75e93bb822619d8ddb8b1843588caa2fad739491",
+ "reference": "75e93bb822619d8ddb8b1843588caa2fad739491",
+ "shasum": ""
+ },
+ "require-dev": {
+ "phpunit/phpunit": "< 6",
+ "satooshi/php-coveralls": "dev-master"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Cloudflare\\": "src/CloudFlare"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "James Bell",
+ "email": "james@james-bell.co.uk"
+ }
+ ],
+ "description": "CloudFlare API - PHP",
+ "keywords": [
+ "api",
+ "cloudflare"
+ ],
+ "time": "2017-08-04T19:01:02+00:00"
+ },
+ {
+ "name": "matthiasmullie/minify",
+ "version": "1.3.56",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/matthiasmullie/minify.git",
+ "reference": "86e4a4e4e7eae2d0cd74871735f18bbb132da4b7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/86e4a4e4e7eae2d0cd74871735f18bbb132da4b7",
+ "reference": "86e4a4e4e7eae2d0cd74871735f18bbb132da4b7",
+ "shasum": ""
+ },
+ "require": {
+ "ext-pcre": "*",
+ "matthiasmullie/path-converter": "~1.1",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "~2.0",
+ "matthiasmullie/scrapbook": "~1.0",
+ "phpunit/phpunit": "~4.8"
+ },
+ "suggest": {
+ "psr/cache-implementation": "Cache implementation to use with Minify::cache"
+ },
+ "bin": [
+ "bin/minifycss",
+ "bin/minifyjs"
+ ],
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "MatthiasMullie\\Minify\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matthias Mullie",
+ "email": "minify@mullie.eu",
+ "homepage": "http://www.mullie.eu",
+ "role": "Developer"
+ }
+ ],
+ "description": "CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.",
+ "homepage": "http://www.minifier.org",
+ "keywords": [
+ "JS",
+ "css",
+ "javascript",
+ "minifier",
+ "minify"
+ ],
+ "time": "2017-11-24T12:51:16+00:00"
+ },
+ {
+ "name": "matthiasmullie/path-converter",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/matthiasmullie/path-converter.git",
+ "reference": "08551ec1b156e923c242a10ab484bd4d6ead6631"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/08551ec1b156e923c242a10ab484bd4d6ead6631",
+ "reference": "08551ec1b156e923c242a10ab484bd4d6ead6631",
+ "shasum": ""
+ },
+ "require": {
+ "ext-pcre": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.8"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "MatthiasMullie\\PathConverter\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matthias Mullie",
+ "email": "pathconverter@mullie.eu",
+ "homepage": "http://www.mullie.eu",
+ "role": "Developer"
+ }
+ ],
+ "description": "Relative path converter",
+ "homepage": "http://github.com/matthiasmullie/path-converter",
+ "keywords": [
+ "converter",
+ "path",
+ "paths",
+ "relative"
+ ],
+ "time": "2017-01-26T08:54:49+00:00"
+ }
+ ],
+ "packages-dev": [
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v0.4.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
+ "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08",
+ "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0",
+ "php": "^5.3|^7",
+ "squizlabs/php_codesniffer": "*"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "wimg/php-compatibility": "^8.0"
+ },
+ "suggest": {
+ "dealerdirect/qa-tools": "All the PHP QA tools you'll need"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "f.nijhof@dealerdirect.nl",
+ "homepage": "http://workingatdealerdirect.eu",
+ "role": "Developer"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://workingatdealerdirect.eu",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "time": "2017-12-06T16:27:17+00:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e",
+ "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2017-10-16T22:40:25+00:00"
+ },
+ {
+ "name": "wimg/php-compatibility",
+ "version": "8.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/wimg/PHPCompatibility.git",
+ "reference": "4c4385fb891dff0501009670f988d4fe36785249"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4c4385fb891dff0501009670f988d4fe36785249",
+ "reference": "4c4385fb891dff0501009670f988d4fe36785249",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "squizlabs/php_codesniffer": "^2.2 || ^3.0.2"
+ },
+ "conflict": {
+ "squizlabs/php_codesniffer": "2.6.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0"
+ },
+ "suggest": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1"
+ },
+ "type": "phpcodesniffer-standard",
+ "autoload": {
+ "psr-4": {
+ "PHPCompatibility\\": "PHPCompatibility/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "Wim Godden",
+ "role": "lead"
+ }
+ ],
+ "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
+ "keywords": [
+ "compatibility",
+ "phpcs",
+ "standards"
+ ],
+ "time": "2017-08-07T19:39:05+00:00"
+ },
+ {
+ "name": "wp-coding-standards/wpcs",
+ "version": "0.14.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
+ "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c",
+ "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
+ },
+ "suggest": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
+ },
+ "type": "phpcodesniffer-standard",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "wordpress"
+ ],
+ "time": "2017-11-01T15:10:46+00:00"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": []
+}
diff --git a/inc/3rd-party/3rd-party.php b/inc/3rd-party/3rd-party.php
index 109eac0cd5..a08bf4b9ce 100644
--- a/inc/3rd-party/3rd-party.php
+++ b/inc/3rd-party/3rd-party.php
@@ -1,10 +1,14 @@
=' ) ) {
require( WP_ROCKET_3RD_PARTY_PATH . 'hosting/savvii.php' );
@@ -12,42 +16,59 @@
require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/geotargetingwp.php' );
}
-require( WP_ROCKET_3RD_PARTY_PATH . 'slider/revslider.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'i18n/wpml.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'i18n/polylang.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/woocommerce.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-currencyswitcher.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-prices-by-country.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-tax-display-by-country.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/woocommerce-multilingual.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/woocommerce-currency-converter-widget.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/edd-software-licencing.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'age-verify.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'autoptimize.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'eu-cookie-law.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'weepie-cookie-allow.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'kk-star-ratings.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'wp-postratings.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'wp-print.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'buddypress.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'disqus.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'give.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'custom-login.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'mobile/amp.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'mobile/wp-appkit.php' );
-//require( WP_ROCKET_3RD_PARTY_PATH . 'jetpack.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'yoast-seo.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'all-in-one-seo-pack.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'wp-rest-api.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/beaver-builder.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/thrive-visual-editor.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/visual-composer.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'security/secupress.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'simple-custom-css.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'wp-retina-2x.php' );
-require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/sf-move-login.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/slider/revslider.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/slider/layerslider.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/slider/meta-slider.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/slider/soliloquy.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/i18n/wpml.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/i18n/polylang.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/woocommerce.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/aelia-currencyswitcher.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/aelia-prices-by-country.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/aelia-tax-display-by-country.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/woocommerce-multilingual.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/woocommerce-currency-converter-widget.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/edd-software-licencing.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/easy-digital-downloads.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/ithemes-exchange.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/jigoshop.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/wpshop.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/ecommerce/give.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/age-verify.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/appbanners.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/autoptimize.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/envira-gallery.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/cookies/eu-cookie-law.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/cookies/weepie-cookie-allow.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/rating/kk-star-ratings.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/rating/wp-postratings.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/wp-print.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/buddypress.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/disqus.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/custom-login.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/mobile/amp.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/mobile/wp-appkit.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/mobile/wp-touch.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/seo/yoast-seo.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/seo/all-in-one-seo-pack.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/wp-rest-api.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/page-builder/beaver-builder.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/page-builder/thrive-visual-editor.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/page-builder/visual-composer.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/security/secupress.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/security/sf-move-login.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/security/wps-hide-login.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/simple-custom-css.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/wp-retina-2x.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/varnish-http-purge.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/thrive-leads.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/mailchimp.php' );
require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/advanced-custom-fields.php' );
require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/wp-offload-s3.php' );
require( WP_ROCKET_3RD_PARTY_PATH . 'plugins/wp-offload-s3-assets.php' );
require( WP_ROCKET_3RD_PARTY_PATH . 'themes/divi.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'themes/avada.php' );
+require( WP_ROCKET_3RD_PARTY_PATH . 'themes/studiopress.php' );
+
+require( WP_ROCKET_3RD_PARTY_PATH . 'aqua-resizer.php' );
diff --git a/inc/3rd-party/aqua-resizer.php b/inc/3rd-party/aqua-resizer.php
new file mode 100644
index 0000000000..cbccec41ed
--- /dev/null
+++ b/inc/3rd-party/aqua-resizer.php
@@ -0,0 +1,16 @@
+HCSVarnishPurgeAll();
+ }
+}
+add_action( 'after_rocket_clean_domain', 'rocket_clean_pagely' );
diff --git a/inc/3rd-party/hosting/pressidium.php b/inc/3rd-party/hosting/pressidium.php
new file mode 100644
index 0000000000..020fe7e79f
--- /dev/null
+++ b/inc/3rd-party/hosting/pressidium.php
@@ -0,0 +1,37 @@
+purgeAllCaches();
+ }
+ add_action( 'after_rocket_clean_domain', 'rocket_clean_pressidium' );
+endif;
diff --git a/inc/3rd-party/hosting/savvii.php b/inc/3rd-party/hosting/savvii.php
index 86c9f64651..d07c5492fc 100644
--- a/inc/3rd-party/hosting/savvii.php
+++ b/inc/3rd-party/hosting/savvii.php
@@ -1,5 +1,5 @@
purge_cache();
+ }
+}
+add_action( 'wp_ajax_sg-cachepress-purge' , 'rocket_clean_domain', 0 );
+add_action( 'admin_post_sg-cachepress-purge', 'rocket_clean_domain', 0 );
+add_action( 'after_rocket_clean_domain' , 'rocket_clean_supercacher' );
diff --git a/inc/3rd-party/hosting/varnish.php b/inc/3rd-party/hosting/varnish.php
index a7182e0a3d..c775950515 100644
--- a/inc/3rd-party/hosting/varnish.php
+++ b/inc/3rd-party/hosting/varnish.php
@@ -1,5 +1,5 @@
is_dir( $cache_path ) ) {
+ rocket_mkdir_p( $cache_path );
+ }
+
+ if ( ! rocket_direct_filesystem()->exists( $css_path ) ) {
+ ob_start();
+ mailchimpSF_main_css();
+ $content = ob_get_contents();
+ ob_end_clean();
+
+ rocket_put_content( $css_path, $content );
+ }
+
+ wp_deregister_style( 'mailchimpSF_main_css' );
+ wp_register_style( 'mailchimpSF_main_css', $cache_url . 'mailchimpSF_main_css.css', null, MCSF_VER );
+}
+add_action( 'init', 'rocket_fix_mailchimp_main_css', PHP_INT_MAX );
diff --git a/inc/3rd-party/mobile/amp.php b/inc/3rd-party/plugins/mobile/amp.php
similarity index 84%
rename from inc/3rd-party/mobile/amp.php
rename to inc/3rd-party/plugins/mobile/amp.php
index 82faeb4474..712ec7aae5 100644
--- a/inc/3rd-party/mobile/amp.php
+++ b/inc/3rd-party/plugins/mobile/amp.php
@@ -1,5 +1,5 @@
'sitemap_preload',
- 'type' => 'checkbox',
- 'label' => __( 'All in One SEO XML sitemap', 'rocket' ),
- 'label_for' => 'all_in_one_seo_xml_sitemap',
- 'label_screen' => sprintf( __( 'Preload the sitemap from the %s plugin', 'rocket' ), 'All in One SEO Pack' ),
- 'default' => 0,
- );
+ 'parent' => 'sitemap_preload',
+ 'type' => 'checkbox',
+ 'label' => __( 'All in One SEO XML sitemap', 'rocket' ),
+ 'label_for' => 'all_in_one_seo_xml_sitemap',
+ // translators: %s is the name of the plugin used for sitemap.
+ 'label_screen' => sprintf( __( 'Preload the sitemap from the %s plugin', 'rocket' ), 'All in One SEO Pack' ),
+ 'default' => 0,
+ );
$options[] = array(
- 'parent' => 'sitemap_preload',
- 'type' => 'helper_description',
- 'name' => 'all_in_one_seo_xml_sitemap_desc',
- 'description' => sprintf( __( 'We automatically detected the sitemap generated by the %s plugin. You can check the option to preload it.', 'rocket' ), 'All in One SEO Pack' ),
+ 'parent' => 'sitemap_preload',
+ 'type' => 'helper_description',
+ 'name' => 'all_in_one_seo_xml_sitemap_desc',
+ // translators: %s is the name of the plugin used for sitemap.
+ 'description' => sprintf( __( 'We automatically detected the sitemap generated by the %s plugin. You can check the option to preload it.', 'rocket' ), 'All in One SEO Pack' ),
);
return $options;
}
diff --git a/inc/3rd-party/yoast-seo.php b/inc/3rd-party/plugins/seo/yoast-seo.php
similarity index 73%
rename from inc/3rd-party/yoast-seo.php
rename to inc/3rd-party/plugins/seo/yoast-seo.php
index ec1a69b6d0..315737f692 100644
--- a/inc/3rd-party/yoast-seo.php
+++ b/inc/3rd-party/plugins/seo/yoast-seo.php
@@ -1,5 +1,5 @@
'sitemap_preload',
- 'type' => 'checkbox',
- 'label' => __( 'Yoast SEO XML sitemap', 'rocket' ),
- 'label_for' => 'yoast_xml_sitemap',
- 'label_screen' => sprintf( __( 'Preload the sitemap from the %s plugin', 'rocket' ), 'Yoast SEO' ),
- 'default' => 0,
- );
+ 'parent' => 'sitemap_preload',
+ 'type' => 'checkbox',
+ 'label' => __( 'Yoast SEO XML sitemap', 'rocket' ),
+ 'label_for' => 'yoast_xml_sitemap',
+ // translators: %s is the name of the plugin used for the sitemap.
+ 'label_screen' => sprintf( __( 'Preload the sitemap from the %s plugin', 'rocket' ), 'Yoast SEO' ),
+ 'default' => 0,
+ );
$options[] = array(
- 'parent' => 'sitemap_preload',
- 'type' => 'helper_description',
- 'name' => 'yoast_xml_sitemap_desc',
- 'description' => sprintf( __( 'We automatically detected the sitemap generated by the %s plugin. You can check the option to preload it.', 'rocket' ), 'Yoast SEO' ),
+ 'parent' => 'sitemap_preload',
+ 'type' => 'helper_description',
+ 'name' => 'yoast_xml_sitemap_desc',
+ // translators: %s is the name of the plugin used for the sitemap.
+ 'description' => sprintf( __( 'We automatically detected the sitemap generated by the %s plugin. You can check the option to preload it.', 'rocket' ), 'Yoast SEO' ),
);
return $options;
}
diff --git a/inc/3rd-party/simple-custom-css.php b/inc/3rd-party/plugins/simple-custom-css.php
similarity index 94%
rename from inc/3rd-party/simple-custom-css.php
rename to inc/3rd-party/plugins/simple-custom-css.php
index 20daaace5b..9b928e0ed8 100644
--- a/inc/3rd-party/simple-custom-css.php
+++ b/inc/3rd-party/plugins/simple-custom-css.php
@@ -1,5 +1,5 @@
', $content );
- if ( ! is_dir( $cache_busting_path ) ) {
+ if ( ! rocket_direct_filesystem()->is_dir( $cache_busting_path ) ) {
rocket_mkdir_p( $cache_busting_path );
}
diff --git a/inc/3rd-party/plugins/slider/layerslider.php b/inc/3rd-party/plugins/slider/layerslider.php
new file mode 100644
index 0000000000..938034fb64
--- /dev/null
+++ b/inc/3rd-party/plugins/slider/layerslider.php
@@ -0,0 +1,12 @@
+ 0;
+}
+add_filter( 'rocket_override_donotcachepage', 'rocket_override_donotcachepage_on_thrive_leads' );
diff --git a/inc/3rd-party/plugins/varnish-http-purge.php b/inc/3rd-party/plugins/varnish-http-purge.php
new file mode 100644
index 0000000000..e5ecf78bbf
--- /dev/null
+++ b/inc/3rd-party/plugins/varnish-http-purge.php
@@ -0,0 +1,77 @@
+ 'PURGE',
+ 'blocking' => false,
+ 'headers' => array(
+ 'host' => $p['host'],
+ 'X-Purge-Method' => 'regex',
+ ),
+ )
+ );
+
+ do_action( 'after_purge_url', $url, $purgeme );
+ }
+}
diff --git a/inc/3rd-party/plugins/wp-offload-s3-assets.php b/inc/3rd-party/plugins/wp-offload-s3-assets.php
index 4b2e3099eb..5d0b9c57ed 100644
--- a/inc/3rd-party/plugins/wp-offload-s3-assets.php
+++ b/inc/3rd-party/plugins/wp-offload-s3-assets.php
@@ -8,7 +8,7 @@
/**
* Compatibility with WP Offload S3 assets addon.
- *
+ *
* @since 2.10.7
* @author Remy Perona
*/
@@ -28,7 +28,7 @@ function rocket_as3cf_assets_compatibility() {
* @author Remy Perona
*
* @param string $old_value Previous assets option value.
- * @param string $value New assets option value.
+ * @param string $new_value New assets option value.
*/
function rocket_maybe_deactivate_cdn( $old_value, $new_value ) {
if ( $old_value['enable-addon'] !== $new_value['enable-addon'] && 1 === (int) $new_value['enable-addon'] ) {
diff --git a/inc/3rd-party/plugins/wp-offload-s3.php b/inc/3rd-party/plugins/wp-offload-s3.php
index 538b7693f3..e5fadd5ef7 100644
--- a/inc/3rd-party/plugins/wp-offload-s3.php
+++ b/inc/3rd-party/plugins/wp-offload-s3.php
@@ -8,7 +8,7 @@
/**
* Compatibility with WP Offload S3.
- *
+ *
* @since 2.10.7
* @author Remy Perona
*/
diff --git a/inc/3rd-party/wp-print.php b/inc/3rd-party/plugins/wp-print.php
similarity index 88%
rename from inc/3rd-party/wp-print.php
rename to inc/3rd-party/plugins/wp-print.php
index e82c15fe43..4f3770ef03 100644
--- a/inc/3rd-party/wp-print.php
+++ b/inc/3rd-party/plugins/wp-print.php
@@ -1,5 +1,5 @@
get( 'Name' ) ) {
+ // When Avada theme purge its own cache.
+ add_action( 'avada_clear_dynamic_css_cache', 'rocket_clean_domain' );
+
+ /**
+ * Conflict with Avada theme and WP Rocket CDN
+ *
+ * @since 2.6.1
+ *
+ * @param array $vars An array of variables.
+ * @param string $handle Name of the avada resource.
+ * @return array updated array of variables
+ */
+ function rocket_fix_cdn_for_avada_theme( $vars, $handle ) {
+ if ( 'avada-dynamic' === $handle && get_rocket_option( 'cdn' ) ) {
+
+ $src = get_rocket_cdn_url( get_template_directory_uri() . '/assets/less/theme/dynamic.less' );
+ $vars['template-directory'] = sprintf( '~"%s"', dirname( dirname( dirname( dirname( $src ) ) ) ) );
+ $vars['lessurl'] = sprintf( '~"%s"', dirname( $src ) );
+ }
+ return $vars;
+ }
+ add_filter( 'less_vars', 'rocket_fix_cdn_for_avada_theme', 11, 2 );
+
+ $avada_options = get_option( 'avada_theme_options' );
+
+ function rocket_exclude_avada_dynamic_css( $excluded_files ) {
+ $upload_dir = wp_upload_dir();
+
+ $excluded_files[] = rocket_clean_exclude_file( $upload_dir['baseurl'] . '/fusion-styles/(.*)' );
+
+ return $excluded_files;
+ }
+ add_filter( 'rocket_exclude_cache_busting', 'rocket_exclude_avada_dynamic_css' );
+}
diff --git a/inc/3rd-party/themes/divi.php b/inc/3rd-party/themes/divi.php
index 9fdb8344bb..2238bebb49 100644
--- a/inc/3rd-party/themes/divi.php
+++ b/inc/3rd-party/themes/divi.php
@@ -1,5 +1,5 @@
cache_flush_theme();
+ }
+}
diff --git a/inc/admin/admin.php b/inc/admin/admin.php
index 10c7b1eeb4..ee2ec1815e 100644
--- a/inc/admin/admin.php
+++ b/inc/admin/admin.php
@@ -1,5 +1,5 @@
1,
- ) );
+ wp_send_json(
+ array(
+ 'error' => 1,
+ )
+ );
} else {
wp_nonce_ays( '' );
}
@@ -149,9 +151,11 @@ function rocket_dismiss_boxes( $args ) {
if ( 'admin-post.php' === $GLOBALS['pagenow'] ) {
if ( defined( 'DOING_AJAX' ) ) {
- wp_send_json( array(
- 'error' => 0,
- ) );
+ wp_send_json(
+ array(
+ 'error' => 0,
+ )
+ );
} else {
wp_safe_redirect( wp_get_referer() );
die();
@@ -220,15 +224,15 @@ function rocket_white_label( $plugins ) {
$white_label_description = get_rocket_option( 'wl_description' );
// We change the plugin's header.
$plugins['wp-rocket/wp-rocket.php'] = array(
- 'Name' => get_rocket_option( 'wl_plugin_name' ),
- 'PluginURI' => get_rocket_option( 'wl_plugin_URI' ),
- 'Version' => isset( $plugins['wp-rocket/wp-rocket.php']['Version'] ) ? $plugins['wp-rocket/wp-rocket.php']['Version'] : '',
- 'Description' => reset( ( $white_label_description ) ),
- 'Author' => get_rocket_option( 'wl_author' ),
- 'AuthorURI' => get_rocket_option( 'wl_author_URI' ),
- 'TextDomain' => isset( $plugins['wp-rocket/wp-rocket.php']['TextDomain'] ) ? $plugins['wp-rocket/wp-rocket.php']['TextDomain'] : '',
- 'DomainPath' => isset( $plugins['wp-rocket/wp-rocket.php']['DomainPath'] ) ? $plugins['wp-rocket/wp-rocket.php']['DomainPath'] : '',
- );
+ 'Name' => get_rocket_option( 'wl_plugin_name' ),
+ 'PluginURI' => get_rocket_option( 'wl_plugin_URI' ),
+ 'Version' => isset( $plugins['wp-rocket/wp-rocket.php']['Version'] ) ? $plugins['wp-rocket/wp-rocket.php']['Version'] : '',
+ 'Description' => reset( ( $white_label_description ) ),
+ 'Author' => get_rocket_option( 'wl_author' ),
+ 'AuthorURI' => get_rocket_option( 'wl_author_URI' ),
+ 'TextDomain' => isset( $plugins['wp-rocket/wp-rocket.php']['TextDomain'] ) ? $plugins['wp-rocket/wp-rocket.php']['TextDomain'] : '',
+ 'DomainPath' => isset( $plugins['wp-rocket/wp-rocket.php']['DomainPath'] ) ? $plugins['wp-rocket/wp-rocket.php']['DomainPath'] : '',
+ );
// if white label, remove our names from contributors.
if ( rocket_is_white_label() ) {
@@ -291,13 +295,13 @@ function rocket_rollback() {
wp_nonce_ays( '' );
}
- $plugin_transient = get_site_transient( 'update_plugins' );
- $plugin_folder = plugin_basename( dirname( WP_ROCKET_FILE ) );
- $plugin_file = basename( WP_ROCKET_FILE );
- $version = WP_ROCKET_LASTVERSION;
- $c_key = get_rocket_option( 'consumer_key' );
- $url = sprintf( 'https://wp-rocket.me/%s/wp-rocket_%s.zip', $c_key, $version );
- $temp_array = array(
+ $plugin_transient = get_site_transient( 'update_plugins' );
+ $plugin_folder = plugin_basename( dirname( WP_ROCKET_FILE ) );
+ $plugin_file = basename( WP_ROCKET_FILE );
+ $version = WP_ROCKET_LASTVERSION;
+ $c_key = get_rocket_option( 'consumer_key' );
+ $url = sprintf( 'https://wp-rocket.me/%s/wp-rocket_%s.zip', $c_key, $version );
+ $temp_array = array(
'slug' => $plugin_folder,
'new_version' => $version,
'url' => 'https://wp-rocket.me',
@@ -322,10 +326,12 @@ function rocket_rollback() {
$upgrader = new Plugin_Upgrader( $upgrader_skin );
remove_filter( 'site_transient_update_plugins', 'rocket_check_update', 100 );
$upgrader->upgrade( $plugin );
- // translators: %s is the plugin name.
- wp_die( '', sprintf( __( '%s Update Rollback', 'rocket' ), WP_ROCKET_PLUGIN_NAME ), array(
- 'response' => 200,
- ) );
+ wp_die(
+ // translators: %s is the plugin name.
+ '', sprintf( __( '%s Update Rollback', 'rocket' ), WP_ROCKET_PLUGIN_NAME ), array(
+ 'response' => 200,
+ )
+ );
}
}
add_action( 'admin_post_rocket_rollback', 'rocket_rollback' );
@@ -354,10 +360,10 @@ function rocket_maybe_generate_advanced_cache_file() {
* @since 2.6.5
*/
function rocket_maybe_generate_config_files() {
- list( $host, $path ) = get_rocket_parse_url( home_url() );
- $path = ( ! empty( $path ) ) ? str_replace( '/', '.', untrailingslashit( $path ) ) : '';
+ $home = get_rocket_parse_url( home_url() );
+ $path = ( ! empty( $home['path'] ) ) ? str_replace( '/', '.', untrailingslashit( $home['path'] ) ) : '';
- if ( ! file_exists( WP_ROCKET_CONFIG_PATH . strtolower( $host ) . $path . '.php' ) ) {
+ if ( ! file_exists( WP_ROCKET_CONFIG_PATH . strtolower( $home['host'] ) . $path . '.php' ) ) {
rocket_generate_config_file();
}
}
@@ -373,24 +379,6 @@ function rocket_maybe_set_wp_cache_define() {
}
}
-/**
- * Launches the database optimization from admin
- *
- * @since 2.8
- * @author Remy Perona
- */
-function rocket_optimize_database() {
- if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'rocket_optimize_database' ) ) {
- wp_nonce_ays( '' );
- }
-
- do_rocket_database_optimization();
-
- wp_redirect( wp_get_referer() );
- die();
-}
-add_action( 'admin_post_rocket_optimize_database', 'rocket_optimize_database' );
-
/**
* Filter plugin fetching API results to inject Imagify
*
@@ -451,3 +439,117 @@ function rocket_add_imagify_api_result( $result, $action, $args ) {
return $result;
}
add_filter( 'plugins_api_result', 'rocket_add_imagify_api_result', 11, 3 );
+
+/**
+ * Gets all data to send to the analytics system
+ *
+ * @since 2.11
+ * @author Remy Perona
+ *
+ * @return array An array of data
+ */
+function rocket_analytics_data() {
+ global $wp_version, $is_nginx, $is_apache, $is_iis7, $is_IIS;
+
+ $untracked_wp_rocket_options = array(
+ 'license' => 1,
+ 'consumer_email' => 1,
+ 'consumer_key' => 1,
+ 'secret_key' => 1,
+ 'secret_cache_key' => 1,
+ 'minify_css_key' => 1,
+ 'minify_js_key' => 1,
+ 'sitemaps' => 1,
+ 'cdn_zone' => 1,
+ 'cdn_cnames' => 1,
+ 'cloudflare_email' => 1,
+ 'cloudflare_api_key' => 1,
+ 'cloudflare_domain' => 1,
+ 'cloudflare_zone_id' => 1,
+ 'cloudflare_old_settings' => 1,
+ 'submit_optimize' => 1,
+ 'analytics_enabled' => 1,
+ 'wl_author' => 1,
+ 'wl_author_URI' => 1,
+ 'wl_description' => 1,
+ 'wl_plugin_URI' => 1,
+ 'wl_plugin_name' => 1,
+ 'wl_plugin_slug' => 1,
+ );
+
+ $theme = wp_get_theme();
+ $data = array_diff_key( get_option( WP_ROCKET_SLUG ), $untracked_wp_rocket_options );
+ $locale = explode('_', get_locale() );
+
+ if ( $is_nginx ) {
+ $data['web_server'] = 'NGINX';
+ } elseif ( $is_apache ) {
+ $data['web_server'] = 'Apache';
+ } elseif ( $is_iis7 ) {
+ $data['web_server'] = 'IIS 7';
+ } elseif ( $is_IIS ) {
+ $data['web_server'] = 'IIS';
+ }
+
+ $data['php_version'] = preg_replace( '@^(\d\.\d+).*@', '\1', phpversion() );
+ $data['wordpress_version'] = preg_replace( '@^(\d\.\d+).*@', '\1', $wp_version );
+ $data['current_theme'] = $theme->get( 'Name' );
+ $data['active_plugins'] = rocket_get_active_plugins();
+ $data['locale'] = $locale[0];
+ $data['multisite'] = is_multisite();
+
+ return $data;
+}
+
+/**
+ * Determines if we should send the analytics data
+ *
+ * @since 2.11
+ * @author Remy Perona
+ *
+ * @return bool True if we should send them, false otherwise
+ */
+function rocket_send_analytics_data() {
+ if ( ! get_rocket_option( 'analytics_enabled' ) ) {
+ return false;
+ }
+
+ if ( ! current_user_can( 'administrator' ) ) {
+ return false;
+ }
+
+ if ( false === get_transient( 'rocket_send_analytics_data' ) ) {
+ set_transient( 'rocket_send_analytics_data', 1, 7 * DAY_IN_SECONDS );
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Handles the analytics opt-in notice selection and prevent further display
+ *
+ * @since 2.11
+ * @author Remy Perona
+ */
+function rocket_analytics_optin() {
+ if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'analytics_optin' ) ) {
+ wp_nonce_ays( '' );
+ }
+
+ if ( ! current_user_can( 'administrator' ) ) {
+ wp_redirect( wp_get_referer() );
+ die();
+ }
+
+ if ( 'yes' === $_GET['value'] ) {
+ update_rocket_option( 'analytics_enabled', 1 );
+ set_transient( 'rocket_analytics_optin', 1 );
+ }
+
+ update_option( 'rocket_analytics_notice_displayed', 1 );
+
+ wp_redirect( wp_get_referer() );
+ die();
+}
+add_action( 'admin_post_rocket_analytics_optin', 'rocket_analytics_optin' );
diff --git a/inc/admin/ajax.php b/inc/admin/ajax.php
index 2cb5034159..e07b093f98 100644
--- a/inc/admin/ajax.php
+++ b/inc/admin/ajax.php
@@ -1,5 +1,5 @@
10,
'body' => array(
'data' => array(
- 'user_email' => defined( 'WP_ROCKET_EMAIL' ) ? sanitize_email( WP_ROCKET_EMAIL ) : '',
- 'user_key' => defined( 'WP_ROCKET_KEY' ) ? sanitize_key( WP_ROCKET_KEY ) : '',
- 'user_website' => home_url(),
+ 'user_email' => defined( 'WP_ROCKET_EMAIL' ) ? sanitize_email( WP_ROCKET_EMAIL ) : '',
+ 'user_key' => defined( 'WP_ROCKET_KEY' ) ? sanitize_key( WP_ROCKET_KEY ) : '',
+ 'user_website' => home_url(),
'wp_version' => $GLOBALS['wp_version'],
'wp_active_plugins' => rocket_get_active_plugins(),
'wp_rocket_version' => WP_ROCKET_VERSION,
'wp_rocket_options' => get_option( WP_ROCKET_SLUG ),
- 'support_summary' => $_POST['summary'],
+ 'support_summary' => $_POST['summary'],
'support_description' => $_POST['description'],
),
),
@@ -38,7 +38,11 @@ function wp_ajax_rocket_new_ticket_support() {
if ( ! is_wp_error( $response ) ) {
wp_send_json( wp_remote_retrieve_body( $response ) );
} else {
- wp_send_json( array( 'msg' => 'BAD_SERVER' ) );
+ wp_send_json(
+ array(
+ 'msg' => 'BAD_SERVER',
+ )
+ );
}
}
add_action( 'wp_ajax_rocket_new_ticket_support', 'wp_ajax_rocket_new_ticket_support' );
@@ -55,7 +59,7 @@ function wp_ajax_rocket_helpscout_live_search() {
WP_ROCKET_WEB_MAIN . 'tools/wp-rocket/helpscout/livesearch.php',
array(
'timeout' => 10,
- 'body' => array(
+ 'body' => array(
'query' => esc_html( wp_strip_all_tags( $query, true ) ),
'lang' => get_locale(),
),
diff --git a/inc/admin/class-repeater-field.php b/inc/admin/class-repeater-field.php
index 27cd924e21..08914d8509 100644
--- a/inc/admin/class-repeater-field.php
+++ b/inc/admin/class-repeater-field.php
@@ -1,5 +1,5 @@
option = $args['name'];
+ $this->option = $args['name'];
$this->label_screen = ! empty( $args['label_screen'] ) ? esc_html( $args['label_screen'] ) : false;
- $this->placeholder = ! empty( $args['placeholder'] ) ? 'placeholder="' . $args['placeholder'] . '" ' : '';
+ $this->placeholder = ! empty( $args['placeholder'] ) ? 'placeholder="' . $args['placeholder'] . '" ' : '';
$this->is_drag_n_drop = ! empty( $args['repeater_drag_n_drop'] ) ? true : false;
$this->label_add_field = ! empty( $args['repeater_label_add_field'] ) ? $args['repeater_label_add_field'] : false;
@@ -197,7 +197,6 @@ public function render() {
-
the_field(); ?>
diff --git a/inc/admin/compat/cf-options-5.4.php b/inc/admin/compat/cf-options-5.4.php
index 33edb2e3f4..93aaedc69f 100644
--- a/inc/admin/compat/cf-options-5.4.php
+++ b/inc/admin/compat/cf-options-5.4.php
@@ -1,9 +1,9 @@
-zones( $newvalue['cloudflare_domain'] );
if ( isset( $zone->result[0]->id ) ) {
diff --git a/inc/admin/compat/cf-upgrader-5.4.php b/inc/admin/compat/cf-upgrader-5.4.php
index 33f1a02680..5ebf7ed3e1 100644
--- a/inc/admin/compat/cf-upgrader-5.4.php
+++ b/inc/admin/compat/cf-upgrader-5.4.php
@@ -1,9 +1,9 @@
-zones( $options['cloudflare_domain'] );
if ( isset( $zone->result[0]->id ) ) {
diff --git a/inc/admin/options.php b/inc/admin/options.php
index da3612b679..9a912839b5 100644
--- a/inc/admin/options.php
+++ b/inc/admin/options.php
@@ -1,5 +1,5 @@
',
+ printf(
+ '', $noscripts . '', $buffer );
+
+ return $buffer;
+ }
+
+ /**
+ * Insert critical CSS in the
+ *
+ * @since 2.10
+ * @author Remy Perona
+ */
+ public function insert_critical_css() {
+ global $pagenow;
+
+ if ( ! get_rocket_option( 'async_css' ) ) {
+ return;
+ }
+
+ if ( is_rocket_post_excluded_option( 'async_css' ) ) {
+ return;
+ }
+
+ $current_page_critical_css = $this->get_current_page_critical_css();
+
+ if ( ! $current_page_critical_css ) {
+ return;
+ }
+
+ // Don't apply on wp-login.php/wp-register.php.
+ if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ), true ) ) {
+ return;
+ }
+
+ if ( ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) || ( defined( 'DONOTASYNCCSS' ) && DONOTASYNCCSS ) ) {
+ return;
+ }
+
+ // Don't apply if user is logged-in and cache for logged-in user is off.
+ if ( is_user_logged_in() && ! get_rocket_option( 'cache_logged_user' ) ) {
+ return;
+ }
+
+ // This filter is documented in inc/front/process.php.
+ $rocket_cache_search = apply_filters( 'rocket_cache_search', false );
+
+ // Don't apply on search page.
+ if ( is_search() && ! $rocket_cache_search ) {
+ return;
+ }
+
+ // Don't apply on excluded pages.
+ if ( in_array( $_SERVER['REQUEST_URI'], get_rocket_option( 'cache_reject_uri', array() ), true ) ) {
+ return;
+ }
+
+ // Don't apply on 404 page.
+ if ( is_404() ) {
+ return;
+ }
+
+ if ( 'fallback' === $current_page_critical_css ) {
+ $critical_css_content = get_rocket_option( 'critical_css', '' );
+ } else {
+ $critical_css_content = rocket_direct_filesystem()->get_contents( $this->get_current_page_critical_css() );
+ }
+
+ if ( ! $critical_css_content ) {
+ return;
+ }
+
+ echo '';
+ }
+
+
+ /**
+ * Insert loadCSS script in
+ *
+ * @since 2.10
+ * @author Remy Perona
+ */
+ public function insert_load_css() {
+ global $pagenow;
+
+ if ( ! get_rocket_option( 'async_css' ) ) {
+ return;
+ }
+
+ if ( is_rocket_post_excluded_option( 'async_css' ) ) {
+ return;
+ }
+
+ if ( ! $this->get_current_page_critical_css() ) {
+ return;
+ }
+
+ // Don't apply on wp-login.php/wp-register.php.
+ if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ), true ) ) {
+ return;
+ }
+
+ if ( ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) || ( defined( 'DONOTASYNCCSS' ) && DONOTASYNCCSS ) ) {
+ return;
+ }
+
+ // Don't apply if user is logged-in and cache for logged-in user is off.
+ if ( is_user_logged_in() && ! get_rocket_option( 'cache_logged_user' ) ) {
+ return;
+ }
+
+ // This filter is documented in inc/front/process.php.
+ $rocket_cache_search = apply_filters( 'rocket_cache_search', false );
+
+ // Don't apply on search page.
+ if ( is_search() && ! $rocket_cache_search ) {
+ return;
+ }
+
+ // Don't apply on excluded pages.
+ if ( in_array( $_SERVER['REQUEST_URI'], get_rocket_option( 'cache_reject_uri', array() ), true ) ) {
+ return;
+ }
+
+ // Don't apply on 404 page.
+ if ( is_404() ) {
+ return;
+ }
+
+ echo <<
+/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
+!function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
+/*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
+!function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c
+JS;
+ }
+
+}
diff --git a/inc/classes/class-rocket-database-optimization.php b/inc/classes/class-rocket-database-optimization.php
new file mode 100644
index 0000000000..d60a6e8d67
--- /dev/null
+++ b/inc/classes/class-rocket-database-optimization.php
@@ -0,0 +1,272 @@
+process = new Rocket_Background_Database_Optimization();
+ $this->options = array(
+ 'revisions',
+ 'auto_drafts',
+ 'trashed_posts',
+ 'spam_comments',
+ 'trashed_comments',
+ 'expired_transients',
+ 'all_transients',
+ 'optimize_tables',
+ );
+ }
+
+ /**
+ * Initializes class and hooks.
+ *
+ * @since 2.11
+ * @author Remy Perona
+ */
+ public static function init() {
+ $self = new self();
+
+ add_action( 'init', array( $self, 'database_optimization_scheduled' ) );
+ add_action( 'rocket_database_optimization_time_event', array( $self, 'process_handler' ) );
+ add_action( 'update_option_' . WP_ROCKET_SLUG, array( $self, 'save_optimize' ) );
+ add_action( 'admin_post_rocket_optimize_database', array( $self, 'optimize' ) );
+ add_action( 'admin_notices', array( $self, 'notice_process_running' ) );
+ add_action( 'admin_notices', array( $self, 'notice_process_complete' ) );
+ }
+
+ /**
+ * Performs the database optimization
+ *
+ * @since 2.11
+ * @author Remy Perona
+ */
+ public function process_handler() {
+ $this->process->cancel_process();
+
+ foreach ( $this->options as $option ) {
+ if ( get_rocket_option( 'database_' . $option, false ) ) {
+ $this->process->push_to_queue( $option );
+ }
+ }
+
+ $this->process->save()->dispatch();
+ }
+
+ /**
+ * Launches the database optimization from admin
+ *
+ * @since 2.8
+ * @author Remy Perona
+ *
+ * @see process_handler()
+ */
+ public function optimize() {
+ if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'rocket_optimize_database' ) ) {
+ wp_nonce_ays( '' );
+ }
+
+ $this->process_handler();
+
+ wp_safe_redirect( esc_url_raw( wp_get_referer() ) );
+ die();
+ }
+
+
+ /**
+ * Plans database optimization cron
+ * If the task is not programmed, it is automatically triggered
+ *
+ * @since 2.8
+ * @author Remy Perona
+ *
+ * @see process_handler()
+ */
+ public function database_optimization_scheduled() {
+ if ( get_rocket_option( 'schedule_automatic_cleanup', false ) ) {
+ if ( ! wp_next_scheduled( 'rocket_database_optimization_time_event' ) ) {
+ wp_schedule_event( time(), get_rocket_option( 'automatic_cleanup_frequency', 'weekly' ), 'rocket_database_optimization_time_event' );
+ }
+ }
+ }
+
+ /**
+ * Launches the database optimization when the settings are saved with save and optimize button
+ *
+ * @since 2.8
+ * @author Remy Perona
+ *
+ * @see process_handler()
+ */
+ public function save_optimize() {
+ // Performs the database optimization when settings are saved with the "save and optimize" submit button".
+ if ( ! empty( $_POST ) && isset( $_POST['wp_rocket_settings']['submit_optimize'] ) ) {
+ $this->process_handler();
+ }
+ }
+
+ /**
+ * Count the number of items concerned by the database cleanup
+ *
+ * @since 2.8
+ * @author Remy Perona
+ *
+ * @param string $type Item type to count.
+ * @return int Number of items for this type
+ */
+ public function count_cleanup_items( $type ) {
+ global $wpdb;
+
+ $count = 0;
+
+ switch ( $type ) {
+ case 'revisions':
+ $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'revision'" );
+ break;
+ case 'auto_drafts':
+ $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = 'auto-draft'" );
+ break;
+ case 'trashed_posts':
+ $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_status = 'trash'" );
+ break;
+ case 'spam_comments':
+ $count = $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'" );
+ break;
+ case 'trashed_comments':
+ $count = $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE (comment_approved = 'trash' OR comment_approved = 'post-trashed')" );
+ break;
+ case 'expired_transients':
+ $time = isset( $_SERVER['REQUEST_TIME'] ) ? (int) $_SERVER['REQUEST_TIME'] : time();
+ $count = $wpdb->get_var( "SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name LIKE '_transient_timeout%' AND option_value < $time" );
+ break;
+ case 'all_transients':
+ $count = $wpdb->get_var( "SELECT COUNT(option_id) FROM $wpdb->options WHERE option_name LIKE '_transient_%' OR option_name LIKE '_site_transient_%'" );
+ break;
+ case 'optimize_tables':
+ $count = $wpdb->get_var( "SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" );
+ break;
+ }
+
+ return $count;
+ }
+
+ /**
+ * This notice is displayed after launching the database optimization process
+ *
+ * @since 2.11
+ * @author Remy Perona
+ */
+ public function notice_process_running() {
+ global $current_user;
+
+ $screen = get_current_screen();
+ $rocket_wl_name = get_rocket_option( 'wl_plugin_name', null );
+ $wp_rocket_screen_id = isset( $rocket_wl_name ) ? 'settings_page_' . sanitize_key( $rocket_wl_name ) : 'settings_page_wprocket';
+
+ /** This filter is documented in inc/admin-bar.php */
+ if ( ! current_user_can( apply_filters( 'rocket_capacity', 'manage_options' ) ) ) {
+ return;
+ }
+
+ if ( $screen->id !== $wp_rocket_screen_id ) {
+ return;
+ }
+
+ $notice = get_transient( 'rocket_database_optimization_process' );
+
+ if ( ! $notice ) {
+ return;
+ }
+
+ ?>
+
+ id !== $wp_rocket_screen_id ) {
+ return;
+ }
+
+ $optimized = get_transient( 'rocket_database_optimization_process_complete' );
+
+ if ( false === $optimized ) {
+ return;
+ }
+
+ delete_transient( 'rocket_database_optimization_process_complete' );
+ ?>
+
+
+
+
+
+
+ $number ) : ?>
+ -
+
+
+
+
+
+
+ add_menu( array(
- 'id' => 'wp-rocket',
- 'title' => WP_ROCKET_PLUGIN_NAME,
- 'href' => admin_url( 'options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'id' => 'wp-rocket',
+ 'title' => WP_ROCKET_PLUGIN_NAME,
+ 'href' => admin_url( 'options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG ),
+ )
+ );
// Settings.
- $wp_admin_bar->add_menu(array(
- 'parent' => 'wp-rocket',
- 'id' => 'rocket-settings',
- 'title' => __( 'Settings', 'rocket' ),
- 'href' => admin_url( 'options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'rocket-settings',
+ 'title' => __( 'Settings', 'rocket' ),
+ 'href' => admin_url( 'options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG ),
+ )
+ );
if ( rocket_valid_key() ) {
if ( rocket_is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
// Purge All.
- $wp_admin_bar->add_menu(array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-all',
- 'title' => __( 'Clear cache', 'rocket' ),
- 'href' => '#',
- ));
-
- if ( $langlinks = get_rocket_wpml_langs_for_admin_bar() ) {
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-all',
+ 'title' => __( 'Clear cache', 'rocket' ),
+ 'href' => '#',
+ )
+ );
+
+ $langlinks = get_rocket_wpml_langs_for_admin_bar();
+ if ( $langlinks ) {
foreach ( $langlinks as $lang ) {
- $wp_admin_bar->add_menu( array(
- 'parent' => 'purge-all',
- 'id' => 'purge-all-' . $lang['code'],
- 'title' => $lang['flag'] . ' ' . $lang['anchor'],
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code'] . $referer ), $action . '_all' ),
- ));
- }
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'purge-all',
+ 'id' => 'purge-all-' . $lang['code'],
+ 'title' => $lang['flag'] . ' ' . $lang['anchor'],
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code'] . $referer ), $action . '_all' ),
+ )
+ );
+ }
}
} elseif ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) || rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) || rocket_is_plugin_active( 'polylang/polylang.php' ) || rocket_is_plugin_active( 'polylang-pro/polylang.php' ) ) {
// Purge All.
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-all',
- 'title' => __( 'Clear cache', 'rocket' ),
- 'href' => '#',
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-all',
+ 'title' => __( 'Clear cache', 'rocket' ),
+ 'href' => '#',
+ )
+ );
// Add submenu for each active langs.
if ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) ) {
@@ -77,31 +88,37 @@ function rocket_admin_bar( $wp_admin_bar ) {
}
foreach ( $langlinks as $lang ) {
- $wp_admin_bar->add_menu( array(
- 'parent' => 'purge-all',
- 'id' => 'purge-all-' . $lang['code'],
- 'title' => $lang['flag'] . ' ' . $lang['anchor'],
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code'] . $referer ), $action . '_all' ),
- ));
- }
-
- // Add subemnu "All langs".
- $wp_admin_bar->add_menu( array(
- 'parent' => 'purge-all',
- 'id' => 'purge-all-all',
- 'title' => ' ' . __( 'All languages', 'rocket' ) . '
',
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=all' . $referer ), $action . '_all' ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'purge-all',
+ 'id' => 'purge-all-' . $lang['code'],
+ 'title' => $lang['flag'] . ' ' . $lang['anchor'],
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code'] . $referer ), $action . '_all' ),
+ )
+ );
+ }
+
+ // Add subemnu "All langs".
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'purge-all',
+ 'id' => 'purge-all-all',
+ 'title' => ' ' . __( 'All languages', 'rocket' ) . '
',
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=all' . $referer ), $action . '_all' ),
+ )
+ );
} else {
// Purge All.
- $wp_admin_bar->add_menu(array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-all',
- 'title' => __( 'Clear cache', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all' . $referer ), $action . '_all' ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-all',
+ 'title' => __( 'Clear cache', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all' . $referer ), $action . '_all' ),
+ )
+ );
}
@@ -111,23 +128,27 @@ function rocket_admin_bar( $wp_admin_bar ) {
global $pagenow, $post;
if ( $post && 'post.php' === $pagenow && isset( $_GET['action'], $_GET['post'] ) ) {
$pobject = get_post_type_object( $post->post_type );
- $wp_admin_bar->add_menu(array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-post',
- 'title' => __( 'Clear this post', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=post-' . $post->ID . $referer ), $action . '_post-' . $post->ID ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-post',
+ 'title' => __( 'Clear this post', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=post-' . $post->ID . $referer ), $action . '_post-' . $post->ID ),
+ )
+ );
}
} else {
// Purge this URL (frontend).
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-url',
- 'title' => __( 'Purge this URL', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=url' . $referer ), $action . '_url' ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-url',
+ 'title' => __( 'Purge this URL', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=url' . $referer ), $action . '_url' ),
+ )
+ );
}
@@ -136,110 +157,145 @@ function rocket_admin_bar( $wp_admin_bar ) {
$action = 'rocket_purge_opcache';
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-opcache',
- 'title' => __( 'Purge OPcache', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-opcache',
+ 'title' => __( 'Purge OPcache', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
+ )
+ );
}
+ if ( get_rocket_option( 'async_css' ) ) {
+ // Regenerate Critical Path CSS.
+ $action = 'rocket_generate_critical_css';
+
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'regenerate-critical-path',
+ 'title' => __( 'Regenerate Critical Path CSS', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
+ )
+ );
+ }
+
// Purge CloudFlare cache if CloudFlare is active.
if ( 1 === (int) get_rocket_option( 'do_cloudflare', 0 ) ) {
$action = 'rocket_purge_cloudflare';
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'purge-cloudflare',
- 'title' => __( 'Clear Cloudflare cache', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'purge-cloudflare',
+ 'title' => __( 'Clear Cloudflare cache', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
+ )
+ );
}
$action = 'preload';
- // Go robot gogo!
+ // Go robot gogo!
if ( get_rocket_option( 'manual_preload', 1 ) || get_rocket_option( 'sitemap_preload', false ) ) {
- if ( rocket_is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
-
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'preload-cache',
- 'title' => __( 'Preload cache', 'rocket' ),
- 'href' => '#',
- ));
-
- if ( $langlinks = get_rocket_wpml_langs_for_admin_bar() ) {
- foreach ( $langlinks as $lang ) {
- $wp_admin_bar->add_menu( array(
- 'parent' => 'preload-cache',
- 'id' => 'preload-cache-' . $lang['code'],
- 'title' => $lang['flag'] . ' ' . $lang['anchor'],
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=' . $lang['code'] . $referer ), $action ),
- ));
- }
- }
- } elseif ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) || rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) || rocket_is_plugin_active( 'polylang/polylang.php' ) || rocket_is_plugin_active( 'polylang-pro/polylang.php' ) ) {
-
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'preload-cache',
- 'title' => __( 'Preload cache', 'rocket' ),
- 'href' => '#',
- ));
-
- if ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) ) {
- $langlinks = get_rocket_qtranslate_langs_for_admin_bar();
- } elseif ( rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) ) {
- $langlinks = get_rocket_qtranslate_langs_for_admin_bar( 'x' );
- } elseif ( rocket_is_plugin_active( 'polylang/polylang.php' ) || rocket_is_plugin_active( 'polylang-pro/polylang.php' ) ) {
- $langlinks = get_rocket_polylang_langs_for_admin_bar();
- }
-
- foreach ( $langlinks as $lang ) {
- $wp_admin_bar->add_menu( array(
- 'parent' => 'preload-cache',
- 'id' => 'preload-cache-' . $lang['code'],
- 'title' => $lang['flag'] . ' ' . $lang['anchor'],
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=' . $lang['code'] . $referer ), $action ),
- ));
- }
-
- $wp_admin_bar->add_menu( array(
- 'parent' => 'preload-cache',
- 'id' => 'preload-cache-all',
- 'title' => ' ' . __( 'All languages', 'rocket' ) . '
',
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=all' . $referer ), $action ),
- ));
-
- } else {
-
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'preload-cache',
- 'title' => __( 'Preload cache', 'rocket' ),
- 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
- ));
-
- }
+ if ( rocket_is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
+
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'preload-cache',
+ 'title' => __( 'Preload cache', 'rocket' ),
+ 'href' => '#',
+ )
+ );
+
+ $langlinks = get_rocket_wpml_langs_for_admin_bar();
+ if ( $langlinks ) {
+ foreach ( $langlinks as $lang ) {
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'preload-cache',
+ 'id' => 'preload-cache-' . $lang['code'],
+ 'title' => $lang['flag'] . ' ' . $lang['anchor'],
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=' . $lang['code'] . $referer ), $action ),
+ )
+ );
+ }
+ }
+ } elseif ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) || rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) || rocket_is_plugin_active( 'polylang/polylang.php' ) || rocket_is_plugin_active( 'polylang-pro/polylang.php' ) ) {
+
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'preload-cache',
+ 'title' => __( 'Preload cache', 'rocket' ),
+ 'href' => '#',
+ )
+ );
+
+ if ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) ) {
+ $langlinks = get_rocket_qtranslate_langs_for_admin_bar();
+ } elseif ( rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) ) {
+ $langlinks = get_rocket_qtranslate_langs_for_admin_bar( 'x' );
+ } elseif ( rocket_is_plugin_active( 'polylang/polylang.php' ) || rocket_is_plugin_active( 'polylang-pro/polylang.php' ) ) {
+ $langlinks = get_rocket_polylang_langs_for_admin_bar();
+ }
+
+ foreach ( $langlinks as $lang ) {
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'preload-cache',
+ 'id' => 'preload-cache-' . $lang['code'],
+ 'title' => $lang['flag'] . ' ' . $lang['anchor'],
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=' . $lang['code'] . $referer ), $action ),
+ )
+ );
+ }
+
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'preload-cache',
+ 'id' => 'preload-cache-all',
+ 'title' => ' ' . __( 'All languages', 'rocket' ) . '
',
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&lang=all' . $referer ), $action ),
+ )
+ );
+
+ } else {
+
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'preload-cache',
+ 'title' => __( 'Preload cache', 'rocket' ),
+ 'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . $referer ), $action ),
+ )
+ );
+
+ }
}
}
if ( ! rocket_is_white_label() ) {
// Go to WP Rocket Documentation.
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'docs',
- 'title' => __( 'Documentation', 'rocket' ),
- 'href' => get_rocket_documentation_url(),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'docs',
+ 'title' => __( 'Documentation', 'rocket' ),
+ 'href' => get_rocket_documentation_url(),
+ )
+ );
// Go to WP Rocket FAQ.
- $wp_admin_bar->add_menu( array(
- 'parent' => 'wp-rocket',
- 'id' => 'faq',
- 'title' => __( 'FAQ', 'rocket' ),
- 'href' => get_rocket_faq_url(),
- ));
+ $wp_admin_bar->add_menu(
+ array(
+ 'parent' => 'wp-rocket',
+ 'id' => 'faq',
+ 'title' => __( 'FAQ', 'rocket' ),
+ 'href' => get_rocket_faq_url(),
+ )
+ );
// Go to WP Rocket Support.
$wp_admin_bar->add_menu( array(
diff --git a/inc/common/cloudflare.php b/inc/common/cloudflare.php
index 7072225119..25ac90e8d8 100644
--- a/inc/common/cloudflare.php
+++ b/inc/common/cloudflare.php
@@ -1,5 +1,5 @@
get_rocket_purge_cron_interval(),
- 'display' => sprintf( __( '%s clear', 'rocket' ), WP_ROCKET_PLUGIN_NAME ),
+ 'interval' => get_rocket_purge_cron_interval(),
+ // translators: %s = WP Rocket name (maybe white label).
+ 'display' => sprintf( __( '%s clear', 'rocket' ), WP_ROCKET_PLUGIN_NAME ),
);
}
@@ -73,28 +74,3 @@ function do_rocket_purge_cron() {
run_rocket_preload_cache( 'cache-preload' );
}
add_action( 'rocket_purge_time_event', 'do_rocket_purge_cron' );
-
-/**
- * Planning database optimization cron
- * If the task is not programmed, it is automatically triggered
- *
- * @since 2.8
- * @author Remy Perona
- */
-function rocket_database_optimization_scheduled() {
- if ( get_rocket_option( 'schedule_automatic_cleanup', false ) ) {
- if ( ! wp_next_scheduled( 'rocket_database_optimization_time_event' ) ) {
- wp_schedule_event( time(), get_rocket_option( 'automatic_cleanup_frequency', 'weekly' ), 'rocket_database_optimization_time_event' );
- }
- }
-}
-add_action( 'init', 'rocket_database_optimization_scheduled' );
-
-/**
- * This event is launched when the cron is triggered
- * Performs the database optimization
- *
- * @since 2.8
- * @author Remy Perona
- */
-add_action( 'rocket_database_optimization_time_event', 'do_rocket_database_optimization' );
diff --git a/inc/common/embeds.php b/inc/common/embeds.php
index f064120703..322290b82a 100644
--- a/inc/common/embeds.php
+++ b/inc/common/embeds.php
@@ -1,5 +1,5 @@
public_query_vars = array_diff( $wp->public_query_vars, array(
- 'embed',
- ) );
+ $wp->public_query_vars = array_diff(
+ $wp->public_query_vars, array(
+ 'embed',
+ )
+ );
// Remove the REST API endpoint.
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
diff --git a/inc/common/emoji.php b/inc/common/emoji.php
index 5541b88ac7..7c898d32cb 100644
--- a/inc/common/emoji.php
+++ b/inc/common/emoji.php
@@ -1,5 +1,5 @@
post_type ) {
- if ( $post_type_archive = get_post_type_archive_link( get_post_type( $post_id ) ) ) {
- $post_type_archive = trailingslashit( $post_type_archive );
+ $post_type_archive = get_post_type_archive_link( get_post_type( $post_id ) );
+ if ( $post_type_archive ) {
+ $post_type_archive = trailingslashit( $post_type_archive );
array_push( $purge_urls, $post_type_archive . 'index.html' );
array_push( $purge_urls, $post_type_archive . 'index.html_gzip' );
array_push( $purge_urls, $post_type_archive . $GLOBALS['wp_rewrite']->pagination_base );
- }
+ }
}
// Add next post.
@@ -231,9 +187,9 @@ function rocket_clean_post( $post_id ) {
*
* @since 1.3.0
*
- * @param obj $post The post object
+ * @param obj $post The post object
* @param array $purge_urls URLs cache files to remove
- * @param string $lang The post language
+ * @param string $lang The post language
*/
do_action( 'before_rocket_clean_post', $post, $purge_urls, $lang );
@@ -260,16 +216,16 @@ function rocket_clean_post( $post_id ) {
*
* @since 1.3.0
*
- * @param obj $post The post object
+ * @param obj $post The post object
* @param array $purge_urls URLs cache files to remove
- * @param string $lang The post language
+ * @param string $lang The post language
*/
do_action( 'after_rocket_clean_post', $post, $purge_urls, $lang );
}
-add_action( 'wp_trash_post' , 'rocket_clean_post' );
-add_action( 'delete_post' , 'rocket_clean_post' );
-add_action( 'clean_post_cache' , 'rocket_clean_post' );
-add_action( 'wp_update_comment_count' , 'rocket_clean_post' );
+add_action( 'wp_trash_post' , 'rocket_clean_post' );
+add_action( 'delete_post' , 'rocket_clean_post' );
+add_action( 'clean_post_cache' , 'rocket_clean_post' );
+add_action( 'wp_update_comment_count' , 'rocket_clean_post' );
/**
* Add pattern to clean files of connected users
@@ -282,8 +238,8 @@ function rocket_clean_post( $post_id ) {
function rocket_clean_files_users( $urls ) {
$pattern_urls = array();
foreach ( $urls as $url ) {
- list( $host, $path, $scheme ) = get_rocket_parse_url( $url );
- $pattern_urls[] = $scheme . '://' . $host . '*' . $path;
+ $parse_url = get_rocket_parse_url( $url );
+ $pattern_urls[] = $parse_url['scheme'] . '://' . $parse_url['host'] . '*' . $parse_url['path'];
}
return $pattern_urls;
}
@@ -313,7 +269,7 @@ function rocket_post_purge_urls_for_qtranslate( $urls ) {
foreach ( $urls as $url ) {
foreach ( $enabled_languages as $lang ) {
if ( rocket_is_plugin_active( 'qtranslate/qtranslate.php' ) ) {
- $urls[] = qtrans_convertURL( $url, $lang, true );
+ $urls[] = qtrans_convertURL( $url, $lang, true );
} elseif ( rocket_is_plugin_active( 'qtranslate-x/qtranslate.php' ) ) {
$urls[] = qtranxf_convertURL( $url, $lang, true );
}
@@ -425,7 +381,7 @@ function do_admin_post_rocket_purge_cache() {
// Clear all cache domain.
case 'all':
-
+ set_transient( 'rocket_clear_cache', 'all', HOUR_IN_SECONDS );
// Remove all cache files.
$lang = isset( $_GET['lang'] ) && 'all' !== $_GET['lang'] ? sanitize_key( $_GET['lang'] ) : '';
// Remove all cache files.
@@ -445,30 +401,34 @@ function do_admin_post_rocket_purge_cache() {
update_option( WP_ROCKET_SLUG, $options );
rocket_dismiss_box( 'rocket_warning_plugin_modification' );
+
break;
// Clear terms, homepage and other files associated at current post in back-end.
case 'post':
rocket_clean_post( $_id );
+ set_transient( 'rocket_clear_cache', 'post', HOUR_IN_SECONDS );
break;
// Clear a specific term.
case 'term':
rocket_clean_term( $_id, $_taxonomy );
+ set_transient( 'rocket_clear_cache', 'term', HOUR_IN_SECONDS );
break;
// Clear a specific user.
case 'user':
rocket_clean_user( $_id );
+ set_transient( 'rocket_clear_cache', 'user', HOUR_IN_SECONDS );
break;
// Clear cache file of the current page in front-end.
case 'url':
- $referer = wp_get_referer();
+ $referer = wp_get_referer();
- if ( 0 !== strpos( $referer, 'http' ) ) {
- list( $host, $path, $scheme, $query ) = get_rocket_parse_url( untrailingslashit( home_url() ) );
- $referer = $scheme . '://' . $host . $referer;
+ if ( 0 !== strpos( $referer, 'http' ) ) {
+ $parse_url = get_rocket_parse_url( untrailingslashit( home_url() ) );
+ $referer = $parse_url['scheme'] . '://' . $parse_url['host'] . $referer;
}
if ( home_url( '/' ) === $referer ) {
@@ -546,9 +506,16 @@ function do_admin_post_rocket_purge_cloudflare() {
$cf_purge = rocket_purge_cloudflare();
if ( is_wp_error( $cf_purge ) ) {
- $cf_purge_result = array( 'result' => 'error', 'message' => sprintf( __( 'CloudFlare Cache purge error: %s', 'rocket' ), $cf_purge->get_error_message() ) );
+ $cf_purge_result = array(
+ 'result' => 'error',
+ // translators: %s = CloudFare API return message.
+ 'message' => sprintf( __( 'Cloudflare cache purge error: %s', 'rocket' ), $cf_purge->get_error_message() ),
+ );
} else {
- $cf_purge_result = array( 'result' => 'success', 'message' => __( 'CloudFlare cache sucessfully purged', 'rocket' ) );
+ $cf_purge_result = array(
+ 'result' => 'success',
+ 'message' => __( 'CloudFlare cache sucessfully purged', 'rocket' ),
+ );
}
set_transient( $GLOBALS['current_user']->ID . '_cloudflare_purge_result', $cf_purge_result );
diff --git a/inc/common/updater.php b/inc/common/updater.php
index 8189c726a6..24adc23e60 100644
--- a/inc/common/updater.php
+++ b/inc/common/updater.php
@@ -1,5 +1,5 @@
last_checked = time();
}
- $response = wp_remote_get( WP_ROCKET_WEB_CHECK, array( 'timeout' => 30 ) );
+ $response = wp_remote_get(
+ WP_ROCKET_WEB_CHECK, array(
+ 'timeout' => 30,
+ )
+ );
if ( ! is_a( $response, 'WP_Error' ) && 200 === $response['response']['code'] && strlen( $response['body'] ) > 32 ) {
set_site_transient( 'update_wprocket', time() );
@@ -47,11 +51,11 @@ function rocket_check_update( $value ) {
}
$temp_array = array(
- 'slug' => $plugin_folder,
- 'plugin' => $plugin_folder . '/' . $plugin_file,
- 'new_version' => $version,
- 'url' => 'http://wp-rocket.me',
- 'package' => $url,
+ 'slug' => $plugin_folder,
+ 'plugin' => $plugin_folder . '/' . $plugin_file,
+ 'new_version' => $version,
+ 'url' => 'http://wp-rocket.me',
+ 'package' => $url,
);
$temp_object = (object) $temp_array;
diff --git a/inc/compat.php b/inc/compat.php
index eb2cfe54cf..211fdd2c00 100644
--- a/inc/compat.php
+++ b/inc/compat.php
@@ -1,5 +1,5 @@
'scheme',
- PHP_URL_HOST => 'host',
- PHP_URL_PORT => 'port',
- PHP_URL_USER => 'user',
- PHP_URL_PASS => 'pass',
- PHP_URL_PATH => 'path',
- PHP_URL_QUERY => 'query',
- PHP_URL_FRAGMENT => 'fragment',
+ PHP_URL_SCHEME => 'scheme',
+ PHP_URL_HOST => 'host',
+ PHP_URL_PORT => 'port',
+ PHP_URL_USER => 'user',
+ PHP_URL_PASS => 'pass',
+ PHP_URL_PATH => 'path',
+ PHP_URL_QUERY => 'query',
+ PHP_URL_FRAGMENT => 'fragment',
);
if ( isset( $translation[ $constant ] ) ) {
@@ -227,20 +227,69 @@ function _wp_translate_php_url_constant_to_key( $constant ) {
* @param string $user_string The user-supplied string.
* @return bool Returns TRUE when the two strings are equal, FALSE otherwise.
*/
- function hash_equals( $known_string, $user_string ) {
- $ret = 0;
-
- if ( strlen( $known_string ) !== strlen( $user_string ) ) {
- $user_string = $known_string;
- $ret = 1;
- }
-
- $res = $known_string ^ $user_string;
-
- for ( $i = strlen( $res ) - 1; $i >= 0; --$i ) {
- $ret |= ord( $res[ $i ] );
- }
-
- return ! $ret;
- }
+ function hash_equals( $known_string, $user_string ) {
+ $ret = 0;
+
+ if ( strlen( $known_string ) !== strlen( $user_string ) ) {
+ $user_string = $known_string;
+ $ret = 1;
+ }
+
+ $res = $known_string ^ $user_string;
+
+ for ( $i = strlen( $res ) - 1; $i >= 0; --$i ) {
+ $ret |= ord( $res[ $i ] );
+ }
+
+ return ! $ret;
+ }
+}
+
+if ( ! function_exists( 'wp_json_encode' ) ) {
+ /**
+ * Copied from core for compatibility with WP < 4.1
+ * Encode a variable into JSON, with some sanity checks.
+ *
+ * @since 4.1.0
+ *
+ * @param mixed $data Variable (usually an array or object) to encode as JSON.
+ * @param int $options Optional. Options to be passed to json_encode(). Default 0.
+ * @param int $depth Optional. Maximum depth to walk through $data. Must be
+ * greater than 0. Default 512.
+ * @return string|false The JSON encoded string, or false if it cannot be encoded.
+ */
+ function wp_json_encode( $data, $options = 0, $depth = 512 ) {
+ /*
+ * json_encode() has had extra params added over the years.
+ * $options was added in 5.3, and $depth in 5.5.
+ * We need to make sure we call it with the correct arguments.
+ */
+ if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
+ $args = array( $data, $options, $depth );
+ } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
+ $args = array( $data, $options );
+ } else {
+ $args = array( $data );
+ }
+
+ // Prepare the data for JSON serialization.
+ $args[0] = _wp_json_prepare_data( $data );
+
+ $json = @call_user_func_array( 'json_encode', $args );
+
+ // If json_encode() was successful, no need to do more sanity checking.
+ // ... unless we're in an old version of PHP, and json_encode() returned
+ // a string containing 'null'. Then we need to do more sanity checking.
+ if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) {
+ return $json;
+ }
+
+ try {
+ $args[0] = _wp_json_sanity_check( $data, $depth );
+ } catch ( Exception $e ) {
+ return false;
+ }
+
+ return call_user_func_array( 'json_encode', $args );
+ }
}
diff --git a/inc/deprecated.php b/inc/deprecated.php
index a67f2a27bc..b2fe2928d8 100755
--- a/inc/deprecated.php
+++ b/inc/deprecated.php
@@ -1,5 +1,5 @@
#iU', $buffer, $tags_match );
+
+ if ( ! isset( $tags_match[0] ) ) {
+ return $buffer;
+ }
+
+ foreach ( $tags_match[0] as $i => $tag ) {
+ // Strip query args.
+ $url = strtok( $tags_match[1][ $i ] , '?' );
+
+ $deferred_js_files = array_flip( get_rocket_deferred_js_files() );
+
+ // Check if this file should be deferred.
+ if ( isset( $deferred_js_files[ $url ] ) ) {
+ $deferred_tag = str_replace( '>', ' defer>', $tag );
+ $buffer = str_replace( $tag, $deferred_tag, $buffer );
+ }
+ }
+
+ return $buffer;
+}
+
+/**
+ * Used to display the defered module on settings form
+ *
+ * @since 1.1.0
+ * @deprecated 2.11
+ */
+function rocket_defered_module() {
+ _deprecated_function( __FUNCTION__, '2.11' );
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+task()
+ * @author Remy Perona
+ *
+ * @param string $type Type of optimization to perform.
+ */
+function rocket_database_optimize( $type ) {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Background_Database_Optimisation->task()' );
+}
+
+/**
+ * Launches the database optimization from admin
+ *
+ * @since 2.8
+ * @deprecated 2.11
+ * @see Rocket_Database_Optimisation->optimize()
+ * @author Remy Perona
+ */
+function rocket_optimize_database() {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Database_Optimisation->optimize()' );
+}
+
+/**
+ * Count the number of items concerned by the database cleanup
+ *
+ * @since 2.8
+ * @deprecated 2.11
+ * @see Rocket_Database_Optimisation->count_cleanup_items()
+ * @author Remy Perona
+ *
+ * @param string $type Item type to count.
+ * @return int Number of items for this type
+ */
+function rocket_database_count_cleanup_items( $type ) {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Database_Optimisation->count_cleanup_items()' );
+
+ return 0;
+}
+
+/**
+ * Planning database optimization cron
+ * If the task is not programmed, it is automatically triggered
+ *
+ * @since 2.8
+ * @deprecated 2.11
+ * @see Rocket_Database_Optimisation->database_optimization_scheduled()
+ * @author Remy Perona
+ */
+function rocket_database_optimization_scheduled() {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Database_Optimisation->database_optimization_scheduled()' );
+}
+
+/**
+ * Performs the database optimization
+ *
+ * @since 2.8
+ * @deprecated 2.11
+ * @see Rocket_Database_Optimisation->process_handler()
+ * @author Remy Perona
+ */
+function do_rocket_database_optimization() {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Database_Optimisation->process_handler()' );
+}
+
+/**
+ * Declare and set value to DONOTMINIFYCSS & DONOTMINIFYJS constant
+ *
+ * @since 2.6.2
+ * @deprecated 2.11
+ * @see rocket_define_donotoptimize_constant()
+ *
+ * @param bool $value true or false.
+ */
+function rocket_define_donotminify_constants( $value ) {
+ _deprecated_function( __FUNCTION__, '2.11', 'rocket_define_donotoptimize_constant' );
+
+ if ( ! defined( 'DONOTMINIFYCSS' ) ) {
+ define( 'DONOTMINIFYCSS', (bool) $value );
+ }
+ if ( ! defined( 'DONOTMINIFYJS' ) ) {
+ define( 'DONOTMINIFYJS', (bool) $value );
+ }
+}
+
+/**
+ * Declare and set value to DONOTMASYNCCSS constant
+ *
+ * @since 2.10
+ * @deprecated 2.11
+ * @see rocket_define_donotoptimize_constant()
+ * @author Remy Perona
+ *
+ * @param bool $value true or false.
+ */
+function rocket_define_donotasync_css_constant( $value ) {
+ _deprecated_function( __FUNCTION__, '2.11', 'rocket_define_donotoptimize_constant' );
+
+ if ( ! defined( 'DONOTASYNCCSS' ) ) {
+ define( 'DONOTASYNCCSS', (bool) $value );
+ }
+}
+
+/**
+ * Defer loading of CSS files
+ *
+ * @since 2.10
+ * @deprecated 2.11
+ * @see Rocket_Critical_CSS->async_css()
+ * @author Remy Perona
+ *
+ * @param string $buffer HTML code.
+ * @return string Updated HTML code
+ */
+function rocket_async_css( $buffer ) {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Critical_CSS->async_css()' );
+
+ return $buffer;
+}
+
+/**
+ * Insert critical CSS in the
+ *
+ * @since 2.10
+ * @deprecated 2.11
+ * @see Rocket_Critical_CSS->insert_critical_css()
+ * @author Remy Perona
+ */
+function rocket_insert_critical_css() {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Critical_CSS->insert_critical_css()' );
+}
+
+/**
+ * Insert loadCSS script in
+ *
+ * @since 2.10
+ * @deprecated 2.11
+ * @see Rocket_Critical_CSS->insert_load_css()
+ * @author Remy Perona
+ */
+function rocket_insert_load_css() {
+ _deprecated_function( __FUNCTION__, '2.11', 'Rocket_Critical_CSS->insert_load_css()' );
+}
diff --git a/inc/domain-mapping.php b/inc/domain-mapping.php
index 7be4589097..01c8b09756 100755
--- a/inc/domain-mapping.php
+++ b/inc/domain-mapping.php
@@ -1,5 +1,5 @@
]*\s(rel\s*=\s*[\'"]stylesheet["\']))]*\shref\s*=\s*[\'"]([^\'"]+)[\'"](.*)>/iU' ), $buffer, $tags_match );
-
- if ( ! isset( $tags_match[0] ) ) {
- return $buffer;
- }
-
- $noscripts = '';
-
- foreach ( $tags_match[0] as $i => $tag ) {
- // Strip query args.
- $path = parse_url( $tags_match[2][ $i ] , PHP_URL_PATH );
-
- // Check if this file should be deferred.
- if ( isset( $excluded_css[ $path ] ) ) {
- continue;
- }
-
- $preload = str_replace( 'stylesheet', 'preload', $tags_match[1][ $i ] );
- $onload = str_replace( $tags_match[3][ $i ], ' as="style" onload=""' . $tags_match[3][ $i ] . '>', $tags_match[3][ $i ] );
- $tag = str_replace( $tags_match[3][ $i ] . '>', $onload, $tag );
- $tag = str_replace( $tags_match[1][ $i ], $preload, $tag );
- $tag = str_replace( 'onload=""', 'onload="this.rel=\'stylesheet\'"', $tag );
- $buffer = str_replace( $tags_match[0][ $i ], $tag, $buffer );
-
- $noscripts .= '';
- }
-
- $buffer = str_replace( '', $noscripts . '', $buffer );
-
- return $buffer;
-}
-add_filter( 'rocket_buffer', 'rocket_async_css', 15 );
-
-
-/**
- * Insert critical CSS in the
- *
- * @since 2.10
- * @author Remy Perona
- */
-function rocket_insert_critical_css() {
- global $pagenow;
-
- if ( ! get_rocket_option( 'async_css' ) ) {
- return;
- }
-
- if ( is_rocket_post_excluded_option( 'async_css' ) ) {
- return;
- }
-
- // Don't apply on wp-login.php/wp-register.php.
- if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ), true ) ) {
- return;
- }
-
- // Don't apply if DONOTCACHEPAGE is defined.
- if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) {
- return;
- }
-
- if ( defined( 'DONOTASYNCCSS' ) && DONOTASYNCCSS ) {
- return;
- }
-
- // Don't apply if user is logged-in and cache for logged-in user is off.
- if ( is_user_logged_in() && ! get_rocket_option( 'cache_logged_user' ) ) {
- return;
- }
-
- // This filter is documented in inc/front/process.php.
- $rocket_cache_search = apply_filters( 'rocket_cache_search', false );
-
- // Don't apply on search page.
- if ( is_search() && ! $rocket_cache_search ) {
- return;
- }
-
- // Don't apply on excluded pages.
- if ( in_array( $_SERVER['REQUEST_URI'] , get_rocket_option( 'cache_reject_uri' , array() ), true ) ) {
- return;
- }
-
- // Don't apply on 404 page.
- if ( is_404() ) {
- return;
- }
-
- $critical_css = wp_kses( get_rocket_option( 'critical_css' ), array( '\'', '\"' ) );
- $critical_css = str_replace( '>', '>', $critical_css );
-
- echo '';
-}
-add_action( 'wp_head', 'rocket_insert_critical_css', 1 );
-
-/**
- * Insert loadCSS script in
- *
- * @since 2.10
- * @author Remy Perona
- */
-function rocket_insert_load_css() {
- global $pagenow;
-
- if ( ! get_rocket_option( 'async_css' ) ) {
- return;
- }
-
- if ( is_rocket_post_excluded_option( 'async_css' ) ) {
- return;
- }
-
- // Don't apply on wp-login.php/wp-register.php.
- if ( in_array( $pagenow, array( 'wp-login.php', 'wp-register.php' ), true ) ) {
- return;
- }
-
- // Don't apply if DONOTCACHEPAGE is defined.
- if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) {
- return;
- }
-
- if ( defined( 'DONOTASYNCCSS' ) && DONOTASYNCCSS ) {
- return;
- }
-
- // Don't apply if user is logged-in and cache for logged-in user is off.
- if ( is_user_logged_in() && ! get_rocket_option( 'cache_logged_user' ) ) {
- return;
- }
-
- // This filter is documented in inc/front/process.php.
- $rocket_cache_search = apply_filters( 'rocket_cache_search', false );
-
- // Don't apply on search page.
- if ( is_search() && ! $rocket_cache_search ) {
- return;
- }
-
- // Don't apply on excluded pages.
- if ( in_array( $_SERVER['REQUEST_URI'] , get_rocket_option( 'cache_reject_uri' , array() ), true ) ) {
- return;
- }
-
- // Don't apply on 404 page.
- if ( is_404() ) {
- return;
- }
-
- echo <<
-/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
-!function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
-/*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
-!function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c
-JS;
-}
-add_action( 'wp_head', 'rocket_insert_load_css', PHP_INT_MAX );
diff --git a/inc/front/cdn.php b/inc/front/cdn.php
index 87f0be9991..610becee8f 100644
--- a/inc/front/cdn.php
+++ b/inc/front/cdn.php
@@ -1,5 +1,5 @@
$data ) {
$sources[ $width ]['url'] = rocket_cdn_file( $data['url'] );
@@ -131,12 +144,14 @@ function rocket_add_cdn_on_srcset( $sources ) {
*/
function rocket_cdn_images( $html ) {
// Don't use CDN if the image is in admin, a feed or in a post preview.
- if ( is_admin() || is_feed() || is_preview() || empty( $html ) ) {
+ if ( is_admin() || is_feed() || is_preview() || empty( $html ) || defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) {
return $html;
}
- $zone = array( 'all', 'images' );
- if ( $cnames = get_rocket_cdn_cnames( $zone ) ) {
+ $zone = array( 'all', 'images' );
+ $cnames = get_rocket_cdn_cnames( $zone );
+
+ if ( $cnames ) {
$cnames = array_flip( $cnames );
$home_url = home_url( '/' );
@@ -146,10 +161,11 @@ function rocket_cdn_images( $html ) {
foreach ( $images_match[3] as $k => $image_url ) {
- list( $host, $path, $scheme, $query ) = get_rocket_parse_url( $image_url );
- $path = trim( $path );
+ $parse_url = get_rocket_parse_url( $image_url );
+ $path = trim( $parse_url['path'] );
+ $host = $parse_url['host'];
- if ( empty( $path ) || ! preg_match( '#(' . $wp_content_dirname . '|wp-includes)#', $path ) ) {
+ if ( empty( $path ) || ! preg_match( '#(' . $wp_content_dirname . '|wp-includes)#', $path ) ) {
continue;
}
@@ -160,11 +176,11 @@ function rocket_cdn_images( $html ) {
// Image path is relative, apply the host to it.
if ( empty( $host ) ) {
$image_url = $home_url . ltrim( $image_url, '/' );
- $host = parse_url( $image_url, PHP_URL_HOST );
+ $host = rocket_extract_url_component( $image_url, PHP_URL_HOST );
}
// Check if the link isn't external.
- if ( parse_url( $home_url, PHP_URL_HOST ) !== $host ) {
+ if ( rocket_extract_url_component( $home_url, PHP_URL_HOST ) !== $host ) {
continue;
}
@@ -181,13 +197,15 @@ function rocket_cdn_images( $html ) {
* @since 2.5.5
*
* @param array $html Output that will be printed.
- */
- apply_filters( 'rocket_cdn_images_html', sprintf(
- '',
- trim( $images_match[1][ $k ] ),
- 'src=' . $images_match[2][ $k ] . get_rocket_cdn_url( $image_url, $zone ) . $images_match[4][ $k ],
- trim( $images_match[5][ $k ] )
- ) ),
+ */
+ apply_filters(
+ 'rocket_cdn_images_html', sprintf(
+ '',
+ trim( $images_match[1][ $k ] ),
+ 'src=' . $images_match[2][ $k ] . get_rocket_cdn_url( $image_url, $zone ) . $images_match[4][ $k ],
+ trim( $images_match[5][ $k ] )
+ )
+ ),
$html
);
}
@@ -209,7 +227,7 @@ function rocket_cdn_images( $html ) {
* @return string modified HTML content
*/
function rocket_cdn_inline_styles( $html ) {
- if ( is_preview() || empty( $html ) ) {
+ if ( is_preview() || empty( $html ) || defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) {
return $html;
}
@@ -220,22 +238,23 @@ function rocket_cdn_inline_styles( $html ) {
'css',
);
- if ( $cnames = get_rocket_cdn_cnames( $zone ) ) {
- preg_match_all( '/url\((?![\'\"]?data)[\"\']?([^\)\"\']+)[\"\']?\)/i', $html, $matches );
+ $cnames = get_rocket_cdn_cnames( $zone );
+ if ( $cnames ) {
+ preg_match_all( '/url\((?![\'\"]?data)[\"\']?([^\)\"\']+)[\"\']?\)/i', $html, $matches );
- if ( ( bool ) $matches ) {
- foreach( $matches[1] as $k => $url ) {
- $url = str_replace( array( ' ', '\t', '\n', '\r', '\0', '\x0B', '"', "'", '"', ''' ), '', $url );
+ if ( (bool) $matches ) {
+ foreach ( $matches[1] as $k => $url ) {
+ $url = str_replace( array( ' ', '\t', '\n', '\r', '\0', '\x0B', '"', "'", '"', ''' ), '', $url );
if ( '#' === substr( $url, 0, 1 ) ) {
continue;
}
- $url = get_rocket_cdn_url( $url, $zone );
- $property = str_replace( $matches[1][ $k ], $url, $matches[0][ $k ] );
- $html = str_replace( $matches[0][ $k ], $property, $html );
- }
- }
+ $url = get_rocket_cdn_url( $url, $zone );
+ $property = str_replace( $matches[1][ $k ], $url, $matches[0][ $k ] );
+ $html = str_replace( $matches[0][ $k ], $property, $html );
+ }
+ }
}
return $html;
@@ -252,15 +271,16 @@ function rocket_cdn_inline_styles( $html ) {
* @return string modified HTML content
*/
function rocket_cdn_custom_files( $html ) {
- if ( is_preview() || empty( $html ) ) {
+ if ( is_preview() || empty( $html ) || defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) {
return $html;
}
- $zone = array(
+ $zone = array(
'all',
);
+ $cnames = get_rocket_cdn_cnames( $zone );
- if ( $cnames = get_rocket_cdn_cnames( $zone ) ) {
+ if ( $cnames ) {
/**
* Filters the filetypes allowed for the CDN
@@ -302,11 +322,11 @@ function rocket_cdn_custom_files( $html ) {
*/
function rocket_cdn_enqueue( $src ) {
// Don't use CDN if in admin, in login page, in register page or in a post preview.
- if ( is_admin() || is_preview() || in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ), true ) ) {
+ if ( is_admin() || is_preview() || in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ), true ) || defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) {
return $src;
}
- if ( parse_url( $src, PHP_URL_HOST ) !== '' ) {
+ if ( rocket_extract_url_component( $src, PHP_URL_HOST ) !== '' ) {
$src = rocket_add_url_protocol( $src );
}
@@ -322,9 +342,10 @@ function rocket_cdn_enqueue( $src ) {
$zone[] = 'js';
}
- if ( $cnames = get_rocket_cdn_cnames( $zone ) ) {
+ $cnames = get_rocket_cdn_cnames( $zone );
+ if ( $cnames ) {
// Check if the path isn't empty.
- if ( trim( parse_url( $src, PHP_URL_PATH ), '/' ) !== '' ) {
+ if ( trim( rocket_extract_url_component( $src, PHP_URL_PATH ), '/' ) !== '' ) {
$src = get_rocket_cdn_url( $src, $zone );
}
}
diff --git a/inc/front/cookie.php b/inc/front/cookie.php
index 46e4f88cde..9aa389893b 100755
--- a/inc/front/cookie.php
+++ b/inc/front/cookie.php
@@ -1,5 +1,5 @@
#iU', $buffer, $tags_match );
-
- if ( ! isset( $tags_match[0] ) ) {
- return $buffer;
- }
-
- foreach ( $tags_match[0] as $i => $tag ) {
- // Strip query args.
- $url = strtok( $tags_match[1][ $i ] , '?' );
-
- $deferred_js_files = array_flip( get_rocket_deferred_js_files() );
-
- // Check if this file should be deferred.
- if ( isset( $deferred_js_files[ $url ] ) ) {
- $deferred_tag = str_replace( '>', ' defer>', $tag );
- $buffer = str_replace( $tag, $deferred_tag, $buffer );
- }
- }
-
- return $buffer;
-}
-add_filter( 'rocket_buffer', 'rocket_insert_deferred_js', 11 );
-
+defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
/**
* Defer all JS files.
@@ -69,7 +30,7 @@ function rocket_defer_js( $buffer ) {
foreach ( $tags_match[0] as $i => $tag ) {
// Strip query args.
- $path = parse_url( $tags_match[2][ $i ] , PHP_URL_PATH );
+ $path = rocket_extract_url_component( $tags_match[2][ $i ] , PHP_URL_PATH );
// Check if this file should be deferred.
if ( isset( $exclude_defer_js[ $path ] ) ) {
diff --git a/inc/front/dns-prefetch.php b/inc/front/dns-prefetch.php
index fbb7b1f345..500c7a6a21 100755
--- a/inc/front/dns-prefetch.php
+++ b/inc/front/dns-prefetch.php
@@ -1,5 +1,5 @@
0;if(visible&&getCSS(parent,"overflow")!="visible"){outerRect=parent.getBoundingClientRect();visible=eLright>outerRect.left&&eLleftouterRect.top-1&&eLtop4&&loadMode>2){currentExpand=preloadExpand;lowRuns=0}else if(currentExpand!=defaultExpand&&loadMode>1&&lowRuns>3){currentExpand=defaultExpand}else{currentExpand=shrinkExpand}for(;i=elemNegativeExpand&&(eLtop=rect.top)<=elvH&&(eLright=rect.right)>=elemNegativeExpand&&(eLleft=rect.left)<=eLvW&&(eLbottom||eLright||eLleft||eLtop)&&(isCompleted&&isLoading<3&&lowRuns<4&&!elemExpandVal&&loadMode>2||isNestedVisible(lazyloadElems[i],elemExpand))){unveilElement(lazyloadElems[i],false,rect.width);loadedSomething=true}else if(!loadedSomething&&isCompleted&&!autoLoadElem&&isLoading<3&&lowRuns<4&&loadMode>2&&(preloadElems[0]||lazyRocketsConfig.preloadAfterLoad)&&(preloadElems[0]||!elemExpandVal&&(eLbottom||eLright||eLleft||eLtop))){autoLoadElem=preloadElems[0]||lazyloadElems[i]}}if(autoLoadElem&&!loadedSomething){unveilElement(autoLoadElem)}}};var throttledCheckElements=throttle(checkElements);var switchLoadingClass=function(e){addClass(e.target,lazyRocketsConfig.loadedClass);removeClass(e.target,lazyRocketsConfig.loadingClass);addRemoveLoadEvents(e.target,switchLoadingClass)};var changeIframeSrc=function(elem,src){if(elem.getAttribute("src")!=src){elem.setAttribute("src",src)}};var rafBatch=function(){var isRunning;var batch=[];var runBatch=function(){while(batch.length){batch.shift()()}isRunning=false};return function(fn){batch.push(fn);if(!isRunning){isRunning=true;rAF(runBatch)}}}();var unveilElement=function(elem,force,width){var sources,i,len,sourceSrcset,src,srcset,sizes,parent,isPicture,event,firesLoad,customMedia;var curSrc=elem.currentSrc||elem.src;var isImg=regImg.test(elem.nodeName);var sizes=null;var isAuto=sizes=="auto";if((isAuto||!isCompleted)&&isImg&&curSrc&&!elem.complete&&!hasClass(elem,lazyRocketsConfig.errorClass)){return}elem._lazyRace=true;isLoading++;rafBatch(function lazyUnveil(){if(elem._lazyRace){delete elem._lazyRace}removeClass(elem,lazyRocketsConfig.lazyClass);if(!(event=triggerEvent(elem,"lazybeforeunveil",{force:!!force})).defaultPrevented){srcset=elem.getAttribute("data-lazy-srcset");sizes=elem.getAttribute("data-lazy-sizes");src=elem.getAttribute("data-lazy-src")||elem.getAttribute("data-lazy-original");if(isImg){parent=elem.parentNode;isPicture=parent&®Picture.test(parent.nodeName||"")}firesLoad=event.detail.firesLoad||"src"in elem&&(srcset||sizes||src||isPicture);event={target:elem};if(firesLoad){addRemoveLoadEvents(elem,resetPreloading,true);clearTimeout(resetPreloadingTimer);resetPreloadingTimer=setTimeout(resetPreloading,2500);addClass(elem,lazyRocketsConfig.loadingClass);addRemoveLoadEvents(elem,switchLoadingClass,true)}if(srcset){elem.setAttribute("srcset",srcset)}if(sizes){elem.setAttribute("sizes",sizes)}if(src){if(regIframe.test(elem.nodeName)){changeIframeSrc(elem,src)}else{elem.setAttribute("src",src)}}if(isPicture){updatePolyfill(elem,{src:src})}}if(!firesLoad||elem.complete&&curSrc==(elem.currentSrc||elem.src)){if(firesLoad){resetPreloading(event)}else{isLoading--}switchLoadingClass(event)}})};var onload=function(){var scrollTimer;var afterScroll=function(){lazyRocketsConfig.loadMode=3;throttledCheckElements()};isCompleted=true;lowRuns+=8;lazyRocketsConfig.loadMode=3;addEventListener("scroll",function(){if(lazyRocketsConfig.loadMode==3){lazyRocketsConfig.loadMode=2}clearTimeout(scrollTimer);scrollTimer=setTimeout(afterScroll,99)},true)};return{_:function(){lazyloadElems=document.getElementsByClassName(lazyRocketsConfig.lazyClass);preloadElems=document.getElementsByClassName(lazyRocketsConfig.lazyClass+" "+lazyRocketsConfig.preloadClass);defaultExpand=lazyRocketsConfig.expand;preloadExpand=Math.round(defaultExpand*lazyRocketsConfig.expFactor);addEventListener("scroll",throttledCheckElements,true);addEventListener("resize",throttledCheckElements,true);if(window.MutationObserver){new MutationObserver(prepareThrottledCheckElements).observe(docElem,{childList:true,subtree:true,attributes:true});new MutationObserver(throttledCheckElements).observe(docElem,{childList:true,subtree:true,attributes:true})}else{docElem.addEventListener("DOMNodeInserted",prepareThrottledCheckElements,true);docElem.addEventListener("DOMAttrModified",prepareThrottledCheckElements,true);setInterval(prepareThrottledCheckElements,999);docElem.addEventListener("DOMNodeInserted",throttledCheckElements,true);docElem.addEventListener("DOMAttrModified",throttledCheckElements,true);setInterval(throttledCheckElements,999)}addEventListener("hashchange",prepareThrottledCheckElements,true);["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(name){document.addEventListener(name,throttledCheckElements,true)});if(!(isCompleted=/d$|^c/.test(document.readyState))){addEventListener("load",onload);document.addEventListener("DOMContentLoaded",throttledCheckElements)}else{onload()}throttledCheckElements(lazyloadElems.length>0)},checkElems:throttledCheckElements,unveil:unveilElement}}();var init=function(){if(!init.i){init.i=true;loader._()}};(function(){var prop;var lazyRocketsDefaults={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",init:true,expFactor:2,expand:359,loadMode:2,throttle:99};lazyRocketsConfig=window.lazyRocketsConfig||window.lazyRocketsConfig||{};for(prop in lazyRocketsDefaults){if(!(prop in lazyRocketsConfig)){lazyRocketsConfig[prop]=lazyRocketsDefaults[prop]}}window.lazyRocketsConfig=lazyRocketsConfig;setTimeout(function(){if(lazyRocketsConfig.init){var tmpElems=document.querySelectorAll("[data-lazy-src],[data-lazy-original]");for(var i=0;i0;if(visible&&getCSS(parent,"overflow")!="visible"){outerRect=parent.getBoundingClientRect();visible=eLright>outerRect.left&&eLleftouterRect.top-1&&eLtop4&&loadMode>2){currentExpand=preloadExpand;lowRuns=0}else if(currentExpand!=defaultExpand&&loadMode>1&&lowRuns>3){currentExpand=defaultExpand}else{currentExpand=shrinkExpand}for(;i=elemNegativeExpand&&(eLtop=rect.top)<=elvH&&(eLright=rect.right)>=elemNegativeExpand&&(eLleft=rect.left)<=eLvW&&(eLbottom||eLright||eLleft||eLtop)&&(isCompleted&&isLoading<3&&lowRuns<4&&!elemExpandVal&&loadMode>2||isNestedVisible(lazyloadElems[i],elemExpand))){unveilElement(lazyloadElems[i],false,rect.width);loadedSomething=true}else if(!loadedSomething&&isCompleted&&!autoLoadElem&&isLoading<3&&lowRuns<4&&loadMode>2&&(preloadElems[0]||lazyRocketsConfig.preloadAfterLoad)&&(preloadElems[0]||!elemExpandVal&&(eLbottom||eLright||eLleft||eLtop))){autoLoadElem=preloadElems[0]||lazyloadElems[i]}}if(autoLoadElem&&!loadedSomething){unveilElement(autoLoadElem)}}};var throttledCheckElements=throttle(checkElements);var switchLoadingClass=function(e){addClass(e.target,lazyRocketsConfig.loadedClass);removeClass(e.target,lazyRocketsConfig.loadingClass);addRemoveLoadEvents(e.target,switchLoadingClass)};var changeIframeSrc=function(elem,src){if(elem.getAttribute("src")!=src){elem.setAttribute("src",src)}};var rafBatch=function(){var isRunning;var batch=[];var runBatch=function(){while(batch.length){batch.shift()()}isRunning=false};return function(fn){batch.push(fn);if(!isRunning){isRunning=true;rAF(runBatch)}}}();var unveilElement=function(elem,force,width){var sources,i,len,sourceSrcset,src,srcset,sizes,parent,isPicture,event,firesLoad,customMedia;var curSrc=elem.currentSrc||elem.src;var isImg=regImg.test(elem.nodeName);var sizes=null;var isAuto=sizes=="auto";if((isAuto||!isCompleted)&&isImg&&curSrc&&!elem.complete&&!hasClass(elem,lazyRocketsConfig.errorClass)){return}elem._lazyRace=true;isLoading++;rafBatch(function lazyUnveil(){if(elem._lazyRace){delete elem._lazyRace}removeClass(elem,lazyRocketsConfig.lazyClass);if(!(event=triggerEvent(elem,"lazybeforeunveil",{force:!!force})).defaultPrevented){srcset=elem.getAttribute("data-lazy-srcset");sizes=elem.getAttribute("data-lazy-sizes");src=elem.getAttribute("data-lazy-src")||elem.getAttribute("data-lazy-original");if(isImg){parent=elem.parentNode;isPicture=parent&®Picture.test(parent.nodeName||"")}firesLoad=event.detail.firesLoad||"src"in elem&&(srcset||sizes||src||isPicture);event={target:elem};if(firesLoad){addRemoveLoadEvents(elem,resetPreloading,true);clearTimeout(resetPreloadingTimer);resetPreloadingTimer=setTimeout(resetPreloading,2500);addClass(elem,lazyRocketsConfig.loadingClass);addRemoveLoadEvents(elem,switchLoadingClass,true)}if(srcset){elem.setAttribute("srcset",srcset)}if(sizes){elem.setAttribute("sizes",sizes)}if(src){if(regIframe.test(elem.nodeName)){changeIframeSrc(elem,src)}else{elem.setAttribute("src",src)}}if(isPicture){updatePolyfill(elem,{src:src})}}if(!firesLoad||elem.complete&&curSrc==(elem.currentSrc||elem.src)){if(firesLoad){resetPreloading(event)}else{isLoading--}switchLoadingClass(event)}})};var onload=function(){var scrollTimer;var afterScroll=function(){lazyRocketsConfig.loadMode=3;throttledCheckElements()};isCompleted=true;lowRuns+=8;lazyRocketsConfig.loadMode=3;addEventListener("scroll",function(){if(lazyRocketsConfig.loadMode==3){lazyRocketsConfig.loadMode=2}clearTimeout(scrollTimer);scrollTimer=setTimeout(afterScroll,99)},true)};return{_:function(){lazyloadElems=document.getElementsByClassName(lazyRocketsConfig.lazyClass);preloadElems=document.getElementsByClassName(lazyRocketsConfig.lazyClass+" "+lazyRocketsConfig.preloadClass);defaultExpand=lazyRocketsConfig.expand;preloadExpand=Math.round(defaultExpand*lazyRocketsConfig.expFactor);addEventListener("scroll",throttledCheckElements,true);addEventListener("resize",throttledCheckElements,true);if(window.MutationObserver){new MutationObserver(prepareThrottledCheckElements).observe(docElem,{childList:true,subtree:true,attributes:true});new MutationObserver(throttledCheckElements).observe(docElem,{childList:true,subtree:true,attributes:true})}else{docElem.addEventListener("DOMNodeInserted",prepareThrottledCheckElements,true);docElem.addEventListener("DOMAttrModified",prepareThrottledCheckElements,true);setInterval(prepareThrottledCheckElements,999);docElem.addEventListener("DOMNodeInserted",throttledCheckElements,true);docElem.addEventListener("DOMAttrModified",throttledCheckElements,true);setInterval(throttledCheckElements,999)}addEventListener("hashchange",prepareThrottledCheckElements,true);["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(name){document.addEventListener(name,throttledCheckElements,true)});if(!(isCompleted=/d$|^c/.test(document.readyState))){addEventListener("load",onload);document.addEventListener("DOMContentLoaded",throttledCheckElements)}else{onload()}throttledCheckElements(lazyloadElems.length>0)},checkElems:throttledCheckElements,unveil:unveilElement}}();var init=function(){if(!init.i){init.i=true;loader._()}};(function(){var prop;var lazyRocketsDefaults={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",init:true,expFactor:2,expand:359,loadMode:2,throttle:99};lazyRocketsConfig=window.lazyRocketsConfig||window.lazyRocketsConfig||{};for(prop in lazyRocketsDefaults){if(!(prop in lazyRocketsConfig)){lazyRocketsConfig[prop]=lazyRocketsDefaults[prop]}}window.lazyRocketsConfig=lazyRocketsConfig;setTimeout(function(){if(lazyRocketsConfig.init){var tmpElems=document.querySelectorAll("[data-lazy-src],[data-lazy-original]");for(var i=0;i= getTopOffset(element) + threshold + element.offsetHeight;
+ };
+
+ var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) {
+ var fold = container === window ? window.pageXOffset : getLeftOffset(container);
+ return fold >= getLeftOffset(element) + threshold + element.offsetWidth;
+ };
+
+ var isInsideViewport = function isInsideViewport(element, container, threshold) {
+ return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold);
+ };
+
+ /* Creates instance and notifies it through the window element */
+ var createInstance = function createInstance(classObj, options) {
+ var instance = new classObj(options);
+ var event = new CustomEvent("LazyLoad::Initialized", { detail: { instance: instance } });
+ window.dispatchEvent(event);
+ };
+
+ /* Auto initialization of one or more instances of lazyload, depending on the
+ options passed in (plain object or an array) */
+ var autoInitialize = function autoInitialize(classObj, options) {
+ var optsLength = options.length;
+ if (!optsLength) {
+ // Plain object
+ createInstance(classObj, options);
+ } else {
+ // Array of objects
+ for (var i = 0; i < optsLength; i++) {
+ createInstance(classObj, options[i]);
+ }
+ }
+ };
+
+ var dataPrefix = "data-";
+
+ var getData = function getData(element, attribute) {
+ return element.getAttribute(dataPrefix + attribute);
+ };
+
+ var setData = function setData(element, attribute, value) {
+ return element.setAttribute(dataPrefix + attribute, value);
+ };
+
+ var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) {
+ var parent = element.parentElement;
+ if (parent.tagName !== "PICTURE") {
+ return;
+ }
+ for (var i = 0; i < parent.children.length; i++) {
+ var pictureChild = parent.children[i];
+ if (pictureChild.tagName === "SOURCE") {
+ var sourceSrcset = getData(pictureChild, srcsetDataAttribute);
+ if (sourceSrcset) {
+ pictureChild.setAttribute("srcset", sourceSrcset);
+ }
+ }
+ }
+ };
+
+ var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) {
+ var tagName = element.tagName;
+ var elementSrc = getData(element, srcDataAttribute);
+ if (tagName === "IMG") {
+ setSourcesForPicture(element, srcsetDataAttribute);
+ var imgSrcset = getData(element, srcsetDataAttribute);
+ if (imgSrcset) {
+ element.setAttribute("srcset", imgSrcset);
+ }
+ if (elementSrc) {
+ element.setAttribute("src", elementSrc);
+ }
+ return;
+ }
+ if (tagName === "IFRAME") {
+ if (elementSrc) {
+ element.setAttribute("src", elementSrc);
+ }
+ return;
+ }
+ if (elementSrc) {
+ element.style.backgroundImage = 'url("' + elementSrc + '")';
+ }
+ };
+
+ var supportsClassList = !!document.body.classList;
+
+ var addClass = function addClass(element, className) {
+ if (supportsClassList) {
+ element.classList.add(className);
+ return;
+ }
+ element.className += (element.className ? " " : "") + className;
+ };
+
+ var removeClass = function removeClass(element, className) {
+ if (supportsClassList) {
+ element.classList.remove(className);
+ return;
+ }
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
+ };
+
+ /*
+ * Constructor
+ */
+
+ var LazyLoad = function LazyLoad(instanceSettings) {
+ this._settings = _extends({}, defaultSettings, instanceSettings);
+ this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
+
+ this._previousLoopTime = 0;
+ this._loopTimeout = null;
+ this._boundHandleScroll = this.handleScroll.bind(this);
+
+ this._isFirstLoop = true;
+ window.addEventListener("resize", this._boundHandleScroll);
+ this.update();
+ };
+
+ LazyLoad.prototype = {
+
+ /*
+ * Private methods
+ */
+
+ _reveal: function _reveal(element) {
+ var settings = this._settings;
+
+ var errorCallback = function errorCallback() {
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
+ if (!settings) {
+ return;
+ }
+ element.removeEventListener("load", loadCallback);
+ element.removeEventListener("error", errorCallback);
+ removeClass(element, settings.class_loading);
+ addClass(element, settings.class_error);
+ callCallback(settings.callback_error, element);
+ };
+
+ var loadCallback = function loadCallback() {
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
+ if (!settings) {
+ return;
+ }
+ removeClass(element, settings.class_loading);
+ addClass(element, settings.class_loaded);
+ element.removeEventListener("load", loadCallback);
+ element.removeEventListener("error", errorCallback);
+ /* Calling LOAD callback */
+ callCallback(settings.callback_load, element);
+ };
+
+ if (element.tagName === "IMG" || element.tagName === "IFRAME") {
+ element.addEventListener("load", loadCallback);
+ element.addEventListener("error", errorCallback);
+ addClass(element, settings.class_loading);
+ }
+
+ setSources(element, settings.data_srcset, settings.data_src);
+ /* Calling SET callback */
+ callCallback(settings.callback_set, element);
+ },
+
+ _loopThroughElements: function _loopThroughElements() {
+ var settings = this._settings,
+ elements = this._elements,
+ elementsLength = !elements ? 0 : elements.length;
+ var i = void 0,
+ processedIndexes = [],
+ firstLoop = this._isFirstLoop;
+
+ for (i = 0; i < elementsLength; i++) {
+ var element = elements[i];
+ /* If must skip_invisible and element is invisible, skip it */
+ if (settings.skip_invisible && element.offsetParent === null) {
+ continue;
+ }
+
+ if (isBot || isInsideViewport(element, settings.container, settings.threshold)) {
+ if (firstLoop) {
+ addClass(element, settings.class_initial);
+ }
+ /* Start loading the image */
+ this._reveal(element);
+ /* Marking the element as processed. */
+ processedIndexes.push(i);
+ setData(element, "was-processed", true);
+ }
+ }
+ /* Removing processed elements from this._elements. */
+ while (processedIndexes.length) {
+ elements.splice(processedIndexes.pop(), 1);
+ /* Calling the end loop callback */
+ callCallback(settings.callback_processed, elements.length);
+ }
+ /* Stop listening to scroll event when 0 elements remains */
+ if (elementsLength === 0) {
+ this._stopScrollHandler();
+ }
+ /* Sets isFirstLoop to false */
+ if (firstLoop) {
+ this._isFirstLoop = false;
+ }
+ },
+
+ _purgeElements: function _purgeElements() {
+ var elements = this._elements,
+ elementsLength = elements.length;
+ var i = void 0,
+ elementsToPurge = [];
+
+ for (i = 0; i < elementsLength; i++) {
+ var element = elements[i];
+ /* If the element has already been processed, skip it */
+ if (getData(element, "was-processed")) {
+ elementsToPurge.push(i);
+ }
+ }
+ /* Removing elements to purge from this._elements. */
+ while (elementsToPurge.length > 0) {
+ elements.splice(elementsToPurge.pop(), 1);
+ }
+ },
+
+ _startScrollHandler: function _startScrollHandler() {
+ if (!this._isHandlingScroll) {
+ this._isHandlingScroll = true;
+ this._settings.container.addEventListener("scroll", this._boundHandleScroll);
+ }
+ },
+
+ _stopScrollHandler: function _stopScrollHandler() {
+ if (this._isHandlingScroll) {
+ this._isHandlingScroll = false;
+ this._settings.container.removeEventListener("scroll", this._boundHandleScroll);
+ }
+ },
+
+ /*
+ * Public methods
+ */
+
+ handleScroll: function handleScroll() {
+ var throttle = this._settings.throttle;
+
+ if (throttle !== 0) {
+ var now = Date.now();
+ var remainingTime = throttle - (now - this._previousLoopTime);
+ if (remainingTime <= 0 || remainingTime > throttle) {
+ if (this._loopTimeout) {
+ clearTimeout(this._loopTimeout);
+ this._loopTimeout = null;
+ }
+ this._previousLoopTime = now;
+ this._loopThroughElements();
+ } else if (!this._loopTimeout) {
+ this._loopTimeout = setTimeout(function () {
+ this._previousLoopTime = Date.now();
+ this._loopTimeout = null;
+ this._loopThroughElements();
+ }.bind(this), remainingTime);
+ }
+ } else {
+ this._loopThroughElements();
+ }
+ },
+
+ update: function update() {
+ // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector
+ this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
+ this._purgeElements();
+ this._loopThroughElements();
+ this._startScrollHandler();
+ },
+
+ destroy: function destroy() {
+ window.removeEventListener("resize", this._boundHandleScroll);
+ if (this._loopTimeout) {
+ clearTimeout(this._loopTimeout);
+ this._loopTimeout = null;
+ }
+ this._stopScrollHandler();
+ this._elements = null;
+ this._queryOriginNode = null;
+ this._settings = null;
+ }
+ };
+
+ /* Automatic instances creation if required (useful for async script loading!) */
+ var autoInitOptions = window.lazyLoadOptions;
+ if (autoInitOptions) {
+ autoInitialize(LazyLoad, autoInitOptions);
+ }
+
+ return LazyLoad;
+});
diff --git a/inc/front/js/lazyload-8.2.min.js b/inc/front/js/lazyload-8.2.min.js
new file mode 100644
index 0000000000..0a6005f914
--- /dev/null
+++ b/inc/front/js/lazyload-8.2.min.js
@@ -0,0 +1 @@
+var _extends=Object.assign||function(e){for(var t=1;t=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n=new e(t),o=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(o)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentElement;if("PICTURE"===n.tagName)for(var o=0;o0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o= getTopOffset(element) + threshold + element.offsetHeight;
+ };
+
+ var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) {
+ var fold = container === window ? window.pageXOffset : getLeftOffset(container);
+ return fold >= getLeftOffset(element) + threshold + element.offsetWidth;
+ };
+
+ var isInsideViewport = function isInsideViewport(element, container, threshold) {
+ return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold);
+ };
+
+ /* Creates instance and notifies it through the window element */
+ var createInstance = function createInstance(classObj, options) {
+ var event;
+ var eventString = "LazyLoad::Initialized";
+ var instance = new classObj(options);
+ try {
+ // Works in modern browsers
+ event = new CustomEvent(eventString, { detail: { instance: instance } });
+ } catch (err) {
+ // Works in Internet Explorer (all versions)
+ event = document.createEvent("CustomEvent");
+ event.initCustomEvent(eventString, false, false, { instance: instance });
+ }
+ window.dispatchEvent(event);
+ };
+
+ /* Auto initialization of one or more instances of lazyload, depending on the
+ options passed in (plain object or an array) */
+ var autoInitialize = function autoInitialize(classObj, options) {
+ var optsLength = options.length;
+ if (!optsLength) {
+ // Plain object
+ createInstance(classObj, options);
+ } else {
+ // Array of objects
+ for (var i = 0; i < optsLength; i++) {
+ createInstance(classObj, options[i]);
+ }
+ }
+ };
+
+ var dataPrefix = "data-";
+
+ var getData = function getData(element, attribute) {
+ return element.getAttribute(dataPrefix + attribute);
+ };
+
+ var setData = function setData(element, attribute, value) {
+ return element.setAttribute(dataPrefix + attribute, value);
+ };
+
+ var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) {
+ var parent = element.parentNode;
+ if (parent.tagName !== "PICTURE") {
+ return;
+ }
+ for (var i = 0; i < parent.children.length; i++) {
+ var pictureChild = parent.children[i];
+ if (pictureChild.tagName === "SOURCE") {
+ var sourceSrcset = getData(pictureChild, srcsetDataAttribute);
+ if (sourceSrcset) {
+ pictureChild.setAttribute("srcset", sourceSrcset);
+ }
+ }
+ }
+ };
+
+ var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) {
+ var tagName = element.tagName;
+ var elementSrc = getData(element, srcDataAttribute);
+ if (tagName === "IMG") {
+ setSourcesForPicture(element, srcsetDataAttribute);
+ var imgSrcset = getData(element, srcsetDataAttribute);
+ if (imgSrcset) {
+ element.setAttribute("srcset", imgSrcset);
+ }
+ if (elementSrc) {
+ element.setAttribute("src", elementSrc);
+ }
+ return;
+ }
+ if (tagName === "IFRAME") {
+ if (elementSrc) {
+ element.setAttribute("src", elementSrc);
+ }
+ return;
+ }
+ if (elementSrc) {
+ element.style.backgroundImage = 'url("' + elementSrc + '")';
+ }
+ };
+
+ var supportsClassList = "classList" in document.createElement("p");
+
+ var addClass = function addClass(element, className) {
+ if (supportsClassList) {
+ element.classList.add(className);
+ return;
+ }
+ element.className += (element.className ? " " : "") + className;
+ };
+
+ var removeClass = function removeClass(element, className) {
+ if (supportsClassList) {
+ element.classList.remove(className);
+ return;
+ }
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
+ };
+
+ /*
+ * Constructor
+ */
+
+ var LazyLoad = function LazyLoad(instanceSettings) {
+ this._settings = _extends({}, defaultSettings, instanceSettings);
+ this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
+
+ this._previousLoopTime = 0;
+ this._loopTimeout = null;
+ this._boundHandleScroll = this.handleScroll.bind(this);
+
+ this._isFirstLoop = true;
+ window.addEventListener("resize", this._boundHandleScroll);
+ this.update();
+ };
+
+ LazyLoad.prototype = {
+
+ /*
+ * Private methods
+ */
+
+ _reveal: function _reveal(element) {
+ var settings = this._settings;
+
+ var errorCallback = function errorCallback() {
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
+ if (!settings) {
+ return;
+ }
+ element.removeEventListener("load", loadCallback);
+ element.removeEventListener("error", errorCallback);
+ removeClass(element, settings.class_loading);
+ addClass(element, settings.class_error);
+ callCallback(settings.callback_error, element);
+ };
+
+ var loadCallback = function loadCallback() {
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
+ if (!settings) {
+ return;
+ }
+ removeClass(element, settings.class_loading);
+ addClass(element, settings.class_loaded);
+ element.removeEventListener("load", loadCallback);
+ element.removeEventListener("error", errorCallback);
+ /* Calling LOAD callback */
+ callCallback(settings.callback_load, element);
+ };
+
+ if (element.tagName === "IMG" || element.tagName === "IFRAME") {
+ element.addEventListener("load", loadCallback);
+ element.addEventListener("error", errorCallback);
+ addClass(element, settings.class_loading);
+ }
+
+ setSources(element, settings.data_srcset, settings.data_src);
+ /* Calling SET callback */
+ callCallback(settings.callback_set, element);
+ },
+
+ _loopThroughElements: function _loopThroughElements() {
+ var settings = this._settings,
+ elements = this._elements,
+ elementsLength = !elements ? 0 : elements.length;
+ var i = void 0,
+ processedIndexes = [],
+ firstLoop = this._isFirstLoop;
+
+ for (i = 0; i < elementsLength; i++) {
+ var element = elements[i];
+ /* If must skip_invisible and element is invisible, skip it */
+ if (settings.skip_invisible && element.offsetParent === null) {
+ continue;
+ }
+
+ if (isBot || isInsideViewport(element, settings.container, settings.threshold)) {
+ if (firstLoop) {
+ addClass(element, settings.class_initial);
+ }
+ /* Start loading the image */
+ this._reveal(element);
+ /* Marking the element as processed. */
+ processedIndexes.push(i);
+ setData(element, "was-processed", true);
+ }
+ }
+ /* Removing processed elements from this._elements. */
+ while (processedIndexes.length) {
+ elements.splice(processedIndexes.pop(), 1);
+ /* Calling the end loop callback */
+ callCallback(settings.callback_processed, elements.length);
+ }
+ /* Stop listening to scroll event when 0 elements remains */
+ if (elementsLength === 0) {
+ this._stopScrollHandler();
+ }
+ /* Sets isFirstLoop to false */
+ if (firstLoop) {
+ this._isFirstLoop = false;
+ }
+ },
+
+ _purgeElements: function _purgeElements() {
+ var elements = this._elements,
+ elementsLength = elements.length;
+ var i = void 0,
+ elementsToPurge = [];
+
+ for (i = 0; i < elementsLength; i++) {
+ var element = elements[i];
+ /* If the element has already been processed, skip it */
+ if (getData(element, "was-processed")) {
+ elementsToPurge.push(i);
+ }
+ }
+ /* Removing elements to purge from this._elements. */
+ while (elementsToPurge.length > 0) {
+ elements.splice(elementsToPurge.pop(), 1);
+ }
+ },
+
+ _startScrollHandler: function _startScrollHandler() {
+ if (!this._isHandlingScroll) {
+ this._isHandlingScroll = true;
+ this._settings.container.addEventListener("scroll", this._boundHandleScroll);
+ }
+ },
+
+ _stopScrollHandler: function _stopScrollHandler() {
+ if (this._isHandlingScroll) {
+ this._isHandlingScroll = false;
+ this._settings.container.removeEventListener("scroll", this._boundHandleScroll);
+ }
+ },
+
+ /*
+ * Public methods
+ */
+
+ handleScroll: function handleScroll() {
+ var throttle = this._settings.throttle;
+
+ if (throttle !== 0) {
+ var now = Date.now();
+ var remainingTime = throttle - (now - this._previousLoopTime);
+ if (remainingTime <= 0 || remainingTime > throttle) {
+ if (this._loopTimeout) {
+ clearTimeout(this._loopTimeout);
+ this._loopTimeout = null;
+ }
+ this._previousLoopTime = now;
+ this._loopThroughElements();
+ } else if (!this._loopTimeout) {
+ this._loopTimeout = setTimeout(function () {
+ this._previousLoopTime = Date.now();
+ this._loopTimeout = null;
+ this._loopThroughElements();
+ }.bind(this), remainingTime);
+ }
+ } else {
+ this._loopThroughElements();
+ }
+ },
+
+ update: function update() {
+ // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector
+ this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
+ this._purgeElements();
+ this._loopThroughElements();
+ this._startScrollHandler();
+ },
+
+ destroy: function destroy() {
+ window.removeEventListener("resize", this._boundHandleScroll);
+ if (this._loopTimeout) {
+ clearTimeout(this._loopTimeout);
+ this._loopTimeout = null;
+ }
+ this._stopScrollHandler();
+ this._elements = null;
+ this._queryOriginNode = null;
+ this._settings = null;
+ }
+ };
+
+ /* Automatic instances creation if required (useful for async script loading!) */
+ var autoInitOptions = window.lazyLoadOptions;
+ if (autoInitOptions) {
+ autoInitialize(LazyLoad, autoInitOptions);
+ }
+
+ return LazyLoad;
+});
\ No newline at end of file
diff --git a/inc/front/js/lazyload-8.5.2.min.js b/inc/front/js/lazyload-8.5.2.min.js
new file mode 100755
index 0000000000..df081d6fd9
--- /dev/null
+++ b/inc/front/js/lazyload-8.5.2.min.js
@@ -0,0 +1 @@
+var _extends=Object.assign||function(e){for(var t=1;t=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n,o=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentNode;if("PICTURE"===n.tagName)for(var o=0;o0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o 0);
-
- if(visible && getCSS(parent, 'overflow') != 'visible'){
- outerRect = parent.getBoundingClientRect();
- visible = eLright > outerRect.left &&
- eLleft < outerRect.right &&
- eLbottom > outerRect.top - 1 &&
- eLtop < outerRect.bottom + 1
- ;
- }
- }
-
- return visible;
- };
-
- var checkElements = function() {
- var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal;
-
- if((loadMode = lazyRocketsConfig.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
-
- i = 0;
-
- lowRuns++;
-
- if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 4 && loadMode > 2){
- currentExpand = preloadExpand;
- lowRuns = 0;
- } else if(currentExpand != defaultExpand && loadMode > 1 && lowRuns > 3){
- currentExpand = defaultExpand;
- } else {
- currentExpand = shrinkExpand;
- }
-
- for(; i < eLlen; i++){
-
- if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
-
- if(!supportScroll){unveilElement(lazyloadElems[i]);continue;}
-
- if(!(elemExpandVal = lazyloadElems[i].getAttribute('data-expand')) || !(elemExpand = elemExpandVal * 1)){
- elemExpand = currentExpand;
- }
-
- if(beforeExpandVal !== elemExpand){
- eLvW = innerWidth + elemExpand;
- elvH = innerHeight + elemExpand;
- elemNegativeExpand = elemExpand * -1;
- beforeExpandVal = elemExpand;
- }
-
- rect = lazyloadElems[i].getBoundingClientRect();
-
- if ((eLbottom = rect.bottom) >= elemNegativeExpand &&
- (eLtop = rect.top) <= elvH &&
- (eLright = rect.right) >= elemNegativeExpand &&
- (eLleft = rect.left) <= eLvW &&
- (eLbottom || eLright || eLleft || eLtop) &&
- ((isCompleted && isLoading < 3 && lowRuns < 4 && !elemExpandVal && loadMode > 2) || isNestedVisible(lazyloadElems[i], elemExpand))){
- unveilElement(lazyloadElems[i], false, rect.width);
- loadedSomething = true;
- } else if(!loadedSomething && isCompleted && !autoLoadElem &&
- isLoading < 3 && lowRuns < 4 && loadMode > 2 &&
- (preloadElems[0] || lazyRocketsConfig.preloadAfterLoad) &&
- (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) /*|| lazyloadElems[i].getAttribute(lazyRocketsConfig.sizesAttr) != 'auto'*/)))){
- autoLoadElem = preloadElems[0] || lazyloadElems[i];
- }
- }
-
- if(autoLoadElem && !loadedSomething){
- unveilElement(autoLoadElem);
- }
- }
- };
-
- var throttledCheckElements = throttle(checkElements);
-
- var switchLoadingClass = function(e){
- addClass(e.target, lazyRocketsConfig.loadedClass);
- removeClass(e.target, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(e.target, switchLoadingClass);
- };
-
- var changeIframeSrc = function(elem, src){
- try {
- elem.contentWindow.location.replace(src);
- } catch(e){
- elem.setAttribute('src', src);
- }
- };
-
- var rafBatch = (function(){
- var isRunning;
- var batch = [];
- var runBatch = function(){
- while(batch.length){
- (batch.shift())();
- }
- isRunning = false;
- };
- return function(fn){
- batch.push(fn);
- if(!isRunning){
- isRunning = true;
- rAF(runBatch);
- }
- };
- })();
-
- var unveilElement = function (elem, force, width){
- var sources, i, len, sourceSrcset, src, srcset, parent, isPicture, event, firesLoad, customMedia;
-
- var curSrc = elem.currentSrc || elem.src;
- var isImg = regImg.test(elem.nodeName);
-
- var sizes = null;
- var isAuto = sizes == 'auto';
-
- if( (isAuto || !isCompleted) && isImg && curSrc && !elem.complete && !hasClass(elem, lazyRocketsConfig.errorClass)){return;}
-
- elem._lazyRace = true;
- isLoading++;
-
- rafBatch(function lazyUnveil(){
-
- if(elem._lazyRace){
- delete elem._lazyRace;
- }
-
- removeClass(elem, lazyRocketsConfig.lazyClass);
-
- if(!(event = triggerEvent(elem, 'lazybeforeunveil', {force: !!force})).defaultPrevented){
-
- /*if(sizes){
- if(isAuto){*/
- addClass(elem, lazyRocketsConfig.autosizesClass);
- //} else {
- //elem.setAttribute('sizes', sizes);
- //}
- //}
-
- //srcset = elem.getAttribute(lazyRocketsConfig.srcsetAttr);
- srcset = null;
-
- src = elem.getAttribute('data-lazy-src') || elem.getAttribute('data-lazy-original');
-
- if(isImg) {
- parent = elem.parentNode;
- isPicture = parent && regPicture.test(parent.nodeName || '');
- }
-
- firesLoad = event.detail.firesLoad || (('src' in elem) && (srcset || src || isPicture));
-
- event = {target: elem};
-
- if(firesLoad){
- addRemoveLoadEvents(elem, resetPreloading, true);
- clearTimeout(resetPreloadingTimer);
- resetPreloadingTimer = setTimeout(resetPreloading, 2500);
-
- addClass(elem, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(elem, switchLoadingClass, true);
- }
-
- /*if(isPicture){
- sources = parent.getElementsByTagName('source');
- for(i = 0, len = sources.length; i < len; i++){
- if( (customMedia = lazyRocketsConfig.customMedia[sources[i].getAttribute('data-media') || sources[i].getAttribute('media')]) ){
- sources[i].setAttribute('media', customMedia);
- }
- sourceSrcset = sources[i].getAttribute(lazyRocketsConfig.srcsetAttr);
- if(sourceSrcset){
- sources[i].setAttribute('srcset', sourceSrcset);
- }
- }
- }*/
-
- if(src){
- if(regIframe.test(elem.nodeName)){
- changeIframeSrc(elem, src);
- } else {
- elem.setAttribute('src', src);
- }
- }
-
- if(isPicture){
- updatePolyfill(elem, {src: src});
- }
- }
-
- if( !firesLoad || (elem.complete && curSrc == (elem.currentSrc || elem.src)) ){
- if(firesLoad){
- resetPreloading(event);
- } else {
- isLoading--;
- }
- switchLoadingClass(event);
- }
- });
- };
-
- var onload = function(){
- var scrollTimer;
- var afterScroll = function(){
- lazyRocketsConfig.loadMode = 3;
- throttledCheckElements();
- };
-
- isCompleted = true;
- lowRuns += 8;
-
- lazyRocketsConfig.loadMode = 3;
-
- addEventListener('scroll', function(){
- if(lazyRocketsConfig.loadMode == 3){
- lazyRocketsConfig.loadMode = 2;
- }
- clearTimeout(scrollTimer);
- scrollTimer = setTimeout(afterScroll, 99);
- }, true);
- };
-
- return {
- _: function(){
-
- lazyloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass);
- preloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass + ' ' + lazyRocketsConfig.preloadClass);
-
- /*lazyloadElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- preloadElems = document.querySelectorAll('[data-lazy-src].' + lazyRocketsConfig.preloadClass + ', [data-lazy-original].' + lazyRocketsConfig.preloadClass);*/
-
- defaultExpand = lazyRocketsConfig.expand;
- preloadExpand = Math.round(defaultExpand * lazyRocketsConfig.expFactor);
-
- addEventListener('scroll', throttledCheckElements, true);
-
- addEventListener('resize', throttledCheckElements, true);
-
- if(window.MutationObserver){
- new MutationObserver( prepareThrottledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', prepareThrottledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', prepareThrottledCheckElements, true);
- setInterval(prepareThrottledCheckElements, 999);
- }
-
- addEventListener('hashchange', prepareThrottledCheckElements, true);
-
- /*if(window.MutationObserver){
- new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', throttledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', throttledCheckElements, true);
- setInterval(throttledCheckElements, 999);
- }
-
- addEventListener('hashchange', throttledCheckElements, true);*/
-
- ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend', 'webkitAnimationEnd'].forEach(function(name){
- document.addEventListener(name, throttledCheckElements, true);
- });
-
- if(!(isCompleted = /d$|^c/.test(document.readyState))){
- addEventListener('load', onload);
- document.addEventListener('DOMContentLoaded', throttledCheckElements);
- } else {
- onload();
- }
-
- throttledCheckElements(lazyloadElems.length > 0);
- },
- checkElems: throttledCheckElements,
- unveil: unveilElement
- };
- })();
-
- var init = function(){
- if(!init.i){
- init.i = true;
- loader._();
- }
- };
-
- (function(){
- var prop;
- var lazyRocketsDefaults = {
- lazyClass: 'lazyload',
- loadedClass: 'lazyloaded',
- loadingClass: 'lazyloading',
- preloadClass: 'lazypreload',
- errorClass: 'lazyerror',
- autosizesClass: 'lazyautosizes',
- //srcAttr: 'data-src',
- //srcsetAttr: 'data-srcset',
- //sizesAttr: 'data-sizes',
- //minSize: 40,
- //customMedia: {},
- init: true,
- expFactor: 2,
- expand: 359,
- loadMode: 2,
- throttle: 99
- };
-
- lazyRocketsConfig = window.lazyRocketsConfig || window.lazyRocketsConfig || {};
-
- for(prop in lazyRocketsDefaults){
- if(!(prop in lazyRocketsConfig)){
- lazyRocketsConfig[prop] = lazyRocketsDefaults[prop];
- }
- }
-
- window.lazyRocketsConfig = lazyRocketsConfig;
-
- setTimeout(function(){
- if(lazyRocketsConfig.init){
-
- var tmpElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- for (var i = 0; i < tmpElems.length; i++) {
- addClass(tmpElems[i], lazyRocketsConfig.lazyClass);
- };
-
- init();
- }
- });
- })();
-
- return {
- cfg: lazyRocketsConfig,
- loader: loader,
- init: init,
- uP: updatePolyfill,
- aC: addClass,
- rC: removeClass,
- hC: hasClass,
- fire: triggerEvent
- };
-})(window, document);
diff --git a/inc/front/js/lazyload.1.0.1.min.js b/inc/front/js/lazyload.1.0.1.min.js
deleted file mode 100755
index f017ed2a35..0000000000
--- a/inc/front/js/lazyload.1.0.1.min.js
+++ /dev/null
@@ -1,9 +0,0 @@
-(function(d,g){var c,M=g.documentElement,h=d.addEventListener,p=d.setTimeout,R=d.requestAnimationFrame||p,V=/^picture$/i,N=["load","error","lazyincluded","_lazyloaded"],G=function(a,e){var c=new RegExp("(\\s|^)"+e+"(\\s|$)");return a.className.match(c)&&c},m=function(a,e){G(a,e)||(a.className+=" "+e)},O=function(a,e){var c;if(c=G(a,e))a.className=a.className.replace(c," ")},C=function(a,c,f){var l=f?"addEventListener":"removeEventListener";f&&C(a,c);N.forEach(function(f){a[l](f,c)})},S=function(a,
-c,f,l,d){var k=g.createEvent("CustomEvent");k.initCustomEvent(c,!l,!d,f);k.details=k.detail;a.dispatchEvent(k);return k},T=function(a,e){var f;d.HTMLPictureElement||((f=d.picturefill||d.respimage||c.pf)?f({reevaluate:!0,reparse:!0,elements:[a]}):e&&e.src&&(a.src=e.src))},E=function(a){a=g.querySelectorAll("[data-lazy-src]:not(.lazyload),[data-lazy-original]:not(.lazyload)");for(var e=0;ed&&(d=4);!0===a?m():p(m,d)}}},L=function(){var a,e,f,l,D,k,x,y,z,A,B,H,P,L=/^img$/i,N=/^iframe$/i,X="onscroll"in d&&!/glebot/.test(navigator.userAgent),F=0,v=0,u=0,I=function(b){u--;b&&b.target&&C(b.target,I);if(!b||0>u||!b.target)u=0},n=W(function(){var b,t,d,l,g,q,m,J,n;if((D=c.loadMode)&&8>u&&(b=a.length)){t=0;v++;Fu&&4=m&&(y=d.top)<=x&&(A=d.right)>=m&&(z=d.left)<=k&&(B||A||z||y))&&!(r=f&&3>u&&4>v&&!J&&2p.left&&zp.top-1&&yu&&4>v&&2 0);
-
- if(visible && getCSS(parent, 'overflow') != 'visible'){
- outerRect = parent.getBoundingClientRect();
- visible = eLright > outerRect.left &&
- eLleft < outerRect.right &&
- eLbottom > outerRect.top - 1 &&
- eLtop < outerRect.bottom + 1
- ;
- }
- }
-
- return visible;
- };
-
- var checkElements = function() {
- var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal;
-
- if((loadMode = lazyRocketsConfig.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
-
- i = 0;
-
- lowRuns++;
-
- if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 4 && loadMode > 2){
- currentExpand = preloadExpand;
- lowRuns = 0;
- } else if(currentExpand != defaultExpand && loadMode > 1 && lowRuns > 3){
- currentExpand = defaultExpand;
- } else {
- currentExpand = shrinkExpand;
- }
-
- for(; i < eLlen; i++){
-
- if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
-
- if(!supportScroll){unveilElement(lazyloadElems[i]);continue;}
-
- if(!(elemExpandVal = lazyloadElems[i].getAttribute('data-expand')) || !(elemExpand = elemExpandVal * 1)){
- elemExpand = currentExpand;
- }
-
- if(beforeExpandVal !== elemExpand){
- eLvW = innerWidth + elemExpand;
- elvH = innerHeight + elemExpand;
- elemNegativeExpand = elemExpand * -1;
- beforeExpandVal = elemExpand;
- }
-
- rect = lazyloadElems[i].getBoundingClientRect();
-
- if ((eLbottom = rect.bottom) >= elemNegativeExpand &&
- (eLtop = rect.top) <= elvH &&
- (eLright = rect.right) >= elemNegativeExpand &&
- (eLleft = rect.left) <= eLvW &&
- (eLbottom || eLright || eLleft || eLtop) &&
- ((isCompleted && isLoading < 3 && lowRuns < 4 && !elemExpandVal && loadMode > 2) || isNestedVisible(lazyloadElems[i], elemExpand))){
- unveilElement(lazyloadElems[i], false, rect.width);
- loadedSomething = true;
- } else if(!loadedSomething && isCompleted && !autoLoadElem &&
- isLoading < 3 && lowRuns < 4 && loadMode > 2 &&
- (preloadElems[0] || lazyRocketsConfig.preloadAfterLoad) &&
- (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) /*|| lazyloadElems[i].getAttribute(lazyRocketsConfig.sizesAttr) != 'auto'*/)))){
- autoLoadElem = preloadElems[0] || lazyloadElems[i];
- }
- }
-
- if(autoLoadElem && !loadedSomething){
- unveilElement(autoLoadElem);
- }
- }
- };
-
- var throttledCheckElements = throttle(checkElements);
-
- var switchLoadingClass = function(e){
- addClass(e.target, lazyRocketsConfig.loadedClass);
- removeClass(e.target, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(e.target, switchLoadingClass);
- };
-
- var changeIframeSrc = function(elem, src){
- if(elem.getAttribute('src') != src){
- /*try {
- elem.contentWindow.location.replace(src);
- } catch(e){*/
- elem.setAttribute('src', src);
- //}
- }
- };
-
- var rafBatch = (function(){
- var isRunning;
- var batch = [];
- var runBatch = function(){
- while(batch.length){
- (batch.shift())();
- }
- isRunning = false;
- };
- return function(fn){
- batch.push(fn);
- if(!isRunning){
- isRunning = true;
- rAF(runBatch);
- }
- };
- })();
-
- var unveilElement = function (elem, force, width){
- var sources, i, len, sourceSrcset, src, srcset, parent, isPicture, event, firesLoad, customMedia;
-
- var curSrc = elem.currentSrc || elem.src;
- var isImg = regImg.test(elem.nodeName);
-
- var sizes = null;
- var isAuto = sizes == 'auto';
-
- if( (isAuto || !isCompleted) && isImg && curSrc && !elem.complete && !hasClass(elem, lazyRocketsConfig.errorClass)){return;}
-
- elem._lazyRace = true;
- isLoading++;
-
- rafBatch(function lazyUnveil(){
-
- if(elem._lazyRace){
- delete elem._lazyRace;
- }
-
- removeClass(elem, lazyRocketsConfig.lazyClass);
-
- if(!(event = triggerEvent(elem, 'lazybeforeunveil', {force: !!force})).defaultPrevented){
-
- /*if(sizes){
- if(isAuto){*/
- //addClass(elem, lazyRocketsConfig.autosizesClass);
- //} else {
- //elem.setAttribute('sizes', sizes);
- //}
- //}
-
- //srcset = elem.getAttribute(lazyRocketsConfig.srcsetAttr);
- srcset = null;
-
- src = elem.getAttribute('data-lazy-src') || elem.getAttribute('data-lazy-original');
-
- if(isImg) {
- parent = elem.parentNode;
- isPicture = parent && regPicture.test(parent.nodeName || '');
- }
-
- firesLoad = event.detail.firesLoad || (('src' in elem) && (srcset || src || isPicture));
-
- event = {target: elem};
-
- if(firesLoad){
- addRemoveLoadEvents(elem, resetPreloading, true);
- clearTimeout(resetPreloadingTimer);
- resetPreloadingTimer = setTimeout(resetPreloading, 2500);
-
- addClass(elem, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(elem, switchLoadingClass, true);
- }
-
- /*if(isPicture){
- sources = parent.getElementsByTagName('source');
- for(i = 0, len = sources.length; i < len; i++){
- if( (customMedia = lazyRocketsConfig.customMedia[sources[i].getAttribute('data-media') || sources[i].getAttribute('media')]) ){
- sources[i].setAttribute('media', customMedia);
- }
- sourceSrcset = sources[i].getAttribute(lazyRocketsConfig.srcsetAttr);
- if(sourceSrcset){
- sources[i].setAttribute('srcset', sourceSrcset);
- }
- }
- }*/
-
- if(src){
- if(regIframe.test(elem.nodeName)){
- changeIframeSrc(elem, src);
- } else {
- elem.setAttribute('src', src);
- }
- }
-
- if(isPicture){
- updatePolyfill(elem, {src: src});
- }
- }
-
- if( !firesLoad || (elem.complete && curSrc == (elem.currentSrc || elem.src)) ){
- if(firesLoad){
- resetPreloading(event);
- } else {
- isLoading--;
- }
- switchLoadingClass(event);
- }
- });
- };
-
- var onload = function(){
- var scrollTimer;
- var afterScroll = function(){
- lazyRocketsConfig.loadMode = 3;
- throttledCheckElements();
- };
-
- isCompleted = true;
- lowRuns += 8;
-
- lazyRocketsConfig.loadMode = 3;
-
- addEventListener('scroll', function(){
- if(lazyRocketsConfig.loadMode == 3){
- lazyRocketsConfig.loadMode = 2;
- }
- clearTimeout(scrollTimer);
- scrollTimer = setTimeout(afterScroll, 99);
- }, true);
- };
-
- return {
- _: function(){
-
- lazyloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass);
- preloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass + ' ' + lazyRocketsConfig.preloadClass);
-
- /*lazyloadElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- preloadElems = document.querySelectorAll('[data-lazy-src].' + lazyRocketsConfig.preloadClass + ', [data-lazy-original].' + lazyRocketsConfig.preloadClass);*/
-
- defaultExpand = lazyRocketsConfig.expand;
- preloadExpand = Math.round(defaultExpand * lazyRocketsConfig.expFactor);
-
- addEventListener('scroll', throttledCheckElements, true);
-
- addEventListener('resize', throttledCheckElements, true);
-
- if(window.MutationObserver){
- new MutationObserver( prepareThrottledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
-
- new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', prepareThrottledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', prepareThrottledCheckElements, true);
- setInterval(prepareThrottledCheckElements, 999);
-
- docElem.addEventListener('DOMNodeInserted', throttledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', throttledCheckElements, true);
- setInterval(throttledCheckElements, 999);
- }
-
- addEventListener('hashchange', prepareThrottledCheckElements, true);
-
- /*if(window.MutationObserver){
- new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', throttledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', throttledCheckElements, true);
- setInterval(throttledCheckElements, 999);
- }
-
- addEventListener('hashchange', throttledCheckElements, true);*/
-
- ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend', 'webkitAnimationEnd'].forEach(function(name){
- document.addEventListener(name, throttledCheckElements, true);
- });
-
- if(!(isCompleted = /d$|^c/.test(document.readyState))){
- addEventListener('load', onload);
- document.addEventListener('DOMContentLoaded', throttledCheckElements);
- } else {
- onload();
- }
-
- throttledCheckElements(lazyloadElems.length > 0);
- },
- checkElems: throttledCheckElements,
- unveil: unveilElement
- };
- })();
-
- var init = function(){
- if(!init.i){
- init.i = true;
- loader._();
- }
- };
-
- (function(){
- var prop;
- var lazyRocketsDefaults = {
- lazyClass: 'lazyload',
- loadedClass: 'lazyloaded',
- loadingClass: 'lazyloading',
- preloadClass: 'lazypreload',
- errorClass: 'lazyerror',
- autosizesClass: 'lazyautosizes',
- //srcAttr: 'data-src',
- //srcsetAttr: 'data-srcset',
- //sizesAttr: 'data-sizes',
- //minSize: 40,
- //customMedia: {},
- init: true,
- expFactor: 2,
- expand: 359,
- loadMode: 2,
- throttle: 99
- };
-
- lazyRocketsConfig = window.lazyRocketsConfig || window.lazyRocketsConfig || {};
-
- for(prop in lazyRocketsDefaults){
- if(!(prop in lazyRocketsConfig)){
- lazyRocketsConfig[prop] = lazyRocketsDefaults[prop];
- }
- }
-
- window.lazyRocketsConfig = lazyRocketsConfig;
-
- setTimeout(function(){
- if(lazyRocketsConfig.init){
-
- var tmpElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- for (var i = 0; i < tmpElems.length; i++) {
- addClass(tmpElems[i], lazyRocketsConfig.lazyClass);
- };
-
- init();
- }
- });
- })();
-
- return {
- cfg: lazyRocketsConfig,
- loader: loader,
- init: init,
- uP: updatePolyfill,
- aC: addClass,
- rC: removeClass,
- hC: hasClass,
- fire: triggerEvent
- };
-})(window, document);
diff --git a/inc/front/js/lazyload.1.0.2.min.js b/inc/front/js/lazyload.1.0.2.min.js
deleted file mode 100644
index 00266ba2a9..0000000000
--- a/inc/front/js/lazyload.1.0.2.min.js
+++ /dev/null
@@ -1,10 +0,0 @@
-(function(e,h){var d,f=h.documentElement,k=e.addEventListener,t=e.setTimeout,Q=e.requestAnimationFrame||t,U=/^picture$/i,M=["load","error","lazyincluded","_lazyloaded"],H=function(a,c){return a.className.match(c)},q=function(a,c){H(a,c)||(a.className+=" "+c)},N=function(a,c){var d;if(d=H(a,c))a.className=a.className.replace(d," ")},D=function(a,c,d){var l=d?"addEventListener":"removeEventListener";d&&D(a,c);M.forEach(function(d){a[l](d,c)})},R=function(a,d,m,l,e){var n=h.createEvent("CustomEvent");
-n.initCustomEvent(d,!l,!e,m);n.details=n.detail;a.dispatchEvent(n);return n},S=function(a,c){var m;e.HTMLPictureElement||((m=e.picturefill||e.respimage||d.pf)?m({reevaluate:!0,reparse:!0,elements:[a]}):c&&c.src&&(a.src=c.src))},F=function(a){a=h.querySelectorAll("[data-lazy-src]:not(.lazyload),[data-lazy-original]:not(.lazyload)");for(var c=0;ce&&(e=4);!0===a?f():t(f,e)}}},L=function(){var a,c,m,l,E,n,y,z,A,B,C,I,O,L=/^img$/i,M=/^iframe$/i,W="onscroll"in e&&!/glebot/.test(navigator.userAgent),G=0,v=0,u=0,J=function(b){u--;b&&b.target&&D(b.target,J);if(!b||0>u||!b.target)u=0},g=V(function(){var b,r,e,l,h,w,g,f,t;if((E=d.loadMode)&&8>u&&(b=a.length)){r=0;v++;Gu&&4=g&&(z=e.top)<=y&&(B=e.right)>=g&&(A=e.left)<=n&&(C||B||A||z))&&!(p=m&&3>u&&4>v&&!f&&2k.left&&Ak.top-1&&zu&&4>v&&2 0);
-
- if(visible && getCSS(parent, 'overflow') != 'visible'){
- outerRect = parent.getBoundingClientRect();
- visible = eLright > outerRect.left &&
- eLleft < outerRect.right &&
- eLbottom > outerRect.top - 1 &&
- eLtop < outerRect.bottom + 1
- ;
- }
- }
-
- return visible;
- };
-
- var checkElements = function() {
- var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal;
-
- if((loadMode = lazyRocketsConfig.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)){
-
- i = 0;
-
- lowRuns++;
-
- if(currentExpand < preloadExpand && isLoading < 1 && lowRuns > 4 && loadMode > 2){
- currentExpand = preloadExpand;
- lowRuns = 0;
- } else if(currentExpand != defaultExpand && loadMode > 1 && lowRuns > 3){
- currentExpand = defaultExpand;
- } else {
- currentExpand = shrinkExpand;
- }
-
- for(; i < eLlen; i++){
-
- if(!lazyloadElems[i] || lazyloadElems[i]._lazyRace){continue;}
-
- if(!supportScroll){unveilElement(lazyloadElems[i]);continue;}
-
- if(!(elemExpandVal = lazyloadElems[i].getAttribute('data-expand')) || !(elemExpand = elemExpandVal * 1)){
- elemExpand = currentExpand;
- }
-
- if(beforeExpandVal !== elemExpand){
- eLvW = innerWidth + elemExpand;
- elvH = innerHeight + elemExpand;
- elemNegativeExpand = elemExpand * -1;
- beforeExpandVal = elemExpand;
- }
-
- rect = lazyloadElems[i].getBoundingClientRect();
-
- if ((eLbottom = rect.bottom) >= elemNegativeExpand &&
- (eLtop = rect.top) <= elvH &&
- (eLright = rect.right) >= elemNegativeExpand &&
- (eLleft = rect.left) <= eLvW &&
- (eLbottom || eLright || eLleft || eLtop) &&
- ((isCompleted && isLoading < 3 && lowRuns < 4 && !elemExpandVal && loadMode > 2) || isNestedVisible(lazyloadElems[i], elemExpand))){
- unveilElement(lazyloadElems[i], false, rect.width);
- loadedSomething = true;
- } else if(!loadedSomething && isCompleted && !autoLoadElem &&
- isLoading < 3 && lowRuns < 4 && loadMode > 2 &&
- (preloadElems[0] || lazyRocketsConfig.preloadAfterLoad) &&
- (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) /*|| lazyloadElems[i].getAttribute(lazyRocketsConfig.sizesAttr) != 'auto'*/)))){
- autoLoadElem = preloadElems[0] || lazyloadElems[i];
- }
- }
-
- if(autoLoadElem && !loadedSomething){
- unveilElement(autoLoadElem);
- }
- }
- };
-
- var throttledCheckElements = throttle(checkElements);
-
- var switchLoadingClass = function(e){
- addClass(e.target, lazyRocketsConfig.loadedClass);
- removeClass(e.target, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(e.target, switchLoadingClass);
- };
-
- var changeIframeSrc = function(elem, src){
- if(elem.getAttribute('src') != src){
- /*try {
- elem.contentWindow.location.replace(src);
- } catch(e){*/
- elem.setAttribute('src', src);
- //}
- }
- };
-
- var rafBatch = (function(){
- var isRunning;
- var batch = [];
- var runBatch = function(){
- while(batch.length){
- (batch.shift())();
- }
- isRunning = false;
- };
- return function(fn){
- batch.push(fn);
- if(!isRunning){
- isRunning = true;
- rAF(runBatch);
- }
- };
- })();
-
- var unveilElement = function (elem, force, width){
- var sources, i, len, sourceSrcset, src, srcset, parent, isPicture, event, firesLoad, customMedia;
-
- var curSrc = elem.currentSrc || elem.src;
- var isImg = regImg.test(elem.nodeName);
-
- var sizes = null;
- var isAuto = sizes == 'auto';
-
- if( (isAuto || !isCompleted) && isImg && curSrc && !elem.complete && !hasClass(elem, lazyRocketsConfig.errorClass)){return;}
-
- elem._lazyRace = true;
- isLoading++;
-
- rafBatch(function lazyUnveil(){
-
- if(elem._lazyRace){
- delete elem._lazyRace;
- }
-
- removeClass(elem, lazyRocketsConfig.lazyClass);
-
- if(!(event = triggerEvent(elem, 'lazybeforeunveil', {force: !!force})).defaultPrevented){
-
- /*if(sizes){
- if(isAuto){*/
- //addClass(elem, lazyRocketsConfig.autosizesClass);
- //} else {
- //elem.setAttribute('sizes', sizes);
- //}
- //}
-
- srcset = elem.getAttribute('data-lazy-srcset');
- //srcset = null;
-
- src = elem.getAttribute('data-lazy-src') || elem.getAttribute('data-lazy-original');
-
- if(isImg) {
- parent = elem.parentNode;
- isPicture = parent && regPicture.test(parent.nodeName || '');
- }
-
- firesLoad = event.detail.firesLoad || (('src' in elem) && (srcset || src || isPicture));
-
- event = {target: elem};
-
- if(firesLoad){
- addRemoveLoadEvents(elem, resetPreloading, true);
- clearTimeout(resetPreloadingTimer);
- resetPreloadingTimer = setTimeout(resetPreloading, 2500);
-
- addClass(elem, lazyRocketsConfig.loadingClass);
- addRemoveLoadEvents(elem, switchLoadingClass, true);
- }
-
- /*if(isPicture){
- sources = parent.getElementsByTagName('source');
- for(i = 0, len = sources.length; i < len; i++){
- if( (customMedia = lazyRocketsConfig.customMedia[sources[i].getAttribute('data-media') || sources[i].getAttribute('media')]) ){
- sources[i].setAttribute('media', customMedia);
- }
- sourceSrcset = sources[i].getAttribute(lazyRocketsConfig.srcsetAttr);
- if(sourceSrcset){
- sources[i].setAttribute('srcset', sourceSrcset);
- }
- }
- }*/
- if(srcset){
- elem.setAttribute('srcset', srcset);
- }
- if(src){
- if(regIframe.test(elem.nodeName)){
- changeIframeSrc(elem, src);
- } else {
- elem.setAttribute('src', src);
- }
- }
-
- if(isPicture){
- updatePolyfill(elem, {src: src});
- }
- }
-
- if( !firesLoad || (elem.complete && curSrc == (elem.currentSrc || elem.src)) ){
- if(firesLoad){
- resetPreloading(event);
- } else {
- isLoading--;
- }
- switchLoadingClass(event);
- }
- });
- };
-
- var onload = function(){
- var scrollTimer;
- var afterScroll = function(){
- lazyRocketsConfig.loadMode = 3;
- throttledCheckElements();
- };
-
- isCompleted = true;
- lowRuns += 8;
-
- lazyRocketsConfig.loadMode = 3;
-
- addEventListener('scroll', function(){
- if(lazyRocketsConfig.loadMode == 3){
- lazyRocketsConfig.loadMode = 2;
- }
- clearTimeout(scrollTimer);
- scrollTimer = setTimeout(afterScroll, 99);
- }, true);
- };
-
- return {
- _: function(){
-
- lazyloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass);
- preloadElems = document.getElementsByClassName(lazyRocketsConfig.lazyClass + ' ' + lazyRocketsConfig.preloadClass);
-
- /*lazyloadElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- preloadElems = document.querySelectorAll('[data-lazy-src].' + lazyRocketsConfig.preloadClass + ', [data-lazy-original].' + lazyRocketsConfig.preloadClass);*/
-
- defaultExpand = lazyRocketsConfig.expand;
- preloadExpand = Math.round(defaultExpand * lazyRocketsConfig.expFactor);
-
- addEventListener('scroll', throttledCheckElements, true);
- addEventListener('resize', throttledCheckElements, true);
-
- if(window.MutationObserver){
- new MutationObserver( prepareThrottledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
-
- new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', prepareThrottledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', prepareThrottledCheckElements, true);
- setInterval(prepareThrottledCheckElements, 999);
-
- docElem.addEventListener('DOMNodeInserted', throttledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', throttledCheckElements, true);
- setInterval(throttledCheckElements, 999);
- }
-
- addEventListener('hashchange', prepareThrottledCheckElements, true);
-
- /*if(window.MutationObserver){
- new MutationObserver( throttledCheckElements ).observe( docElem, {childList: true, subtree: true, attributes: true} );
- } else {
- docElem.addEventListener('DOMNodeInserted', throttledCheckElements, true);
- docElem.addEventListener('DOMAttrModified', throttledCheckElements, true);
- setInterval(throttledCheckElements, 999);
- }
-
- addEventListener('hashchange', throttledCheckElements, true);*/
-
- ['focus', 'mouseover', 'click', 'load', 'transitionend', 'animationend', 'webkitAnimationEnd'].forEach(function(name){
- document.addEventListener(name, throttledCheckElements, true);
- });
-
- if(!(isCompleted = /d$|^c/.test(document.readyState))){
- addEventListener('load', onload);
- document.addEventListener('DOMContentLoaded', throttledCheckElements);
- } else {
- onload();
- }
-
- throttledCheckElements(lazyloadElems.length > 0);
- },
- checkElems: throttledCheckElements,
- unveil: unveilElement
- };
- })();
-
- var init = function(){
- if(!init.i){
- init.i = true;
- loader._();
- }
- };
-
- (function(){
- var prop;
- var lazyRocketsDefaults = {
- lazyClass: 'lazyload',
- loadedClass: 'lazyloaded',
- loadingClass: 'lazyloading',
- preloadClass: 'lazypreload',
- errorClass: 'lazyerror',
- autosizesClass: 'lazyautosizes',
- //srcAttr: 'data-src',
- //srcsetAttr: 'data-srcset',
- //sizesAttr: 'data-sizes',
- //minSize: 40,
- //customMedia: {},
- init: true,
- expFactor: 2,
- expand: 359,
- loadMode: 2,
- throttle: 99
- };
-
- lazyRocketsConfig = window.lazyRocketsConfig || window.lazyRocketsConfig || {};
-
- for(prop in lazyRocketsDefaults){
- if(!(prop in lazyRocketsConfig)){
- lazyRocketsConfig[prop] = lazyRocketsDefaults[prop];
- }
- }
-
- window.lazyRocketsConfig = lazyRocketsConfig;
-
- setTimeout(function(){
- if(lazyRocketsConfig.init){
-
- var tmpElems = document.querySelectorAll('[data-lazy-src],[data-lazy-original]');
- for (var i = 0; i < tmpElems.length; i++) {
- addClass(tmpElems[i], lazyRocketsConfig.lazyClass);
- };
-
- init();
- }
- });
- })();
-
- return {
- cfg: lazyRocketsConfig,
- loader: loader,
- init: init,
- uP: updatePolyfill,
- aC: addClass,
- rC: removeClass,
- hC: hasClass,
- fire: triggerEvent
- };
-})(window, document);
diff --git a/inc/front/js/lazyload.1.0.4.min.js b/inc/front/js/lazyload.1.0.4.min.js
deleted file mode 100644
index eee08f2f19..0000000000
--- a/inc/front/js/lazyload.1.0.4.min.js
+++ /dev/null
@@ -1,10 +0,0 @@
-(function(e,g){var d,h=g.documentElement,A=e.addEventListener,p=e.setTimeout,R=e.requestAnimationFrame||p,W=/^picture$/i,N=["load","error","lazyincluded","_lazyloaded"],H=function(a,c){return a.className.match(c)},B=function(a,c){H(a,c)||(a.className+=" "+c)},O=function(a,c){var d;if(d=H(a,c))a.className=a.className.replace(d," ")},C=function(a,c,d){var l=d?"addEventListener":"removeEventListener";d&&C(a,c);N.forEach(function(d){a[l](d,c)})},S=function(a,d,m,l,e){var k=g.createEvent("CustomEvent");
-k.initCustomEvent(d,!l,!e,m);k.details=k.detail;a.dispatchEvent(k);return k},T=function(a,c){var m;e.HTMLPictureElement||((m=e.picturefill||e.respimage||d.pf)?m({reevaluate:!0,reparse:!0,elements:[a]}):c&&c.src&&(a.src=c.src))},E=function(a){a=g.querySelectorAll("[data-lazy-src]:not(.lazyload),[data-lazy-original]:not(.lazyload)");for(var c=0;ce&&(e=4);!0===a?h():p(h,e)}}},M=function(){var a,c,m,l,D,k,v,w,x,y,z,I,P,M=/^img$/i,N=/^iframe$/i,Y="onscroll"in e&&!/glebot/.test(navigator.userAgent),F=0,n=0,u=0,J=function(b){u--;b&&b.target&&C(b.target,J);if(!b||0>u||!b.target)u=0},f=X(function(){var b,r,e,l,g,f,h,K,U;if((D=d.loadMode)&&8>u&&(b=a.length)){r=0;n++;Fu&&4=h&&(w=e.top)<=v&&(y=e.right)>=h&&(x=e.left)<=k&&(z||y||x||w))&&!(q=m&&3>u&&4>n&&!K&&2G.left&&xG.top-1&&wu&&4>n&&2d&&(d=4);!0===b?k():u(k,d)}}},K=function(){var b,e,f,l,B,m,t,v,
-w,x,y,G,O,K=/^img$/i,M=/^iframe$/i,W="onscroll"in d&&!/glebot/.test(navigator.userAgent),C=0,p=0,r=0,H=function(a){r--;a&&a.target&&A(a.target,H);if(!a||0>r||!a.target)r=0},g=V(function(){var a,d,l,I,g,q,h,k;if((B=c.loadMode)&&8>r&&(a=b.length)){d=0;p++;Cr&&4=h&&(v=l.top)<=t&&(x=l.right)>=h&&(w=l.left)<=
-m&&(y||x||w||v))&&!(n=f&&3>r&&4>p&&!0&&2D.left&&wD.top-1&&vr&&4>p&&2window.lazyLoadOptions = {
+ elements_selector: "img, iframe",
+ data_src: "lazy-src",
+ data_srcset: "lazy-srcset",
+ class_loading: "lazyloading",
+ class_loaded: "lazyloaded",
+ threshold: $threshold,
+ callback_load: function(element) {
+ if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
+ if (element.classList.contains("lazyloaded") ) {
+ if (typeof window.jQuery != 'undefined') {
+ if (jQuery.fn.fitVids) {
+ jQuery(element).parent().fitVids();
+ }
+ }
+ }
+ }
+ }
+ };
+HTML;
+
+ if ( get_rocket_option( 'lazyload_youtube' ) ) {
+ echo <<function lazyLoadThumb(e){var t='',a='';return t.replace("ID",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement("iframe"),t="https://www.youtube.com/embed/ID?autoplay=1";e.setAttribute("src",t.replace("ID",this.dataset.id)),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","1"),this.parentNode.replaceChild(e,this)}document.addEventListener("DOMContentLoaded",function(){var e,t,a=document.getElementsByClassName("rll-youtube-player");for(t=0;t
+HTML;
+ }
+}
+add_action( 'wp_footer', 'rocket_lazyload_script', 9 );
+
+/**
+ * Enqueue the lazyload script
+ *
+ * @since 2.11
+ * @author Remy Perona
+ */
+function rocket_lazyload_enqueue() {
+ if ( ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) ) {
+ return;
+ }
+
if ( ( ! get_rocket_option( 'lazyload' ) && ! get_rocket_option( 'lazyload_iframes' ) ) || ( ! apply_filters( 'do_rocket_lazyload', true ) && ! apply_filters( 'do_rocket_lazyload_iframes', true ) ) ) {
return;
}
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
- $lazyload_url = get_rocket_cdn_url( WP_ROCKET_FRONT_JS_URL . 'lazyload.' . WP_ROCKET_LAZYLOAD_JS_VERSION . $suffix . '.js', array( 'all', 'css_and_js', 'js' ) );
+ $lazyload_url = get_rocket_cdn_url( WP_ROCKET_FRONT_JS_URL . 'lazyload-' . WP_ROCKET_LAZYLOAD_JS_VERSION . $suffix . '.js', array( 'all', 'css_and_js', 'js' ) );
+
+ wp_enqueue_script( 'rocket-lazyload', $lazyload_url, null, null, true );
+
+ if ( get_rocket_option( 'lazyload_youtube' ) ) {
+ $css = '.rll-youtube-player{position:relative;padding-bottom:56.23%;height:0;overflow:hidden;max-width:100%;background:#000;margin:5px}.rll-youtube-player iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;background:0 0}.rll-youtube-player img{bottom:0;display:block;left:0;margin:auto;max-width:100%;width:100%;position:absolute;right:0;top:0;border:none;height:auto;cursor:pointer;-webkit-transition:.4s all;-moz-transition:.4s all;transition:.4s all}.rll-youtube-player img:hover{-webkit-filter:brightness(75%)}.rll-youtube-player .play{height:72px;width:72px;left:50%;top:50%;margin-left:-36px;margin-top:-36px;position:absolute;background:url(' . WP_ROCKET_FRONT_URL . 'img/play.png) no-repeat;cursor:pointer}';
+
+ wp_register_style( 'rocket-lazyload', false );
+ wp_enqueue_style( 'rocket-lazyload' );
+ wp_add_inline_style( 'rocket-lazyload', $css );
+ }
+}
+add_action( 'wp_enqueue_scripts', 'rocket_lazyload_enqueue', PHP_INT_MAX );
+
+/**
+ * Add tags to the lazyload script to async and prevent concatenation
+ *
+ * @since 2.11
+ * @author Remy Perona
+ *
+ * @param string $tag HTML for the script.
+ * @param string $handle Handle for the script.
+ *
+ * @return string Updated HTML
+ */
+function rocket_lazyload_async_script( $tag, $handle ) {
+ if ( 'rocket-lazyload' === $handle ) {
+ return str_replace( '';
+ return $tag;
}
-add_action( 'wp_head', 'rocket_lazyload_script', PHP_INT_MAX );
+add_filter( 'script_loader_tag', 'rocket_lazyload_async_script', 10, 2 );
/**
* Replace Gravatar, thumbnails, images in post content and in widget text by LazyLoad
@@ -37,7 +124,7 @@ function rocket_lazyload_script() {
*/
function rocket_lazyload_images( $html ) {
// Don't LazyLoad if process is stopped for these reasons.
- if ( ! get_rocket_option( 'lazyload' ) || ! apply_filters( 'do_rocket_lazyload', true ) || is_feed() || is_preview() || empty( $html ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) || wp_script_is( 'twentytwenty-twentytwenty', 'enqueued' ) ) {
+ if ( ! get_rocket_option( 'lazyload' ) || ! apply_filters( 'do_rocket_lazyload', true ) || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) || empty( $html ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) || wp_script_is( 'twentytwenty-twentytwenty', 'enqueued' ) ) {
return $html;
}
@@ -45,18 +132,18 @@ function rocket_lazyload_images( $html ) {
return $html;
}
-add_filter( 'get_avatar' , 'rocket_lazyload_images', PHP_INT_MAX );
-add_filter( 'the_content' , 'rocket_lazyload_images', PHP_INT_MAX );
-add_filter( 'widget_text' , 'rocket_lazyload_images', PHP_INT_MAX );
-add_filter( 'get_image_tag' , 'rocket_lazyload_images', PHP_INT_MAX );
-add_filter( 'post_thumbnail_html' , 'rocket_lazyload_images', PHP_INT_MAX );
+add_filter( 'get_avatar' , 'rocket_lazyload_images', PHP_INT_MAX );
+add_filter( 'the_content' , 'rocket_lazyload_images', PHP_INT_MAX );
+add_filter( 'widget_text' , 'rocket_lazyload_images', PHP_INT_MAX );
+add_filter( 'get_image_tag' , 'rocket_lazyload_images', PHP_INT_MAX );
+add_filter( 'post_thumbnail_html' , 'rocket_lazyload_images', PHP_INT_MAX );
/**
* Used to check if we have to LazyLoad this or not
*
- * @since 2.5.5 Don't apply LazyLoad on images from WP Retina x2
- * @since 2.5 Don't apply LazyLoad on all images from LayerSlider
- * @since 2.4.2 Don't apply LazyLoad on all images from Media Grid
+ * @since 2.5.5 Don't apply LazyLoad on images from WP Retina x2
+ * @since 2.5 Don't apply LazyLoad on all images from LayerSlider
+ * @since 2.4.2 Don't apply LazyLoad on all images from Media Grid
* @since 2.3.11 Don't apply LazyLoad on all images from Timthumb
* @since 2.3.10 Don't apply LazyLoad on all images from Revolution Slider & Justified Image Grid
* @since 2.3.8 Don't apply LazyLoad on captcha from Really Simple CAPTCHA
@@ -73,48 +160,106 @@ function rocket_lazyload_replace_callback( $matches ) {
}
}
- // TO DO - improve this code with a preg_match - it's ugly!!!!
- if ( strpos( $matches[1] . $matches[3], 'data-no-lazy=' ) === false && strpos( $matches[1] . $matches[3], 'data-lazy-original=' ) === false && strpos( $matches[1] . $matches[3], 'data-lazy-src=' ) === false && strpos( $matches[1] . $matches[3], 'data-lazysrc=' ) === false && strpos( $matches[1] . $matches[3], 'data-src=' ) === false && strpos( $matches[1] . $matches[3], 'data-lazyload=' ) === false && strpos( $matches[1] . $matches[3], 'data-bgposition=' ) === false && strpos( $matches[2], '/wpcf7_captcha/' ) === false && strpos( $matches[2], 'timthumb.php?src' ) === false && strpos( $matches[1] . $matches[3], 'data-envira-src=' ) === false && strpos( $matches[1] . $matches[3], 'fullurl=' ) === false && strpos( $matches[1] . $matches[3], 'lazy-slider-img=' ) === false && strpos( $matches[1] . $matches[3], 'data-srcset=' ) === false && strpos( $matches[1] . $matches[3], 'class="ls-l' ) === false && strpos( $matches[1] . $matches[3], 'class="ls-bg' ) === false ) {
+ /**
+ * Filters the attributes used to prevent lazylad from being applied
+ *
+ * @since 2.11
+ * @author Remy Perona
+ *
+ * @param array $excluded_attributes An array of excluded attributes.
+ */
+ $excluded_attributes = apply_filters(
+ 'rocket_lazyload_excluded_attributes', array(
+ 'data-no-lazy=',
+ 'data-lazy-original=',
+ 'data-lazy-src=',
+ 'data-lazysrc=',
+ 'data-lazyload=',
+ 'data-bgposition=',
+ 'data-envira-src=',
+ 'fullurl=',
+ 'lazy-slider-img=',
+ 'data-srcset=',
+ 'class="ls-l',
+ 'class="ls-bg',
+ )
+ );
- /**
- * Filter the LazyLoad placeholder on src attribute
- *
- * @since 2.6
- *
- * @param string Output that will be printed
- */
- $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=' );
+ /**
+ * Filters the src used to prevent lazylad from being applied
+ *
+ * @since 2.11
+ * @author Remy Perona
+ *
+ * @param array $excluded_src An array of excluded src.
+ */
+ $excluded_src = apply_filters(
+ 'rocket_lazyload_excluded_src', array(
+ '/wpcf7_captcha/',
+ 'timthumb.php?src',
+ )
+ );
+
+ if ( rocket_is_excluded_lazyload( $matches[1] . $matches[3], $excluded_attributes ) || rocket_is_excluded_lazyload( $matches[2], $excluded_src ) ) {
+ return $matches[0];
+ }
- $html = sprintf( '', $matches[1], $matches[2], $matches[3], $placeholder );
+ /**
+ * Filter the LazyLoad placeholder on src attribute
+ *
+ * @since 1.1
+ *
+ * @param string $placeholder Placeholder that will be printed.
+ */
+ $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=' );
- $html_noscript = sprintf( '', $matches[1], $matches[2], $matches[3] );
+ $html = sprintf( '', $matches[1], $matches[2], $matches[3], $placeholder );
- /**
- * Filter the LazyLoad HTML output on images
- *
- * @since 2.3.8
- *
- * @param string $html Output that will be printed
- */
- $html = apply_filters( 'rocket_lazyload_html', $html, true );
+ $html_noscript = sprintf( '', $matches[1], $matches[2], $matches[3] );
- return $html . $html_noscript;
- } else {
- return $matches[0];
+ /**
+ * Filter the LazyLoad HTML output
+ *
+ * @since 1.0.2
+ *
+ * @param array $html Output that will be printed
+ */
+ $html = apply_filters( 'rocket_lazyload_html', $html, true );
+
+ return $html . $html_noscript;
+}
+
+/**
+ * Determine if the current image should be excluded from lazyload
+ *
+ * @since 1.1
+ * @author Remy Perona
+ *
+ * @param string $string String to search.
+ * @param array $excluded_values Array of excluded values to search in the string.
+ * @return bool True if one of the excluded values was found, false otherwise
+ */
+function rocket_is_excluded_lazyload( $string, $excluded_values ) {
+ foreach ( $excluded_values as $excluded_value ) {
+ if ( strpos( $string, $excluded_value ) !== false ) {
+ return true;
+ }
}
+
+ return false;
}
/**
* Replace WordPress smilies by Lazy Load
*
- * @since 2.0 New system for replace smilies by Lazy Load
+ * @since 2.0 New system for replace smilies by Lazy Load
* @since 1.3.5 It's possible to exclude LazyLoad process by used do_rocket_lazyload filter
* @since 1.1.0 Don't lazy-load if the thumbnail has already been run through previously
* @since 1.0.1 Add priority of hooks at maximum later with PHP_INT_MAX
* @since 1.0
*/
function rocket_lazyload_smilies() {
- if ( ! get_rocket_option( 'lazyload' ) || ! apply_filters( 'do_rocket_lazyload', true, 'smilies' ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) ) {
+ if ( ! get_rocket_option( 'lazyload' ) || ! apply_filters( 'do_rocket_lazyload', true, 'smilies' ) || ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) ) {
return;
}
@@ -241,44 +386,70 @@ function rocket_translate_smiley( $matches ) {
*/
function rocket_lazyload_iframes( $html ) {
// Don't LazyLoad if process is stopped for these reasons.
- if ( ! get_rocket_option( 'lazyload_iframes' ) || ! apply_filters( 'do_rocket_lazyload_iframes', true ) || is_feed() || is_preview() || empty( $html ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) ) {
+ if ( ! get_rocket_option( 'lazyload_iframes' ) || ! apply_filters( 'do_rocket_lazyload_iframes', true ) || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || empty( $html ) || ( defined( 'DONOTROCKETOPTIMIZE' ) && DONOTROCKETOPTIMIZE ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) ) {
return $html;
}
$matches = array();
- preg_match_all( '/