HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/advanced-ads-responsive/includes/class-amp-ad.php
<?php
/**
 * The AMP ad class
 *
 * @package AdvancedAds\AMP
 * @author  Advanced Ads <info@wpadvancedads.com>
 */

namespace AdvancedAds\AMP;

use AdvancedAds\Abstracts\Ad;
use AdvancedAds\Interfaces\Ad_Interface;

defined( 'ABSPATH' ) || exit;

/**
 * AMP ad class
 */
class Amp_Ad extends Ad implements Ad_Interface {
	/**
	 * Prepare output for frontend.
	 *
	 * @return string
	 */
	public function prepare_frontend_output(): string {
		$options    = $this->get_prop( 'amp' ) ?? [];
		$attributes = ( ! empty( $options['attributes'] ) && is_array( $options['attributes'] ) ) ? $options['attributes'] : [];

		if ( ! empty( $this->get_width() ) ) {
			$attributes['width'] = $this->get_width();
		}

		if ( ! empty( $this->get_height() ) ) {
			$attributes['height'] = $this->get_height();
		}

		if ( ! empty( $attributes['type'] ) ) {
			$content     = '';
			$attr_string = [];
			foreach ( $attributes as $attribute => $data ) {
				$attr_string[] = sprintf( "%s='%s'", sanitize_key( $attribute ), esc_attr( $data ) );
			}
			$attr_string = implode( ' ', $attr_string );

			if ( ! empty( $options['fallback'] ) ) {
				$content = sprintf( '<div fallback>%s</div>', esc_html( $options['fallback'] ) );
			}

			return sprintf( '<%1$s %2$s>%3$s</%1$s>', 'amp-ad', $attr_string, $content );
		}

		return '';
	}
}