Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/5987: Lazyload bg css #6039

Merged
merged 125 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
e2f04df
Added skeleton
CrochetFeve0251 Jun 21, 2023
b867ee5
Fixed code standards
CrochetFeve0251 Jun 22, 2023
cbb0247
Added Filesystem cache
CrochetFeve0251 Jun 22, 2023
fc8a9bc
Added generate_url method
CrochetFeve0251 Jun 22, 2023
e9181c2
Added code and tests for `delete` and `deleteMultiple`
CrochetFeve0251 Jun 22, 2023
c68468a
Added remaining methods and tests
CrochetFeve0251 Jun 23, 2023
c5d8296
Added simple cache library
CrochetFeve0251 Jun 23, 2023
c543804
Notice and tests
CrochetFeve0251 Jun 26, 2023
59024c3
Fixed code standards
CrochetFeve0251 Jun 26, 2023
3c0fc1e
Fixed code standards
CrochetFeve0251 Jun 26, 2023
fe64484
Added page class
CrochetFeve0251 Jun 26, 2023
c1eb256
Added Services providers
CrochetFeve0251 Jun 26, 2023
d26e19f
Added extract css common operation
CrochetFeve0251 Jun 27, 2023
0b34c7b
Added HTML
CrochetFeve0251 Jun 27, 2023
f7ff15e
Added business logic
CrochetFeve0251 Jul 4, 2023
3f95fa6
Added missing tests resources
CrochetFeve0251 Jul 4, 2023
53df7bf
Merge branch 'feature/5998-filesystem-cache' into feature/5997-create…
CrochetFeve0251 Jul 4, 2023
201736f
Fixed issues with the business logic
CrochetFeve0251 Jul 5, 2023
5b52205
Fixed issues with the business logic
CrochetFeve0251 Jul 5, 2023
b2b3249
Fixed tests
CrochetFeve0251 Jul 5, 2023
f60a0e9
Fixed code standards
CrochetFeve0251 Jul 5, 2023
e45ce7c
Fixed unit tests
CrochetFeve0251 Jul 5, 2023
1985dce
Added new unit tests
CrochetFeve0251 Jul 5, 2023
7e770ee
Fixed conflicts
CrochetFeve0251 Jul 6, 2023
dfafda2
Fixed subscriber class
CrochetFeve0251 Jul 6, 2023
9dcd4d0
Added logger
CrochetFeve0251 Jul 7, 2023
46dea31
Fixed issues with the lazyload
CrochetFeve0251 Jul 7, 2023
b0b65cf
Fixed tests and make code able to respect parameters
CrochetFeve0251 Jul 10, 2023
7e6dc29
Fixed integration tests
CrochetFeve0251 Jul 10, 2023
a1b8f18
Added the context
CrochetFeve0251 Jul 11, 2023
b113aa9
Added filter in `meta-boxes.php`
CrochetFeve0251 Jul 11, 2023
d239d9b
Added new filters
CrochetFeve0251 Jul 11, 2023
342b38d
Merge branch 'develop' into feature/5987-lazyload-css
CrochetFeve0251 Jul 11, 2023
efbe181
Added service provider
CrochetFeve0251 Jul 12, 2023
244ffc1
Fixed integration tests
CrochetFeve0251 Jul 12, 2023
1112b30
Fixed integration tests
CrochetFeve0251 Jul 12, 2023
28ef501
Pushed fixes
CrochetFeve0251 Jul 12, 2023
680a0f8
Fixed test
CrochetFeve0251 Jul 12, 2023
6dddca0
Fixed test CleanPartialCache
CrochetFeve0251 Jul 12, 2023
6adb374
Fixed admin tests
CrochetFeve0251 Jul 12, 2023
dbdb9e6
Fixed tests CleanKinstaPostCache
CrochetFeve0251 Jul 12, 2023
5bc9939
LazyLoad CSS Background Images: Create skeleton #6000 (#6004)
CrochetFeve0251 Jul 13, 2023
244bf11
Closes #5998 Lazyload CSS background images: filesystem cache (#6006)
CrochetFeve0251 Jul 13, 2023
0b0b039
Fixed QA feedback
CrochetFeve0251 Jul 17, 2023
2cb6bac
Fixed feedback from QA on lazyload script loading when the option is …
CrochetFeve0251 Jul 17, 2023
2a72ad2
Fixed replacement to prevent a bug with twice same url
CrochetFeve0251 Jul 18, 2023
d34fa66
Fixed code standards
CrochetFeve0251 Jul 18, 2023
570b729
Added exclusion for content
CrochetFeve0251 Jul 18, 2023
0ea1be5
Added docblock `rocket_lazyload_css_cache_root`
CrochetFeve0251 Jul 18, 2023
184f733
Merge branch 'develop' into feature/5987-lazyload-css
CrochetFeve0251 Jul 18, 2023
9430ba4
Fixed issue with meta box
CrochetFeve0251 Jul 18, 2023
6ea0745
Fixed issue with undefined
CrochetFeve0251 Jul 18, 2023
fafb7b0
Fixed issue with multi background images
CrochetFeve0251 Jul 18, 2023
68b6a95
Prevent crash on invalid dom
CrochetFeve0251 Jul 18, 2023
563c8b1
Fix no slash issue and code standards
CrochetFeve0251 Jul 18, 2023
b7c00c5
Added JS exclusions
CrochetFeve0251 Jul 18, 2023
98ffbbb
Added lazyload minification
CrochetFeve0251 Jul 18, 2023
9d0428e
Refactored addLazyloadScriptRocketDelayJsExclusions.php unit tests
CrochetFeve0251 Jul 19, 2023
251ba8b
Added new activated tests for exclusions
CrochetFeve0251 Jul 19, 2023
26e004e
Fixed path for background-sss
CrochetFeve0251 Jul 19, 2023
7d72f1d
Isolated filter add_lazyload_script_exclude_js
CrochetFeve0251 Jul 19, 2023
c2915ea
Isolated filter add_lazyload_script_exclude_js
CrochetFeve0251 Jul 19, 2023
08685e3
Added fix for admin tests
CrochetFeve0251 Jul 19, 2023
ff802a9
Added fix for admin tests
CrochetFeve0251 Jul 19, 2023
5f411b4
Fixed admin test
CrochetFeve0251 Jul 19, 2023
6bb95d0
Added new build for the script lazyload-css.js
CrochetFeve0251 Jul 19, 2023
77eb85c
Added new build for the script lazyload-css.js
CrochetFeve0251 Jul 19, 2023
92efcf0
Merge remote-tracking branch 'origin/feature/5987-lazyload-css' into …
CrochetFeve0251 Jul 19, 2023
2b31b97
Added new lazyload not crashing
CrochetFeve0251 Jul 19, 2023
4055ded
Added safemode option
CrochetFeve0251 Jul 20, 2023
6a26e5a
Merge remote-tracking branch 'origin/feature/5987-lazyload-css' into …
CrochetFeve0251 Jul 20, 2023
9e21dc4
Fixed standards
CrochetFeve0251 Jul 20, 2023
a4e5970
Fixed an issue with placeholders due to duplication
CrochetFeve0251 Jul 20, 2023
b0c4fb2
Fixed issue with double slash
CrochetFeve0251 Jul 20, 2023
4eaa4a6
Fixed issue with lazyload script loading on search
CrochetFeve0251 Jul 21, 2023
6ca9476
Added a way
CrochetFeve0251 Jul 21, 2023
3f98a56
Added external files handling
CrochetFeve0251 Jul 24, 2023
5423935
Fixed code standards
CrochetFeve0251 Jul 24, 2023
a5e8e77
Excluded comments from replacement
CrochetFeve0251 Jul 24, 2023
e39b4d3
Added excluded test
CrochetFeve0251 Jul 24, 2023
a2e6cbb
Fixed issue with avada
CrochetFeve0251 Jul 24, 2023
cd72454
Fixed code standards
CrochetFeve0251 Jul 24, 2023
7e30c0f
Added fix for tests
CrochetFeve0251 Jul 24, 2023
324dd70
Added a fix for \r line return
CrochetFeve0251 Jul 25, 2023
d377c9d
Added a fix for html comments
CrochetFeve0251 Jul 25, 2023
761c9f1
Allow the case where both background and background-image are present
CrochetFeve0251 Jul 26, 2023
90cf6db
Added timestamp on urls to prevent browser cache issue
CrochetFeve0251 Jul 26, 2023
65c317a
Added domain on relative urls
CrochetFeve0251 Jul 26, 2023
cc9cf6f
Added moving logic for css content
CrochetFeve0251 Jul 27, 2023
180e23a
Added a fix for files without background
CrochetFeve0251 Jul 27, 2023
c110d44
Fixed unit tests from `create_lazy_css_files`
CrochetFeve0251 Jul 27, 2023
ae5d116
Fixed full urs for relative urls exclusions
CrochetFeve0251 Jul 27, 2023
766bcfb
Added exclusion tag
CrochetFeve0251 Jul 28, 2023
4a8eac0
Added AMP compatibility
CrochetFeve0251 Jul 28, 2023
9caf2c9
Refactored the code to make it easier to read
CrochetFeve0251 Aug 3, 2023
994c9cb
Added data structures to prevent checking types all the time
CrochetFeve0251 Aug 3, 2023
02abe91
Merge branch 'branch-3.15' into feature/lazyload-bg-images
remyperona Aug 7, 2023
49f3d76
Merge branch 'feature/lazyload-bg-images' into feature/5987-lazyload-css
remyperona Aug 7, 2023
5fca415
remove extra require
remyperona Aug 7, 2023
0b3040d
Merge branch 'branch-3.15' into feature/lazyload-bg-images
remyperona Aug 7, 2023
a4b9537
Merge branch 'feature/lazyload-bg-images' into feature/5987-lazyload-css
remyperona Aug 7, 2023
9ca3806
Fixed CR
CrochetFeve0251 Aug 10, 2023
bff6dc4
Fixed unit tests
CrochetFeve0251 Aug 14, 2023
d7e5426
Fixed conflicts
CrochetFeve0251 Aug 14, 2023
7b118c6
Fixed conflicts
CrochetFeve0251 Aug 14, 2023
430a639
Added cleaning from post meta option
CrochetFeve0251 Aug 16, 2023
1521e11
Fixed an issue with the post meta
CrochetFeve0251 Aug 16, 2023
46bc4ab
Moved content inside local files too.
CrochetFeve0251 Aug 16, 2023
895d495
Merged develop
CrochetFeve0251 Aug 16, 2023
327775e
Merge branch 'develop' into feature/5987-lazyload-css
CrochetFeve0251 Aug 17, 2023
a8810ff
Fixed conflicts
CrochetFeve0251 Aug 17, 2023
99d9e49
Reverted changes on dependencies
CrochetFeve0251 Aug 18, 2023
e6ad9ea
Added a fix for rules without ;
CrochetFeve0251 Aug 18, 2023
b408803
Added fix for cdn and CR
CrochetFeve0251 Aug 24, 2023
f01c134
Added fix for cdn and CR
CrochetFeve0251 Aug 24, 2023
890f529
Merge branch 'branch-3.15' into feature/5987-lazyload-css
engahmeds3ed Aug 24, 2023
9003bc0
update version to 3.15-alpha1
engahmeds3ed Aug 24, 2023
0e9ff8b
Removed delete on trash or delete added new possible cases on regex f…
CrochetFeve0251 Aug 25, 2023
8517fa5
Fixed a bug when having two blocks with the same selector
CrochetFeve0251 Aug 28, 2023
df61774
Apply cdn only on internal URLs
CrochetFeve0251 Aug 28, 2023
cb9c8ed
Fix phpcs
CrochetFeve0251 Aug 28, 2023
1aec0db
Fixed the bug with spaces
CrochetFeve0251 Aug 28, 2023
0d5591f
Added fix for tests
CrochetFeve0251 Aug 28, 2023
bcef911
Added fix for the meta classes
CrochetFeve0251 Aug 29, 2023
233f70a
Added a wider selector regex
CrochetFeve0251 Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions assets/js/lazyload-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function rocket_css_lazyload() {

const pairs = rocket_pairs || [];

const styleElement = document.querySelector('#wpr-lazyload-bg');

const threshold = rocket_lazyload_css_data.threshold || 300;

const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const pairs = rocket_pairs.filter(s => entry.target.matches(s.selector));
pairs.map(pair => {
if (pair) {
styleElement.innerHTML += pair.style;
pair.elements.forEach(el => {
el.setAttribute('data-rocket-lazy-bg', 'loaded');
// Stop observing the target element
observer.unobserve(el);
});
}
})
}
});
}, {
rootMargin: threshold + 'px'
});

pairs.forEach(pair => {
try {
const elements = document.querySelectorAll(pair.selector);
elements.forEach(el => {
observer.observe(el);
// Save el in the pair object (create a new empty array if it doesn't exist)
(pair.elements ||= []).push(el);
});
} catch (error) {
console.error(error);
}
});
}

rocket_css_lazyload();
1 change: 1 addition & 0 deletions assets/js/lazyload-css.js.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions assets/js/lazyload-css.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/lazyload-css.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,27 @@ const bundleJsWithoutWatch = () => {
.pipe(gulp.dest('assets/js'))
}

exports.bundleJsWithoutWatch = bundleJsWithoutWatch;
// Bundle script without watching.
const bundleLazyloadJsWithoutWatch = () => {
var bundle = browserify({
entries: './src/js/global/lazyload-css.js',
debug: true
}).transform(babel);

return bundle.bundle()
.pipe(source('lazyload-css.js'))
.pipe(buffer())
.pipe(uglify())
.pipe( rename( { suffix: '.min' } ) )
.pipe(sourcemaps.init({loadMaps: false}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('assets/js'))
}

exports.bundleLazyloadJsWithoutWatch = bundleLazyloadJsWithoutWatch;

// Run build without watching: watching keeps git actions stuck on 'build'
gulp.task('run:build', gulp.parallel(bundleJsWithoutWatch, 'run:build:sass'));
gulp.task('run:build', gulp.parallel(bundleJsWithoutWatch, bundleLazyloadJsWithoutWatch, 'run:build:sass'));

/**
* Compiles a standalone script file.
Expand Down
10 changes: 10 additions & 0 deletions inc/Dependencies/Psr/SimpleCache/CacheException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace WP_Rocket\Dependencies\Psr\SimpleCache;

/**
* Interface used for all types of exceptions thrown by the implementing library.
*/
interface CacheException
{
}
97 changes: 97 additions & 0 deletions inc/Dependencies/Psr/SimpleCache/CacheInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace WP_Rocket\Dependencies\Psr\SimpleCache;

interface CacheInterface
{
/**
* Fetches a value from the cache.
*
* @param string $key The unique key of this item in the cache.
* @param mixed $default Default value to return if the key does not exist.
*
* @return mixed The value of the item from the cache, or $default in case of cache miss.
*
*/
public function get($key, $default = null);

/**
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
*
* @param string $key The key of the item to store.
* @param mixed $value The value of the item to store, must be serializable.
* @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.
*
* @return bool True on success and false on failure.
*
*/
public function set($key, $value, $ttl = null);

/**
* Delete an item from the cache by its unique key.
*
* @param string $key The unique cache key of the item to delete.
*
* @return bool True if the item was successfully removed. False if there was an error.
*
*/
public function delete($key);

/**
* Wipes clean the entire cache's keys.
*
* @return bool True on success and false on failure.
*/
public function clear();

/**
* Obtains multiple cache items by their unique keys.
*
* @param iterable $keys A list of keys that can obtained in a single operation.
* @param mixed $default Default value to return for keys that do not exist.
*
* @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
*
*/
public function getMultiple($keys, $default = null);

/**
* Persists a set of key => value pairs in the cache, with an optional TTL.
*
* @param iterable $values A list of key => value pairs for a multiple-set operation.
* @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.
*
* @return bool True on success and false on failure.
*
*/
public function setMultiple($values, $ttl = null);

/**
* Deletes multiple cache items in a single operation.
*
* @param iterable $keys A list of string-based keys to be deleted.
*
* @return bool True if the items were successfully removed. False if there was an error.
*
*/
public function deleteMultiple($keys);

/**
* Determines whether an item is present in the cache.
*
* NOTE: It is recommended that has() is only to be used for cache warming type purposes
* and not to be used within your live applications operations for get/set, as this method
* is subject to a race condition where your has() will return true and immediately after,
* another script can remove it making the state of your app out of date.
*
* @param string $key The cache item key.
*
* @return bool
*
*/
public function has($key);
}
13 changes: 13 additions & 0 deletions inc/Dependencies/Psr/SimpleCache/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace WP_Rocket\Dependencies\Psr\SimpleCache;

/**
* Exception interface for invalid cache arguments.
*
* When an invalid argument is passed it must throw an exception which implements
* this interface
*/
interface InvalidArgumentException extends CacheException
{
}
2 changes: 1 addition & 1 deletion inc/Dependencies/RocketLazyload/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function getYoutubeThumbnailScript( $args = [] ) {
}
}

return "<script>function lazyLoadThumb(e){var t='{$image}',a='<button class=\"play\" aria-label=\"play Youtube video\"></button>';return t.replace(\"ID\",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement(\"iframe\"),t=\"ID?autoplay=1\";t+=0===this.parentNode.dataset.query.length?'':'&'+this.parentNode.dataset.query;e.setAttribute(\"src\",t.replace(\"ID\",this.parentNode.dataset.src)),e.setAttribute(\"frameborder\",\"0\"),e.setAttribute(\"allowfullscreen\",\"1\"),e.setAttribute(\"allow\", \"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\"),this.parentNode.parentNode.replaceChild(e,this.parentNode)}document.addEventListener(\"DOMContentLoaded\",function(){var e,t,p,a=document.getElementsByClassName(\"rll-youtube-player\");for(t=0;t<a.length;t++)e=document.createElement(\"div\"),e.setAttribute(\"data-id\",a[t].dataset.id),e.setAttribute(\"data-query\", a[t].dataset.query),e.setAttribute(\"data-src\", a[t].dataset.src),e.innerHTML=lazyLoadThumb(a[t].dataset.id),a[t].appendChild(e),p=e.querySelector('.play'),p.onclick=lazyLoadYoutubeIframe});</script>";
return "<script>function lazyLoadThumb(e,alt){var t='{$image}',a='<button class=\"play\" aria-label=\"play Youtube video\"></button>';t=t.replace('alt=\"\"','alt=\"'+alt+'\"');return t.replace(\"ID\",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement(\"iframe\"),t=\"ID?autoplay=1\";t+=0===this.parentNode.dataset.query.length?'':'&'+this.parentNode.dataset.query;e.setAttribute(\"src\",t.replace(\"ID\",this.parentNode.dataset.src)),e.setAttribute(\"frameborder\",\"0\"),e.setAttribute(\"allowfullscreen\",\"1\"),e.setAttribute(\"allow\", \"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\"),this.parentNode.parentNode.replaceChild(e,this.parentNode)}document.addEventListener(\"DOMContentLoaded\",function(){var e,t,p,a=document.getElementsByClassName(\"rll-youtube-player\");for(t=0;t<a.length;t++)e=document.createElement(\"div\"),e.setAttribute(\"data-id\",a[t].dataset.id),e.setAttribute(\"data-query\", a[t].dataset.query),e.setAttribute(\"data-src\", a[t].dataset.src),e.innerHTML=lazyLoadThumb(a[t].dataset.id,a[t].dataset.alt),a[t].appendChild(e),p=e.querySelector('.play'),p.onclick=lazyLoadYoutubeIframe});</script>";
}

/**
Expand Down
6 changes: 5 additions & 1 deletion inc/Dependencies/RocketLazyload/Iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,18 @@ private function replaceYoutubeThumbnail( $iframe ) {

$youtube_url = $this->changeYoutubeUrlForYoutuDotBe( $iframe['src'] );
$youtube_url = $this->cleanYoutubeUrl( $iframe['src'] );

preg_match( '@\s*title\s*=\s*(\'|")(?<title>.*)\1@iUs', $iframe['atts'], $atts );

$title = $atts['title'] ?? '';
/**
* Filter the LazyLoad HTML output on Youtube iframes
*
* @since 2.11
*
* @param array $html Output that will be printed.
*/
$youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '<div class="rll-youtube-player" data-src="' . esc_attr( $youtube_url ) . '" data-id="' . esc_attr( $youtube_id ) . '" data-query="' . esc_attr( $query ) . '"></div>' );
$youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '<div class="rll-youtube-player" data-src="' . esc_attr( $youtube_url ) . '" data-id="' . esc_attr( $youtube_id ) . '" data-query="' . esc_attr( $query ) . '" data-alt="' . esc_attr( $title ) . '"></div>' );
$youtube_lazyload .= '<noscript>' . $iframe[0] . '</noscript>';

return $youtube_lazyload;
Expand Down
38 changes: 31 additions & 7 deletions inc/Engine/Admin/Settings/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,15 @@ private function media_section() {
$disable_iframes_lazyload = (array) apply_filters( 'rocket_maybe_disable_iframes_lazyload_helper', $disable_iframes_lazyload );
$disable_iframes_lazyload = $this->sanitize_and_format_list( $disable_iframes_lazyload );

$disable_css_bg_img_lazyload = false;

/**
* Lazyload Helper filter which disables WPR lazyload functionality for bg css.
*
* @param bool $disable_css_bg_img_lazyload Should the lazyload CSS be disabled.
*/
$disable_css_bg_img_lazyload = (bool) apply_filters( 'rocket_maybe_disable_css_bg_img_lazyload_helper', $disable_css_bg_img_lazyload );

/**
* Lazyload Helper filter which disables WPR lazyload functionality to replace YouTube iframe with preview image.
*
Expand Down Expand Up @@ -1054,7 +1063,7 @@ private function media_section() {

$this->settings->add_settings_fields(
[
'lazyload' => [
'lazyload' => [
'type' => 'checkbox',
'label' => __( 'Enable for images', 'rocket' ),
'section' => 'lazyload_section',
Expand All @@ -1070,7 +1079,22 @@ private function media_section() {
// translators: %1$s = “WP Rocket”, %2$s = a list of plugin names.
'description' => ! empty( $disable_images_lazyload ) ? sprintf( __( 'LazyLoad for images is currently activated in %2$s. If you want to use %1$s’s LazyLoad, disable this option in %2$s.', 'rocket' ), WP_ROCKET_PLUGIN_NAME, $disable_images_lazyload ) : '',
],
'lazyload_iframes' => [
'lazyload_css_bg_img' => [
'container_class' => [
$disable_css_bg_img_lazyload ? 'wpr-isDisabled' : '',
'wpr-isParent',
],
'type' => 'checkbox',
'label' => __( 'Enable for CSS background images', 'rocket' ),
'section' => 'lazyload_section',
'page' => 'media',
'default' => 0,
'sanitize_callback' => 'sanitize_checkbox',
'input_attr' => [
'disabled' => $disable_css_bg_img_lazyload ? 1 : 0,
],
],
'lazyload_iframes' => [
'container_class' => [
! empty( $disable_iframes_lazyload ) ? 'wpr-isDisabled' : '',
'wpr-isParent',
Expand All @@ -1085,7 +1109,7 @@ private function media_section() {
'disabled' => ! empty( $disable_iframes_lazyload ) ? 1 : 0,
],
],
'lazyload_youtube' => [
'lazyload_youtube' => [
'container_class' => [
! empty( $disable_youtube_lazyload ) ? 'wpr-isDisabled' : '',
'wpr-field--children',
Expand All @@ -1103,20 +1127,20 @@ private function media_section() {
'disabled' => ! empty( $disable_youtube_lazyload ) ? 1 : 0,
],
],
'exclude_lazyload' => [
'exclude_lazyload' => [
'container_class' => [
'wpr-Delayjs',
],
'type' => 'textarea',
'label' => __( 'Excluded images or iframes', 'rocket' ),
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
'description' => sprintf( __( 'Specify keywords (e.g. image filename, CSS class, domain) from the image or iframe code to be excluded (one per line). %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $exclude_lazyload['url'] ) . '" data-beacon-article="' . esc_attr( $exclude_lazyload['id'] ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ),
'description' => sprintf( __( 'Specify keywords (e.g. image filename, CSS filename, CSS class, domain) from the image or iframe code to be excluded (one per line). %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $exclude_lazyload['url'] ) . '" data-beacon-article="' . esc_attr( $exclude_lazyload['id'] ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ),
'section' => 'lazyload_section',
'page' => 'media',
'default' => [],
'placeholder' => "example-image.jpg\nslider-image",
'placeholder' => "example-image.jpg\nslider-image\nbackground-image-style.css",
],
'image_dimensions' => [
'image_dimensions' => [
'type' => 'checkbox',
'label' => __( 'Add missing image dimensions', 'rocket' ),
'section' => 'dimensions_section',
Expand Down
36 changes: 36 additions & 0 deletions inc/Engine/Common/Cache/CacheInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace WP_Rocket\Engine\Common\Cache;

interface CacheInterface extends \WP_Rocket\Dependencies\Psr\SimpleCache\CacheInterface {

/**
* Generate the real URL.
*
* @param string $url original URL.
* @return string
*/
public function generate_url( string $url ): string;

/**
* Is the root path available.
*
* @return bool
*/
public function is_accessible(): bool;

/**
* Get root path from the cache.
*
* @return string
*/
public function get_root_path(): string;

/**
* Generate a path from the URL.
*
* @param string $url URL to change to a path.
* @return string
*/
public function generate_path( string $url ): string;
}
Loading
Loading