diff --git a/inc/admin/ui/modules/cdn.php b/inc/admin/ui/modules/cdn.php
index 7a90af031e..568aed21a3 100644
--- a/inc/admin/ui/modules/cdn.php
+++ b/inc/admin/ui/modules/cdn.php
@@ -21,7 +21,7 @@
$rocket_do_cloudflare_settings[] = array(
'type' => 'helper_warning',
'name' => 'rocket_cloudflare_warning',
- 'description' => __( 'Your PHP version is lower than 5.4. Cloudflare’s integration requires PHP 5.4 or greater and therefore is not available for you currently. We recommend you contact your web host in order to upgrade to a PHP 5.6 or greater.', 'rocket' ),
+ 'description' => __( 'Your PHP version is lower than 5.4. Cloudflare’s integration requires PHP 5.4 or greater and therefore is not available for you currently. We recommend you contact your web host in order to upgrade to the latest PHP version.', 'rocket' ),
);
}
diff --git a/inc/admin/upgrader.php b/inc/admin/upgrader.php
index 97a18bc551..7db47e4950 100644
--- a/inc/admin/upgrader.php
+++ b/inc/admin/upgrader.php
@@ -25,7 +25,7 @@ function rocket_upgrader() {
rocket_renew_all_boxes( 0, array( 'rocket_warning_plugin_modification' ) );
- $options = get_option( WP_ROCKET_SLUG ); // do not use get_rocket_option() here.
+ $options = get_option( WP_ROCKET_SLUG ); // do not use get_rocket_option() here.
$options['version'] = WP_ROCKET_VERSION;
$keys = rocket_check_key();
@@ -60,11 +60,11 @@ function rocket_first_install() {
// Generate an random key for minify md5 filename.
$minify_css_key = create_rocket_uniqid();
- $minify_js_key = create_rocket_uniqid();
+ $minify_js_key = create_rocket_uniqid();
// Create Option.
add_option(
- WP_ROCKET_SLUG,
+ WP_ROCKET_SLUG,
/**
* Filters the default rocket options array
*
@@ -210,10 +210,10 @@ function rocket_new_upgrade( $wp_rocket_version, $actual_version ) {
}
// Add a value to the new CF zone_id field if the CF domain is set.
- if ( version_compare( $actual_version, '2.8.21', '<' ) && phpversion() >= '5.4' ) {
+ if ( version_compare( $actual_version, '2.8.21', '<' ) && version_compare( phpversion(), '5.4' ) >= 0 ) {
$options = get_option( WP_ROCKET_SLUG );
if ( 0 < $options['do_cloudflare'] && '' !== $options['cloudflare_domain'] ) {
- require( WP_ROCKET_ADMIN_PATH . 'compat/cf-upgrader-5.4.php' );
+ require WP_ROCKET_ADMIN_PATH . 'compat/cf-upgrader-5.4.php';
}
}
@@ -248,5 +248,30 @@ function rocket_new_upgrade( $wp_rocket_version, $actual_version ) {
rocket_clean_cache_busting();
rocket_generate_advanced_cache_file();
}
+
+ if ( version_compare( $actual_version, '2.11.2', '<' ) ) {
+ $options = get_option( WP_ROCKET_SLUG );
+ $options = is_array( $options ) ? $options : array();
+ $update = false;
+
+ if ( ! isset( $options['wl_plugin_URI'] ) || 'http://www.wp-rocket.me' === $options['wl_plugin_URI'] ) {
+ $options['wl_plugin_URI'] = 'https://wp-rocket.me';
+ $update = true;
+ }
+
+ if ( ! isset( $options['wl_author'] ) || 'WP Rocket' === $options['wl_author'] ) {
+ $options['wl_author'] = 'WP Media';
+ $update = true;
+ }
+
+ if ( ! isset( $options['wl_author_URI'] ) || 'http://www.wp-rocket.me' === $options['wl_author_URI'] ) {
+ $options['wl_author_URI'] = 'https://wp-media.me';
+ $update = true;
+ }
+
+ if ( $update ) {
+ update_option( WP_ROCKET_SLUG, $options );
+ }
+ }
}
add_action( 'wp_rocket_upgrade', 'rocket_new_upgrade', 10, 2 );
diff --git a/inc/classes/class-rocket-critical-css.php b/inc/classes/class-rocket-critical-css.php
index 82295fd8eb..7cb27170e7 100644
--- a/inc/classes/class-rocket-critical-css.php
+++ b/inc/classes/class-rocket-critical-css.php
@@ -108,7 +108,11 @@ public function init() {
*/
public function process_handler() {
$this->clean_critical_css();
- $this->process->cancel_process();
+
+ if ( method_exists( $this->process, 'cancel_process' ) ) {
+ $this->process->cancel_process();
+ }
+
$this->set_items();
foreach ( $this->items as $item ) {
@@ -172,7 +176,10 @@ public function generate_critical_css_on_activation( $old_value, $value ) {
*/
public function stop_process_on_deactivation( $old_value, $value ) {
if ( ! empty( $_POST[ WP_ROCKET_SLUG ] ) && isset( $old_value['async_css'], $value['async_css'] ) && ( $old_value['async_css'] !== $value['async_css'] ) && 0 === (int) $value['async_css'] ) {
- $this->process->cancel_process();
+ if ( method_exists( $this->process, 'cancel_process' ) ) {
+ $this->process->cancel_process();
+ }
+
delete_transient( 'rocket_critical_css_generation_process_running' );
delete_transient( 'rocket_critical_css_generation_process_complete' );
}
@@ -536,7 +543,7 @@ public function async_css( $buffer ) {
$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 );
+ $tag = str_replace( 'onload=""', 'onload="this.onload=null;this.rel=\'stylesheet\'"', $tag );
$buffer = str_replace( $tags_match[0][ $i ], $tag, $buffer );
$noscripts .= '';
@@ -619,6 +626,7 @@ public function insert_critical_css() {
/**
* Insert loadCSS script in
*
+ * @since 2.11.2 Updated loadCSS rel=preload polyfill to version 2.0.1
* @since 2.10
* @author Remy Perona
*/
@@ -671,10 +679,15 @@ public function insert_load_css() {
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
index d60a6e8d67..d427bad5a9 100644
--- a/inc/classes/class-rocket-database-optimization.php
+++ b/inc/classes/class-rocket-database-optimization.php
@@ -54,7 +54,7 @@ public function __construct() {
public static function init() {
$self = new self();
- add_action( 'init', array( $self, 'database_optimization_scheduled' ) );
+ 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' ) );
@@ -69,7 +69,9 @@ public static function init() {
* @author Remy Perona
*/
public function process_handler() {
- $this->process->cancel_process();
+ if ( method_exists( $this->process, 'cancel_process' ) ) {
+ $this->process->cancel_process();
+ }
foreach ( $this->options as $option ) {
if ( get_rocket_option( 'database_' . $option, false ) ) {
@@ -163,7 +165,7 @@ public function count_cleanup_items( $type ) {
$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();
+ $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':
@@ -259,6 +261,7 @@ public function notice_process_complete() {
* —Kris Kristofferson
*
* We shall do the same, shan’t we?
+ *
* @todo Replace $k in the printf() arguments with something nicer to read.
*/
?>
diff --git a/inc/deprecated.php b/inc/deprecated.php
index 08f81ff64b..10a3e4e5d5 100755
--- a/inc/deprecated.php
+++ b/inc/deprecated.php
@@ -422,14 +422,14 @@ function rocket_insert_deferred_js( $buffer ) {
foreach ( $tags_match[0] as $i => $tag ) {
// Strip query args.
- $url = strtok( $tags_match[1][ $i ] , '?' );
+ $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 );
+ $buffer = str_replace( $tag, $deferred_tag, $buffer );
}
}
@@ -809,7 +809,7 @@ function do_rocket_database_optimization() {
_deprecated_function( __FUNCTION__, '2.11', 'Rocket_Database_Optimisation->process_handler()' );
}
-if ( ! function_exists( 'rocket_define_donotminify_constants') ) {
+if ( ! function_exists( 'rocket_define_donotminify_constants' ) ) {
/**
* Declare and set value to DONOTMINIFYCSS & DONOTMINIFYJS constant
*
@@ -870,12 +870,12 @@ function rocket_async_css( $buffer ) {
/**
* Insert critical CSS in the
- *
+ *
* @since 2.10
* @deprecated 2.11
- * @see Rocket_Critical_CSS->insert_critical_css()
- * @author Remy Perona
- */
+ * @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()' );
}
@@ -891,3 +891,23 @@ function rocket_insert_critical_css() {
function rocket_insert_load_css() {
_deprecated_function( __FUNCTION__, '2.11', 'Rocket_Critical_CSS->insert_load_css()' );
}
+
+if ( ! function_exists( 'rocket_lazyload_async_script' ) ) {
+ /**
+ * Add tags to the lazyload script to async and prevent concatenation
+ *
+ * @since 2.11
+ * @deprecated 2.11.2
+ * @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 ) {
+ _deprecated_function( __FUNCTION__, '2.11.2' );
+
+ return $tag;
+ }
+}
diff --git a/inc/front/enqueue.php b/inc/front/enqueue.php
index 5c8c90bc01..0f9b17e0fb 100755
--- a/inc/front/enqueue.php
+++ b/inc/front/enqueue.php
@@ -23,7 +23,7 @@ function rocket_browser_cache_busting( $src ) {
return get_rocket_browser_cache_busting( $src, $current_filter );
}
-add_filter( 'style_loader_src', 'rocket_browser_cache_busting', PHP_INT_MAX );
+add_filter( 'style_loader_src', 'rocket_browser_cache_busting', PHP_INT_MAX );
add_filter( 'script_loader_src', 'rocket_browser_cache_busting', PHP_INT_MAX );
/**
@@ -190,11 +190,11 @@ function rocket_cache_dynamic_resource( $src ) {
switch ( $current_filter ) {
case 'script_loader_src':
- $extension = '.js';
+ $extension = '.js';
$minify_key = get_rocket_option( 'minify_js_key' );
break;
case 'style_loader_src':
- $extension = '.css';
+ $extension = '.css';
$minify_key = get_rocket_option( 'minify_css_key' );
break;
}
@@ -216,8 +216,8 @@ function rocket_cache_dynamic_resource( $src ) {
return $src;
}
- $relative_src = ltrim( $file['path'], '/' );
- $abspath_src = rocket_realpath( strtok( $full_src, '?' ), true, $hosts_index );
+ $relative_src = ltrim( $file['path'], '/' );
+ $abspath_src = rocket_realpath( strtok( $full_src, '?' ), true, $hosts_index );
/*
* Filters the dynamic resource cache filename
@@ -227,7 +227,7 @@ function rocket_cache_dynamic_resource( $src ) {
*
* @param string $filename filename for the cache file
*/
- $cache_dynamic_resource_filename = apply_filters( 'rocket_dynamic_resource_cache_filename', preg_replace( '/\.(php)$/', '-' . $minify_key . $extension, $relative_src ) );
+ $cache_dynamic_resource_filename = apply_filters( 'rocket_dynamic_resource_cache_filename', preg_replace( '/\.(php)$/', '-' . $minify_key . '.' . $extension, $relative_src ) );
$cache_busting_paths = rocket_get_cache_busting_paths( $cache_dynamic_resource_filename, $extension );
if ( file_exists( $cache_busting_paths['filepath'] ) && is_readable( $cache_busting_paths['filepath'] ) ) {
@@ -240,5 +240,5 @@ function rocket_cache_dynamic_resource( $src ) {
return $src;
}
}
-add_filter( 'style_loader_src', 'rocket_cache_dynamic_resource', 16 );
+add_filter( 'style_loader_src', 'rocket_cache_dynamic_resource', 16 );
add_filter( 'script_loader_src', 'rocket_cache_dynamic_resource', 16 );
diff --git a/inc/front/js/lazyload-10.3.5.js b/inc/front/js/lazyload-10.3.5.js
new file mode 100755
index 0000000000..6df7a24800
--- /dev/null
+++ b/inc/front/js/lazyload-10.3.5.js
@@ -0,0 +1,249 @@
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+(function (global, factory) {
+ (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory();
+})(this, function () {
+ 'use strict';
+
+ var defaultSettings = {
+ elements_selector: "img",
+ container: document,
+ threshold: 300,
+ data_src: "src",
+ data_srcset: "srcset",
+ class_loading: "loading",
+ class_loaded: "loaded",
+ class_error: "error",
+ callback_load: null,
+ callback_error: null,
+ callback_set: null
+ };
+
+ 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 purgeElements = function purgeElements(elements) {
+ return elements.filter(function (element) {
+ return !getData(element, "was-processed");
+ });
+ };
+
+ /* 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) {
+ if (!options.length) {
+ // Plain object
+ createInstance(classObj, options);
+ } else {
+ // Array of objects
+ for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) {
+ createInstance(classObj, optionsItem);
+ }
+ }
+ };
+
+ var setSourcesForPicture = function setSourcesForPicture(element, settings) {
+ var dataSrcSet = settings.data_srcset;
+
+ var parent = element.parentNode;
+ if (parent.tagName !== "PICTURE") {
+ return;
+ }
+ for (var i = 0, pictureChild; pictureChild = parent.children[i]; i += 1) {
+ if (pictureChild.tagName === "SOURCE") {
+ var sourceSrcset = getData(pictureChild, dataSrcSet);
+ if (sourceSrcset) {
+ pictureChild.setAttribute("srcset", sourceSrcset);
+ }
+ }
+ }
+ };
+
+ var setSources = function setSources(element, settings) {
+ var dataSrc = settings.data_src,
+ dataSrcSet = settings.data_srcset;
+
+ var tagName = element.tagName;
+ var elementSrc = getData(element, dataSrc);
+ if (tagName === "IMG") {
+ setSourcesForPicture(element, settings);
+ var imgSrcset = getData(element, dataSrcSet);
+ 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+$/, "");
+ };
+
+ var callCallback = function callCallback(callback, argument) {
+ if (callback) {
+ callback(argument);
+ }
+ };
+
+ var loadString = "load";
+ var errorString = "error";
+
+ var removeListeners = function removeListeners(element, loadHandler, errorHandler) {
+ element.removeEventListener(loadString, loadHandler);
+ element.removeEventListener(errorString, errorHandler);
+ };
+
+ var addOneShotListeners = function addOneShotListeners(element, settings) {
+ var onLoad = function onLoad(event) {
+ onEvent(event, true, settings);
+ removeListeners(element, onLoad, onError);
+ };
+ var onError = function onError(event) {
+ onEvent(event, false, settings);
+ removeListeners(element, onLoad, onError);
+ };
+ element.addEventListener(loadString, onLoad);
+ element.addEventListener(errorString, onError);
+ };
+
+ var onEvent = function onEvent(event, success, settings) {
+ var element = event.target;
+ removeClass(element, settings.class_loading);
+ addClass(element, success ? settings.class_loaded : settings.class_error); // Setting loaded or error class
+ callCallback(success ? settings.callback_load : settings.callback_error, element); // Calling loaded or error callback
+ };
+
+ var revealElement = function revealElement(element, settings) {
+ if (["IMG", "IFRAME"].indexOf(element.tagName) > -1) {
+ addOneShotListeners(element, settings);
+ addClass(element, settings.class_loading);
+ }
+ setSources(element, settings);
+ setData(element, "was-processed", true);
+ callCallback(settings.callback_set, element);
+ };
+
+ var LazyLoad = function LazyLoad(instanceSettings, elements) {
+ this._settings = _extends({}, defaultSettings, instanceSettings);
+ this._setObserver();
+ this.update(elements);
+ };
+
+ LazyLoad.prototype = {
+ _setObserver: function _setObserver() {
+ var _this = this;
+
+ if (!("IntersectionObserver" in window)) {
+ return;
+ }
+
+ var settings = this._settings;
+ var onIntersection = function onIntersection(entries) {
+ entries.forEach(function (entry) {
+ if (entry.intersectionRatio > 0) {
+ var element = entry.target;
+ revealElement(element, settings);
+ _this._observer.unobserve(element);
+ }
+ });
+ _this._elements = purgeElements(_this._elements);
+ };
+ this._observer = new IntersectionObserver(onIntersection, {
+ root: settings.container === document ? null : settings.container,
+ rootMargin: settings.threshold + "px"
+ });
+ },
+
+ update: function update(elements) {
+ var _this2 = this;
+
+ var settings = this._settings;
+ var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector);
+
+ this._elements = purgeElements(Array.prototype.slice.call(nodeSet)); // nodeset to array for IE compatibility
+ if (this._observer) {
+ this._elements.forEach(function (element) {
+ _this2._observer.observe(element);
+ });
+ return;
+ }
+ // Fallback: load all elements at once
+ this._elements.forEach(function (element) {
+ revealElement(element, settings);
+ });
+ this._elements = purgeElements(this._elements);
+ },
+
+ destroy: function destroy() {
+ var _this3 = this;
+
+ if (this._observer) {
+ purgeElements(this._elements).forEach(function (element) {
+ _this3._observer.unobserve(element);
+ });
+ this._observer = null;
+ }
+ this._elements = 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-10.3.5.min.js b/inc/front/js/lazyload-10.3.5.min.js
new file mode 100755
index 0000000000..80cac38931
--- /dev/null
+++ b/inc/front/js/lazyload-10.3.5.min.js
@@ -0,0 +1 @@
+var _extends=Object.assign||function(e){for(var t=1;t-1&&(f(e,t),c(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),u(t.callback_set,e)},m=function(t,n){this._settings=_extends({},e,t),this._setObserver(),this.update(n)};m.prototype={_setObserver:function(){var e=this;if("IntersectionObserver"in window){var t=this._settings;this._observer=new IntersectionObserver(function(n){n.forEach(function(n){if(n.intersectionRatio>0){var r=n.target;_(r,t),e._observer.unobserve(r)}}),e._elements=r(e._elements)},{root:t.container===document?null:t.container,rootMargin:t.threshold+"px"})}},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){_(e,n)}),this._elements=r(this._elements))},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var b=window.lazyLoadOptions;return b&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(m,b),m});
\ No newline at end of file
diff --git a/inc/front/lazyload.php b/inc/front/lazyload.php
index 0fa9db8521..7cdfe6f474 100755
--- a/inc/front/lazyload.php
+++ b/inc/front/lazyload.php
@@ -18,6 +18,8 @@ function rocket_lazyload_script() {
return;
}
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
+
/**
* Filters the threshold at which lazyload is triggered
*
@@ -28,27 +30,33 @@ function rocket_lazyload_script() {
*/
$threshold = apply_filters( 'rocket_lazyload_threshold', 300 );
- echo <<window.lazyLoadOptions = {
+ echo '
-HTML;
+ }
+ }; // Your options here. See "recipes" for more information about async.
+ b.appendChild(s);
+}(window, document));';
if ( get_rocket_option( 'lazyload_youtube' ) ) {
echo <<)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between.
- $stop = count( $textarr );// loop stuff.
+ $stop = count( $textarr );// loop stuff.
// Ignore proessing of specific tags.
- $tags_to_ignore = 'code|pre|style|script|textarea';
+ $tags_to_ignore = 'code|pre|style|script|textarea';
$ignore_block_element = '';
for ( $i = 0; $i < $stop; $i++ ) {
@@ -339,10 +322,10 @@ function rocket_translate_smiley( $matches ) {
}
$smiley = trim( reset( $matches ) );
- $img = $wpsmiliestrans[ $smiley ];
+ $img = $wpsmiliestrans[ $smiley ];
- $matches = array();
- $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
+ $matches = array();
+ $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
// Don't convert smilies that aren't images - they're probably emoji.
@@ -422,7 +405,7 @@ function rocket_lazyload_iframes( $html ) {
*
* @param array $html Output that will be printed.
*/
- $youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '' );
+ $youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '' );
$youtube_lazyload .= '';
$html = str_replace( $iframe[0], $youtube_lazyload, $html );
@@ -445,7 +428,7 @@ function rocket_lazyload_iframes( $html ) {
*
* @param array $html Output that will be printed.
*/
- $iframe_lazyload = apply_filters( 'rocket_lazyload_iframe_html', str_replace( $iframe[1], $placeholder . '" data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . $iframe[1], $iframe[0] ) );
+ $iframe_lazyload = apply_filters( 'rocket_lazyload_iframe_html', str_replace( $iframe[1], $placeholder . '" data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . $iframe[1], $iframe[0] ) );
$iframe_lazyload .= $iframe_noscript;
$html = str_replace( $iframe[0], $iframe_lazyload, $html );
diff --git a/inc/functions/bots.php b/inc/functions/bots.php
index 57b0bdd09d..1bb6752689 100755
--- a/inc/functions/bots.php
+++ b/inc/functions/bots.php
@@ -104,7 +104,11 @@ function run_rocket_preload_cache( $spider, $do_sitemap_preload = true ) {
if ( $do_sitemap_preload & get_rocket_option( 'sitemap_preload', false ) ) {
$rocket_background_process = $GLOBALS['rocket_sitemap_background_process'];
- $rocket_background_process->cancel_process();
+
+ if ( method_exists( $rocket_background_process, 'cancel_process' ) ) {
+ $rocket_background_process->cancel_process();
+ }
+
delete_transient( 'rocket_sitemap_preload_running' );
delete_transient( 'rocket_sitemap_preload_complete' );
run_rocket_sitemap_preload();
@@ -229,7 +233,7 @@ function rocket_process_sitemap( $sitemap_url, $urls = array() ) {
if ( $url_count > 0 ) {
for ( $i = 0; $i < $url_count; $i++ ) {
- $page_url = (string) $xml->url[ $i ]->loc;
+ $page_url = (string) $xml->url[ $i ]->loc;
$tmp_urls[] = $page_url;
}
} else {
@@ -238,7 +242,7 @@ function rocket_process_sitemap( $sitemap_url, $urls = array() ) {
if ( $sitemap_children > 0 ) {
for ( $i = 0; $i < $sitemap_children; $i++ ) {
$sub_sitemap_url = (string) $xml->sitemap[ $i ]->loc;
- $urls = rocket_process_sitemap( $sub_sitemap_url, $urls );
+ $urls = rocket_process_sitemap( $sub_sitemap_url, $urls );
}
}
}
diff --git a/inc/functions/formatting.php b/inc/functions/formatting.php
index 53bd47c660..ab47340ab4 100755
--- a/inc/functions/formatting.php
+++ b/inc/functions/formatting.php
@@ -74,7 +74,7 @@ function rocket_sanitize_xml( $file ) {
* @return string $url The URL without protocol
*/
function rocket_remove_url_protocol( $url, $no_dots = false ) {
- $url = str_replace( array( 'http://', 'https://' ) , '', $url );
+ $url = str_replace( array( 'http://', 'https://' ), '', $url );
/** This filter is documented in inc/front/htaccess.php */
if ( apply_filters( 'rocket_url_no_dots', $no_dots ) ) {
@@ -135,7 +135,7 @@ function rocket_get_domain( $url ) {
$url = rocket_add_url_protocol( trim( $url ) );
$url_array = wp_parse_url( $url );
- $host = $url_array['host'];
+ $host = $url_array['host'];
/**
* Filters the tld max range for edge cases
*
@@ -245,20 +245,26 @@ function rocket_get_cache_busting_paths( $filename, $extension ) {
*
* @param string $file File to determine realpath for.
* @param bool $absolute True to return an absolute path, false to return a relative one.
+ * @param array $hosts An array of possible hosts for the file.
* @return string Resolved file path
*/
function rocket_realpath( $file, $absolute = true, $hosts = '' ) {
if ( $absolute ) {
- $file_host = rocket_extract_url_component( $file, PHP_URL_HOST );
+ $file_components = get_rocket_parse_url( $file );
+ $site_components = get_rocket_parse_url( site_url() );
- if ( isset( $hosts[ $file_host ] ) && 'home' !== $hosts[ $file_host ] ) {
- $site_url = trailingslashit( rocket_add_url_protocol( $file_host ) );
+ if ( isset( $hosts[ $file_components['host'] ] ) && 'home' !== $hosts[ $file_components['host'] ] ) {
+ $site_url = trailingslashit( rocket_add_url_protocol( $file_components['host'] ) );
+
+ if ( $file_components['path'] !== $site_components['path'] ) {
+ $site_url .= ltrim( $site_components['path'], '/' );
+ }
} else {
$site_url = trailingslashit( rocket_add_url_protocol( site_url() ) );
}
- $abspath = wp_normalize_path( ABSPATH );
- $file = str_replace( $site_url, $abspath, rocket_set_internal_url_scheme( $file ) );
+ $abspath = wp_normalize_path( ABSPATH );
+ $file = str_replace( $site_url, $abspath, rocket_set_internal_url_scheme( $file ) );
}
$path = array();
diff --git a/inc/functions/minify.php b/inc/functions/minify.php
index 12c2e38324..a3d0dd0839 100644
--- a/inc/functions/minify.php
+++ b/inc/functions/minify.php
@@ -22,14 +22,18 @@ function rocket_minify_files( $buffer, $extension ) {
}
if ( 'js' === $extension ) {
+ $js_files_in_head = '';
$header_files = array();
$concatenate = get_rocket_option( 'minify_concatenate_js', false ) ? true : false;
- $js_files_in_head = implode( '|', $rocket_js_enqueued_in_head );
+ if ( $rocket_js_enqueued_in_head && is_array( $rocket_js_enqueued_in_head ) ) {
+ $js_files_in_head = implode( '|', $rocket_js_enqueued_in_head );
+ }
// Get all js files with this regex.
preg_match_all( apply_filters( 'rocket_minify_js_regex_pattern', '#