-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses_LazyLoad.php.html
More file actions
761 lines (630 loc) · 33.4 KB
/
classes_LazyLoad.php.html
File metadata and controls
761 lines (630 loc) · 33.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PoweredCache Hooks: Source: classes/LazyLoad.php</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: classes/LazyLoad.php</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code><?php
/**
* LazyLoad
*
* Most of the code borrowed from https://github.com/Angrycreative/bj-lazy-load
*
* @package PoweredCache
*/
namespace PoweredCache;
use const PoweredCache\Constants\POST_META_DISABLE_LAZYLOAD_KEY;
// phpcs:disable WordPressVIPMinimum.Security.ProperEscapingFunction.hrefSrcEscUrl
/**
* Class LazyLoad
*/
class LazyLoad {
/**
* Hold plugin settings
*
* @var array $settings
*/
private static $settings = null;
/**
* Return an instance of the current class
*
* @return LazyLoad
*/
public static function factory() {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
$instance->setup();
}
return $instance;
}
/**
* Setup routine
*/
public function setup() {
if ( ! self::$settings ) {
self::$settings = \PoweredCache\Utils\get_settings();
}
if ( self::$settings['enable_lazy_load'] ) {
add_action( 'wp', [ $this, 'init' ], 9999 ); // run this as late as possible
add_action( 'powered_cache_lazy_load_compat', [ $this, 'compat' ] );
add_action( 'powered_cache_lazy_load_run_filter', [ $this, 'maybe_disable_through_meta' ] );
add_filter( 'powered_cache_delayed_js_skip', [ $this, 'delayed_js_skip' ], 10, 2 );
add_filter( 'powered_cache_fo_excluded_js_files', [ $this, 'add_file_optimizer_exclusion' ] );
}
/**
* Filter to disable native lazyload support.
*
* @hook powered_cache_disable_native_lazyload
*
* @param {boolean} $status true to disable native lazy load.
*
* @return {boolean} New value.
* @since 2.0
*/
if ( apply_filters( 'powered_cache_disable_native_lazyload', self::$settings['disable_wp_lazy_load'] ) ) {
add_filter( 'wp_lazy_loading_enabled', '__return_false', 9999 );
}
}
/**
* Initialize the setup
*/
public function init() {
/* We do not touch the feeds */
if ( is_admin() || is_feed() || is_preview() ) {
return;
}
/**
* Fires before filtering lazy-load hooks.
*
* @hook powered_cache_lazy_load_compat
*
* @since 1.0
*/
do_action( 'powered_cache_lazy_load_compat' );
/**
* Filters lazy-load status.
*
* @hook powered_cache_lazy_load_enabled
*
* @param {boolean} $enable true to enable
*
* @return {boolean} New value
* @since 1.0
*/
$enabled = apply_filters( 'powered_cache_lazy_load_enabled', true );
if ( $enabled ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
$this->setup_filtering();
}
}
/**
* Enqueue scripts
*/
public function enqueue_scripts() {
wp_enqueue_script( 'PCLL', POWERED_CACHE_URL . 'dist/js/lazyload.js', null, POWERED_CACHE_VERSION, true );
/**
* Filters screen threshold value.
*
* @hook powered_cache_lazy_load_threshold
*
* @param {int} $threshold Screen display threshold.
*
* @return {int} New value
* @since 1.0
*/
$threshold = apply_filters( 'powered_cache_lazy_load_threshold', 200 );
/**
* Filters the count of images that skipped from lazyload.
*
* @hook powered_cache_lazy_load_skip_first_nth_img
*
* @param {int} $immediate_load_count Default image count
*
* @return {int} New value
* @since 3.1
*/
$immediate_load_count = apply_filters( 'powered_cache_lazy_load_skip_first_nth_img', self::$settings['lazy_load_skip_first_nth_img'] );
if ( 200 !== (int) $threshold || 3 !== (int) $immediate_load_count ) {
wp_localize_script(
'PCLL',
'PCLL_options',
[
'threshold' => $threshold,
'immediate_load_count' => $immediate_load_count,
]
);
}
if ( self::$settings['lazy_load_youtube'] ) {
wp_register_style( 'pcll-youtube-lazyload', false ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_enqueue_style( 'pcll-youtube-lazyload' );
wp_add_inline_style( 'pcll-youtube-lazyload', $this->add_inline_youtube_css() );
}
}
/**
* Set up filtering for certain content
*/
protected function setup_filtering() {
/**
* Filters whether apply or not apply lazyload for images.
*
* @hook powered_cache_lazy_load_images
*
* @param {boolean} true to lazyload for images
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_images', self::$settings['lazy_load_images'] ) ) {
add_filter( 'powered_cache_lazy_load_filter', array( __CLASS__, 'filter_images' ) );
}
/**
* Filters whether apply or not apply lazyload for iframes.
*
* @hook powered_cache_lazy_load_iframes
*
* @param {boolean} true to apply lazyload for iframes
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_iframes', self::$settings['lazy_load_iframes'] ) ) {
add_filter( 'powered_cache_lazy_load_filter', array( __CLASS__, 'filter_iframes' ) );
}
/**
* Filters whether apply or not apply lazyload for post_content.
*
* @hook powered_cache_lazy_load_post_content
*
* @param {boolean} true to apply lazyload for post_content
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_post_content', self::$settings['lazy_load_post_content'] ) ) {
add_filter( 'the_content', array( __CLASS__, 'filter' ), 200 );
}
/**
* Filters whether apply or not apply lazyload for widgets.
*
* @hook powered_cache_lazy_load_widget_text
*
* @param {boolean} true to apply lazyload for widgets
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_widget_text', self::$settings['lazy_load_widgets'] ) ) {
add_filter( 'widget_text', array( __CLASS__, 'filter' ), 200 );
}
/**
* Filters whether apply or not apply lazyload for thumbnails.
*
* @hook powered_cache_lazy_load_post_thumbnail
*
* @param {boolean} true to apply lazyload for thumbnails
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_post_thumbnail', self::$settings['lazy_load_post_thumbnail'] ) ) {
add_filter( 'post_thumbnail_html', array( __CLASS__, 'filter' ), 200 );
}
/**
* Filters whether replace youtube iframe with thumbnail.
*
* @hook powered_cache_lazy_load_youtube
*
* @param {boolean} true to replace youtube iframe with thumbnail
*
* @return {boolean} New value.
* @since 3.4
*/
if ( true === apply_filters( 'powered_cache_lazy_load_youtube', self::$settings['lazy_load_youtube'] ) ) {
add_filter( 'powered_cache_lazy_load_filter', array( __CLASS__, 'replace_youtube_iframe_with_thumbnail' ), 9 );
}
/**
* Filters whether apply or not apply lazyload for avatars.
*
* @hook powered_cache_lazy_load_avatar
*
* @param {boolean} true to apply lazyload for avatars
*
* @return {boolean} New value.
* @since 1.0
*/
if ( true === apply_filters( 'powered_cache_lazy_load_avatar', self::$settings['lazy_load_avatars'] ) ) {
add_filter( 'get_avatar', array( __CLASS__, 'filter' ), 200 );
}
/**
* * Filters whether apply or not apply lazyload for html.
*
* @hook powered_cache_lazy_load_html
*
* @param {boolean} true to apply lazyload for html
*
* @return {boolean} New value.
* @since 1.0
*/
add_filter( 'powered_cache_lazy_load_html', array( __CLASS__, 'filter' ) );
}
/**
* Filter HTML content. Replace supported content with placeholders.
*
* @param string $content The HTML string to filter
*
* @return string The filtered HTML string
*/
public static function filter( $content ) {
// Last chance to bail out before running the filter
/**
* Filters lazy-load run filter.
*
* @hook powered_cache_lazy_load_run_filter
*
* @param {boolean} $run_filter true to enable
*
* @return {boolean} New value
* @since 1.0
*/
$run_filter = apply_filters( 'powered_cache_lazy_load_run_filter', true );
if ( ! $run_filter ) {
return $content;
}
/**
* Filters the content
*
* @hook powered_cache_lazy_load_filter
*
* @param string $content The HTML string to filter
*
* @since 1.0
*/
$content = apply_filters( 'powered_cache_lazy_load_filter', $content );
return $content;
}
/**
* Replace images with placeholders in the content
*
* @param string $content The HTML to do the filtering on
*
* @return string The HTML with the images replaced
*/
public static function filter_images( $content ) {
/**
* Filters the content
*
* @hook powered_cache_lazy_load_filter
*
* @param string $content The HTML string to filter
*
* @since 1.0
*/
$placeholder_url = apply_filters( 'powered_cache_lazy_load_placeholder_url', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=' );
$match_content = self::get_content_haystack( $content );
$matches = array();
preg_match_all( '/<img[\s\r\n]+.*?>/is', $match_content, $matches );
$search = array();
$replace = array();
foreach ( $matches[0] as $img_html ) {
if ( self::is_excluded( $img_html ) ) {
continue;
}
// don't to the replacement if the image is a data-uri
if ( ! preg_match( "/src=['\"]data:image/is", $img_html ) ) {
$placeholder_url_used = $placeholder_url;
// replace the src and add the data-src attribute
$replace_html = preg_replace( '/<img(.*?)src=/is', '<img$1src="' . esc_attr( $placeholder_url_used ) . '" data-lazy-type="image" data-lazy-src=', $img_html );
// also replace the srcset (responsive images)
$replace_html = str_replace( 'srcset', 'data-lazy-srcset', $replace_html );
// add the lazy class to the img element
if ( preg_match( '/class=["\']/i', $replace_html ) ) {
$replace_html = preg_replace( '/class=(["\'])(.*?)["\']/is', 'class=$1lazy lazy-hidden $2$1', $replace_html );
} else {
$replace_html = preg_replace( '/<img/is', '<img class="lazy lazy-hidden"', $replace_html );
}
$replace_html .= '<noscript>' . $img_html . '</noscript>';
array_push( $search, $img_html );
array_push( $replace, $replace_html );
}
}
$content = str_replace( $search, $replace, $content );
return $content;
}
/**
* Replace iframes with placeholders in the content
*
* @param string $content The HTML to do the filtering on
*
* @return string The HTML with the iframes replaced
*/
public static function filter_iframes( $content ) {
/**
* Filters the lazyload placeholder URL.
*
* @hook powered_cache_lazy_load_placeholder_url
*
* @param string $image default placeholder url. Base64 string as default.
*
* @since 1.0
*/
$placeholder_url = apply_filters( 'powered_cache_lazy_load_placeholder_url', 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=' );
$match_content = self::get_content_haystack( $content );
$matches = array();
preg_match_all( '|<iframe\s+.*?</iframe>|si', $match_content, $matches );
$search = array();
$replace = array();
foreach ( $matches[0] as $iframe_html ) {
if ( self::is_excluded( $iframe_html ) ) {
continue;
}
// Don't mess with the Gravity Forms ajax iframe
if ( strpos( $iframe_html, 'gform_ajax_frame' ) ) {
continue;
}
$replace_html = '<img src="' . esc_attr( $placeholder_url ) . '" class="lazy lazy-hidden" data-lazy-type="iframe" data-lazy-src="' . esc_attr( $iframe_html ) . '" alt="">';
$replace_html .= '<noscript>' . $iframe_html . '</noscript>';
array_push( $search, $iframe_html );
array_push( $replace, $replace_html );
}
$content = str_replace( $search, $replace, $content );
return $content;
}
/**
* Remove elements we don’t want to filter from the HTML string
* We’re reducing the haystack by removing the hay we know we don’t want to look for needles in
*
* @param string $content The HTML string
*
* @return string The HTML string without the unwanted elements
*/
protected static function get_content_haystack( $content ) {
$content = self::remove_noscript( $content );
$content = self::remove_skip_classes_elements( $content );
return $content;
}
/**
* Remove <noscript> elements from HTML string
*
* @param string $content The HTML string
*
* @return string The HTML string without <noscript> elements
* @author sigginet
*/
public static function remove_noscript( $content ) {
return preg_replace( '/<noscript.*?(\/noscript>)/i', '', $content );
}
/**
* Remove HTML elements with certain classnames (or IDs) from HTML string
*
* @param string $content The HTML string
*
* @return string The HTML string without the unwanted elements
*/
public static function remove_skip_classes_elements( $content ) {
$skip_classes = self::get_skip_classes( 'html' );
/**
* http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
* We can’t do this, but we still do it.
*/
$skip_classes_quoted = array_map( 'preg_quote', $skip_classes );
$skip_classes_ored = implode( '|', $skip_classes_quoted );
$regex = '/<\s*\w*\s*class\s*=\s*[\'"]?(|.*\s)?' . $skip_classes_ored . '(|\s.*)?[\'"]?.*?>/isU';
return preg_replace( $regex, '', $content );
}
/**
* Get the skip classes
*
* @param string $content_type The content type (image/iframe etc)
*
* @return array An array of strings with the class names
*/
protected static function get_skip_classes( $content_type ) {
/**
* Filters the class names to skip
*
* @hook powered_cache_lazy_load_skip_classes
*
* @param {array} $skip_classes The current classes to skip
* @param {string} $content_type The current content type
*
* @return {array} New value.
* @since 1.0
*/
$skip_classes = apply_filters( 'powered_cache_lazy_load_skip_classes', array( 'lazy' ), $content_type );
return $skip_classes;
}
/**
* Manage 3rd party compat cases
*/
public function compat() {
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
if ( function_exists( 'bp_is_my_profile' ) && bp_is_my_profile() ) {
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
if ( function_exists( 'mopr_get_option' ) && WP_CONTENT_DIR . mopr_get_option( 'mobile_theme_root', 1 ) === get_theme_root() ) {
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) ) { // phpcs:ignore
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
if ( 1 === intval( get_query_var( 'print' ) ) || 1 === intval( get_query_var( 'printpage' ) ) ) {
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
if ( function_exists( 'bnc_wptouch_is_mobile' ) || defined( 'WPTOUCH_VERSION' ) ) {
add_filter( 'powered_cache_lazy_load_enabled', '__return_false' );
}
}
/**
* Maybe disable lazyloading for a particular post
*
* @param bool $status Lazyload filter status
*
* @return bool
* @since 2.0
*/
public function maybe_disable_through_meta( $status ) {
if ( in_the_loop() && get_post_meta( get_the_ID(), POST_META_DISABLE_LAZYLOAD_KEY, true ) ) {
$status = false;
}
return $status;
}
/**
* Skip lazyload for delayed script
*
* @param boolean $is_delay_skipped Whether skip or not skip delayed JS
* @param string $script script
*
* @return boolean
*/
public function delayed_js_skip( $is_delay_skipped, $script ) {
if ( false !== stripos( $script, 'powered-cache/dist/js/lazyload.js' ) || false !== stripos( $script, 'PCLL_' ) ) {
return true;
}
return $is_delay_skipped;
}
/**
* Exclude link preloader from file optimizer
*
* @param array $excluded_files the list of excluded files for optimization
*
* @return mixed
*/
public function add_file_optimizer_exclusion( $excluded_files ) {
$excluded_files[] = POWERED_CACHE_URL . 'dist/js/lazyload.js';
return $excluded_files;
}
/**
* Replace youtube iframe with thumbnail
*
* @param string $content HTML content, or the content of the current post if called in the loop.
*
* @return array|string|string[]|null
* @since 3.4
*/
public static function replace_youtube_iframe_with_thumbnail( $content ) {
$match_content = self::get_content_haystack( $content );
// Regular expression to match YouTube iframes
$pattern = '/<iframe[^>]+src="https?:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]+)([^"]*)"[^>]*><\/iframe>/i';
// Find all YouTube iframes
preg_match_all( $pattern, $match_content, $matches );
$search = array();
$replace = array();
foreach ( $matches[0] as $iframe_html ) {
if ( self::is_excluded( $iframe_html ) ) {
continue;
}
// Extract video ID and additional parameters
preg_match( $pattern, $iframe_html, $iframe_parts );
$video_id = $iframe_parts[1];
$params = $iframe_parts[2];
// Construct the replacement HTML using the video ID
$replacement = '<div class="pcll-youtube-player" data-src="https://www.youtube.com/embed/' . $video_id . $params . '">
<img src="https://img.youtube.com/vi/' . $video_id . '/0.jpg" style="width:100%;height:auto;">
<div style="width: 100%; height: 100%;cursor:pointer;">
<svg class="pcll-youtube-play-button" viewBox="0 0 68 48" style="position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; margin-left: -34px; margin-top: -24px; transition: opacity .25s cubic-bezier(0,0,.2,1); z-index: 63; cursor: pointer;">
<path d="M66.52,7.74c-0.78-2.93-3.07-5.22-6-6C53.08,0.74,34,0.74,34,0.74s-19.08,0-26.52,1C4.57,2.52,2.28,4.81,1.5,7.74C0.68,11,0.68,24,0.68,24s0,13,0.82,16.26c0.78,2.93,3.07,5.22,6,6c7.44,1,26.52,1,26.52,1s19.08,0,26.52-1c2.93-0.78,5.22-3.07,6-6C67.32,37,67.32,24,67.32,24S67.32,11,66.52,7.74z" fill-opacity="0.8" fill="#FF0000"></path>
<path d="M 45,24 27,14 27,34" fill="#fff"></path>
</svg>
</div>
</div>';
// Add original iframe HTML and replacement HTML to their respective arrays
array_push( $search, $iframe_html );
array_push( $replace, $replacement );
}
// Replace all YouTube iframes with their corresponding thumbnail placeholders
$content = str_replace( $search, $replace, $content );
return $content;
}
/**
* Add inline css for youtube lazyload
*
* @return string
* @since 3.4
*/
public function add_inline_youtube_css() {
$css = '';
$yt_lazyload = wp_normalize_path( POWERED_CACHE_PATH . 'dist/css/lazyload-youtube.css' );
if ( file_exists( $yt_lazyload ) ) {
$css = (string) file_get_contents( $yt_lazyload ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
}
/**
* Filters the inline css for youtube lazyload
*
* @hook powered_cache_lazy_load_youtube_css
*
* @param string $css
*
* @return string
* @since 3.4
*/
$css = apply_filters( 'powered_cache_lazy_load_youtube_css', $css );
return $css;
}
/**
* Get lazyload exclusion list
*
* @return array
* @since 3.4
*/
public static function get_exclusions() {
if ( ! self::$settings ) {
self::$settings = \PoweredCache\Utils\get_settings();
}
$load_exclusions = preg_split( '#(\r\n|\n|\r)#', self::$settings['lazy_load_exclusions'], - 1, PREG_SPLIT_NO_EMPTY );
$load_exclusions[] = 'selectors.core.image.lightboxObjectFit'; // exclude core lightboxed images
/**
* Filter the lazyload exclusions
*
* @hook powered_cache_lazy_load_exclusions
*
* @param {array} $load_exclusions The current exclusions
*
* @return {array} New value
* @since 3.4
*/
return (array) apply_filters( 'powered_cache_lazy_load_exclusions', $load_exclusions );
}
/**
* Check if excluded or not from defer
*
* @param string $tag Resource
*
* @return bool
* @since 3.4
*/
public static function is_excluded( $tag ) {
$excluded_files = self::get_exclusions();
$excluded_files = implode( '|', $excluded_files );
if ( ! empty( $excluded_files ) && preg_match( '#(' . $excluded_files . ')#', $tag ) ) {
return true;
}
return false;
}
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Actions</h3><ul><li><a href="powered_cache_admin_page_after_settings_nav.html">powered_cache_admin_page_after_settings_nav</a></li><li><a href="powered_cache_admin_page_before_file_optimization.html">powered_cache_admin_page_before_file_optimization</a></li><li><a href="powered_cache_advanced_cache_purge_on_comment_update.html">powered_cache_advanced_cache_purge_on_comment_update</a></li><li><a href="powered_cache_advanced_cache_purge_post.html">powered_cache_advanced_cache_purge_post</a></li><li><a href="powered_cache_after_clean_up.html">powered_cache_after_clean_up</a></li><li><a href="powered_cache_cache_dir_htaccess_file_content.html">powered_cache_cache_dir_htaccess_file_content</a></li><li><a href="powered_cache_cdn_setup.html">powered_cache_cdn_setup</a></li><li><a href="powered_cache_clean_site_cache_dir.html">powered_cache_clean_site_cache_dir</a></li><li><a href="powered_cache_create_config_file.html">powered_cache_create_config_file</a></li><li><a href="powered_cache_flushed.html">powered_cache_flushed</a></li><li><a href="powered_cache_fo_js_concat_did_items.html">powered_cache_fo_js_concat_did_items</a></li><li><a href="powered_cache_get_url_dir.html">powered_cache_get_url_dir</a></li><li><a href="powered_cache_init.html">powered_cache_init</a></li><li><a href="powered_cache_lazy_load_compat.html">powered_cache_lazy_load_compat</a></li><li><a href="powered_cache_lazy_load_filter.html">powered_cache_lazy_load_filter</a></li><li><a href="powered_cache_lazy_load_placeholder_url.html">powered_cache_lazy_load_placeholder_url</a></li><li><a href="powered_cache_loaded.html">powered_cache_loaded</a></li><li><a href="powered_cache_mobile_browsers.html">powered_cache_mobile_browsers</a></li><li><a href="powered_cache_mobile_prefixes.html">powered_cache_mobile_prefixes</a></li><li><a href="powered_cache_page_cache_enable.html">powered_cache_page_cache_enable</a></li><li><a href="powered_cache_page_cached.html">powered_cache_page_cached</a></li><li><a href="powered_cache_preload_http_request.html">powered_cache_preload_http_request</a></li><li><a href="powered_cache_purge_all_cache.html">powered_cache_purge_all_cache</a></li><li><a href="powered_cache_settings_saved.html">powered_cache_settings_saved</a></li><li><a href="powered_cache_updated.html">powered_cache_updated</a></li></ul><h3>Filters</h3><ul><li><a href="populate_preload_queue_urls.html">populate_preload_queue_urls</a></li><li><a href="powered_cache_accepted_query_strings.html">powered_cache_accepted_query_strings</a></li><li><a href="powered_cache_advanced_cache_file_content.html">powered_cache_advanced_cache_file_content</a></li><li><a href="powered_cache_advanced_cache_purge_urls.html">powered_cache_advanced_cache_purge_urls</a></li><li><a href="powered_cache_after_htaccess.html">powered_cache_after_htaccess</a></li><li><a href="powered_cache_auto_htaccess_update.html">powered_cache_auto_htaccess_update</a></li><li><a href="powered_cache_browser_cache.html">powered_cache_browser_cache</a></li><li><a href="powered_cache_browser_cache_assets_lifespan.html">powered_cache_browser_cache_assets_lifespan</a></li><li><a href="powered_cache_browser_cache_default_lifespan.html">powered_cache_browser_cache_default_lifespan</a></li><li><a href="powered_cache_browser_cache_lifespan.html">powered_cache_browser_cache_lifespan</a></li><li><a href="powered_cache_cache_purge_interval.html">powered_cache_cache_purge_interval</a></li><li><a href="powered_cache_cache_query_strings.html">powered_cache_cache_query_strings</a></li><li><a href="powered_cache_cdn_addresses.html">powered_cache_cdn_addresses</a></li><li><a href="powered_cache_cdn_disable.html">powered_cache_cdn_disable</a></li><li><a href="powered_cache_cdn_extensions.html">powered_cache_cdn_extensions</a></li><li><a href="powered_cache_cdn_image_extensions.html">powered_cache_cdn_image_extensions</a></li><li><a href="powered_cache_cdn_rewrite_relative_urls.html">powered_cache_cdn_rewrite_relative_urls</a></li><li><a href="powered_cache_cdn_site_hostnames.html">powered_cache_cdn_site_hostnames</a></li><li><a href="powered_cache_cdn_zones.html">powered_cache_cdn_zones</a></li><li><a href="powered_cache_default_settings.html">powered_cache_default_settings</a></li><li><a href="powered_cache_defer_exclusions.html">powered_cache_defer_exclusions</a></li><li><a href="powered_cache_delay_exclusions.html">powered_cache_delay_exclusions</a></li><li><a href="powered_cache_delayed_js_script_content.html">powered_cache_delayed_js_script_content</a></li><li><a href="powered_cache_delayed_js_script_loader.html">powered_cache_delayed_js_script_loader</a></li><li><a href="powered_cache_delayed_js_skip.html">powered_cache_delayed_js_skip</a></li><li><a href="powered_cache_delayed_js_timeout.html">powered_cache_delayed_js_timeout</a></li><li><a href="powered_cache_disable_advanced_cache_notices.html">powered_cache_disable_advanced_cache_notices</a></li><li><a href="powered_cache_disable_js_defer.html">powered_cache_disable_js_defer</a></li><li><a href="powered_cache_disable_js_defer_inline.html">powered_cache_disable_js_defer_inline</a></li><li><a href="powered_cache_disable_native_lazyload.html">powered_cache_disable_native_lazyload</a></li><li><a href="powered_cache_fo_allow_gzip_compression.html">powered_cache_fo_allow_gzip_compression</a></li><li><a href="powered_cache_fo_cache_ttl.html">powered_cache_fo_cache_ttl</a></li><li><a href="powered_cache_fo_css_do_concat.html">powered_cache_fo_css_do_concat</a></li><li><a href="powered_cache_fo_dashboard.html">powered_cache_fo_dashboard</a></li><li><a href="powered_cache_fo_disable.html">powered_cache_fo_disable</a></li><li><a href="powered_cache_fo_disable_css_combine.html">powered_cache_fo_disable_css_combine</a></li><li><a href="powered_cache_fo_disable_css_minify.html">powered_cache_fo_disable_css_minify</a></li><li><a href="powered_cache_fo_disable_html_minify.html">powered_cache_fo_disable_html_minify</a></li><li><a href="powered_cache_fo_disable_js_combine.html">powered_cache_fo_disable_js_combine</a></li><li><a href="powered_cache_fo_disable_js_minify.html">powered_cache_fo_disable_js_minify</a></li><li><a href="powered_cache_fo_excluded_css_files.html">powered_cache_fo_excluded_css_files</a></li><li><a href="powered_cache_fo_excluded_js_files.html">powered_cache_fo_excluded_js_files</a></li><li><a href="powered_cache_fo_google_font_display.html">powered_cache_fo_google_font_display</a></li><li><a href="powered_cache_fo_google_fonts_domain.html">powered_cache_fo_google_fonts_domain</a></li><li><a href="powered_cache_fo_js_do_concat.html">powered_cache_fo_js_do_concat</a></li><li><a href="powered_cache_fo_relative_path.html">powered_cache_fo_relative_path</a></li><li><a href="powered_cache_fo_script_loader_tag.html">powered_cache_fo_script_loader_tag</a></li><li><a href="powered_cache_fo_site_url.html">powered_cache_fo_site_url</a></li><li><a href="powered_cache_fo_style_loader_tag.html">powered_cache_fo_style_loader_tag</a></li><li><a href="powered_cache_get_page_cache_dir.html">powered_cache_get_page_cache_dir</a></li><li><a href="powered_cache_htaccess_add_cors.html">powered_cache_htaccess_add_cors</a></li><li><a href="powered_cache_htaccess_cache_control_rules.html">powered_cache_htaccess_cache_control_rules</a></li><li><a href="powered_cache_htaccess_enable_gzip_compression.html">powered_cache_htaccess_enable_gzip_compression</a></li><li><a href="powered_cache_ignored_query_strings.html">powered_cache_ignored_query_strings</a></li><li><a href="powered_cache_js_execution_methods.html">powered_cache_js_execution_methods</a></li><li><a href="powered_cache_known_headers.html">powered_cache_known_headers</a></li><li><a href="powered_cache_lazy_load_avatar.html">powered_cache_lazy_load_avatar</a></li><li><a href="powered_cache_lazy_load_enabled.html">powered_cache_lazy_load_enabled</a></li><li><a href="powered_cache_lazy_load_exclusions.html">powered_cache_lazy_load_exclusions</a></li><li><a href="powered_cache_lazy_load_html.html">powered_cache_lazy_load_html</a></li><li><a href="powered_cache_lazy_load_iframes.html">powered_cache_lazy_load_iframes</a></li><li><a href="powered_cache_lazy_load_images.html">powered_cache_lazy_load_images</a></li><li><a href="powered_cache_lazy_load_post_content.html">powered_cache_lazy_load_post_content</a></li><li><a href="powered_cache_lazy_load_post_thumbnail.html">powered_cache_lazy_load_post_thumbnail</a></li><li><a href="powered_cache_lazy_load_run_filter.html">powered_cache_lazy_load_run_filter</a></li><li><a href="powered_cache_lazy_load_skip_classes.html">powered_cache_lazy_load_skip_classes</a></li><li><a href="powered_cache_lazy_load_skip_first_nth_img.html">powered_cache_lazy_load_skip_first_nth_img</a></li><li><a href="powered_cache_lazy_load_threshold.html">powered_cache_lazy_load_threshold</a></li><li><a href="powered_cache_lazy_load_widget_text.html">powered_cache_lazy_load_widget_text</a></li><li><a href="powered_cache_lazy_load_youtube.html">powered_cache_lazy_load_youtube</a></li><li><a href="powered_cache_lazy_load_youtube_css.html">powered_cache_lazy_load_youtube_css</a></li><li><a href="powered_cache_log_destination.html">powered_cache_log_destination</a></li><li><a href="powered_cache_log_message.html">powered_cache_log_message</a></li><li><a href="powered_cache_log_message_type.html">powered_cache_log_message_type</a></li><li><a href="powered_cache_maybe_1and1_hosting.html">powered_cache_maybe_1and1_hosting</a></li><li><a href="powered_cache_mod_rewrite.html">powered_cache_mod_rewrite</a></li><li><a href="powered_cache_object_cache_dropins.html">powered_cache_object_cache_dropins</a></li><li><a href="powered_cache_object_cache_file_content.html">powered_cache_object_cache_file_content</a></li><li><a href="powered_cache_page_cache_meta_info.html">powered_cache_page_cache_meta_info</a></li><li><a href="powered_cache_page_cache_meta_params.html">powered_cache_page_cache_meta_params</a></li><li><a href="powered_cache_page_caching_buffer.html">powered_cache_page_caching_buffer</a></li><li><a href="powered_cache_post_related_urls.html">powered_cache_post_related_urls</a></li><li><a href="powered_cache_pre_htaccess.html">powered_cache_pre_htaccess</a></li><li><a href="powered_cache_preconnect_resource.html">powered_cache_preconnect_resource</a></li><li><a href="powered_cache_prefetch_dns.html">powered_cache_prefetch_dns</a></li><li><a href="powered_cache_preload_add_url_to_queue.html">powered_cache_preload_add_url_to_queue</a></li><li><a href="powered_cache_preload_expired_urls.html">powered_cache_preload_expired_urls</a></li><li><a href="powered_cache_preload_mobile_user_agent.html">powered_cache_preload_mobile_user_agent</a></li><li><a href="powered_cache_preload_post_limit.html">powered_cache_preload_post_limit</a></li><li><a href="powered_cache_preload_post_types.html">powered_cache_preload_post_types</a></li><li><a href="powered_cache_preload_public_posts_offset.html">powered_cache_preload_public_posts_offset</a></li><li><a href="powered_cache_preload_public_taxonomies_offset.html">powered_cache_preload_public_taxonomies_offset</a></li><li><a href="powered_cache_preload_request_interval.html">powered_cache_preload_request_interval</a></li><li><a href="powered_cache_preload_tax_term_args.html">powered_cache_preload_tax_term_args</a></li><li><a href="powered_cache_preload_taxonomies.html">powered_cache_preload_taxonomies</a></li><li><a href="powered_cache_preload_term_limit.html">powered_cache_preload_term_limit</a></li><li><a href="powered_cache_preload_url_request_args.html">powered_cache_preload_url_request_args</a></li><li><a href="powered_cache_preloader_max_server_load.html">powered_cache_preloader_max_server_load</a></li><li><a href="powered_cache_preloader_should_continue.html">powered_cache_preloader_should_continue</a></li><li><a href="powered_cache_rejected_cookies.html">powered_cache_rejected_cookies</a></li><li><a href="powered_cache_rejected_referrers.html">powered_cache_rejected_referrers</a></li><li><a href="powered_cache_rejected_uri_list.html">powered_cache_rejected_uri_list</a></li><li><a href="powered_cache_rejected_user_agents.html">powered_cache_rejected_user_agents</a></li><li><a href="powered_cache_sanitized_options.html">powered_cache_sanitized_options</a></li><li><a href="powered_cache_scheduled_cleanup_frequency_options.html">powered_cache_scheduled_cleanup_frequency_options</a></li><li><a href="powered_cache_site_cache_dir.html">powered_cache_site_cache_dir</a></li><li><a href="powered_cache_vary_cookies.html">powered_cache_vary_cookies</a></li></ul>
</nav>
<br class="clear">
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>