HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: //opt/sg-cachepress/core/Lazy_Load/Lazy_Load_Iframes.php
<?php
namespace SiteGround_Optimizer\Lazy_Load;

use SiteGround_Optimizer\Options\Options;
/**
 * SG Lazy_Load_Images main plugin class
 */
class Lazy_Load_Iframes extends Abstract_Lazy_Load {

	/**
	 * Regex parts for checking content
	 *
	 * @var string
	 */
	public $regexp = '/(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/i';

	/**
	 * Regex for already replaced items
	 *
	 * @var string
	 */
	public $regex_replaced = "/class=['\"][\w\s]*(lazyload)+[\w\s]*['\"]/is";

	/**
	 * Search patterns.
	 *
	 * @var array
	 */
	public $patterns = array(
		'/(<iframe.*?)(src)=["|\']((?!data).*?)["|\']/i',
	);

	/**
	 * Replace patterns.
	 *
	 * @var array
	 */
	public $replacements = array(
		'$1data-$2="$3"',
	);

	/**
	 * Add classname to the html element.
	 *
	 * @since  5.6.0
	 *
	 * @param  string $element HTML element.
	 *
	 * @return string          HTML element with lazyload class.
	 */
	public function add_lazyload_class( $element ) {
		return str_replace( '<iframe', '<iframe class="lazyload"', $element );
	}
}