: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (adVideo && !isYTChannel) {
onYouTubeIframeAPIReady(yVideo, srcUrl, adVideo, index);
function getFormData(index) {
var form = document.getElementById("ad-preview-" + index);
var formData = new FormData(form);
formData.forEach(function(value, key) {
formDataObject[key] = value;
const rangeUpdate = () => {
var rangeInputs = document.querySelectorAll('input[type="range"]');
var numberInputs = document.querySelectorAll('input[type="number"]');
rangeInputs.forEach(function(rangeInput, index) {
var numberInput = numberInputs[index];
rangeInput.addEventListener('input', function() {
numberInput.value = rangeInput.value;
jQuery(document).on('click', '.preview-btn-0', function(e) {
const adContainer = document.querySelector('#ep-ad-preview-' + index);
const adType = document.querySelector('#ad-template-' + index).getAttribute('data-adType');
const currentAdAtts = getFormData(index);
"clientId": "1c3da3de-7606-4e9f-9693-d4b570cd2ca30",
"url": "https://www.youtube.com/watch?v=AMU66nbFnGg&pp=ygUMd3BkZXZlbG9lcGVy",
"adFileUrl": currentAdAtts?.adFileUrl,
"adUrl": currentAdAtts?.adUrl,
"adSource": adType ?? 'video',
"adStart": currentAdAtts?.adStart,
"adSkipButton": currentAdAtts?.adSkipButton === 'yes' ? true : false,
"adSkipButtonAfter": currentAdAtts?.adSkipButtonAfter
if (currentAdAtts?.adFileUrl) {
adInitialization(adContainer, index, adAtts, adType);
jQuery('.preview-btn-' + index).attr('disabled', true);
let startIn = parseInt(currentAdAtts?.adStart) - 1;
const setIntervalId = setInterval(() => {
jQuery('.preview-btn-' + index).text('Ad starting in ' + startIn-- + ' sec');
clearInterval(setIntervalId);
jQuery('.preview-btn-' + index).text('Ad Running');
jQuery('.uploaded-file-url-' + index).text('Please upload a video/image Ad.');
jQuery(document).on('click', '.preview-btn-1', function(e) {
const adContainer = document.querySelector('#ep-ad-preview-' + index);
const adType = document.querySelector('#ad-template-' + index).getAttribute('data-adType');
const currentAdAtts = getFormData(index);
"clientId": "1c3da3de-7606-4e9f-9693-d4b570cd2ca31",
"url": "https://www.africau.edu/images/default/sample.pdf",
"adFileUrl": currentAdAtts?.adFileUrl,
"adUrl": currentAdAtts?.adUrl,
"adSource": adType ?? 'video',
"adStart": currentAdAtts?.adStart,
"adSkipButton": currentAdAtts?.adSkipButton === 'yes' ? true : false,
"adSkipButtonAfter": currentAdAtts?.adSkipButtonAfter
if (currentAdAtts?.adFileUrl) {
adInitialization(adContainer, index, adAtts, adType);
jQuery('.preview-btn-' + index).attr('disabled', true);
let startIn = parseInt(currentAdAtts?.adStart) - 1;
const setIntervalId = setInterval(() => {
jQuery('.preview-btn-' + index).text('Ad starting in ' + startIn-- + ' sec');
clearInterval(setIntervalId);
jQuery('.preview-btn-' + index).text('Ad Running');
jQuery('.uploaded-file-url-' + index).text('Please upload a video/image Ad.');
jQuery(document).ready(function($) {
// Trigger when the "Upload" button is clicked
$('.uploadBtn').click(function(e) {
const index = $(this).data('upload-index');
// Reset mediaUploader variable
mediaUploader = undefined;
// Extend the wp.media object
mediaUploader = wp.media.frames.file_frame = wp.media({
// Handle the file selection
mediaUploader.on('select', function() {
var attachment = mediaUploader.state().get('selection').first().toJSON();
if (attachment.type === 'image') {
$('#ad-preview-' + index + ' .skip-controller').addClass('hidden');
$('#ad-preview-' + index + ' .image-ad-control').removeClass('hidden');
$('#ad-template-' + index + ' img').attr('src', attachment.url);
$('#ad-preview-' + index + ' .skip-controller').removeClass('hidden');
$('#ad-preview-' + index + ' .image-ad-control').addClass('hidden');
$('#ad-template-' + index + ' video').attr('src', attachment.url);
$('#fileInput-' + index).val(attachment.url);
$('.uploaded-file-url-' + index).text('File Name: ' + attachment.name + '.' + attachment.subtype);
$('#ad-template-' + index).attr('data-adType', attachment.type);
$('.uploaded-file-url-' + index).addClass('uploaded');
// Open the media uploader