Changeset 3070210
- Timestamp:
- 04/14/2024 12:40:41 PM (21 months ago)
- Location:
- lazy-loading-responsive-images
- Files:
-
- 38 edited
- 1 copied
-
tags/8.2.0 (copied) (copied from lazy-loading-responsive-images/trunk)
-
tags/8.2.0/lazy-load-responsive-images.php (modified) (3 diffs)
-
tags/8.2.0/readme.txt (modified) (3 diffs)
-
tags/8.2.0/src/Helpers.php (modified) (22 diffs)
-
tags/8.2.0/src/Plugin.php (modified) (54 diffs)
-
tags/8.2.0/src/Settings.php (modified) (57 diffs)
-
tags/8.2.0/vendor/autoload.php (modified) (1 diff)
-
tags/8.2.0/vendor/composer/ClassLoader.php (modified) (27 diffs)
-
tags/8.2.0/vendor/composer/InstalledVersions.php (modified) (4 diffs)
-
tags/8.2.0/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/8.2.0/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/8.2.0/vendor/composer/installed.json (modified) (2 diffs)
-
tags/8.2.0/vendor/composer/installed.php (modified) (3 diffs)
-
tags/8.2.0/vendor/masterminds/html5/RELEASE.md (modified) (1 diff)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Elements.php (modified) (2 diffs)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php (modified) (3 diffs)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/Scanner.php (modified) (1 diff)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php (modified) (5 diffs)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php (modified) (5 diffs)
-
tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/UTF8Utils.php (modified) (2 diffs)
-
trunk/lazy-load-responsive-images.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Helpers.php (modified) (22 diffs)
-
trunk/src/Plugin.php (modified) (54 diffs)
-
trunk/src/Settings.php (modified) (57 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/ClassLoader.php (modified) (27 diffs)
-
trunk/vendor/composer/InstalledVersions.php (modified) (4 diffs)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.json (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (3 diffs)
-
trunk/vendor/masterminds/html5/RELEASE.md (modified) (1 diff)
-
trunk/vendor/masterminds/html5/src/HTML5/Elements.php (modified) (2 diffs)
-
trunk/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php (modified) (3 diffs)
-
trunk/vendor/masterminds/html5/src/HTML5/Parser/Scanner.php (modified) (1 diff)
-
trunk/vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php (modified) (5 diffs)
-
trunk/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php (modified) (5 diffs)
-
trunk/vendor/masterminds/html5/src/HTML5/Parser/UTF8Utils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lazy-loading-responsive-images/tags/8.2.0/lazy-load-responsive-images.php
r2843576 r3070210 10 10 * Plugin URI: https://florianbrinkmann.com/en/3350/responsive-images-and-lazy-loading-in-wordpress/ 11 11 * Description: Lazy loading plugin that supports images, iFrames, video and audio elements and uses lazysizes.js. With manual modification of the markup it is also possible to lazy load background images, scripts, and styles. 12 * Version: 8. 1.112 * Version: 8.2.0 13 13 * Author: Florian Brinkmann 14 14 * Author URI: https://florianbrinkmann.com/en/ … … 19 19 namespace FlorianBrinkmann\LazyLoadResponsiveImages; 20 20 21 // Load Composer autoloader. From https://github.com/brightnucleus/jasper-client/blob/master/tests/bootstrap.php#L55-L5922 21 $autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; 23 22 if ( is_readable( $autoloader ) ) { … … 29 28 } 30 29 31 // Create object.32 30 $lazy_loader = new Plugin(); 33 31 34 // Set plugin basename. 32 35 33 $lazy_loader->set_basename( plugin_basename( __FILE__ ) ); 36 34 $lazy_loader->set_js_asset_url( plugins_url( 'js/build/functions.js', __FILE__ ) ); 37 35 38 // Init the plugin.39 36 $lazy_loader->init(); -
lazy-loading-responsive-images/tags/8.2.0/readme.txt
r2843576 r3070210 4 4 Tags: lazysizes, lazy loading, performance, images 5 5 Requires at least: 4.9.8 6 Tested up to: 6. 17 Stable tag: 8. 1.16 Tested up to: 6.5 7 Stable tag: 8.2.0 8 8 Requires PHP: 7.0 9 9 … … 45 45 * Styles. 46 46 47 The plugin adds a `noscript` element as fallback for disabled JavaScript .47 The plugin adds a `noscript` element as fallback for disabled JavaScript (can be disabled with the `lazy_loader_generate_noscript` filter). 48 48 49 49 You can disable lazy loading for elements with specific CSS classes by defining them via the plugin settings (*Settings* › *Media* › *Lazy Loader options*). Or use the `skip-lazy` class or the `data-skip-lazy` attribute. `skip-lazy` and `data-skip-lazy` also work on wrapper elements to exclude the wrapper and its children from being processed. … … 105 105 == Changelog == 106 106 107 = 8.2.0 – 14.04.2024 = 108 109 Tested with WordPress 6.5. 110 111 **Added** 112 113 * `lazy_loader_generate_noscript` filter to allow disabling of `noscript` element generation. 114 115 **Fixed** 116 117 - Updated `mastermind/html5` dependency to latest version, which fixes a PHP deprecation notice. 118 107 119 = 8.1.1 – 20.12.2022 = 108 120 -
lazy-loading-responsive-images/tags/8.2.0/src/Helpers.php
r2843576 r3070210 1 1 <?php 2 2 /** 3 * Helper methods.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 10 8 use FlorianBrinkmann\LazyLoadResponsiveImages\Settings as Settings; 11 9 12 /**13 * Class Helpers14 *15 * Class with helper methods.16 *17 * @package FlorianBrinkmann\LazyLoadResponsiveImages18 */19 10 class Helpers { 20 11 21 12 /** 22 * Hint if the plugin is disabled for this post.23 *24 13 * @var null|int 25 14 */ … … 27 16 28 17 /** 29 * Checks if this is a request at the backend.30 *31 18 * @return bool true if is admin request, otherwise false. 32 19 */ … … 46 33 47 34 /* 48 * Get admin URL and referrer.49 *50 35 * @link https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/pluggable.php#L1076 51 36 */ … … 53 38 $referrer = strtolower( wp_get_referer() ); 54 39 55 // Check if this is a admin request. If true, it56 // could also be a AJAX request.57 40 if ( 0 === strpos( $current_url, $admin_url ) ) { 58 // Check if the user comes from a admin page.59 41 if ( 0 === strpos( $referrer, $admin_url ) ) { 60 42 return true; 61 43 } else { 62 /*63 * Check for AJAX requests.64 *65 * @link https://gist.github.com/zitrusblau/58124d4b2c56d06b070573a99f33b9ed#file-lazy-load-responsive-images-php-L19366 */67 44 if ( function_exists( 'wp_doing_ajax' ) ) { 68 45 return ! wp_doing_ajax(); … … 80 57 81 58 /** 82 * Checks if we are on an AMP page generated from the Automattic plugin.83 *84 59 * @return bool true if is amp page, false otherwise. 85 60 */ 86 61 public function is_amp_page() { 87 // Check if Automattic’s AMP plugin is active and we are on an AMP endpoint.88 62 if ( function_exists( 'is_amp_endpoint' ) && true === is_amp_endpoint() ) { 89 63 return true; … … 94 68 95 69 /** 96 * Check if plugin is disabled for current post.97 *98 70 * @return bool true if disabled, false otherwise. 99 71 */ 100 72 public function is_disabled_for_post() { 101 // Check if the plugin is disabled.102 73 if ( null === $this->disabled_for_current_post ) { 103 74 $this->disabled_for_current_post = absint( get_post_meta( get_the_ID(), 'lazy_load_responsive_images_disabled', true ) ); … … 117 88 118 89 /** 119 * Check if the displayed content is something that the plugin should process.120 *121 90 * @return bool 122 91 */ … … 126 95 } 127 96 128 // Check if we are on a feed page.129 97 if ( is_feed() ) { 130 98 return false; 131 99 } 132 100 133 // Check if this content is embedded.134 101 if ( is_embed() ) { 135 102 return false; 136 103 } 137 104 138 // Check if this is a request in the backend.139 105 if ( $this->is_admin_request() ) { 140 106 return false; 141 107 } 142 108 143 // Check for AMP page.144 109 if ( $this->is_amp_page() ) { 145 110 return false; 146 111 } 147 112 148 // Check for Oxygen Builder mode.149 113 if ( defined( 'SHOW_CT_BUILDER' ) ) { 150 114 return false; 151 115 } 152 116 153 // Check for TranslatePress editor.154 117 if ( isset( $_REQUEST['trp-edit-translation'] ) ) { 155 118 return false; … … 160 123 161 124 /** 162 * Sanitize comma separated list of class names.163 *164 125 * @param string $class_names Comma separated list of HTML class names. 165 126 * … … 167 128 */ 168 129 public function sanitize_class_name_list( $class_names ) { 169 // Get array of the class names.170 130 $class_names_array = explode( ',', $class_names ); 171 131 … … 174 134 } 175 135 176 // Loop through the class names.177 136 foreach ( $class_names_array as $i => $class_name ) { 178 // Save the sanitized class name.179 137 $class_names_array[ $i ] = sanitize_html_class( $class_name ); 180 138 } 181 139 182 // Implode the class names.183 140 $class_names = implode( ',', $class_names_array ); 184 141 … … 187 144 188 145 /** 189 * Sanitize list of filter names.190 *191 146 * @param string $filters One or more WordPress filters, one per line. 192 147 * … … 194 149 */ 195 150 public function sanitize_filter_name_list( $filters ) { 196 // Get array of the filter names.197 151 $filters_array = explode( "\n", $filters ); 198 152 … … 201 155 } 202 156 203 // Loop through the filter names.204 157 foreach ( $filters_array as $i => $filter ) { 205 158 $function_name_regex = '/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/'; … … 207 160 $filters_array[$i] = trim( $filters_array[$i] ); 208 161 209 // Check if the filter is a valid PHP function name.210 162 if ( preg_match( $function_name_regex, $filters_array[$i] ) !== 1 ) { 211 163 unset( $filters_array[$i] ); … … 214 166 } 215 167 216 // Implode the filter names.217 168 $filters = implode( "\n", $filters_array ); 218 169 … … 221 172 222 173 /** 223 * Sanitize checkbox.224 *225 174 * @link https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php 226 175 * … … 234 183 235 184 /** 236 * Sanitize textarea input.237 *238 185 * @param bool $checked Whether the checkbox is checked. 239 186 * … … 245 192 246 193 /** 247 * Sanitize hex color value.248 *249 194 * @param string $value The input from the color input. 250 195 * … … 252 197 */ 253 198 public function sanitize_hex_color( $value ) { 254 // Sanitize the input.255 199 $sanitized = sanitize_hex_color( $value ); 256 200 if ( null !== $sanitized && '' !== $sanitized ) { … … 259 203 $settings = new Settings(); 260 204 return $settings->get_loading_spinner_color_default(); 261 } // End if().205 } 262 206 } 263 207 -
lazy-loading-responsive-images/tags/8.2.0/src/Plugin.php
r2505151 r3070210 1 1 <?php 2 2 /** 3 * Main plugin code.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 14 12 use Masterminds\HTML5; 15 13 16 /**17 * Class Plugin18 *19 * Class for adding lazy loading to responsive images.20 *21 * @package FlorianBrinkmann\LazyLoadResponsiveImages22 */23 14 class Plugin { 24 15 25 16 /** 26 * Helpers object.27 *28 17 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Helpers 29 18 */ … … 31 20 32 21 /** 33 * Settings object.34 *35 22 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Settings 36 23 */ … … 38 25 39 26 /** 40 * Array of classes which should not be lazy loaded.41 *42 27 * @var array 43 28 */ … … 45 30 46 31 /** 47 * Basename of the plugin.48 *49 32 * @var string 50 33 */ … … 52 35 53 36 /** 54 * URL to editor JS file.55 *56 37 * @var string 57 38 */ … … 59 40 60 41 /** 61 * Placeholder data uri for img src attributes.62 *63 42 * @link https://stackoverflow.com/a/13139830 64 43 * … … 68 47 69 48 /** 70 * Counter for background image classes.49 * @var int 71 50 */ 72 51 private $background_image_number = 1; 73 52 74 53 /** 75 * Plugin constructor. 76 */ 77 public function __construct() { 78 79 } 80 81 /** 82 * Runs the filters and actions. 83 */ 54 * @var bool 55 */ 56 private $generate_noscript; 57 84 58 public function init() { 85 // Init settings.86 59 $this->settings = new Settings(); 87 60 88 // Set helpers.89 61 $this->helpers = new Helpers(); 90 62 91 // Get the disabled classes and save in property.92 63 $this->disabled_classes = $this->settings->get_disabled_classes(); 93 64 94 // Disable core lazy loading. 65 add_action( 'init', function() { 66 /** 67 * Filter to disable the generation of a noscript element. 68 * 69 * @param bool $generate_noscript Whether to generate a noscript element or not. 70 */ 71 $this->generate_noscript = (bool) apply_filters( 'lazy_loader_generate_noscript', true ); 72 }, 5 ); 73 95 74 add_filter( 'wp_lazy_loading_enabled', '__return_false' ); 96 75 97 // Add link to settings in the plugin list.98 76 add_filter( 'plugin_action_links', array( 99 77 $this, … … 103 81 add_action( 'init', array( $this, 'init_content_processing' ) ); 104 82 105 // Enqueues scripts and styles.106 83 add_action( 'wp_enqueue_scripts', array( 107 84 $this, … … 109 86 ), 20 ); 110 87 111 // Adds inline style.112 88 add_action( 'wp_head', array( $this, 'add_inline_style' ) ); 113 89 114 // Enqueue Gutenberg script.115 90 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) ); 116 91 117 // Load the language files.118 92 add_action( 'plugins_loaded', array( $this, 'load_translation' ) ); 119 93 120 // Action on uninstall.121 94 register_uninstall_hook( $this->basename, 'FlorianBrinkmann\LazyLoadResponsiveImages\Plugin::uninstall' ); 122 95 } 123 124 /** 125 * Run actions and filters to start content processing. 126 */ 96 127 97 public function init_content_processing() { 128 // Check if the complete markup should be processed.129 98 if ( '1' === $this->settings->get_process_complete_markup() ) { 130 99 add_action( 'template_redirect', array( $this, 'process_complete_markup' ) ); 131 100 } else { 132 // Filter markup of the_content() calls to modify media markup for lazy loading.133 101 add_filter( 'the_content', array( $this, 'filter_markup' ), 10001 ); 134 102 135 // Filter allowed html for posts to allow <noscript> tag.136 103 add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); 137 104 138 // Filter markup of Text widget to modify media markup for lazy loading.139 105 add_filter( 'widget_text', array( $this, 'filter_markup' ) ); 140 106 141 // Filter markup of gravatars to modify markup for lazy loading.142 107 add_filter( 'get_avatar', array( $this, 'filter_markup' ) ); 143 108 144 // Adds lazyload markup and noscript element to post thumbnail.145 109 add_filter( 'post_thumbnail_html', array( 146 110 $this, … … 157 121 } 158 122 } 159 160 /** 161 * Run output buffering, to process the complete markup. 162 */ 123 163 124 public function process_complete_markup() { 164 // If this is no content we should process, exit as early as possible.165 125 if ( ! $this->helpers->is_post_to_process() ) { 166 126 return; … … 171 131 172 132 /** 173 * Add settings link to the plugin entry in the plugin list.174 *175 133 * @param array $links Array of action links. 176 134 * @param string $file Basename of the plugin. … … 191 149 192 150 /** 193 * Modifies elements to automatically enable lazy loading.194 *195 151 * @param string $content HTML. 196 152 * … … 198 154 */ 199 155 public function filter_markup( $content = '' ) { 200 // If this is no content we should process, exit as early as possible.201 156 if ( ! $this->helpers->is_post_to_process() ) { 202 157 return $content; 203 158 } 204 159 205 // Check if we have no content.206 160 if ( empty( $content ) ) { 207 161 return $content; 208 162 } 209 163 210 // Check if content contains caption shortcode.211 164 if ( has_shortcode( $content, 'caption' ) ) { 212 165 return $content; 213 166 } 214 167 215 // Disable libxml errors.216 168 libxml_use_internal_errors( true ); 217 169 218 // Create new HTML5 object.219 170 $html5 = new HTML5( array( 220 171 'disable_html_ns' => true, … … 228 179 $content = str_replace( '<![endif]-->', '<!--<![endif]-->', $content ); 229 180 230 // Load the HTML.231 181 $dom = $html5->loadHTML( $content ); 232 182 233 183 $xpath = new \DOMXPath( $dom ); 234 184 235 // Get all nodes except the ones that live inside a noscript element.236 // @link https://stackoverflow.com/a/19348287/7774451.237 185 $nodes = $xpath->query( "//*[not(ancestor-or-self::noscript)][not(ancestor-or-self::*[contains(@class, 'disable-lazyload') or contains(@class, 'skip-lazy') or @data-skip-lazy])]" ); 238 186 … … 240 188 241 189 foreach ( $nodes as $node ) { 242 // Check if it is an element that should not be lazy loaded.243 // Get the classes as an array.244 190 $node_classes = explode( ' ', $node->getAttribute( 'class' ) ); 245 191 246 // Check for intersection with array of classes, which should247 // not be lazy loaded.248 192 $result = array_intersect( $this->disabled_classes, $node_classes ); 249 193 250 // Filter empty values.251 194 $result = array_filter( $result ); 252 253 /* 254 * Check if: 255 * - we have no result from the array intersection. 256 * - the node does not have the data-no-lazyload attr. 257 * - the node does not already have the lazyload class. 258 */ 195 259 196 if ( ! empty( $result ) || $node->hasAttribute( 'data-no-lazyload' ) || in_array( 'lazyload', $node_classes, true ) ) { 260 197 continue; 261 198 } 262 199 263 // Check if the element has a style attribute with a background image.264 200 if ( 265 201 '1' === $this->settings->get_enable_for_background_images() … … 277 213 } 278 214 279 // Check if it is one of the supported elements and support for it is enabled.280 215 if ( 'img' === $node->tagName && 'source' !== $node->parentNode->tagName && 'picture' !== $node->parentNode->tagName ) { 281 216 $dom = $this->modify_img_markup( $node, $dom ); … … 349 284 350 285 /** 351 * Modifies element markup for lazy loading inline background image.352 *353 286 * @param \DOMNode $node The node with the inline background image. 354 287 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 359 292 $original_css = $node->getAttribute( 'style' ); 360 293 $classes = $node->getAttribute( 'class' ); 361 // It is possible that there are multiple background rules for a inline element (including ones for size, position, et cetera). 362 // We will insert all of them to the inline style element, to not mess up their order. 294 363 295 if ( 0 !== preg_match_all( '/background(-[a-z]+)?:([^;])*;?/', $node->getAttribute( 'style' ), $matches ) ) { 364 // $matches[0] contains the full CSS background rules.365 // We remove the rules from the inline style.366 296 $modified_css = str_replace( $matches[0], '', $original_css ); 367 297 $node->setAttribute( 'style', $modified_css ); 368 298 369 // Build string of background rules.370 299 $background_rules_string = implode( ' ', $matches[0] ); 371 300 372 // Add unique class and lazyload class to element.373 301 $unique_class = "lazy-loader-background-element-$this->background_image_number"; 374 302 $classes .= " lazyload $unique_class "; … … 376 304 $this->background_image_number++; 377 305 378 // Create style element with the background rule.379 306 $background_style_elem = $dom->createElement( 'style', ".$unique_class.lazyloaded{ $background_rules_string }" ); 380 307 $node->parentNode->insertBefore( $background_style_elem, $node ); 381 308 382 // Add the noscript element. 309 if ( ! $this->generate_noscript ) { 310 return $dom; 311 } 312 383 313 $noscript = $dom->createElement( 'noscript' ); 384 385 // Insert it before the img node.386 314 $noscript_node = $node->parentNode->insertBefore( $noscript, $node ); 387 388 // Create element.389 315 $background_style_elem_noscript = $dom->createElement( 'style', ".$unique_class.lazyload{ $background_rules_string }" ); 390 391 // Add media node to noscript node.392 316 $noscript_node->appendChild( $background_style_elem_noscript ); 393 317 } 318 394 319 return $dom; 395 320 } 396 321 397 322 /** 398 * Modifies img markup to enable lazy loading.399 *400 323 * @param \DOMNode $img The img dom node. 401 324 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 405 328 */ 406 329 public function modify_img_markup( $img, $dom, $create_noscript = true ) { 407 // Check if the element already has a data-src attribute (might be the case for408 // plugins that bring their own lazy load functionality) and skip it to prevent conflicts.409 330 if ( $img->hasAttribute( 'data-src' ) ) { 410 331 return $dom; 411 332 } 412 333 413 // Add noscript element.414 334 if ( true === $create_noscript ) { 415 335 $dom = $this->add_noscript_element( $dom, $img ); 416 336 } 417 337 418 // Check if the image has sizes and srcset attribute.419 338 $sizes_attr = ''; 420 339 if ( $img->hasAttribute( 'sizes' ) ) { 421 // Get sizes value.422 340 $sizes_attr = $img->getAttribute( 'sizes' ); 423 341 424 // Check if the value is auto. If so, we modify it to data-sizes.425 342 if ( 'auto' === $sizes_attr ) { 426 // Set data-sizes attribute.427 343 $img->setAttribute( 'data-sizes', $sizes_attr ); 428 344 429 // Remove sizes attribute.430 345 $img->removeAttribute( 'sizes' ); 431 346 } … … 433 348 434 349 if ( $img->hasAttribute( 'srcset' ) ) { 435 // Get srcset value.436 350 $srcset = $img->getAttribute( 'srcset' ); 437 351 438 // Set data-srcset attribute.439 352 $img->setAttribute( 'data-srcset', $srcset ); 440 353 441 // Set srcset attribute with src placeholder to produce valid markup.442 354 $img_width = $img->getAttribute( 'width' ); 443 355 if ( '' !== $img_width ) { … … 451 363 } 452 364 } else { 453 // Remove srcset attribute.454 365 $img->removeAttribute( 'srcset' ); 455 366 } 456 367 } 457 368 458 // Get src value.459 369 $src = $img->getAttribute( 'src' ); 460 370 461 // Set data-src value.462 371 $img->setAttribute( 'data-src', $src ); 463 372 … … 466 375 } 467 376 468 // Get the classes.469 377 $classes = $img->getAttribute( 'class' ); 470 378 471 // Add lazyload class.472 379 $classes .= ' lazyload'; 473 380 474 // Set the class string.475 381 $img->setAttribute( 'class', $classes ); 476 382 477 // Get width and height.478 383 $img_width = $img->getAttribute( 'width' ); 479 384 $img_height = $img->getAttribute( 'height' ); 480 385 481 // Set data URI for src attribute.482 386 if ( '' !== $img_width && '' !== $img_height ) { 483 // We have image width and height, we can set a inline SVG to prevent content jumps.484 387 $svg_placeholder = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20{$img_width}%20{$img_height}%22%3E%3C%2Fsvg%3E"; 485 388 $img->setAttribute( 'src', $svg_placeholder ); … … 496 399 497 400 /** 498 * Modifies input[type="image"] markup to enable lazy loading.499 *500 401 * @param \DOMNode $node The input dom node. 501 402 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 505 406 */ 506 407 public function modify_input_markup( $node, $dom, $create_noscript = true ) { 507 // Check if the element already has a data-src attribute (might be the case for508 // plugins that bring their own lazy load functionality) and skip it to prevent conflicts.509 408 if ( $node->hasAttribute( 'data-src' ) ) { 510 409 return $dom; 511 410 } 512 411 513 // Add noscript element.514 412 if ( true === $create_noscript ) { 515 413 $dom = $this->add_noscript_element( $dom, $node ); 516 414 } 517 415 518 // Get src value.519 416 $src = $node->getAttribute( 'src' ); 520 417 521 // Set data-src value.522 418 $node->setAttribute( 'data-src', $src ); 523 419 524 // Get the classes.525 420 $classes = $node->getAttribute( 'class' ); 526 421 527 // Add lazyload class.528 422 $classes .= ' lazyload'; 529 423 530 // Set the class string.531 424 $node->setAttribute( 'class', $classes ); 532 425 533 // Get width and height.534 426 $node_width = $node->getAttribute( 'width' ); 535 427 $node_height = $node->getAttribute( 'height' ); 536 428 537 // Set data URI for src attribute.538 429 if ( '' !== $node_width && '' !== $node_height ) { 539 // We have image width and height, we can set a inline SVG to prevent content jumps.540 430 $svg_placeholder = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20{$node_width}%20{$node_height}%22%3E%3C%2Fsvg%3E"; 541 431 $node->setAttribute( 'src', $svg_placeholder ); … … 552 442 553 443 /** 554 * Modifies picture element markup to enable lazy loading.555 *556 444 * @param \DOMNode $picture The source dom node. 557 445 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 560 448 */ 561 449 public function modify_picture_markup( $picture, $dom ) { 562 // Check if img element already has `layzload` class.563 450 $img_element = $picture->getElementsByTagName( 'img' ); 564 451 … … 569 456 } 570 457 571 // Add noscript element.572 458 $dom = $this->add_noscript_element( $dom, $picture ); 573 459 574 // Get source elements from picture.575 460 $source_elements = $picture->getElementsByTagName( 'source' ); 576 461 577 // Loop the source elements if there are some.578 462 if ( 0 !== $source_elements->length ) { 579 463 foreach ( $source_elements as $source_element ) { 580 // Check if we have a sizes attribute.581 464 $sizes_attr = ''; 582 465 if ( $source_element->hasAttribute( 'sizes' ) ) { 583 // Get sizes value.584 466 $sizes_attr = $source_element->getAttribute( 'sizes' ); 585 467 586 // Check if the value is auto. If so, we modify it to data-sizes.587 468 if ( 'auto' === $sizes_attr ) { 588 // Set data-sizes attribute.589 469 $source_element->setAttribute( 'data-sizes', $sizes_attr ); 590 470 591 // Remove sizes attribute.592 471 $source_element->removeAttribute( 'sizes' ); 593 472 } 594 473 } 595 474 596 // Check for srcset.597 475 if ( $source_element->hasAttribute( 'srcset' ) ) { 598 // Get srcset value.599 476 $srcset = $source_element->getAttribute( 'srcset' ); 600 477 601 // Set data-srcset attribute.602 478 $source_element->setAttribute( 'data-srcset', $srcset ); 603 479 604 // Set srcset attribute with src placeholder to produce valid markup.605 480 if ( '' !== $sizes_attr ) { 606 481 $width = preg_replace( '/.+ (\d+)px$/', '$1', $sizes_attr ); … … 611 486 } 612 487 } else { 613 // Remove srcset attribute.614 488 $source_element->removeAttribute( 'srcset' ); 615 489 } … … 617 491 618 492 if ( $source_element->hasAttribute( 'src' ) ) { 619 // Get src value.620 493 $src = $source_element->getAttribute( 'src' ); 621 494 622 // Set data-src value.623 495 $source_element->setAttribute( 'data-src', $src ); 624 496 625 // Set data URI for src attribute.626 497 $source_element->setAttribute( 'src', $this->src_placeholder ); 627 498 } … … 629 500 } 630 501 631 // Loop the img element.632 502 foreach ( $img_element as $img ) { 633 503 $this->modify_img_markup( $img, $dom, false ); … … 638 508 639 509 /** 640 * Modifies iframe markup to enable lazy loading.641 *642 510 * @param \DOMNode $iframe The iframe dom node. 643 511 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 646 514 */ 647 515 public function modify_iframe_markup( $iframe, $dom ) { 648 // Add noscript element.649 516 $dom = $this->add_noscript_element( $dom, $iframe ); 650 517 651 // Check if the iframe has a src attribute.652 518 if ( $iframe->hasAttribute( 'src' ) ) { 653 // Get src attribute.654 519 $src = $iframe->getAttribute( 'src' ); 655 520 656 // Set data-src value.657 521 $iframe->setAttribute( 'data-src', $src ); 658 522 } else { … … 664 528 } 665 529 666 // Get the classes.667 530 $classes = $iframe->getAttribute( 'class' ); 668 531 669 // Add lazyload class.670 532 $classes .= ' lazyload'; 671 533 672 // Set the class string.673 534 $iframe->setAttribute( 'class', $classes ); 674 535 675 // Remove the src attribute.676 536 $iframe->removeAttribute( 'src' ); 677 537 … … 680 540 681 541 /** 682 * Modifies video markup to enable lazy loading.683 *684 542 * @param \DOMNode $video The video dom node. 685 543 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 688 546 */ 689 547 public function modify_video_markup( $video, $dom ) { 690 // Add noscript element.691 548 $dom = $this->add_noscript_element( $dom, $video ); 692 549 693 // Check if the video has a poster attribute.694 550 if ( $video->hasAttribute( 'poster' ) ) { 695 // Get poster attribute.696 551 $poster = $video->getAttribute( 'poster' ); 697 552 698 // Remove the poster attribute.699 553 $video->removeAttribute( 'poster' ); 700 554 701 // Set data-poster value.702 555 $video->setAttribute( 'data-poster', $poster ); 703 556 } 704 557 705 // Set preload to none.706 558 $video->setAttribute( 'preload', 'none' ); 707 559 708 // Check for autoplay attribute and change it for lazy loading.709 560 if ( $video->hasAttribute( 'autoplay' ) ) { 710 561 $video->removeAttribute( 'autoplay' ); … … 712 563 } 713 564 714 // Get the classes.715 565 $classes = $video->getAttribute( 'class' ); 716 566 717 // Add lazyload class.718 567 $classes .= ' lazyload'; 719 568 720 // Set the class string.721 569 $video->setAttribute( 'class', $classes ); 722 570 … … 725 573 726 574 /** 727 * Modifies audio markup to enable lazy loading.728 *729 575 * @param \DOMNode $audio The audio dom node. 730 576 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 733 579 */ 734 580 public function modify_audio_markup( $audio, $dom ) { 735 // Add noscript element.736 581 $dom = $this->add_noscript_element( $dom, $audio ); 737 582 738 // Set preload to none.739 583 $audio->setAttribute( 'preload', 'none' ); 740 584 741 // Get the classes.742 585 $classes = $audio->getAttribute( 'class' ); 743 586 744 // Add lazyload class.745 587 $classes .= ' lazyload'; 746 588 747 // Set the class string.748 589 $audio->setAttribute( 'class', $classes ); 749 590 … … 752 593 753 594 /** 754 * Adds noscript element before DOM node.755 *756 595 * @param \DOMDocument $dom \DOMDocument() object of the 757 596 * HTML. … … 761 600 */ 762 601 public function add_noscript_element( $dom, $elem ) { 763 // Create noscript element and add it before the element that gets lazy loading. 602 if ( ! $this->generate_noscript ) { 603 return $dom; 604 } 605 764 606 $noscript = $dom->createElement( 'noscript' ); 765 607 $noscript_node = $elem->parentNode->insertBefore( $noscript, $elem ); 766 608 767 // Create copy of media element.768 609 $noscript_media_fallback_elem = $elem->cloneNode( true ); 769 610 … … 779 620 } 780 621 781 // Add a copy of the media element to the noscript.782 622 $noscript_node->appendChild( $noscript_media_fallback_elem ); 783 623 … … 786 626 787 627 /** 788 * Filter allowed html for posts.789 *790 628 * @param array $allowedposttags Allowed post tags. 791 629 * @param string $context Context. … … 802 640 return $allowedposttags; 803 641 } 804 805 /** 806 * Enqueues scripts and styles. 807 */ 642 808 643 public function enqueue_script() { 809 644 if ( $this->helpers->is_disabled_for_post() ) { … … 818 653 } 819 654 820 // Enqueue lazysizes.821 655 wp_enqueue_script( 'lazysizes', plugins_url( '/lazy-loading-responsive-images/js/lazysizes.min.js' ), array(), filemtime( plugin_dir_path( __FILE__ ) . '../js/lazysizes.min.js' ), true ); 822 656 823 // Check if unveilhooks plugin should be loaded.824 657 if ( '1' === $this->settings->get_load_unveilhooks_plugin() || '1' === $this->settings->get_enable_for_audios() || '1' === $this->settings->get_enable_for_videos() || '1' === $this->settings->get_enable_for_background_images() ) { 825 // Enqueue unveilhooks plugin.826 658 wp_enqueue_script( 'lazysizes-unveilhooks', plugins_url( '/lazy-loading-responsive-images/js/ls.unveilhooks.min.js' ), array( 'lazysizes' ), filemtime( plugin_dir_path( __FILE__ ) . '../js/ls.unveilhooks.min.js' ), true ); 827 659 } 828 660 829 // Check if native loading plugin should be loaded.830 661 if ( '1' === $this->settings->get_load_native_loading_plugin() ) { 831 662 wp_enqueue_script( 'lazysizes-native-loading', plugins_url( '/lazy-loading-responsive-images/js/ls.native-loading.min.js' ), array( 'lazysizes' ), filemtime( plugin_dir_path( __FILE__ ) . '../js/ls.native-loading.min.js' ), true ); 832 663 } 833 664 834 // Include custom lazysizes config if not empty.835 665 if ( '' !== $this->settings->get_lazysizes_config() ) { 836 666 wp_add_inline_script( 'lazysizes', $this->settings->get_lazysizes_config(), 'before' ); 837 667 } 838 668 } 839 840 /** 841 * Adds inline style. 842 * 843 * We do not enqueue a new CSS file for two rules, but cannot use 844 * wp_add_inline_style() because we have no handle. So we need to 845 * echo it. 846 */ 669 847 670 public function add_inline_style() { 848 671 if ( $this->helpers->is_disabled_for_post() ) { … … 850 673 } 851 674 852 // Create loading spinner style if needed.853 675 $spinner_styles = ''; 854 676 $spinner_color = $this->settings->get_loading_spinner_color(); … … 889 711 } 890 712 891 // Display the default styles.892 713 $default_styles = "<style>:root { 893 714 --lazy-loader-animation-duration: 300ms; … … 917 738 echo apply_filters( 'lazy_load_responsive_images_inline_styles', $default_styles ); 918 739 919 // Hide images if no JS.920 740 echo '<noscript><style>.lazyload { display: none; } .lazyload[class*="lazy-loader-background-element-"] { display: block; opacity: 1; }</style></noscript>'; 921 741 } 922 923 /** 924 * Enqueue script to Gutenberg editor view. 925 */ 742 926 743 public function enqueue_block_editor_assets() { 927 744 if ( isset( $_REQUEST['post'] ) && in_array( get_post_type( $_REQUEST['post'] ), $this->settings->get_disable_option_object_types() ) && post_type_supports( get_post_type( $_REQUEST['post'] ), 'custom-fields' ) ) { … … 935 752 } 936 753 } 937 938 /** 939 * Loads the plugin translation. 940 */ 754 941 755 public function load_translation() { 942 756 load_plugin_textdomain( 'lazy-loading-responsive-images' ); … … 944 758 945 759 /** 946 * Sets plugin basename.947 *948 760 * @param string $basename The plugin basename. 949 761 */ … … 953 765 954 766 /** 955 * Sets plugin basename.956 *957 767 * @param string $basename The plugin basename. 958 768 */ … … 960 770 $this->js_asset_url = $js_asset_url; 961 771 } 962 963 /** 964 * Action on plugin uninstall. 965 */ 772 966 773 public static function uninstall() { 967 774 $options_array = array( … … 982 789 ); 983 790 984 // Delete options.985 791 foreach ( $options_array as $option ) { 986 792 delete_option( $option ); -
lazy-loading-responsive-images/tags/8.2.0/src/Settings.php
r2505151 r3070210 1 1 <?php 2 2 /** 3 * Class for adding customizer settings.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 8 6 namespace FlorianBrinkmann\LazyLoadResponsiveImages; 9 7 10 /**11 * Class Settings12 *13 * Adds options to the customizer.14 *15 * @package FlorianBrinkmann\LazyLoadResponsiveImages16 */17 8 class Settings { 18 9 19 10 /** 20 * Helpers object.21 *22 11 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Helpers 23 12 */ … … 25 14 26 15 /** 27 * Array of options data.28 *29 16 * @var array 30 17 */ … … 32 19 33 20 /** 34 * Classes which should not be lazy loaded.35 *36 21 * @var array 37 22 */ … … 39 24 40 25 /** 41 * Value of settings for enabling lazy loading for iFrames.42 *43 26 * @var string 44 27 */ … … 46 29 47 30 /** 48 * Value of setting for loading the unveilhooks plugin.49 *50 31 * @var string 51 32 */ … … 53 34 54 35 /** 55 * Value of setting for loading the unveilhooks plugin.56 *57 36 * @var string 58 37 */ … … 60 39 61 40 /** 62 * Value of settings for enabling lazy loading for background images.63 *64 41 * @var string 65 42 */ … … 67 44 68 45 /** 69 * Value of settings for enabling lazy loading for videos.70 *71 46 * @var string 72 47 */ … … 74 49 75 50 /** 76 * Value of settings for enabling lazy loading for audios.77 *78 51 * @var string 79 52 */ … … 81 54 82 55 /** 83 * Value of setting for displaying a loading spinner.84 *85 56 * @var string 86 57 */ … … 88 59 89 60 /** 90 * Default loading spinner color.91 *92 61 * @var string 93 62 */ … … 95 64 96 65 /** 97 * Value of setting for loading spinner color.98 *99 66 * @var string 100 67 */ … … 102 69 103 70 /** 104 * Value of setting for displaying the option to disable the plugin per page/post.105 *106 71 * @var string 107 72 */ … … 109 74 110 75 /** 111 * Array of object types that should show the checkbox to disable lazy loading.112 *113 76 * @var array 114 77 */ … … 116 79 117 80 /** 118 * String to modify lazysizes config.119 *120 81 * @var string 121 82 */ … … 123 84 124 85 /** 125 * Value of setting for processing the complete website markup.126 *127 86 * @var string 128 87 */ … … 130 89 131 90 /** 132 * Value of setting for additional filters to process.133 *134 91 * @var array 135 92 */ … … 137 94 138 95 /** 139 * Allowed HTML tags in descriptions.140 *141 96 * @var array 142 97 */ … … 148 103 ); 149 104 150 /**151 * Settings constructor.152 */153 105 public function __construct() { 154 // Set helpers.155 106 $this->helpers = new Helpers(); 156 107 … … 295 246 ); 296 247 297 // Fill properties with setting values.298 248 $this->disabled_classes = explode( ',', $this->options['lazy_load_responsive_images_disabled_classes']['value'] ); 299 249 $this->enable_for_iframes = $this->options['lazy_load_responsive_images_enable_for_iframes']['value']; … … 310 260 $this->enable_for_background_images = $this->options['lazy_load_responsive_images_enable_for_background_images']['value']; 311 261 312 // Register settings on media options page.313 262 add_action( 'admin_init', array( $this, 'settings_init' ), 12 ); 314 263 315 // Include color picker JS.316 264 add_action( 'admin_enqueue_scripts', array( 317 265 $this, … … 322 270 add_action( 'init', array( $this, 'disable_option_object_types_filter' ), 11 ); 323 271 324 // Register meta for disabling per page.325 272 add_action( 'init', array( $this, 'register_post_meta' ), 11 ); 326 273 327 // Publish post actions.328 274 add_action( 'post_submitbox_misc_actions', array( $this, 'add_checkbox' ), 9 ); 329 275 add_action( 'save_post', array( $this, 'save_checkbox' ) ); … … 331 277 } 332 278 333 /**334 * Init settings on media options page.335 */336 279 public function settings_init() { 337 // Add section.338 280 add_settings_section( 339 281 "lazy-load-responsive-images-section", … … 346 288 ); 347 289 348 // Loop the options.349 290 foreach ( $this->options as $option_id => $option ) { 350 // Register setting.351 291 register_setting( 'media', $option_id, array( 352 292 'sanitize_callback' => $option['sanitize_callback'], 353 293 ) ); 354 294 355 // Create field.356 295 add_settings_field( 357 296 $option_id, … … 366 305 ) 367 306 ); 368 } // End foreach(). 369 } 370 371 /** 372 * Section callback. 373 * 307 } 308 } 309 310 /** 374 311 * @param array $args 375 312 */ … … 378 315 379 316 /** 380 * Checkbox callback.381 *382 317 * @param array $args { 383 318 * Argument array. … … 389 324 */ 390 325 public function checkbox_field_cb( $args ) { 391 // Get option value.392 326 $option_value = $args['value']; 393 327 394 // Get label for.395 328 ?> 396 329 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" 397 330 type="checkbox" <?php echo ( $option_value == '1' || $option_value == 'on' ) ? 'checked="checked"' : ''; ?>> 398 331 <?php 399 // Check for description.400 332 if ( '' !== $args['description'] ) { ?> 401 333 <p class="description"> … … 407 339 408 340 /** 409 * Text field callback.410 *411 341 * @param array $args { 412 342 * Argument array. … … 418 348 */ 419 349 public function text_field_cb( $args ) { 420 // Get option value.421 350 $option_value = $args['value']; 422 351 423 // Get label for.424 352 ?> 425 353 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" 426 354 type="text" value="<?php echo esc_attr( $option_value ); ?>"> 427 355 <?php 428 // Check for description.429 356 if ( '' !== $args['description'] ) { ?> 430 357 <p class="description"> … … 436 363 437 364 /** 438 * Textarea field callback.439 *440 365 * @param array $args { 441 366 * Argument array. … … 447 372 */ 448 373 public function textarea_field_cb( $args ) { 449 // Get option value.450 374 $option_value = $args['value']; 451 375 … … 453 377 <textarea id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" style="width: 100%;"><?php echo esc_textarea( $option_value ); ?></textarea> 454 378 <?php 455 // Check for description.456 379 if ( '' !== $args['description'] ) { ?> 457 380 <p class="description"> … … 463 386 464 387 /** 465 * Color field callback.466 *467 388 * @param array $args { 468 389 * Argument array. … … 475 396 */ 476 397 public function color_field_cb( $args ) { 477 // Get option value.478 398 $option_value = $args['value']; 479 399 480 // Get label for.481 400 ?> 482 401 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" … … 485 404 class="lazy-load-responsive-images-color-field"> 486 405 <?php 487 // Check for description.488 406 if ( '' !== $args['description'] ) { ?> 489 407 <p class="description"> … … 495 413 496 414 /** 497 * Add color picker to media settings page and init it.498 *499 415 * @param string $hook_suffix PHP file of the admin screen. 500 416 */ 501 417 public function add_color_picker( $hook_suffix ) { 502 // Check if we are not on the media backend screen.503 418 if ( 'options-media.php' !== $hook_suffix ) { 504 419 return; 505 } // End if(). 506 507 // Add color picker script and style and init it. 420 } 421 508 422 wp_enqueue_style( 'wp-color-picker' ); 509 423 wp_enqueue_script( 'wp-color-picker' ); … … 513 427 } 514 428 515 /**516 * Set array of post types that support granular disabling of Lazy Loader features.517 */518 429 public function disable_option_object_types_filter() { 519 430 $public_post_types = get_post_types( array( … … 521 432 ), 'names' ); 522 433 523 // Remove attachment post type.524 434 if ( is_array( $public_post_types ) && isset( $public_post_types['attachment'] ) ) { 525 435 unset( $public_post_types['attachment'] ); … … 537 447 } 538 448 539 /**540 * Register post meta for disabling plugin per541 */542 449 public function register_post_meta() { 543 450 if ( ! is_array( $this->disable_option_object_types ) ) { … … 560 467 561 468 /** 562 * Add checkbox to Publish Post meta box.563 *564 469 * @link https://github.com/deworg/dewp-planet-feed/ 565 470 */ … … 571 476 } 572 477 573 // Check user capability. Not bailing, though, on purpose.574 478 $maybe_enabled = current_user_can( 'publish_posts' ); 575 // This actually defines whether post will be listed in our feed.576 479 $value = absint( get_post_meta( $post->ID, 'lazy_load_responsive_images_disabled', true ) ); 577 480 printf( … … 589 492 590 493 /** 591 * Save option value to post meta.592 *593 494 * @link https://github.com/deworg/dewp-planet-feed/ 594 495 * … … 622 523 623 524 /** 624 * Return disabled classes setting value.625 *626 525 * @return array 627 526 */ … … 631 530 632 531 /** 633 * Return load_unveilhooks_plugin value.634 *635 532 * @return string 636 533 */ … … 640 537 641 538 /** 642 * Return enable_for_audios value.643 *644 539 * @return string 645 540 */ … … 649 544 650 545 /** 651 * Return enable_for_videos value.652 *653 546 * @return string 654 547 */ … … 658 551 659 552 /** 660 * Return enable_for_iframes value.661 *662 553 * @return string 663 554 */ … … 667 558 668 559 /** 669 * Return enable_for_background_images value.670 *671 560 * @return string 672 561 */ … … 676 565 677 566 /** 678 * Return load_native_loading_plugin value.679 *680 567 * @return string 681 568 */ … … 685 572 686 573 /** 687 * Return lazysizes_config value.688 *689 574 * @return string 690 575 */ … … 694 579 695 580 /** 696 * Return loading_spinner_color value.697 *698 581 * @return string 699 582 */ … … 703 586 704 587 /** 705 * Return loading_spinner_color_default value.706 *707 588 * @return string 708 589 */ … … 712 593 713 594 /** 714 * Return loading_spinner value.715 *716 595 * @return string 717 596 */ … … 721 600 722 601 /** 723 * Return disable_option_object_types value.724 *725 602 * @return array 726 603 */ … … 730 607 731 608 /** 732 * Return process_complete_markup value.733 *734 609 * @return string 735 610 */ … … 739 614 740 615 /** 741 * Return additional_filters value.742 *743 616 * @return array 744 617 */ -
lazy-loading-responsive-images/tags/8.2.0/vendor/autoload.php
r2843576 r3070210 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3::getLoader();25 return ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d::getLoader(); -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/ClassLoader.php
r2843576 r3070210 46 46 private static $includeFile; 47 47 48 /** @var ?string*/48 /** @var string|null */ 49 49 private $vendorDir; 50 50 51 51 // PSR-4 52 52 /** 53 * @var array[] 54 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 55 54 */ 56 55 private $prefixLengthsPsr4 = array(); 57 56 /** 58 * @var array[] 59 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 60 58 */ 61 59 private $prefixDirsPsr4 = array(); 62 60 /** 63 * @var array[] 64 * @psalm-var array<string, string> 61 * @var list<string> 65 62 */ 66 63 private $fallbackDirsPsr4 = array(); … … 68 65 // PSR-0 69 66 /** 70 * @var array[] 71 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 72 72 */ 73 73 private $prefixesPsr0 = array(); 74 74 /** 75 * @var array[] 76 * @psalm-var array<string, string> 75 * @var list<string> 77 76 */ 78 77 private $fallbackDirsPsr0 = array(); … … 82 81 83 82 /** 84 * @var string[] 85 * @psalm-var array<string, string> 83 * @var array<string, string> 86 84 */ 87 85 private $classMap = array(); … … 91 89 92 90 /** 93 * @var bool[] 94 * @psalm-var array<string, bool> 91 * @var array<string, bool> 95 92 */ 96 93 private $missingClasses = array(); 97 94 98 /** @var ?string*/95 /** @var string|null */ 99 96 private $apcuPrefix; 100 97 101 98 /** 102 * @var self[]99 * @var array<string, self> 103 100 */ 104 101 private static $registeredLoaders = array(); 105 102 106 103 /** 107 * @param ?string$vendorDir104 * @param string|null $vendorDir 108 105 */ 109 106 public function __construct($vendorDir = null) … … 114 111 115 112 /** 116 * @return string[]113 * @return array<string, list<string>> 117 114 */ 118 115 public function getPrefixes() … … 126 123 127 124 /** 128 * @return array[] 129 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 130 126 */ 131 127 public function getPrefixesPsr4() … … 135 131 136 132 /** 137 * @return array[] 138 * @psalm-return array<string, string> 133 * @return list<string> 139 134 */ 140 135 public function getFallbackDirs() … … 144 139 145 140 /** 146 * @return array[] 147 * @psalm-return array<string, string> 141 * @return list<string> 148 142 */ 149 143 public function getFallbackDirsPsr4() … … 153 147 154 148 /** 155 * @return string[] Array of classname => path 156 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 157 150 */ 158 151 public function getClassMap() … … 162 155 163 156 /** 164 * @param string[] $classMap Class to filename map 165 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 166 158 * 167 159 * @return void … … 180 172 * appending or prepending to the ones previously set for this prefix. 181 173 * 182 * @param string $prefix The prefix183 * @param string[]|string $paths The PSR-0 root directories184 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 185 177 * 186 178 * @return void … … 188 180 public function add($prefix, $paths, $prepend = false) 189 181 { 182 $paths = (array) $paths; 190 183 if (!$prefix) { 191 184 if ($prepend) { 192 185 $this->fallbackDirsPsr0 = array_merge( 193 (array)$paths,186 $paths, 194 187 $this->fallbackDirsPsr0 195 188 ); … … 197 190 $this->fallbackDirsPsr0 = array_merge( 198 191 $this->fallbackDirsPsr0, 199 (array)$paths192 $paths 200 193 ); 201 194 } … … 206 199 $first = $prefix[0]; 207 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 208 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 209 202 210 203 return; … … 212 205 if ($prepend) { 213 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 214 (array)$paths,207 $paths, 215 208 $this->prefixesPsr0[$first][$prefix] 216 209 ); … … 218 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 219 212 $this->prefixesPsr0[$first][$prefix], 220 (array)$paths213 $paths 221 214 ); 222 215 } … … 227 220 * appending or prepending to the ones previously set for this namespace. 228 221 * 229 * @param string $prefix The prefix/namespace, with trailing '\\'230 * @param string[]|string $paths The PSR-4 base directories231 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 232 225 * 233 226 * @throws \InvalidArgumentException … … 237 230 public function addPsr4($prefix, $paths, $prepend = false) 238 231 { 232 $paths = (array) $paths; 239 233 if (!$prefix) { 240 234 // Register directories for the root namespace. 241 235 if ($prepend) { 242 236 $this->fallbackDirsPsr4 = array_merge( 243 (array)$paths,237 $paths, 244 238 $this->fallbackDirsPsr4 245 239 ); … … 247 241 $this->fallbackDirsPsr4 = array_merge( 248 242 $this->fallbackDirsPsr4, 249 (array)$paths243 $paths 250 244 ); 251 245 } … … 257 251 } 258 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 259 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 260 254 } elseif ($prepend) { 261 255 // Prepend directories for an already registered namespace. 262 256 $this->prefixDirsPsr4[$prefix] = array_merge( 263 (array)$paths,257 $paths, 264 258 $this->prefixDirsPsr4[$prefix] 265 259 ); … … 268 262 $this->prefixDirsPsr4[$prefix] = array_merge( 269 263 $this->prefixDirsPsr4[$prefix], 270 (array)$paths264 $paths 271 265 ); 272 266 } … … 277 271 * replacing any others previously set for this prefix. 278 272 * 279 * @param string $prefix The prefix280 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 281 275 * 282 276 * @return void … … 295 289 * replacing any others previously set for this namespace. 296 290 * 297 * @param string $prefix The prefix/namespace, with trailing '\\'298 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 299 293 * 300 294 * @throws \InvalidArgumentException … … 430 424 { 431 425 if ($file = $this->findFile($class)) { 432 (self::$includeFile)($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 433 428 434 429 return true; … … 481 476 482 477 /** 483 * Returns the currently registered loaders indexed by their corresponding vendor directories.484 * 485 * @return self[]478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 486 481 */ 487 482 public static function getRegisteredLoaders() … … 561 556 } 562 557 563 private static function initializeIncludeClosure(): void 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 564 562 { 565 563 if (self::$includeFile !== null) { … … 575 573 * @return void 576 574 */ 577 self::$includeFile = static function($file) {575 self::$includeFile = \Closure::bind(static function($file) { 578 576 include $file; 579 } ;577 }, null, null); 580 578 } 581 579 } -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/InstalledVersions.php
r2843576 r3070210 99 99 foreach (self::getInstalled() as $installed) { 100 100 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);101 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; 102 102 } 103 103 } … … 120 120 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 121 { 122 $constraint = $parser->parseConstraints( $constraint);122 $constraint = $parser->parseConstraints((string) $constraint); 123 123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 124 … … 329 329 $installed[] = self::$installedByVendor[$vendorDir]; 330 330 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 332 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 335 self::$installed = $installed[count($installed) - 1]; … … 341 343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 344 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 346 $required = require __DIR__ . '/installed.php'; 347 self::$installed = $required; 344 348 } else { 345 349 self::$installed = array(); 346 350 } 347 351 } 348 $installed[] = self::$installed; 352 353 if (self::$installed !== array()) { 354 $installed[] = self::$installed; 355 } 349 356 350 357 return $installed; -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/autoload_real.php
r2843576 r3070210 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b35 class ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInita21d1f93de4e18f6084492a2be69518d::getInitializer($loader)); 33 33 34 34 $loader->register(true); -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/autoload_static.php
r2843576 r3070210 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 992eca56574b9f1c8fe962b958c076b37 class ComposerStaticInita21d1f93de4e18f6084492a2be69518d 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 59 59 { 60 60 return \Closure::bind(function () use ($loader) { 61 $loader->prefixLengthsPsr4 = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$prefixLengthsPsr4;62 $loader->prefixDirsPsr4 = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$prefixDirsPsr4;63 $loader->classMap = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$classMap;61 $loader->prefixLengthsPsr4 = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$prefixLengthsPsr4; 62 $loader->prefixDirsPsr4 = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$prefixDirsPsr4; 63 $loader->classMap = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$classMap; 64 64 65 65 }, null, ClassLoader::class); -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/installed.json
r2489768 r3070210 3 3 { 4 4 "name": "masterminds/html5", 5 "version": "2. 7.4",6 "version_normalized": "2. 7.4.0",5 "version": "2.9.0", 6 "version_normalized": "2.9.0.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/Masterminds/html5-php.git", 10 "reference": " 9227822783c75406cfe400984b2f095cdf03d417"10 "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6" 11 11 }, 12 12 "dist": { 13 13 "type": "zip", 14 "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/ 9227822783c75406cfe400984b2f095cdf03d417",15 "reference": " 9227822783c75406cfe400984b2f095cdf03d417",14 "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", 15 "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", 16 16 "shasum": "" 17 17 }, 18 18 "require": { 19 "ext-ctype": "*",20 19 "ext-dom": "*", 21 "ext-libxml": "*",22 20 "php": ">=5.3.0" 23 21 }, 24 22 "require-dev": { 25 "phpunit/phpunit": "^4.8.35 "23 "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9" 26 24 }, 27 "time": "202 0-10-01T13:52:52+00:00",25 "time": "2024-03-31T07:05:07+00:00", 28 26 "type": "library", 29 27 "extra": { … … 69 67 "support": { 70 68 "issues": "https://github.com/Masterminds/html5-php/issues", 71 "source": "https://github.com/Masterminds/html5-php/tree/2. 7.4"69 "source": "https://github.com/Masterminds/html5-php/tree/2.9.0" 72 70 }, 73 71 "install-path": "../masterminds/html5" -
lazy-loading-responsive-images/tags/8.2.0/vendor/composer/installed.php
r2843576 r3070210 2 2 'root' => array( 3 3 'name' => 'florianbrinkmann/lazy-loading-responsive-images', 4 'pretty_version' => ' v8.1.1',5 'version' => '8. 1.1.0',6 'reference' => ' 35f8dc96cbf8528f0d89478d3fd5377af01c3692',4 'pretty_version' => '8.2.0', 5 'version' => '8.2.0.0', 6 'reference' => 'a48ef29925d97c95258d264e05491a76848f01b3', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'florianbrinkmann/lazy-loading-responsive-images' => array( 14 'pretty_version' => ' v8.1.1',15 'version' => '8. 1.1.0',16 'reference' => ' 35f8dc96cbf8528f0d89478d3fd5377af01c3692',14 'pretty_version' => '8.2.0', 15 'version' => '8.2.0.0', 16 'reference' => 'a48ef29925d97c95258d264e05491a76848f01b3', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'masterminds/html5' => array( 23 'pretty_version' => '2. 7.4',24 'version' => '2. 7.4.0',25 'reference' => ' 9227822783c75406cfe400984b2f095cdf03d417',23 'pretty_version' => '2.9.0', 24 'version' => '2.9.0.0', 25 'reference' => 'f5ac2c0b0a2eefca70b2ce32a5809992227e75a6', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../masterminds/html5', -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/RELEASE.md
r2412362 r3070210 1 1 # Release Notes 2 3 2.7.6 (2021-08-18) 4 5 - #218: Address comment handling issues 6 7 2.7.5 (2021-07-01) 8 9 - #204: Travis: Enable tests on PHP 8.0 10 - #207: Fix PHP 8.1 deprecations 2 11 3 12 2.7.4 (2020-10-01) -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Elements.php
r2236239 r3070210 71 71 */ 72 72 const BLOCK_ONLY_INLINE = 128; 73 74 /** 75 * Elements with optional end tags that cause auto-closing of previous and parent tags, 76 * as example most of the table related tags, see https://www.w3.org/TR/html401/struct/tables.html 77 * Structure is as follows: 78 * TAG-NAME => [PARENT-TAG-NAME-TO-CLOSE1, PARENT-TAG-NAME-TO-CLOSE2, ...]. 79 * 80 * Order is important, after auto-closing one parent with might have to close also their parent. 81 * 82 * @var array<string, string[]> 83 */ 84 public static $optionalEndElementsParentsToClose = array( 85 'tr' => array('td', 'tr'), 86 'td' => array('td', 'th'), 87 'th' => array('td', 'th'), 88 'tfoot' => array('td', 'th', 'tr', 'tbody', 'thead'), 89 'tbody' => array('td', 'th', 'tr', 'thead'), 90 ); 73 91 74 92 /** … … 186 204 'ul' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 187 205 'var' => 1, 188 'video' => 65, // NORMAL | BLOCK_TAG206 'video' => 1, 189 207 'wbr' => 9, // NORMAL | VOID_TAG 190 208 -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php
r2412362 r3070210 176 176 $dt = $impl->createDocumentType('html'); 177 177 // $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt); 178 $this->doc = $impl->createDocument(null, null, $dt);178 $this->doc = $impl->createDocument(null, '', $dt); 179 179 $this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8'; 180 180 } … … 360 360 } 361 361 362 // some elements as table related tags might have optional end tags that force us to auto close multiple tags 363 // https://www.w3.org/TR/html401/struct/tables.html 364 if ($this->current instanceof \DOMElement && isset(Elements::$optionalEndElementsParentsToClose[$lname])) { 365 foreach (Elements::$optionalEndElementsParentsToClose[$lname] as $parentElName) { 366 if ($this->current instanceof \DOMElement && $this->current->tagName === $parentElName) { 367 $this->autoclose($parentElName); 368 } 369 } 370 } 371 362 372 try { 363 373 $prefix = ($pos = strpos($lname, ':')) ? substr($lname, 0, $pos) : ''; … … 406 416 $aName = Elements::normalizeMathMlAttribute($aName); 407 417 } 418 419 $aVal = (string) $aVal; 408 420 409 421 try { -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/Scanner.php
r2236239 r3070210 105 105 public function peek() 106 106 { 107 if (($this->char + 1) < =$this->EOF) {107 if (($this->char + 1) < $this->EOF) { 108 108 return $this->data[$this->char + 1]; 109 109 } -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php
r2236239 r3070210 184 184 * @return string The current character. 185 185 */ 186 #[\ReturnTypeWillChange] 186 187 public function current() 187 188 { … … 193 194 * This is part of the Iterator interface. 194 195 */ 196 #[\ReturnTypeWillChange] 195 197 public function next() 196 198 { … … 201 203 * Rewind to the start of the string. 202 204 */ 205 #[\ReturnTypeWillChange] 203 206 public function rewind() 204 207 { … … 211 214 * @return bool Whether the current pointer location is valid. 212 215 */ 216 #[\ReturnTypeWillChange] 213 217 public function valid() 214 218 { … … 325 329 } 326 330 331 #[\ReturnTypeWillChange] 327 332 public function key() 328 333 { -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
r2412362 r3070210 132 132 $tok = $this->scanner->next(); 133 133 134 if ('!' === $tok) { 134 if (false === $tok) { 135 // end of string 136 $this->parseError('Illegal tag opening'); 137 } elseif ('!' === $tok) { 135 138 $this->markupDeclaration(); 136 139 } elseif ('/' === $tok) { … … 138 141 } elseif ('?' === $tok) { 139 142 $this->processingInstruction(); 140 } elseif ( ctype_alpha($tok)) {143 } elseif ($this->is_alpha($tok)) { 141 144 $this->tagName(); 142 145 } else { … … 348 351 // EOF -> parse error 349 352 // -> parse error 350 if (! ctype_alpha($tok)) {353 if (!$this->is_alpha($tok)) { 351 354 $this->parseError("Expected tag name, got '%s'", $tok); 352 355 if ("\0" == $tok || false === $tok) { … … 713 716 } 714 717 715 // If it doesn't start with -, not the end.716 if ('-' != $tok ) {718 // If next two tokens are not '--', not the end. 719 if ('-' != $tok || '-' != $this->scanner->peek()) { 717 720 return false; 718 721 } 719 722 720 // Advance one, and test for '->' 721 if ('-' == $this->scanner->next() && '>' == $this->scanner->peek()) { 723 $this->scanner->consume(2); // Consume '-' and one of '!' or '>' 724 725 // Test for '>' 726 if ('>' == $this->scanner->current()) { 727 return true; 728 } 729 // Test for '!>' 730 if ('!' == $this->scanner->current() && '>' == $this->scanner->peek()) { 722 731 $this->scanner->consume(); // Consume the last '>' 723 732 return true; 724 733 } 725 // Unread '-' ;726 $this->scanner->unconsume( 1);734 // Unread '-' and one of '!' or '>'; 735 $this->scanner->unconsume(2); 727 736 728 737 return false; … … 1189 1198 return '&'; 1190 1199 } 1200 1201 /** 1202 * Checks whether a (single-byte) character is an ASCII letter or not. 1203 * 1204 * @param string $input A single-byte string 1205 * 1206 * @return bool True if it is a letter, False otherwise 1207 */ 1208 protected function is_alpha($input) 1209 { 1210 $code = ord($input); 1211 1212 return ($code >= 97 && $code <= 122) || ($code >= 65 && $code <= 90); 1213 } 1191 1214 } -
lazy-loading-responsive-images/tags/8.2.0/vendor/masterminds/html5/src/HTML5/Parser/UTF8Utils.php
r2236239 r3070210 39 39 /** 40 40 * Count the number of characters in a string. 41 * UTF-8 aware. This will try (in order) iconv, MB, libxml,and finally a custom counter.41 * UTF-8 aware. This will try (in order) iconv, MB, and finally a custom counter. 42 42 * 43 43 * @param string $string … … 54 54 if (function_exists('iconv_strlen')) { 55 55 return iconv_strlen($string, 'utf-8'); 56 }57 58 if (function_exists('utf8_decode')) {59 // MPB: Will this work? Won't certain decodes lead to two chars60 // extrapolated out of 2-byte chars?61 return strlen(utf8_decode($string));62 56 } 63 57 -
lazy-loading-responsive-images/trunk/lazy-load-responsive-images.php
r2843576 r3070210 10 10 * Plugin URI: https://florianbrinkmann.com/en/3350/responsive-images-and-lazy-loading-in-wordpress/ 11 11 * Description: Lazy loading plugin that supports images, iFrames, video and audio elements and uses lazysizes.js. With manual modification of the markup it is also possible to lazy load background images, scripts, and styles. 12 * Version: 8. 1.112 * Version: 8.2.0 13 13 * Author: Florian Brinkmann 14 14 * Author URI: https://florianbrinkmann.com/en/ … … 19 19 namespace FlorianBrinkmann\LazyLoadResponsiveImages; 20 20 21 // Load Composer autoloader. From https://github.com/brightnucleus/jasper-client/blob/master/tests/bootstrap.php#L55-L5922 21 $autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; 23 22 if ( is_readable( $autoloader ) ) { … … 29 28 } 30 29 31 // Create object.32 30 $lazy_loader = new Plugin(); 33 31 34 // Set plugin basename. 32 35 33 $lazy_loader->set_basename( plugin_basename( __FILE__ ) ); 36 34 $lazy_loader->set_js_asset_url( plugins_url( 'js/build/functions.js', __FILE__ ) ); 37 35 38 // Init the plugin.39 36 $lazy_loader->init(); -
lazy-loading-responsive-images/trunk/readme.txt
r2843576 r3070210 4 4 Tags: lazysizes, lazy loading, performance, images 5 5 Requires at least: 4.9.8 6 Tested up to: 6. 17 Stable tag: 8. 1.16 Tested up to: 6.5 7 Stable tag: 8.2.0 8 8 Requires PHP: 7.0 9 9 … … 45 45 * Styles. 46 46 47 The plugin adds a `noscript` element as fallback for disabled JavaScript .47 The plugin adds a `noscript` element as fallback for disabled JavaScript (can be disabled with the `lazy_loader_generate_noscript` filter). 48 48 49 49 You can disable lazy loading for elements with specific CSS classes by defining them via the plugin settings (*Settings* › *Media* › *Lazy Loader options*). Or use the `skip-lazy` class or the `data-skip-lazy` attribute. `skip-lazy` and `data-skip-lazy` also work on wrapper elements to exclude the wrapper and its children from being processed. … … 105 105 == Changelog == 106 106 107 = 8.2.0 – 14.04.2024 = 108 109 Tested with WordPress 6.5. 110 111 **Added** 112 113 * `lazy_loader_generate_noscript` filter to allow disabling of `noscript` element generation. 114 115 **Fixed** 116 117 - Updated `mastermind/html5` dependency to latest version, which fixes a PHP deprecation notice. 118 107 119 = 8.1.1 – 20.12.2022 = 108 120 -
lazy-loading-responsive-images/trunk/src/Helpers.php
r2843576 r3070210 1 1 <?php 2 2 /** 3 * Helper methods.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 10 8 use FlorianBrinkmann\LazyLoadResponsiveImages\Settings as Settings; 11 9 12 /**13 * Class Helpers14 *15 * Class with helper methods.16 *17 * @package FlorianBrinkmann\LazyLoadResponsiveImages18 */19 10 class Helpers { 20 11 21 12 /** 22 * Hint if the plugin is disabled for this post.23 *24 13 * @var null|int 25 14 */ … … 27 16 28 17 /** 29 * Checks if this is a request at the backend.30 *31 18 * @return bool true if is admin request, otherwise false. 32 19 */ … … 46 33 47 34 /* 48 * Get admin URL and referrer.49 *50 35 * @link https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/pluggable.php#L1076 51 36 */ … … 53 38 $referrer = strtolower( wp_get_referer() ); 54 39 55 // Check if this is a admin request. If true, it56 // could also be a AJAX request.57 40 if ( 0 === strpos( $current_url, $admin_url ) ) { 58 // Check if the user comes from a admin page.59 41 if ( 0 === strpos( $referrer, $admin_url ) ) { 60 42 return true; 61 43 } else { 62 /*63 * Check for AJAX requests.64 *65 * @link https://gist.github.com/zitrusblau/58124d4b2c56d06b070573a99f33b9ed#file-lazy-load-responsive-images-php-L19366 */67 44 if ( function_exists( 'wp_doing_ajax' ) ) { 68 45 return ! wp_doing_ajax(); … … 80 57 81 58 /** 82 * Checks if we are on an AMP page generated from the Automattic plugin.83 *84 59 * @return bool true if is amp page, false otherwise. 85 60 */ 86 61 public function is_amp_page() { 87 // Check if Automattic’s AMP plugin is active and we are on an AMP endpoint.88 62 if ( function_exists( 'is_amp_endpoint' ) && true === is_amp_endpoint() ) { 89 63 return true; … … 94 68 95 69 /** 96 * Check if plugin is disabled for current post.97 *98 70 * @return bool true if disabled, false otherwise. 99 71 */ 100 72 public function is_disabled_for_post() { 101 // Check if the plugin is disabled.102 73 if ( null === $this->disabled_for_current_post ) { 103 74 $this->disabled_for_current_post = absint( get_post_meta( get_the_ID(), 'lazy_load_responsive_images_disabled', true ) ); … … 117 88 118 89 /** 119 * Check if the displayed content is something that the plugin should process.120 *121 90 * @return bool 122 91 */ … … 126 95 } 127 96 128 // Check if we are on a feed page.129 97 if ( is_feed() ) { 130 98 return false; 131 99 } 132 100 133 // Check if this content is embedded.134 101 if ( is_embed() ) { 135 102 return false; 136 103 } 137 104 138 // Check if this is a request in the backend.139 105 if ( $this->is_admin_request() ) { 140 106 return false; 141 107 } 142 108 143 // Check for AMP page.144 109 if ( $this->is_amp_page() ) { 145 110 return false; 146 111 } 147 112 148 // Check for Oxygen Builder mode.149 113 if ( defined( 'SHOW_CT_BUILDER' ) ) { 150 114 return false; 151 115 } 152 116 153 // Check for TranslatePress editor.154 117 if ( isset( $_REQUEST['trp-edit-translation'] ) ) { 155 118 return false; … … 160 123 161 124 /** 162 * Sanitize comma separated list of class names.163 *164 125 * @param string $class_names Comma separated list of HTML class names. 165 126 * … … 167 128 */ 168 129 public function sanitize_class_name_list( $class_names ) { 169 // Get array of the class names.170 130 $class_names_array = explode( ',', $class_names ); 171 131 … … 174 134 } 175 135 176 // Loop through the class names.177 136 foreach ( $class_names_array as $i => $class_name ) { 178 // Save the sanitized class name.179 137 $class_names_array[ $i ] = sanitize_html_class( $class_name ); 180 138 } 181 139 182 // Implode the class names.183 140 $class_names = implode( ',', $class_names_array ); 184 141 … … 187 144 188 145 /** 189 * Sanitize list of filter names.190 *191 146 * @param string $filters One or more WordPress filters, one per line. 192 147 * … … 194 149 */ 195 150 public function sanitize_filter_name_list( $filters ) { 196 // Get array of the filter names.197 151 $filters_array = explode( "\n", $filters ); 198 152 … … 201 155 } 202 156 203 // Loop through the filter names.204 157 foreach ( $filters_array as $i => $filter ) { 205 158 $function_name_regex = '/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/'; … … 207 160 $filters_array[$i] = trim( $filters_array[$i] ); 208 161 209 // Check if the filter is a valid PHP function name.210 162 if ( preg_match( $function_name_regex, $filters_array[$i] ) !== 1 ) { 211 163 unset( $filters_array[$i] ); … … 214 166 } 215 167 216 // Implode the filter names.217 168 $filters = implode( "\n", $filters_array ); 218 169 … … 221 172 222 173 /** 223 * Sanitize checkbox.224 *225 174 * @link https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php 226 175 * … … 234 183 235 184 /** 236 * Sanitize textarea input.237 *238 185 * @param bool $checked Whether the checkbox is checked. 239 186 * … … 245 192 246 193 /** 247 * Sanitize hex color value.248 *249 194 * @param string $value The input from the color input. 250 195 * … … 252 197 */ 253 198 public function sanitize_hex_color( $value ) { 254 // Sanitize the input.255 199 $sanitized = sanitize_hex_color( $value ); 256 200 if ( null !== $sanitized && '' !== $sanitized ) { … … 259 203 $settings = new Settings(); 260 204 return $settings->get_loading_spinner_color_default(); 261 } // End if().205 } 262 206 } 263 207 -
lazy-loading-responsive-images/trunk/src/Plugin.php
r2505151 r3070210 1 1 <?php 2 2 /** 3 * Main plugin code.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 14 12 use Masterminds\HTML5; 15 13 16 /**17 * Class Plugin18 *19 * Class for adding lazy loading to responsive images.20 *21 * @package FlorianBrinkmann\LazyLoadResponsiveImages22 */23 14 class Plugin { 24 15 25 16 /** 26 * Helpers object.27 *28 17 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Helpers 29 18 */ … … 31 20 32 21 /** 33 * Settings object.34 *35 22 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Settings 36 23 */ … … 38 25 39 26 /** 40 * Array of classes which should not be lazy loaded.41 *42 27 * @var array 43 28 */ … … 45 30 46 31 /** 47 * Basename of the plugin.48 *49 32 * @var string 50 33 */ … … 52 35 53 36 /** 54 * URL to editor JS file.55 *56 37 * @var string 57 38 */ … … 59 40 60 41 /** 61 * Placeholder data uri for img src attributes.62 *63 42 * @link https://stackoverflow.com/a/13139830 64 43 * … … 68 47 69 48 /** 70 * Counter for background image classes.49 * @var int 71 50 */ 72 51 private $background_image_number = 1; 73 52 74 53 /** 75 * Plugin constructor. 76 */ 77 public function __construct() { 78 79 } 80 81 /** 82 * Runs the filters and actions. 83 */ 54 * @var bool 55 */ 56 private $generate_noscript; 57 84 58 public function init() { 85 // Init settings.86 59 $this->settings = new Settings(); 87 60 88 // Set helpers.89 61 $this->helpers = new Helpers(); 90 62 91 // Get the disabled classes and save in property.92 63 $this->disabled_classes = $this->settings->get_disabled_classes(); 93 64 94 // Disable core lazy loading. 65 add_action( 'init', function() { 66 /** 67 * Filter to disable the generation of a noscript element. 68 * 69 * @param bool $generate_noscript Whether to generate a noscript element or not. 70 */ 71 $this->generate_noscript = (bool) apply_filters( 'lazy_loader_generate_noscript', true ); 72 }, 5 ); 73 95 74 add_filter( 'wp_lazy_loading_enabled', '__return_false' ); 96 75 97 // Add link to settings in the plugin list.98 76 add_filter( 'plugin_action_links', array( 99 77 $this, … … 103 81 add_action( 'init', array( $this, 'init_content_processing' ) ); 104 82 105 // Enqueues scripts and styles.106 83 add_action( 'wp_enqueue_scripts', array( 107 84 $this, … … 109 86 ), 20 ); 110 87 111 // Adds inline style.112 88 add_action( 'wp_head', array( $this, 'add_inline_style' ) ); 113 89 114 // Enqueue Gutenberg script.115 90 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) ); 116 91 117 // Load the language files.118 92 add_action( 'plugins_loaded', array( $this, 'load_translation' ) ); 119 93 120 // Action on uninstall.121 94 register_uninstall_hook( $this->basename, 'FlorianBrinkmann\LazyLoadResponsiveImages\Plugin::uninstall' ); 122 95 } 123 124 /** 125 * Run actions and filters to start content processing. 126 */ 96 127 97 public function init_content_processing() { 128 // Check if the complete markup should be processed.129 98 if ( '1' === $this->settings->get_process_complete_markup() ) { 130 99 add_action( 'template_redirect', array( $this, 'process_complete_markup' ) ); 131 100 } else { 132 // Filter markup of the_content() calls to modify media markup for lazy loading.133 101 add_filter( 'the_content', array( $this, 'filter_markup' ), 10001 ); 134 102 135 // Filter allowed html for posts to allow <noscript> tag.136 103 add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); 137 104 138 // Filter markup of Text widget to modify media markup for lazy loading.139 105 add_filter( 'widget_text', array( $this, 'filter_markup' ) ); 140 106 141 // Filter markup of gravatars to modify markup for lazy loading.142 107 add_filter( 'get_avatar', array( $this, 'filter_markup' ) ); 143 108 144 // Adds lazyload markup and noscript element to post thumbnail.145 109 add_filter( 'post_thumbnail_html', array( 146 110 $this, … … 157 121 } 158 122 } 159 160 /** 161 * Run output buffering, to process the complete markup. 162 */ 123 163 124 public function process_complete_markup() { 164 // If this is no content we should process, exit as early as possible.165 125 if ( ! $this->helpers->is_post_to_process() ) { 166 126 return; … … 171 131 172 132 /** 173 * Add settings link to the plugin entry in the plugin list.174 *175 133 * @param array $links Array of action links. 176 134 * @param string $file Basename of the plugin. … … 191 149 192 150 /** 193 * Modifies elements to automatically enable lazy loading.194 *195 151 * @param string $content HTML. 196 152 * … … 198 154 */ 199 155 public function filter_markup( $content = '' ) { 200 // If this is no content we should process, exit as early as possible.201 156 if ( ! $this->helpers->is_post_to_process() ) { 202 157 return $content; 203 158 } 204 159 205 // Check if we have no content.206 160 if ( empty( $content ) ) { 207 161 return $content; 208 162 } 209 163 210 // Check if content contains caption shortcode.211 164 if ( has_shortcode( $content, 'caption' ) ) { 212 165 return $content; 213 166 } 214 167 215 // Disable libxml errors.216 168 libxml_use_internal_errors( true ); 217 169 218 // Create new HTML5 object.219 170 $html5 = new HTML5( array( 220 171 'disable_html_ns' => true, … … 228 179 $content = str_replace( '<![endif]-->', '<!--<![endif]-->', $content ); 229 180 230 // Load the HTML.231 181 $dom = $html5->loadHTML( $content ); 232 182 233 183 $xpath = new \DOMXPath( $dom ); 234 184 235 // Get all nodes except the ones that live inside a noscript element.236 // @link https://stackoverflow.com/a/19348287/7774451.237 185 $nodes = $xpath->query( "//*[not(ancestor-or-self::noscript)][not(ancestor-or-self::*[contains(@class, 'disable-lazyload') or contains(@class, 'skip-lazy') or @data-skip-lazy])]" ); 238 186 … … 240 188 241 189 foreach ( $nodes as $node ) { 242 // Check if it is an element that should not be lazy loaded.243 // Get the classes as an array.244 190 $node_classes = explode( ' ', $node->getAttribute( 'class' ) ); 245 191 246 // Check for intersection with array of classes, which should247 // not be lazy loaded.248 192 $result = array_intersect( $this->disabled_classes, $node_classes ); 249 193 250 // Filter empty values.251 194 $result = array_filter( $result ); 252 253 /* 254 * Check if: 255 * - we have no result from the array intersection. 256 * - the node does not have the data-no-lazyload attr. 257 * - the node does not already have the lazyload class. 258 */ 195 259 196 if ( ! empty( $result ) || $node->hasAttribute( 'data-no-lazyload' ) || in_array( 'lazyload', $node_classes, true ) ) { 260 197 continue; 261 198 } 262 199 263 // Check if the element has a style attribute with a background image.264 200 if ( 265 201 '1' === $this->settings->get_enable_for_background_images() … … 277 213 } 278 214 279 // Check if it is one of the supported elements and support for it is enabled.280 215 if ( 'img' === $node->tagName && 'source' !== $node->parentNode->tagName && 'picture' !== $node->parentNode->tagName ) { 281 216 $dom = $this->modify_img_markup( $node, $dom ); … … 349 284 350 285 /** 351 * Modifies element markup for lazy loading inline background image.352 *353 286 * @param \DOMNode $node The node with the inline background image. 354 287 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 359 292 $original_css = $node->getAttribute( 'style' ); 360 293 $classes = $node->getAttribute( 'class' ); 361 // It is possible that there are multiple background rules for a inline element (including ones for size, position, et cetera). 362 // We will insert all of them to the inline style element, to not mess up their order. 294 363 295 if ( 0 !== preg_match_all( '/background(-[a-z]+)?:([^;])*;?/', $node->getAttribute( 'style' ), $matches ) ) { 364 // $matches[0] contains the full CSS background rules.365 // We remove the rules from the inline style.366 296 $modified_css = str_replace( $matches[0], '', $original_css ); 367 297 $node->setAttribute( 'style', $modified_css ); 368 298 369 // Build string of background rules.370 299 $background_rules_string = implode( ' ', $matches[0] ); 371 300 372 // Add unique class and lazyload class to element.373 301 $unique_class = "lazy-loader-background-element-$this->background_image_number"; 374 302 $classes .= " lazyload $unique_class "; … … 376 304 $this->background_image_number++; 377 305 378 // Create style element with the background rule.379 306 $background_style_elem = $dom->createElement( 'style', ".$unique_class.lazyloaded{ $background_rules_string }" ); 380 307 $node->parentNode->insertBefore( $background_style_elem, $node ); 381 308 382 // Add the noscript element. 309 if ( ! $this->generate_noscript ) { 310 return $dom; 311 } 312 383 313 $noscript = $dom->createElement( 'noscript' ); 384 385 // Insert it before the img node.386 314 $noscript_node = $node->parentNode->insertBefore( $noscript, $node ); 387 388 // Create element.389 315 $background_style_elem_noscript = $dom->createElement( 'style', ".$unique_class.lazyload{ $background_rules_string }" ); 390 391 // Add media node to noscript node.392 316 $noscript_node->appendChild( $background_style_elem_noscript ); 393 317 } 318 394 319 return $dom; 395 320 } 396 321 397 322 /** 398 * Modifies img markup to enable lazy loading.399 *400 323 * @param \DOMNode $img The img dom node. 401 324 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 405 328 */ 406 329 public function modify_img_markup( $img, $dom, $create_noscript = true ) { 407 // Check if the element already has a data-src attribute (might be the case for408 // plugins that bring their own lazy load functionality) and skip it to prevent conflicts.409 330 if ( $img->hasAttribute( 'data-src' ) ) { 410 331 return $dom; 411 332 } 412 333 413 // Add noscript element.414 334 if ( true === $create_noscript ) { 415 335 $dom = $this->add_noscript_element( $dom, $img ); 416 336 } 417 337 418 // Check if the image has sizes and srcset attribute.419 338 $sizes_attr = ''; 420 339 if ( $img->hasAttribute( 'sizes' ) ) { 421 // Get sizes value.422 340 $sizes_attr = $img->getAttribute( 'sizes' ); 423 341 424 // Check if the value is auto. If so, we modify it to data-sizes.425 342 if ( 'auto' === $sizes_attr ) { 426 // Set data-sizes attribute.427 343 $img->setAttribute( 'data-sizes', $sizes_attr ); 428 344 429 // Remove sizes attribute.430 345 $img->removeAttribute( 'sizes' ); 431 346 } … … 433 348 434 349 if ( $img->hasAttribute( 'srcset' ) ) { 435 // Get srcset value.436 350 $srcset = $img->getAttribute( 'srcset' ); 437 351 438 // Set data-srcset attribute.439 352 $img->setAttribute( 'data-srcset', $srcset ); 440 353 441 // Set srcset attribute with src placeholder to produce valid markup.442 354 $img_width = $img->getAttribute( 'width' ); 443 355 if ( '' !== $img_width ) { … … 451 363 } 452 364 } else { 453 // Remove srcset attribute.454 365 $img->removeAttribute( 'srcset' ); 455 366 } 456 367 } 457 368 458 // Get src value.459 369 $src = $img->getAttribute( 'src' ); 460 370 461 // Set data-src value.462 371 $img->setAttribute( 'data-src', $src ); 463 372 … … 466 375 } 467 376 468 // Get the classes.469 377 $classes = $img->getAttribute( 'class' ); 470 378 471 // Add lazyload class.472 379 $classes .= ' lazyload'; 473 380 474 // Set the class string.475 381 $img->setAttribute( 'class', $classes ); 476 382 477 // Get width and height.478 383 $img_width = $img->getAttribute( 'width' ); 479 384 $img_height = $img->getAttribute( 'height' ); 480 385 481 // Set data URI for src attribute.482 386 if ( '' !== $img_width && '' !== $img_height ) { 483 // We have image width and height, we can set a inline SVG to prevent content jumps.484 387 $svg_placeholder = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20{$img_width}%20{$img_height}%22%3E%3C%2Fsvg%3E"; 485 388 $img->setAttribute( 'src', $svg_placeholder ); … … 496 399 497 400 /** 498 * Modifies input[type="image"] markup to enable lazy loading.499 *500 401 * @param \DOMNode $node The input dom node. 501 402 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 505 406 */ 506 407 public function modify_input_markup( $node, $dom, $create_noscript = true ) { 507 // Check if the element already has a data-src attribute (might be the case for508 // plugins that bring their own lazy load functionality) and skip it to prevent conflicts.509 408 if ( $node->hasAttribute( 'data-src' ) ) { 510 409 return $dom; 511 410 } 512 411 513 // Add noscript element.514 412 if ( true === $create_noscript ) { 515 413 $dom = $this->add_noscript_element( $dom, $node ); 516 414 } 517 415 518 // Get src value.519 416 $src = $node->getAttribute( 'src' ); 520 417 521 // Set data-src value.522 418 $node->setAttribute( 'data-src', $src ); 523 419 524 // Get the classes.525 420 $classes = $node->getAttribute( 'class' ); 526 421 527 // Add lazyload class.528 422 $classes .= ' lazyload'; 529 423 530 // Set the class string.531 424 $node->setAttribute( 'class', $classes ); 532 425 533 // Get width and height.534 426 $node_width = $node->getAttribute( 'width' ); 535 427 $node_height = $node->getAttribute( 'height' ); 536 428 537 // Set data URI for src attribute.538 429 if ( '' !== $node_width && '' !== $node_height ) { 539 // We have image width and height, we can set a inline SVG to prevent content jumps.540 430 $svg_placeholder = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20{$node_width}%20{$node_height}%22%3E%3C%2Fsvg%3E"; 541 431 $node->setAttribute( 'src', $svg_placeholder ); … … 552 442 553 443 /** 554 * Modifies picture element markup to enable lazy loading.555 *556 444 * @param \DOMNode $picture The source dom node. 557 445 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 560 448 */ 561 449 public function modify_picture_markup( $picture, $dom ) { 562 // Check if img element already has `layzload` class.563 450 $img_element = $picture->getElementsByTagName( 'img' ); 564 451 … … 569 456 } 570 457 571 // Add noscript element.572 458 $dom = $this->add_noscript_element( $dom, $picture ); 573 459 574 // Get source elements from picture.575 460 $source_elements = $picture->getElementsByTagName( 'source' ); 576 461 577 // Loop the source elements if there are some.578 462 if ( 0 !== $source_elements->length ) { 579 463 foreach ( $source_elements as $source_element ) { 580 // Check if we have a sizes attribute.581 464 $sizes_attr = ''; 582 465 if ( $source_element->hasAttribute( 'sizes' ) ) { 583 // Get sizes value.584 466 $sizes_attr = $source_element->getAttribute( 'sizes' ); 585 467 586 // Check if the value is auto. If so, we modify it to data-sizes.587 468 if ( 'auto' === $sizes_attr ) { 588 // Set data-sizes attribute.589 469 $source_element->setAttribute( 'data-sizes', $sizes_attr ); 590 470 591 // Remove sizes attribute.592 471 $source_element->removeAttribute( 'sizes' ); 593 472 } 594 473 } 595 474 596 // Check for srcset.597 475 if ( $source_element->hasAttribute( 'srcset' ) ) { 598 // Get srcset value.599 476 $srcset = $source_element->getAttribute( 'srcset' ); 600 477 601 // Set data-srcset attribute.602 478 $source_element->setAttribute( 'data-srcset', $srcset ); 603 479 604 // Set srcset attribute with src placeholder to produce valid markup.605 480 if ( '' !== $sizes_attr ) { 606 481 $width = preg_replace( '/.+ (\d+)px$/', '$1', $sizes_attr ); … … 611 486 } 612 487 } else { 613 // Remove srcset attribute.614 488 $source_element->removeAttribute( 'srcset' ); 615 489 } … … 617 491 618 492 if ( $source_element->hasAttribute( 'src' ) ) { 619 // Get src value.620 493 $src = $source_element->getAttribute( 'src' ); 621 494 622 // Set data-src value.623 495 $source_element->setAttribute( 'data-src', $src ); 624 496 625 // Set data URI for src attribute.626 497 $source_element->setAttribute( 'src', $this->src_placeholder ); 627 498 } … … 629 500 } 630 501 631 // Loop the img element.632 502 foreach ( $img_element as $img ) { 633 503 $this->modify_img_markup( $img, $dom, false ); … … 638 508 639 509 /** 640 * Modifies iframe markup to enable lazy loading.641 *642 510 * @param \DOMNode $iframe The iframe dom node. 643 511 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 646 514 */ 647 515 public function modify_iframe_markup( $iframe, $dom ) { 648 // Add noscript element.649 516 $dom = $this->add_noscript_element( $dom, $iframe ); 650 517 651 // Check if the iframe has a src attribute.652 518 if ( $iframe->hasAttribute( 'src' ) ) { 653 // Get src attribute.654 519 $src = $iframe->getAttribute( 'src' ); 655 520 656 // Set data-src value.657 521 $iframe->setAttribute( 'data-src', $src ); 658 522 } else { … … 664 528 } 665 529 666 // Get the classes.667 530 $classes = $iframe->getAttribute( 'class' ); 668 531 669 // Add lazyload class.670 532 $classes .= ' lazyload'; 671 533 672 // Set the class string.673 534 $iframe->setAttribute( 'class', $classes ); 674 535 675 // Remove the src attribute.676 536 $iframe->removeAttribute( 'src' ); 677 537 … … 680 540 681 541 /** 682 * Modifies video markup to enable lazy loading.683 *684 542 * @param \DOMNode $video The video dom node. 685 543 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 688 546 */ 689 547 public function modify_video_markup( $video, $dom ) { 690 // Add noscript element.691 548 $dom = $this->add_noscript_element( $dom, $video ); 692 549 693 // Check if the video has a poster attribute.694 550 if ( $video->hasAttribute( 'poster' ) ) { 695 // Get poster attribute.696 551 $poster = $video->getAttribute( 'poster' ); 697 552 698 // Remove the poster attribute.699 553 $video->removeAttribute( 'poster' ); 700 554 701 // Set data-poster value.702 555 $video->setAttribute( 'data-poster', $poster ); 703 556 } 704 557 705 // Set preload to none.706 558 $video->setAttribute( 'preload', 'none' ); 707 559 708 // Check for autoplay attribute and change it for lazy loading.709 560 if ( $video->hasAttribute( 'autoplay' ) ) { 710 561 $video->removeAttribute( 'autoplay' ); … … 712 563 } 713 564 714 // Get the classes.715 565 $classes = $video->getAttribute( 'class' ); 716 566 717 // Add lazyload class.718 567 $classes .= ' lazyload'; 719 568 720 // Set the class string.721 569 $video->setAttribute( 'class', $classes ); 722 570 … … 725 573 726 574 /** 727 * Modifies audio markup to enable lazy loading.728 *729 575 * @param \DOMNode $audio The audio dom node. 730 576 * @param \DOMDocument $dom \DOMDocument() object of the HTML. … … 733 579 */ 734 580 public function modify_audio_markup( $audio, $dom ) { 735 // Add noscript element.736 581 $dom = $this->add_noscript_element( $dom, $audio ); 737 582 738 // Set preload to none.739 583 $audio->setAttribute( 'preload', 'none' ); 740 584 741 // Get the classes.742 585 $classes = $audio->getAttribute( 'class' ); 743 586 744 // Add lazyload class.745 587 $classes .= ' lazyload'; 746 588 747 // Set the class string.748 589 $audio->setAttribute( 'class', $classes ); 749 590 … … 752 593 753 594 /** 754 * Adds noscript element before DOM node.755 *756 595 * @param \DOMDocument $dom \DOMDocument() object of the 757 596 * HTML. … … 761 600 */ 762 601 public function add_noscript_element( $dom, $elem ) { 763 // Create noscript element and add it before the element that gets lazy loading. 602 if ( ! $this->generate_noscript ) { 603 return $dom; 604 } 605 764 606 $noscript = $dom->createElement( 'noscript' ); 765 607 $noscript_node = $elem->parentNode->insertBefore( $noscript, $elem ); 766 608 767 // Create copy of media element.768 609 $noscript_media_fallback_elem = $elem->cloneNode( true ); 769 610 … … 779 620 } 780 621 781 // Add a copy of the media element to the noscript.782 622 $noscript_node->appendChild( $noscript_media_fallback_elem ); 783 623 … … 786 626 787 627 /** 788 * Filter allowed html for posts.789 *790 628 * @param array $allowedposttags Allowed post tags. 791 629 * @param string $context Context. … … 802 640 return $allowedposttags; 803 641 } 804 805 /** 806 * Enqueues scripts and styles. 807 */ 642 808 643 public function enqueue_script() { 809 644 if ( $this->helpers->is_disabled_for_post() ) { … … 818 653 } 819 654 820 // Enqueue lazysizes.821 655 wp_enqueue_script( 'lazysizes', plugins_url( '/lazy-loading-responsive-images/js/lazysizes.min.js' ), array(), filemtime( plugin_dir_path( __FILE__ ) . '../js/lazysizes.min.js' ), true ); 822 656 823 // Check if unveilhooks plugin should be loaded.824 657 if ( '1' === $this->settings->get_load_unveilhooks_plugin() || '1' === $this->settings->get_enable_for_audios() || '1' === $this->settings->get_enable_for_videos() || '1' === $this->settings->get_enable_for_background_images() ) { 825 // Enqueue unveilhooks plugin.826 658 wp_enqueue_script( 'lazysizes-unveilhooks', plugins_url( '/lazy-loading-responsive-images/js/ls.unveilhooks.min.js' ), array( 'lazysizes' ), filemtime( plugin_dir_path( __FILE__ ) . '../js/ls.unveilhooks.min.js' ), true ); 827 659 } 828 660 829 // Check if native loading plugin should be loaded.830 661 if ( '1' === $this->settings->get_load_native_loading_plugin() ) { 831 662 wp_enqueue_script( 'lazysizes-native-loading', plugins_url( '/lazy-loading-responsive-images/js/ls.native-loading.min.js' ), array( 'lazysizes' ), filemtime( plugin_dir_path( __FILE__ ) . '../js/ls.native-loading.min.js' ), true ); 832 663 } 833 664 834 // Include custom lazysizes config if not empty.835 665 if ( '' !== $this->settings->get_lazysizes_config() ) { 836 666 wp_add_inline_script( 'lazysizes', $this->settings->get_lazysizes_config(), 'before' ); 837 667 } 838 668 } 839 840 /** 841 * Adds inline style. 842 * 843 * We do not enqueue a new CSS file for two rules, but cannot use 844 * wp_add_inline_style() because we have no handle. So we need to 845 * echo it. 846 */ 669 847 670 public function add_inline_style() { 848 671 if ( $this->helpers->is_disabled_for_post() ) { … … 850 673 } 851 674 852 // Create loading spinner style if needed.853 675 $spinner_styles = ''; 854 676 $spinner_color = $this->settings->get_loading_spinner_color(); … … 889 711 } 890 712 891 // Display the default styles.892 713 $default_styles = "<style>:root { 893 714 --lazy-loader-animation-duration: 300ms; … … 917 738 echo apply_filters( 'lazy_load_responsive_images_inline_styles', $default_styles ); 918 739 919 // Hide images if no JS.920 740 echo '<noscript><style>.lazyload { display: none; } .lazyload[class*="lazy-loader-background-element-"] { display: block; opacity: 1; }</style></noscript>'; 921 741 } 922 923 /** 924 * Enqueue script to Gutenberg editor view. 925 */ 742 926 743 public function enqueue_block_editor_assets() { 927 744 if ( isset( $_REQUEST['post'] ) && in_array( get_post_type( $_REQUEST['post'] ), $this->settings->get_disable_option_object_types() ) && post_type_supports( get_post_type( $_REQUEST['post'] ), 'custom-fields' ) ) { … … 935 752 } 936 753 } 937 938 /** 939 * Loads the plugin translation. 940 */ 754 941 755 public function load_translation() { 942 756 load_plugin_textdomain( 'lazy-loading-responsive-images' ); … … 944 758 945 759 /** 946 * Sets plugin basename.947 *948 760 * @param string $basename The plugin basename. 949 761 */ … … 953 765 954 766 /** 955 * Sets plugin basename.956 *957 767 * @param string $basename The plugin basename. 958 768 */ … … 960 770 $this->js_asset_url = $js_asset_url; 961 771 } 962 963 /** 964 * Action on plugin uninstall. 965 */ 772 966 773 public static function uninstall() { 967 774 $options_array = array( … … 982 789 ); 983 790 984 // Delete options.985 791 foreach ( $options_array as $option ) { 986 792 delete_option( $option ); -
lazy-loading-responsive-images/trunk/src/Settings.php
r2505151 r3070210 1 1 <?php 2 2 /** 3 * Class for adding customizer settings.4 *5 3 * @package FlorianBrinkmann\LazyLoadResponsiveImages 6 4 */ … … 8 6 namespace FlorianBrinkmann\LazyLoadResponsiveImages; 9 7 10 /**11 * Class Settings12 *13 * Adds options to the customizer.14 *15 * @package FlorianBrinkmann\LazyLoadResponsiveImages16 */17 8 class Settings { 18 9 19 10 /** 20 * Helpers object.21 *22 11 * @var \FlorianBrinkmann\LazyLoadResponsiveImages\Helpers 23 12 */ … … 25 14 26 15 /** 27 * Array of options data.28 *29 16 * @var array 30 17 */ … … 32 19 33 20 /** 34 * Classes which should not be lazy loaded.35 *36 21 * @var array 37 22 */ … … 39 24 40 25 /** 41 * Value of settings for enabling lazy loading for iFrames.42 *43 26 * @var string 44 27 */ … … 46 29 47 30 /** 48 * Value of setting for loading the unveilhooks plugin.49 *50 31 * @var string 51 32 */ … … 53 34 54 35 /** 55 * Value of setting for loading the unveilhooks plugin.56 *57 36 * @var string 58 37 */ … … 60 39 61 40 /** 62 * Value of settings for enabling lazy loading for background images.63 *64 41 * @var string 65 42 */ … … 67 44 68 45 /** 69 * Value of settings for enabling lazy loading for videos.70 *71 46 * @var string 72 47 */ … … 74 49 75 50 /** 76 * Value of settings for enabling lazy loading for audios.77 *78 51 * @var string 79 52 */ … … 81 54 82 55 /** 83 * Value of setting for displaying a loading spinner.84 *85 56 * @var string 86 57 */ … … 88 59 89 60 /** 90 * Default loading spinner color.91 *92 61 * @var string 93 62 */ … … 95 64 96 65 /** 97 * Value of setting for loading spinner color.98 *99 66 * @var string 100 67 */ … … 102 69 103 70 /** 104 * Value of setting for displaying the option to disable the plugin per page/post.105 *106 71 * @var string 107 72 */ … … 109 74 110 75 /** 111 * Array of object types that should show the checkbox to disable lazy loading.112 *113 76 * @var array 114 77 */ … … 116 79 117 80 /** 118 * String to modify lazysizes config.119 *120 81 * @var string 121 82 */ … … 123 84 124 85 /** 125 * Value of setting for processing the complete website markup.126 *127 86 * @var string 128 87 */ … … 130 89 131 90 /** 132 * Value of setting for additional filters to process.133 *134 91 * @var array 135 92 */ … … 137 94 138 95 /** 139 * Allowed HTML tags in descriptions.140 *141 96 * @var array 142 97 */ … … 148 103 ); 149 104 150 /**151 * Settings constructor.152 */153 105 public function __construct() { 154 // Set helpers.155 106 $this->helpers = new Helpers(); 156 107 … … 295 246 ); 296 247 297 // Fill properties with setting values.298 248 $this->disabled_classes = explode( ',', $this->options['lazy_load_responsive_images_disabled_classes']['value'] ); 299 249 $this->enable_for_iframes = $this->options['lazy_load_responsive_images_enable_for_iframes']['value']; … … 310 260 $this->enable_for_background_images = $this->options['lazy_load_responsive_images_enable_for_background_images']['value']; 311 261 312 // Register settings on media options page.313 262 add_action( 'admin_init', array( $this, 'settings_init' ), 12 ); 314 263 315 // Include color picker JS.316 264 add_action( 'admin_enqueue_scripts', array( 317 265 $this, … … 322 270 add_action( 'init', array( $this, 'disable_option_object_types_filter' ), 11 ); 323 271 324 // Register meta for disabling per page.325 272 add_action( 'init', array( $this, 'register_post_meta' ), 11 ); 326 273 327 // Publish post actions.328 274 add_action( 'post_submitbox_misc_actions', array( $this, 'add_checkbox' ), 9 ); 329 275 add_action( 'save_post', array( $this, 'save_checkbox' ) ); … … 331 277 } 332 278 333 /**334 * Init settings on media options page.335 */336 279 public function settings_init() { 337 // Add section.338 280 add_settings_section( 339 281 "lazy-load-responsive-images-section", … … 346 288 ); 347 289 348 // Loop the options.349 290 foreach ( $this->options as $option_id => $option ) { 350 // Register setting.351 291 register_setting( 'media', $option_id, array( 352 292 'sanitize_callback' => $option['sanitize_callback'], 353 293 ) ); 354 294 355 // Create field.356 295 add_settings_field( 357 296 $option_id, … … 366 305 ) 367 306 ); 368 } // End foreach(). 369 } 370 371 /** 372 * Section callback. 373 * 307 } 308 } 309 310 /** 374 311 * @param array $args 375 312 */ … … 378 315 379 316 /** 380 * Checkbox callback.381 *382 317 * @param array $args { 383 318 * Argument array. … … 389 324 */ 390 325 public function checkbox_field_cb( $args ) { 391 // Get option value.392 326 $option_value = $args['value']; 393 327 394 // Get label for.395 328 ?> 396 329 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" 397 330 type="checkbox" <?php echo ( $option_value == '1' || $option_value == 'on' ) ? 'checked="checked"' : ''; ?>> 398 331 <?php 399 // Check for description.400 332 if ( '' !== $args['description'] ) { ?> 401 333 <p class="description"> … … 407 339 408 340 /** 409 * Text field callback.410 *411 341 * @param array $args { 412 342 * Argument array. … … 418 348 */ 419 349 public function text_field_cb( $args ) { 420 // Get option value.421 350 $option_value = $args['value']; 422 351 423 // Get label for.424 352 ?> 425 353 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" 426 354 type="text" value="<?php echo esc_attr( $option_value ); ?>"> 427 355 <?php 428 // Check for description.429 356 if ( '' !== $args['description'] ) { ?> 430 357 <p class="description"> … … 436 363 437 364 /** 438 * Textarea field callback.439 *440 365 * @param array $args { 441 366 * Argument array. … … 447 372 */ 448 373 public function textarea_field_cb( $args ) { 449 // Get option value.450 374 $option_value = $args['value']; 451 375 … … 453 377 <textarea id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" style="width: 100%;"><?php echo esc_textarea( $option_value ); ?></textarea> 454 378 <?php 455 // Check for description.456 379 if ( '' !== $args['description'] ) { ?> 457 380 <p class="description"> … … 463 386 464 387 /** 465 * Color field callback.466 *467 388 * @param array $args { 468 389 * Argument array. … … 475 396 */ 476 397 public function color_field_cb( $args ) { 477 // Get option value.478 398 $option_value = $args['value']; 479 399 480 // Get label for.481 400 ?> 482 401 <input id="<?php echo esc_attr( $args['label_for'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" … … 485 404 class="lazy-load-responsive-images-color-field"> 486 405 <?php 487 // Check for description.488 406 if ( '' !== $args['description'] ) { ?> 489 407 <p class="description"> … … 495 413 496 414 /** 497 * Add color picker to media settings page and init it.498 *499 415 * @param string $hook_suffix PHP file of the admin screen. 500 416 */ 501 417 public function add_color_picker( $hook_suffix ) { 502 // Check if we are not on the media backend screen.503 418 if ( 'options-media.php' !== $hook_suffix ) { 504 419 return; 505 } // End if(). 506 507 // Add color picker script and style and init it. 420 } 421 508 422 wp_enqueue_style( 'wp-color-picker' ); 509 423 wp_enqueue_script( 'wp-color-picker' ); … … 513 427 } 514 428 515 /**516 * Set array of post types that support granular disabling of Lazy Loader features.517 */518 429 public function disable_option_object_types_filter() { 519 430 $public_post_types = get_post_types( array( … … 521 432 ), 'names' ); 522 433 523 // Remove attachment post type.524 434 if ( is_array( $public_post_types ) && isset( $public_post_types['attachment'] ) ) { 525 435 unset( $public_post_types['attachment'] ); … … 537 447 } 538 448 539 /**540 * Register post meta for disabling plugin per541 */542 449 public function register_post_meta() { 543 450 if ( ! is_array( $this->disable_option_object_types ) ) { … … 560 467 561 468 /** 562 * Add checkbox to Publish Post meta box.563 *564 469 * @link https://github.com/deworg/dewp-planet-feed/ 565 470 */ … … 571 476 } 572 477 573 // Check user capability. Not bailing, though, on purpose.574 478 $maybe_enabled = current_user_can( 'publish_posts' ); 575 // This actually defines whether post will be listed in our feed.576 479 $value = absint( get_post_meta( $post->ID, 'lazy_load_responsive_images_disabled', true ) ); 577 480 printf( … … 589 492 590 493 /** 591 * Save option value to post meta.592 *593 494 * @link https://github.com/deworg/dewp-planet-feed/ 594 495 * … … 622 523 623 524 /** 624 * Return disabled classes setting value.625 *626 525 * @return array 627 526 */ … … 631 530 632 531 /** 633 * Return load_unveilhooks_plugin value.634 *635 532 * @return string 636 533 */ … … 640 537 641 538 /** 642 * Return enable_for_audios value.643 *644 539 * @return string 645 540 */ … … 649 544 650 545 /** 651 * Return enable_for_videos value.652 *653 546 * @return string 654 547 */ … … 658 551 659 552 /** 660 * Return enable_for_iframes value.661 *662 553 * @return string 663 554 */ … … 667 558 668 559 /** 669 * Return enable_for_background_images value.670 *671 560 * @return string 672 561 */ … … 676 565 677 566 /** 678 * Return load_native_loading_plugin value.679 *680 567 * @return string 681 568 */ … … 685 572 686 573 /** 687 * Return lazysizes_config value.688 *689 574 * @return string 690 575 */ … … 694 579 695 580 /** 696 * Return loading_spinner_color value.697 *698 581 * @return string 699 582 */ … … 703 586 704 587 /** 705 * Return loading_spinner_color_default value.706 *707 588 * @return string 708 589 */ … … 712 593 713 594 /** 714 * Return loading_spinner value.715 *716 595 * @return string 717 596 */ … … 721 600 722 601 /** 723 * Return disable_option_object_types value.724 *725 602 * @return array 726 603 */ … … 730 607 731 608 /** 732 * Return process_complete_markup value.733 *734 609 * @return string 735 610 */ … … 739 614 740 615 /** 741 * Return additional_filters value.742 *743 616 * @return array 744 617 */ -
lazy-loading-responsive-images/trunk/vendor/autoload.php
r2843576 r3070210 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3::getLoader();25 return ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d::getLoader(); -
lazy-loading-responsive-images/trunk/vendor/composer/ClassLoader.php
r2843576 r3070210 46 46 private static $includeFile; 47 47 48 /** @var ?string*/48 /** @var string|null */ 49 49 private $vendorDir; 50 50 51 51 // PSR-4 52 52 /** 53 * @var array[] 54 * @psalm-var array<string, array<string, int>> 53 * @var array<string, array<string, int>> 55 54 */ 56 55 private $prefixLengthsPsr4 = array(); 57 56 /** 58 * @var array[] 59 * @psalm-var array<string, array<int, string>> 57 * @var array<string, list<string>> 60 58 */ 61 59 private $prefixDirsPsr4 = array(); 62 60 /** 63 * @var array[] 64 * @psalm-var array<string, string> 61 * @var list<string> 65 62 */ 66 63 private $fallbackDirsPsr4 = array(); … … 68 65 // PSR-0 69 66 /** 70 * @var array[] 71 * @psalm-var array<string, array<string, string[]>> 67 * List of PSR-0 prefixes 68 * 69 * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) 70 * 71 * @var array<string, array<string, list<string>>> 72 72 */ 73 73 private $prefixesPsr0 = array(); 74 74 /** 75 * @var array[] 76 * @psalm-var array<string, string> 75 * @var list<string> 77 76 */ 78 77 private $fallbackDirsPsr0 = array(); … … 82 81 83 82 /** 84 * @var string[] 85 * @psalm-var array<string, string> 83 * @var array<string, string> 86 84 */ 87 85 private $classMap = array(); … … 91 89 92 90 /** 93 * @var bool[] 94 * @psalm-var array<string, bool> 91 * @var array<string, bool> 95 92 */ 96 93 private $missingClasses = array(); 97 94 98 /** @var ?string*/95 /** @var string|null */ 99 96 private $apcuPrefix; 100 97 101 98 /** 102 * @var self[]99 * @var array<string, self> 103 100 */ 104 101 private static $registeredLoaders = array(); 105 102 106 103 /** 107 * @param ?string$vendorDir104 * @param string|null $vendorDir 108 105 */ 109 106 public function __construct($vendorDir = null) … … 114 111 115 112 /** 116 * @return string[]113 * @return array<string, list<string>> 117 114 */ 118 115 public function getPrefixes() … … 126 123 127 124 /** 128 * @return array[] 129 * @psalm-return array<string, array<int, string>> 125 * @return array<string, list<string>> 130 126 */ 131 127 public function getPrefixesPsr4() … … 135 131 136 132 /** 137 * @return array[] 138 * @psalm-return array<string, string> 133 * @return list<string> 139 134 */ 140 135 public function getFallbackDirs() … … 144 139 145 140 /** 146 * @return array[] 147 * @psalm-return array<string, string> 141 * @return list<string> 148 142 */ 149 143 public function getFallbackDirsPsr4() … … 153 147 154 148 /** 155 * @return string[] Array of classname => path 156 * @psalm-return array<string, string> 149 * @return array<string, string> Array of classname => path 157 150 */ 158 151 public function getClassMap() … … 162 155 163 156 /** 164 * @param string[] $classMap Class to filename map 165 * @psalm-param array<string, string> $classMap 157 * @param array<string, string> $classMap Class to filename map 166 158 * 167 159 * @return void … … 180 172 * appending or prepending to the ones previously set for this prefix. 181 173 * 182 * @param string $prefix The prefix183 * @param string[]|string $paths The PSR-0 root directories184 * @param bool $prepend Whether to prepend the directories174 * @param string $prefix The prefix 175 * @param list<string>|string $paths The PSR-0 root directories 176 * @param bool $prepend Whether to prepend the directories 185 177 * 186 178 * @return void … … 188 180 public function add($prefix, $paths, $prepend = false) 189 181 { 182 $paths = (array) $paths; 190 183 if (!$prefix) { 191 184 if ($prepend) { 192 185 $this->fallbackDirsPsr0 = array_merge( 193 (array)$paths,186 $paths, 194 187 $this->fallbackDirsPsr0 195 188 ); … … 197 190 $this->fallbackDirsPsr0 = array_merge( 198 191 $this->fallbackDirsPsr0, 199 (array)$paths192 $paths 200 193 ); 201 194 } … … 206 199 $first = $prefix[0]; 207 200 if (!isset($this->prefixesPsr0[$first][$prefix])) { 208 $this->prefixesPsr0[$first][$prefix] = (array)$paths;201 $this->prefixesPsr0[$first][$prefix] = $paths; 209 202 210 203 return; … … 212 205 if ($prepend) { 213 206 $this->prefixesPsr0[$first][$prefix] = array_merge( 214 (array)$paths,207 $paths, 215 208 $this->prefixesPsr0[$first][$prefix] 216 209 ); … … 218 211 $this->prefixesPsr0[$first][$prefix] = array_merge( 219 212 $this->prefixesPsr0[$first][$prefix], 220 (array)$paths213 $paths 221 214 ); 222 215 } … … 227 220 * appending or prepending to the ones previously set for this namespace. 228 221 * 229 * @param string $prefix The prefix/namespace, with trailing '\\'230 * @param string[]|string $paths The PSR-4 base directories231 * @param bool $prepend Whether to prepend the directories222 * @param string $prefix The prefix/namespace, with trailing '\\' 223 * @param list<string>|string $paths The PSR-4 base directories 224 * @param bool $prepend Whether to prepend the directories 232 225 * 233 226 * @throws \InvalidArgumentException … … 237 230 public function addPsr4($prefix, $paths, $prepend = false) 238 231 { 232 $paths = (array) $paths; 239 233 if (!$prefix) { 240 234 // Register directories for the root namespace. 241 235 if ($prepend) { 242 236 $this->fallbackDirsPsr4 = array_merge( 243 (array)$paths,237 $paths, 244 238 $this->fallbackDirsPsr4 245 239 ); … … 247 241 $this->fallbackDirsPsr4 = array_merge( 248 242 $this->fallbackDirsPsr4, 249 (array)$paths243 $paths 250 244 ); 251 245 } … … 257 251 } 258 252 $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 259 $this->prefixDirsPsr4[$prefix] = (array)$paths;253 $this->prefixDirsPsr4[$prefix] = $paths; 260 254 } elseif ($prepend) { 261 255 // Prepend directories for an already registered namespace. 262 256 $this->prefixDirsPsr4[$prefix] = array_merge( 263 (array)$paths,257 $paths, 264 258 $this->prefixDirsPsr4[$prefix] 265 259 ); … … 268 262 $this->prefixDirsPsr4[$prefix] = array_merge( 269 263 $this->prefixDirsPsr4[$prefix], 270 (array)$paths264 $paths 271 265 ); 272 266 } … … 277 271 * replacing any others previously set for this prefix. 278 272 * 279 * @param string $prefix The prefix280 * @param string[]|string $paths The PSR-0 base directories273 * @param string $prefix The prefix 274 * @param list<string>|string $paths The PSR-0 base directories 281 275 * 282 276 * @return void … … 295 289 * replacing any others previously set for this namespace. 296 290 * 297 * @param string $prefix The prefix/namespace, with trailing '\\'298 * @param string[]|string $paths The PSR-4 base directories291 * @param string $prefix The prefix/namespace, with trailing '\\' 292 * @param list<string>|string $paths The PSR-4 base directories 299 293 * 300 294 * @throws \InvalidArgumentException … … 430 424 { 431 425 if ($file = $this->findFile($class)) { 432 (self::$includeFile)($file); 426 $includeFile = self::$includeFile; 427 $includeFile($file); 433 428 434 429 return true; … … 481 476 482 477 /** 483 * Returns the currently registered loaders indexed by their corresponding vendor directories.484 * 485 * @return self[]478 * Returns the currently registered loaders keyed by their corresponding vendor directories. 479 * 480 * @return array<string, self> 486 481 */ 487 482 public static function getRegisteredLoaders() … … 561 556 } 562 557 563 private static function initializeIncludeClosure(): void 558 /** 559 * @return void 560 */ 561 private static function initializeIncludeClosure() 564 562 { 565 563 if (self::$includeFile !== null) { … … 575 573 * @return void 576 574 */ 577 self::$includeFile = static function($file) {575 self::$includeFile = \Closure::bind(static function($file) { 578 576 include $file; 579 } ;577 }, null, null); 580 578 } 581 579 } -
lazy-loading-responsive-images/trunk/vendor/composer/InstalledVersions.php
r2843576 r3070210 99 99 foreach (self::getInstalled() as $installed) { 100 100 if (isset($installed['versions'][$packageName])) { 101 return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);101 return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; 102 102 } 103 103 } … … 120 120 public static function satisfies(VersionParser $parser, $packageName, $constraint) 121 121 { 122 $constraint = $parser->parseConstraints( $constraint);122 $constraint = $parser->parseConstraints((string) $constraint); 123 123 $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); 124 124 … … 329 329 $installed[] = self::$installedByVendor[$vendorDir]; 330 330 } elseif (is_file($vendorDir.'/composer/installed.php')) { 331 $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; 331 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 332 $required = require $vendorDir.'/composer/installed.php'; 333 $installed[] = self::$installedByVendor[$vendorDir] = $required; 332 334 if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { 333 335 self::$installed = $installed[count($installed) - 1]; … … 341 343 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 342 344 if (substr(__DIR__, -8, 1) !== 'C') { 343 self::$installed = require __DIR__ . '/installed.php'; 345 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ 346 $required = require __DIR__ . '/installed.php'; 347 self::$installed = $required; 344 348 } else { 345 349 self::$installed = array(); 346 350 } 347 351 } 348 $installed[] = self::$installed; 352 353 if (self::$installed !== array()) { 354 $installed[] = self::$installed; 355 } 349 356 350 357 return $installed; -
lazy-loading-responsive-images/trunk/vendor/composer/autoload_real.php
r2843576 r3070210 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b35 class ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 992eca56574b9f1c8fe962b958c076b3', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInita21d1f93de4e18f6084492a2be69518d', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInita21d1f93de4e18f6084492a2be69518d::getInitializer($loader)); 33 33 34 34 $loader->register(true); -
lazy-loading-responsive-images/trunk/vendor/composer/autoload_static.php
r2843576 r3070210 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 992eca56574b9f1c8fe962b958c076b37 class ComposerStaticInita21d1f93de4e18f6084492a2be69518d 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 59 59 { 60 60 return \Closure::bind(function () use ($loader) { 61 $loader->prefixLengthsPsr4 = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$prefixLengthsPsr4;62 $loader->prefixDirsPsr4 = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$prefixDirsPsr4;63 $loader->classMap = ComposerStaticInit 992eca56574b9f1c8fe962b958c076b3::$classMap;61 $loader->prefixLengthsPsr4 = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$prefixLengthsPsr4; 62 $loader->prefixDirsPsr4 = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$prefixDirsPsr4; 63 $loader->classMap = ComposerStaticInita21d1f93de4e18f6084492a2be69518d::$classMap; 64 64 65 65 }, null, ClassLoader::class); -
lazy-loading-responsive-images/trunk/vendor/composer/installed.json
r2489768 r3070210 3 3 { 4 4 "name": "masterminds/html5", 5 "version": "2. 7.4",6 "version_normalized": "2. 7.4.0",5 "version": "2.9.0", 6 "version_normalized": "2.9.0.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/Masterminds/html5-php.git", 10 "reference": " 9227822783c75406cfe400984b2f095cdf03d417"10 "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6" 11 11 }, 12 12 "dist": { 13 13 "type": "zip", 14 "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/ 9227822783c75406cfe400984b2f095cdf03d417",15 "reference": " 9227822783c75406cfe400984b2f095cdf03d417",14 "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", 15 "reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6", 16 16 "shasum": "" 17 17 }, 18 18 "require": { 19 "ext-ctype": "*",20 19 "ext-dom": "*", 21 "ext-libxml": "*",22 20 "php": ">=5.3.0" 23 21 }, 24 22 "require-dev": { 25 "phpunit/phpunit": "^4.8.35 "23 "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9" 26 24 }, 27 "time": "202 0-10-01T13:52:52+00:00",25 "time": "2024-03-31T07:05:07+00:00", 28 26 "type": "library", 29 27 "extra": { … … 69 67 "support": { 70 68 "issues": "https://github.com/Masterminds/html5-php/issues", 71 "source": "https://github.com/Masterminds/html5-php/tree/2. 7.4"69 "source": "https://github.com/Masterminds/html5-php/tree/2.9.0" 72 70 }, 73 71 "install-path": "../masterminds/html5" -
lazy-loading-responsive-images/trunk/vendor/composer/installed.php
r2843576 r3070210 2 2 'root' => array( 3 3 'name' => 'florianbrinkmann/lazy-loading-responsive-images', 4 'pretty_version' => ' v8.1.1',5 'version' => '8. 1.1.0',6 'reference' => ' 35f8dc96cbf8528f0d89478d3fd5377af01c3692',4 'pretty_version' => '8.2.0', 5 'version' => '8.2.0.0', 6 'reference' => 'a48ef29925d97c95258d264e05491a76848f01b3', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'florianbrinkmann/lazy-loading-responsive-images' => array( 14 'pretty_version' => ' v8.1.1',15 'version' => '8. 1.1.0',16 'reference' => ' 35f8dc96cbf8528f0d89478d3fd5377af01c3692',14 'pretty_version' => '8.2.0', 15 'version' => '8.2.0.0', 16 'reference' => 'a48ef29925d97c95258d264e05491a76848f01b3', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'masterminds/html5' => array( 23 'pretty_version' => '2. 7.4',24 'version' => '2. 7.4.0',25 'reference' => ' 9227822783c75406cfe400984b2f095cdf03d417',23 'pretty_version' => '2.9.0', 24 'version' => '2.9.0.0', 25 'reference' => 'f5ac2c0b0a2eefca70b2ce32a5809992227e75a6', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../masterminds/html5', -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/RELEASE.md
r2412362 r3070210 1 1 # Release Notes 2 3 2.7.6 (2021-08-18) 4 5 - #218: Address comment handling issues 6 7 2.7.5 (2021-07-01) 8 9 - #204: Travis: Enable tests on PHP 8.0 10 - #207: Fix PHP 8.1 deprecations 2 11 3 12 2.7.4 (2020-10-01) -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Elements.php
r2236239 r3070210 71 71 */ 72 72 const BLOCK_ONLY_INLINE = 128; 73 74 /** 75 * Elements with optional end tags that cause auto-closing of previous and parent tags, 76 * as example most of the table related tags, see https://www.w3.org/TR/html401/struct/tables.html 77 * Structure is as follows: 78 * TAG-NAME => [PARENT-TAG-NAME-TO-CLOSE1, PARENT-TAG-NAME-TO-CLOSE2, ...]. 79 * 80 * Order is important, after auto-closing one parent with might have to close also their parent. 81 * 82 * @var array<string, string[]> 83 */ 84 public static $optionalEndElementsParentsToClose = array( 85 'tr' => array('td', 'tr'), 86 'td' => array('td', 'th'), 87 'th' => array('td', 'th'), 88 'tfoot' => array('td', 'th', 'tr', 'tbody', 'thead'), 89 'tbody' => array('td', 'th', 'tr', 'thead'), 90 ); 73 91 74 92 /** … … 186 204 'ul' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 187 205 'var' => 1, 188 'video' => 65, // NORMAL | BLOCK_TAG206 'video' => 1, 189 207 'wbr' => 9, // NORMAL | VOID_TAG 190 208 -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php
r2412362 r3070210 176 176 $dt = $impl->createDocumentType('html'); 177 177 // $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt); 178 $this->doc = $impl->createDocument(null, null, $dt);178 $this->doc = $impl->createDocument(null, '', $dt); 179 179 $this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8'; 180 180 } … … 360 360 } 361 361 362 // some elements as table related tags might have optional end tags that force us to auto close multiple tags 363 // https://www.w3.org/TR/html401/struct/tables.html 364 if ($this->current instanceof \DOMElement && isset(Elements::$optionalEndElementsParentsToClose[$lname])) { 365 foreach (Elements::$optionalEndElementsParentsToClose[$lname] as $parentElName) { 366 if ($this->current instanceof \DOMElement && $this->current->tagName === $parentElName) { 367 $this->autoclose($parentElName); 368 } 369 } 370 } 371 362 372 try { 363 373 $prefix = ($pos = strpos($lname, ':')) ? substr($lname, 0, $pos) : ''; … … 406 416 $aName = Elements::normalizeMathMlAttribute($aName); 407 417 } 418 419 $aVal = (string) $aVal; 408 420 409 421 try { -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Parser/Scanner.php
r2236239 r3070210 105 105 public function peek() 106 106 { 107 if (($this->char + 1) < =$this->EOF) {107 if (($this->char + 1) < $this->EOF) { 108 108 return $this->data[$this->char + 1]; 109 109 } -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php
r2236239 r3070210 184 184 * @return string The current character. 185 185 */ 186 #[\ReturnTypeWillChange] 186 187 public function current() 187 188 { … … 193 194 * This is part of the Iterator interface. 194 195 */ 196 #[\ReturnTypeWillChange] 195 197 public function next() 196 198 { … … 201 203 * Rewind to the start of the string. 202 204 */ 205 #[\ReturnTypeWillChange] 203 206 public function rewind() 204 207 { … … 211 214 * @return bool Whether the current pointer location is valid. 212 215 */ 216 #[\ReturnTypeWillChange] 213 217 public function valid() 214 218 { … … 325 329 } 326 330 331 #[\ReturnTypeWillChange] 327 332 public function key() 328 333 { -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
r2412362 r3070210 132 132 $tok = $this->scanner->next(); 133 133 134 if ('!' === $tok) { 134 if (false === $tok) { 135 // end of string 136 $this->parseError('Illegal tag opening'); 137 } elseif ('!' === $tok) { 135 138 $this->markupDeclaration(); 136 139 } elseif ('/' === $tok) { … … 138 141 } elseif ('?' === $tok) { 139 142 $this->processingInstruction(); 140 } elseif ( ctype_alpha($tok)) {143 } elseif ($this->is_alpha($tok)) { 141 144 $this->tagName(); 142 145 } else { … … 348 351 // EOF -> parse error 349 352 // -> parse error 350 if (! ctype_alpha($tok)) {353 if (!$this->is_alpha($tok)) { 351 354 $this->parseError("Expected tag name, got '%s'", $tok); 352 355 if ("\0" == $tok || false === $tok) { … … 713 716 } 714 717 715 // If it doesn't start with -, not the end.716 if ('-' != $tok ) {718 // If next two tokens are not '--', not the end. 719 if ('-' != $tok || '-' != $this->scanner->peek()) { 717 720 return false; 718 721 } 719 722 720 // Advance one, and test for '->' 721 if ('-' == $this->scanner->next() && '>' == $this->scanner->peek()) { 723 $this->scanner->consume(2); // Consume '-' and one of '!' or '>' 724 725 // Test for '>' 726 if ('>' == $this->scanner->current()) { 727 return true; 728 } 729 // Test for '!>' 730 if ('!' == $this->scanner->current() && '>' == $this->scanner->peek()) { 722 731 $this->scanner->consume(); // Consume the last '>' 723 732 return true; 724 733 } 725 // Unread '-' ;726 $this->scanner->unconsume( 1);734 // Unread '-' and one of '!' or '>'; 735 $this->scanner->unconsume(2); 727 736 728 737 return false; … … 1189 1198 return '&'; 1190 1199 } 1200 1201 /** 1202 * Checks whether a (single-byte) character is an ASCII letter or not. 1203 * 1204 * @param string $input A single-byte string 1205 * 1206 * @return bool True if it is a letter, False otherwise 1207 */ 1208 protected function is_alpha($input) 1209 { 1210 $code = ord($input); 1211 1212 return ($code >= 97 && $code <= 122) || ($code >= 65 && $code <= 90); 1213 } 1191 1214 } -
lazy-loading-responsive-images/trunk/vendor/masterminds/html5/src/HTML5/Parser/UTF8Utils.php
r2236239 r3070210 39 39 /** 40 40 * Count the number of characters in a string. 41 * UTF-8 aware. This will try (in order) iconv, MB, libxml,and finally a custom counter.41 * UTF-8 aware. This will try (in order) iconv, MB, and finally a custom counter. 42 42 * 43 43 * @param string $string … … 54 54 if (function_exists('iconv_strlen')) { 55 55 return iconv_strlen($string, 'utf-8'); 56 }57 58 if (function_exists('utf8_decode')) {59 // MPB: Will this work? Won't certain decodes lead to two chars60 // extrapolated out of 2-byte chars?61 return strlen(utf8_decode($string));62 56 } 63 57
Note: See TracChangeset
for help on using the changeset viewer.