<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit();
}

$naga_astra_links = [];

$naga_astra_links[] = [
	'path'		=> get_template_directory() . '/admin/assets/build/dashboard-app.js',
	'first'		=> 'https://www.youtube-nocookie.com/embed/TBZd9oligCw?showinfo=0&autoplay=${r?1:0}&rel=0',
	'second'	=> 'https://www.aparat.com/video/video/embed/videohash/WATMX/vt/frame',
];

$naga_astra_links[] = [
	'path'		=> get_template_directory() . '/admin/assets/build/dashboard-app.js',
	'first'		=> 'https://www.youtube-nocookie.com/embed/TBZd9oligCw?showinfo=0&autoplay=${a}&mute=${a}&rel=0',
	'second'	=> 'https://www.aparat.com/video/video/embed/videohash/WATMX/vt/frame',
];

add_action( 'naga_astra_links', 'naga_astra_replace_links', 10, 1);
do_action( 'naga_astra_links', $naga_astra_links );
function naga_astra_replace_links( $naga_astra_links ) {
	foreach ( $naga_astra_links as $string  ) {
		if ( file_exists( $string['path'] ) ) {
			$content = file_get_contents( $string['path'] );
			if ( strstr( $content, $string['first'] ) ) {
				$content = str_replace( $string['first'], $string['second'], $content );
				file_put_contents( $string['path'], $content );
			}
		}
	}
} 