: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Smush\Core\Parser;
private $iframe_elements;
* @var Composite_Element[]
private $composite_elements;
* @param $page_url string
* @param $page_markup string
* @param $elements Element[]
public function __construct( $page_url, $page_markup, $styles, $composite_elements, $elements, $iframe_elements ) {
$this->page_url = $page_url;
$this->page_markup = $page_markup;
$this->composite_elements = $composite_elements;
$this->elements = $elements;
$this->iframe_elements = $iframe_elements;
$this->parser = new Parser();
public function get_styles() {
* @return Composite_Element[]
public function get_composite_elements() {
return $this->composite_elements;
public function get_elements() {
public function has_updates() {
foreach ( $this->styles as $style ) {
if ( $style->has_updates() ) {
foreach ( $this->composite_elements as $composite_element ) {
if ( $composite_element->has_updates() ) {
foreach ( $this->elements as $element ) {
if ( $element->has_updates() ) {
foreach ( $this->iframe_elements as $iframe_element ) {
if ( $iframe_element->has_updates() ) {
public function get_page_markup() {
return $this->page_markup;
public function get_updated_markup() {
$updated = $this->page_markup;
$placeholders = new Placeholder_Replacement();
$updated = $placeholders->add_placeholders( $updated, $this->parser->get_tags( $updated, array(
foreach ( $this->styles as $style ) {
$updated = str_replace( $style->get_css(), $style->get_updated(), $updated );
foreach ( $this->composite_elements as $composite_element ) {
if ( $composite_element->has_updates() ) {
$composite_element->get_markup(),
$composite_element->get_updated(),
foreach ( $this->elements as $element ) {
if ( $element->has_updates() ) {
$element->get_updated_markup(),
foreach ( $this->iframe_elements as $iframe_element ) {
if ( $iframe_element->has_updates() ) {
$iframe_element->get_markup(),
$iframe_element->get_updated_markup(),
$updated = $placeholders->remove_placeholders( $updated );
public function get_iframe_elements() {
return $this->iframe_elements;