: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace EmbedPress\AMP\Adapter;
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
* Entity that represents the embed provider for AMP.
* @author EmbedPress <help@embedpress.com>
* @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
* @license GPLv3 or later
private $ampEmbedHandler;
public function __construct($parsedContent, $urlData, $attributes)
add_action('amp_post_template_head', [$this, 'addScripts']);
$this->parsedContent = $parsedContent;
$this->urlData = $urlData;
$this->attributes = $attributes;
* Convert the HTML for AMP compatible tag.
public function process()
// Check we have the required class
if ( ! class_exists('AMP_HTML_Utils')) {
return $this->parsedContent;
$attributes = wp_parse_args($this->attributes, $defaults);
$parsedContent = \AMP_HTML_Utils::build_tag(
'data-src' => $this->urlData->originalContent,
'layout' => 'responsive',
'data-embedtype' => "post",
'width' => $attributes['data-width'],
'height' => $attributes['data-height'],
* Add scripts to the output.
public function addScripts()
if ( ! defined('PPEMB_REDDIT_AMP_SCRIPT_LOADED')) {
echo '<script async custom-element="amp-reddit" src="https://cdn.ampproject.org/v0/amp-reddit-0.1.js"></script>';
define('PPEMB_REDDIT_AMP_SCRIPT_LOADED', 1);