HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/web/wordpress/wp-content/brizy/compatibilities/wp-ultimo.php
<?php

class Brizy_Compatibilities_WpUltimo {

	public function __construct() {
		add_action( 'init', [ $this, 'init' ] );
	}

	public function init() {
		if ( isset( $_GET[ Brizy_Editor::prefix( '-edit' ) ] ) || isset( $_GET[ Brizy_Editor::prefix( '-edit-iframe' ) ] ) ) {
			add_filter( 'brizy_editor_config', [ $this, 'remappingAssetsUrl' ] );
		}
	}

	public function remappingAssetsUrl( $config ) {

		if ( ! class_exists( 'Mercator\Mapping' ) ) {
			return $config;
		}

		$mapping = Mercator\Mapping::get_by_domain( $_SERVER['HTTP_HOST'] );

		if ( empty( $mapping ) || ! $mapping->is_active() ) {
			return $config;
		}

		$url_mapped = $mapping->get_domain();

		$original_url = get_blog_option( $mapping->get_site_id(), 'siteurl' );
		$original_url = trim( preg_replace( '#^https?://#', '', $original_url ), '/' );

		$config['urls']['assets'] = str_replace( $original_url, $url_mapped, $config['urls']['assets'] );

		return $config;
	}
}