Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../assets/js
File: front.js
/**
[0] Fix | Delete
* @package EmbedPress
[1] Fix | Delete
* @author EmbedPress <help@embedpress.com>
[2] Fix | Delete
* @copyright Copyright (C) 2023 EmbedPress. All rights reserved.
[3] Fix | Delete
* @license GPLv2 or later
[4] Fix | Delete
* @since 1.7.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
[8] Fix | Delete
[9] Fix | Delete
let epGlobals = {};
[10] Fix | Delete
[11] Fix | Delete
(function ($) {
[12] Fix | Delete
'use strict';
[13] Fix | Delete
// function equivalent to jquery ready()
[14] Fix | Delete
function ready(fn) {
[15] Fix | Delete
if (document.readyState !== 'loading') {
[16] Fix | Delete
fn();
[17] Fix | Delete
} else {
[18] Fix | Delete
document.addEventListener('DOMContentLoaded', fn);
[19] Fix | Delete
}
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
ready(function () {
[23] Fix | Delete
let option = {
[24] Fix | Delete
forceObject: true,
[25] Fix | Delete
};
[26] Fix | Delete
let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
[27] Fix | Delete
if (selector.length) {
[28] Fix | Delete
selector.forEach((function (value, index, thisArg) {
[29] Fix | Delete
let id = value.dataset['emid'];
[30] Fix | Delete
let src = value.dataset['emsrc'];
[31] Fix | Delete
PDFObject?.embed(src, "." + id, option);
[32] Fix | Delete
}));
[33] Fix | Delete
}
[34] Fix | Delete
if (typeof epGlobals.youtubeChannelGallery === 'function') {
[35] Fix | Delete
epGlobals.youtubeChannelGallery();
[36] Fix | Delete
}
[37] Fix | Delete
});
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
*
[41] Fix | Delete
* Make embeds responsive so they don't overflow their container.
[42] Fix | Delete
*/
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Add max-width & max-height to <iframe> elements, depending on their width & height props.
[46] Fix | Delete
*
[47] Fix | Delete
*
[48] Fix | Delete
* @return {void}
[49] Fix | Delete
*/
[50] Fix | Delete
function embedPressResponsiveEmbeds() {
[51] Fix | Delete
var proportion, parentWidth;
[52] Fix | Delete
[53] Fix | Delete
// Loop iframe elements.
[54] Fix | Delete
document.querySelectorAll('iframe').forEach(function (iframe) {
[55] Fix | Delete
// Only continue if the iframe has a width & height defined.
[56] Fix | Delete
if (iframe.width && iframe.height) {
[57] Fix | Delete
// Calculate the proportion/ratio based on the width & height.
[58] Fix | Delete
proportion = parseFloat(iframe.width) / parseFloat(iframe.height);
[59] Fix | Delete
// Get the parent element's width.
[60] Fix | Delete
parentWidth = parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
[61] Fix | Delete
// Set the max-width & height.
[62] Fix | Delete
iframe.style.maxWidth = '100%';
[63] Fix | Delete
iframe.style.maxHeight = Math.round(parentWidth / proportion).toString() + 'px';
[64] Fix | Delete
}
[65] Fix | Delete
});
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
epGlobals.handlePosterImageLoad = function () {
[69] Fix | Delete
var posterImages = document.querySelectorAll(".plyr__poster");
[70] Fix | Delete
posterImages.forEach(function (posterImage) {
[71] Fix | Delete
if (posterImage) {
[72] Fix | Delete
var videoWrappers = document.querySelectorAll("[data-playerid]");
[73] Fix | Delete
videoWrappers.forEach(function (videoWrapper) {
[74] Fix | Delete
var observer = new MutationObserver(function (mutationsList, observer) {
[75] Fix | Delete
var posterImageStyle = window.getComputedStyle(posterImage);
[76] Fix | Delete
if (posterImageStyle.getPropertyValue('background-image') !== 'none') {
[77] Fix | Delete
setTimeout(function () {
[78] Fix | Delete
videoWrapper.style.opacity = "1";
[79] Fix | Delete
}, 200);
[80] Fix | Delete
observer.disconnect();
[81] Fix | Delete
}
[82] Fix | Delete
});
[83] Fix | Delete
[84] Fix | Delete
observer.observe(posterImage, { attributes: true, attributeFilter: ['style'] });
[85] Fix | Delete
});
[86] Fix | Delete
}
[87] Fix | Delete
});
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
[91] Fix | Delete
[92] Fix | Delete
// Run on initial load.
[93] Fix | Delete
embedPressResponsiveEmbeds();
[94] Fix | Delete
[95] Fix | Delete
// Run on resize.
[96] Fix | Delete
window.onresize = embedPressResponsiveEmbeds;
[97] Fix | Delete
[98] Fix | Delete
[99] Fix | Delete
function hasClass(ele, cls) {
[100] Fix | Delete
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
function addClass(ele, cls) {
[104] Fix | Delete
if (!hasClass(ele, cls)) ele.className += " " + cls;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
function removeClass(ele, cls) {
[108] Fix | Delete
if (hasClass(ele, cls)) {
[109] Fix | Delete
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
[110] Fix | Delete
ele.className = ele.className.replace(reg, " ");
[111] Fix | Delete
}
[112] Fix | Delete
}
[113] Fix | Delete
if (!Element.prototype.matches) {
[114] Fix | Delete
Element.prototype.matches =
[115] Fix | Delete
Element.prototype.matchesSelector ||
[116] Fix | Delete
Element.prototype.webkitMatchesSelector ||
[117] Fix | Delete
Element.prototype.mozMatchesSelector ||
[118] Fix | Delete
Element.prototype.msMatchesSelector ||
[119] Fix | Delete
Element.prototype.oMatchesSelector ||
[120] Fix | Delete
function (s) {
[121] Fix | Delete
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
[122] Fix | Delete
i = matches.length;
[123] Fix | Delete
while (--i >= 0 && matches.item(i) !== this) { }
[124] Fix | Delete
return i > -1;
[125] Fix | Delete
};
[126] Fix | Delete
}
[127] Fix | Delete
var delegate = function (el, evt, sel, handler) {
[128] Fix | Delete
el.addEventListener(evt, function (event) {
[129] Fix | Delete
var t = event.target;
[130] Fix | Delete
while (t && t !== this) {
[131] Fix | Delete
if (t.matches(sel)) {
[132] Fix | Delete
handler.call(t, event);
[133] Fix | Delete
}
[134] Fix | Delete
t = t.parentNode;
[135] Fix | Delete
}
[136] Fix | Delete
});
[137] Fix | Delete
};
[138] Fix | Delete
[139] Fix | Delete
function sendRequest(url, postData, callback) {
[140] Fix | Delete
var req = createXMLHTTPObject();
[141] Fix | Delete
if (!req) return;
[142] Fix | Delete
var method = postData ? "POST" : "GET";
[143] Fix | Delete
req.open(method, url, true);
[144] Fix | Delete
if (postData) {
[145] Fix | Delete
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
[146] Fix | Delete
}
[147] Fix | Delete
req.onreadystatechange = function () {
[148] Fix | Delete
if (req.readyState != 4) return;
[149] Fix | Delete
if (req.status != 200 && req.status != 304) {
[150] Fix | Delete
return;
[151] Fix | Delete
}
[152] Fix | Delete
callback(req);
[153] Fix | Delete
};
[154] Fix | Delete
if (req.readyState == 4) return;
[155] Fix | Delete
req.send(postData);
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
var XMLHttpFactories = [
[159] Fix | Delete
function () {
[160] Fix | Delete
return new XMLHttpRequest();
[161] Fix | Delete
},
[162] Fix | Delete
function () {
[163] Fix | Delete
return new ActiveXObject("Msxml3.XMLHTTP");
[164] Fix | Delete
},
[165] Fix | Delete
function () {
[166] Fix | Delete
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
[167] Fix | Delete
},
[168] Fix | Delete
function () {
[169] Fix | Delete
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
[170] Fix | Delete
},
[171] Fix | Delete
function () {
[172] Fix | Delete
return new ActiveXObject("Msxml2.XMLHTTP");
[173] Fix | Delete
},
[174] Fix | Delete
function () {
[175] Fix | Delete
return new ActiveXObject("Microsoft.XMLHTTP");
[176] Fix | Delete
},
[177] Fix | Delete
];
[178] Fix | Delete
[179] Fix | Delete
function createXMLHTTPObject() {
[180] Fix | Delete
var xmlhttp = false;
[181] Fix | Delete
for (var i = 0; i < XMLHttpFactories.length; i++) {
[182] Fix | Delete
try {
[183] Fix | Delete
xmlhttp = XMLHttpFactories[i]();
[184] Fix | Delete
} catch (e) {
[185] Fix | Delete
continue;
[186] Fix | Delete
}
[187] Fix | Delete
break;
[188] Fix | Delete
}
[189] Fix | Delete
return xmlhttp;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
epGlobals.youtubeChannelGallery = function () {
[193] Fix | Delete
var playerWraps = document.getElementsByClassName("ep-player-wrap");
[194] Fix | Delete
if (playerWraps && playerWraps.length) {
[195] Fix | Delete
for (var i = 0, im = playerWraps.length; im > i; i++) {
[196] Fix | Delete
youtubeChannelEvents(playerWraps[i])
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
function youtubeChannelEvents(playerWrap) {
[202] Fix | Delete
[203] Fix | Delete
delegate(playerWrap, "click", ".item", function (event) {
[204] Fix | Delete
var embed = "https://www.youtube.com/embed/";
[205] Fix | Delete
var vid = this.getAttribute("data-vid");
[206] Fix | Delete
var iframe = playerWrap.getElementsByTagName("iframe");
[207] Fix | Delete
if (vid) {
[208] Fix | Delete
if (iframe) {
[209] Fix | Delete
var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
[210] Fix | Delete
if (vidSrc.indexOf('autoplay') > 0) {
[211] Fix | Delete
vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
[212] Fix | Delete
}
[213] Fix | Delete
else {
[214] Fix | Delete
vidSrc += '&autoplay=1';
[215] Fix | Delete
}
[216] Fix | Delete
iframe[0].src = vidSrc;
[217] Fix | Delete
playerWrap.scrollIntoView();
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
});
[221] Fix | Delete
[222] Fix | Delete
var currentPage = 1;
[223] Fix | Delete
[224] Fix | Delete
let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
[225] Fix | Delete
[226] Fix | Delete
delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
[227] Fix | Delete
const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
[228] Fix | Delete
const closestClass = event.target.closest('.ose-youtube').classList;
[229] Fix | Delete
[230] Fix | Delete
const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
[231] Fix | Delete
if (activePage) {
[232] Fix | Delete
document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
[236] Fix | Delete
[237] Fix | Delete
var isNext = this.classList.contains("ep-next");
[238] Fix | Delete
[239] Fix | Delete
if (isNext) {
[240] Fix | Delete
currentPage++;
[241] Fix | Delete
} else {
[242] Fix | Delete
currentPage--;
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
var data = {
[246] Fix | Delete
action: "youtube_rest_api",
[247] Fix | Delete
playlistid: this.getAttribute("data-playlistid"),
[248] Fix | Delete
pagetoken: this.getAttribute("data-pagetoken"),
[249] Fix | Delete
pagesize: this.getAttribute("data-pagesize"),
[250] Fix | Delete
currentpage: currentPage
[251] Fix | Delete
};
[252] Fix | Delete
[253] Fix | Delete
var formBody = [];
[254] Fix | Delete
for (var property in data) {
[255] Fix | Delete
var encodedKey = encodeURIComponent(property);
[256] Fix | Delete
var encodedValue = encodeURIComponent(data[property]);
[257] Fix | Delete
formBody.push(encodedKey + "=" + encodedValue);
[258] Fix | Delete
}
[259] Fix | Delete
formBody = formBody.join("&");
[260] Fix | Delete
[261] Fix | Delete
var galleryWrapper = playerWrap.getElementsByClassName(
[262] Fix | Delete
"ep-youtube__content__block"
[263] Fix | Delete
);
[264] Fix | Delete
[265] Fix | Delete
playerWrap.setAttribute('data-current-page', currentPage);
[266] Fix | Delete
[267] Fix | Delete
[268] Fix | Delete
let x = 1;
[269] Fix | Delete
[270] Fix | Delete
sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
[271] Fix | Delete
if (galleryWrapper && galleryWrapper[0] && request.responseText) {
[272] Fix | Delete
var response = JSON.parse(request.responseText);
[273] Fix | Delete
galleryWrapper[0].outerHTML = response.html;
[274] Fix | Delete
[275] Fix | Delete
var currentPageNode =
[276] Fix | Delete
galleryWrapper[0].getElementsByClassName("current-page");
[277] Fix | Delete
if (currentPageNode && currentPageNode[0]) {
[278] Fix | Delete
currentPageNode[0].textContent = currentPage;
[279] Fix | Delete
[280] Fix | Delete
}
[281] Fix | Delete
}
[282] Fix | Delete
});
[283] Fix | Delete
[284] Fix | Delete
const intervalID = setInterval(() => {
[285] Fix | Delete
x++
[286] Fix | Delete
[287] Fix | Delete
if (playerWrap.querySelector('.ep-youtube__content__block')) {
[288] Fix | Delete
const newNearestEpContentId = playerWrap
[289] Fix | Delete
.querySelector('.ep-youtube__content__block')
[290] Fix | Delete
.getAttribute('data-unique-id');
[291] Fix | Delete
[292] Fix | Delete
if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
[293] Fix | Delete
playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
[294] Fix | Delete
nearestEpContentId = newNearestEpContentId;
[295] Fix | Delete
clearInterval(intervalID);
[296] Fix | Delete
}
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
if (x > 100) {
[300] Fix | Delete
clearInterval(intervalID);
[301] Fix | Delete
}
[302] Fix | Delete
}, 100);
[303] Fix | Delete
[304] Fix | Delete
});
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
//Load more for OpenaSea collection
[308] Fix | Delete
const epLoadMore = () => {
[309] Fix | Delete
[310] Fix | Delete
$('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
[311] Fix | Delete
let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
[312] Fix | Delete
[313] Fix | Delete
let loadmorelabel = $(selctorEl).data('loadmorelabel');
[314] Fix | Delete
let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
[315] Fix | Delete
[316] Fix | Delete
let spinicon = `<svg width="18" height="18" fill="${iconcolor || '#fff'}" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>`;
[317] Fix | Delete
[318] Fix | Delete
$(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
[319] Fix | Delete
$('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
[320] Fix | Delete
[321] Fix | Delete
$(selctorEl + " .nft-loadmore").click(function (e) {
[322] Fix | Delete
//change the text of the button
[323] Fix | Delete
$(this).html(loadmorelabel + spinicon);
[324] Fix | Delete
//disable the button
[325] Fix | Delete
$(this).prop("disabled", true);
[326] Fix | Delete
//wait for 1 seconds
[327] Fix | Delete
setTimeout(function () {
[328] Fix | Delete
//change the text back
[329] Fix | Delete
$(selctorEl + " .nft-loadmore").text(loadmorelabel);
[330] Fix | Delete
//enable the button
[331] Fix | Delete
$(selctorEl + " .nft-loadmore").prop("disabled", false);
[332] Fix | Delete
$(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
[333] Fix | Delete
if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
[334] Fix | Delete
$(selctorEl + " .nft-loadmore").fadeOut("slow");
[335] Fix | Delete
}
[336] Fix | Delete
}, 500);
[337] Fix | Delete
});
[338] Fix | Delete
});
[339] Fix | Delete
};
[340] Fix | Delete
[341] Fix | Delete
if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
[342] Fix | Delete
epLoadMore();
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
// Content protection system function
[346] Fix | Delete
const unlockSubmitHander = (perentSel, that) => {
[347] Fix | Delete
var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
[348] Fix | Delete
var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
[349] Fix | Delete
var post_id = jQuery(`input[name="post_id"]`).val();
[350] Fix | Delete
const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
[351] Fix | Delete
const unlokingText = jQuery(that).data('unlocking-text');
[352] Fix | Delete
[353] Fix | Delete
[354] Fix | Delete
var data = {
[355] Fix | Delete
'action': 'lock_content_form_handler',
[356] Fix | Delete
'client_id': ep_client_id,
[357] Fix | Delete
'password': password,
[358] Fix | Delete
'post_id': post_id,
[359] Fix | Delete
};
[360] Fix | Delete
[361] Fix | Delete
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
[362] Fix | Delete
[363] Fix | Delete
jQuery.post(eplocalize.ajaxurl, data, function (response) {
[364] Fix | Delete
if (response.success) {
[365] Fix | Delete
if (!response.embedHtml) {
[366] Fix | Delete
[367] Fix | Delete
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
[368] Fix | Delete
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
[369] Fix | Delete
jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
[370] Fix | Delete
}
[371] Fix | Delete
else {
[372] Fix | Delete
jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
[373] Fix | Delete
[374] Fix | Delete
if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
[375] Fix | Delete
epGlobals.youtubeChannelGallery();
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
[379] Fix | Delete
epLoadMore();
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
// Custom player initialization when content protection enabled
[383] Fix | Delete
document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').classList.remove('plyr-initialized');
[384] Fix | Delete
[385] Fix | Delete
initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper'));
[386] Fix | Delete
[387] Fix | Delete
if (eplocalize.is_pro_plugin_active) {
[388] Fix | Delete
const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]');
[389] Fix | Delete
adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index'));
[390] Fix | Delete
}
[391] Fix | Delete
[392] Fix | Delete
}
[393] Fix | Delete
} else {
[394] Fix | Delete
jQuery('#password-error_' + ep_client_id).html(response.form);
[395] Fix | Delete
jQuery('#password-error_' + ep_client_id).show();
[396] Fix | Delete
}
[397] Fix | Delete
}, 'json');
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
// unlockSubmitHander called for gutentberg
[401] Fix | Delete
jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
[402] Fix | Delete
e.preventDefault(); // Prevent the default form submission
[403] Fix | Delete
unlockSubmitHander('ep-gutenberg-content', this);
[404] Fix | Delete
});
[405] Fix | Delete
[406] Fix | Delete
window.addEventListener('load', function (e) {
[407] Fix | Delete
const urlParams = new URLSearchParams(window.location.search);
[408] Fix | Delete
const hash = urlParams.get('hash');
[409] Fix | Delete
[410] Fix | Delete
// find the element with the matching id
[411] Fix | Delete
const element = document.getElementById(hash);
[412] Fix | Delete
[413] Fix | Delete
if (element) {
[414] Fix | Delete
element.scrollIntoView({ behavior: 'smooth' });
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
});
[418] Fix | Delete
[419] Fix | Delete
// Get the insta-gallery container element
[420] Fix | Delete
const getPopupTemplate = (instPost, hashtag = '', accountType) => {
[421] Fix | Delete
[422] Fix | Delete
let instaPostData = JSON.parse(instPost);
[423] Fix | Delete
[424] Fix | Delete
[425] Fix | Delete
let likeIcon = '<svg aria-label="Like" class="x1lliihq x1n2onr6" color="#262626" fill="#262626" height="24" viewBox="0 0 24 24" width="24"><path d="M16.792 3.904A4.989 4.989 0 0 1 21.5 9.122c0 3.072-2.652 4.959-5.197 7.222-2.512 2.243-3.865 3.469-4.303 3.752-.477-.309-2.143-1.823-4.303-3.752C5.141 14.072 2.5 12.167 2.5 9.122a4.989 4.989 0 0 1 4.708-5.218 4.21 4.21 0 0 1 3.675 1.941c.84 1.175.98 1.763 1.12 1.763s.278-.588 1.11-1.766a4.17 4.17 0 0 1 3.679-1.938m0-2a6.04 6.04 0 0 0-4.797 2.127 6.052 6.052 0 0 0-4.787-2.127A6.985 6.985 0 0 0 .5 9.122c0 3.61 2.55 5.827 5.015 7.97.283.246.569.494.853.747l1.027.918a44.998 44.998 0 0 0 3.518 3.018 2 2 0 0 0 2.174 0 45.263 45.263 0 0 0 3.626-3.115l.922-.824c.293-.26.59-.519.885-.774 2.334-2.025 4.98-4.32 4.98-7.94a6.985 6.985 0 0 0-6.708-7.218Z"/></svg>';
[426] Fix | Delete
[427] Fix | Delete
if (instaPostData.like_count > 0) {
[428] Fix | Delete
likeIcon = '<svg aria-label="Unlike" class="x1lliihq x1n2onr6" color="#FF3040" fill="#FF3040" height="24" viewBox="0 0 48 48" width="24"><path d="M34.6 3.1c-4.5 0-7.9 1.8-10.6 5.6-2.7-3.7-6.1-5.5-10.6-5.5C6 3.1 0 9.6 0 17.6c0 7.3 5.4 12 10.6 16.5.6.5 1.3 1.1 1.9 1.7l2.3 2c4.4 3.9 6.6 5.9 7.6 6.5.5.3 1.1.5 1.6.5s1.1-.2 1.6-.5c1-.6 2.8-2.2 7.8-6.8l2-1.8c.7-.6 1.3-1.2 2-1.7C42.7 29.6 48 25 48 17.6c0-8-6-14.5-13.4-14.5z"/></svg>';
[429] Fix | Delete
}
[430] Fix | Delete
[431] Fix | Delete
const commentsIcon = '<svg aria-label="Comment" class="x1lliihq x1n2onr6" color="#000" height="24" viewBox="0 0 24 24" width="24"><path d="M20.656 17.008a9.993 9.993 0 1 0-3.59 3.615L22 22Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2"/></svg>';
[432] Fix | Delete
[433] Fix | Delete
const shareIcon = '<svg width="20" height="20" viewBox="0 0 0.6 0.6" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path stroke-width="1" d="m.543.282-.2-.2A.025.025 0 0 0 .3.1v.089a.275.275 0 0 0-.25.274V.5a.025.025 0 0 0 .045.015.3.3 0 0 1 .197-.101L.3.413V.5a.025.025 0 0 0 .043.018l.2-.2a.025.025 0 0 0 0-.035M.35.44V.388A.025.025 0 0 0 .325.363L.286.365a.35.35 0 0 0-.185.074.225.225 0 0 1 .224-.201A.025.025 0 0 0 .35.213V.16L.49.3Z"/></svg>';
[434] Fix | Delete
[435] Fix | Delete
const instaIcon = '<svg width="18" height="18" viewBox="0 0 0.338 0.338" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.248.079H.27M.102.012h.135a.09.09 0 0 1 .09.09v.135a.09.09 0 0 1-.09.09H.102a.09.09 0 0 1-.09-.09V.102a.09.09 0 0 1 .09-.09ZM.17.237a.068.068 0 1 1 0-.135.068.068 0 0 1 0 .135Z" stroke="#000" stroke-width=".032"/></svg>';
[436] Fix | Delete
[437] Fix | Delete
[438] Fix | Delete
[439] Fix | Delete
const instaUserInfo = instPost.user_info;
[440] Fix | Delete
[441] Fix | Delete
let getDate = new Date(instaPostData.timestamp);
[442] Fix | Delete
getDate = getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
[443] Fix | Delete
[444] Fix | Delete
let getTime = new Date(instaPostData.timestamp);
[445] Fix | Delete
getTime = getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
[446] Fix | Delete
[447] Fix | Delete
let captionText = instaPostData.caption ? instaPostData.caption : '';
[448] Fix | Delete
const tagRegex = /(#\w+)/g;
[449] Fix | Delete
[450] Fix | Delete
const wrapTag = (match) => {
[451] Fix | Delete
const tag = match.substring(1); // Remove the '#' character
[452] Fix | Delete
const tagUrl = `https://www.instagram.com/explore/tags/${tag}`;
[453] Fix | Delete
return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`;
[454] Fix | Delete
};
[455] Fix | Delete
[456] Fix | Delete
captionText = captionText.replace(tagRegex, wrapTag);
[457] Fix | Delete
[458] Fix | Delete
let carouselTemplate = '';
[459] Fix | Delete
if (instaPostData.media_type === 'CAROUSEL_ALBUM') {
[460] Fix | Delete
carouselTemplate += `<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`;
[461] Fix | Delete
[462] Fix | Delete
instaPostData.children.data?.map((item) => {
[463] Fix | Delete
if (item.media_type?.toLowerCase() === 'video') {
[464] Fix | Delete
carouselTemplate += `<video width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" controls src="${item.media_url || ''}" alt="${item.caption || ''}" controlsList="nodownload"></video>`;
[465] Fix | Delete
}
[466] Fix | Delete
else {
[467] Fix | Delete
carouselTemplate += `<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url || ''}" alt="${item.caption || ''}" />`;
[468] Fix | Delete
}
[469] Fix | Delete
});
[470] Fix | Delete
[471] Fix | Delete
carouselTemplate += `</div></div>`;
[472] Fix | Delete
[473] Fix | Delete
carouselTemplate += `<div class="cg-carousel__btns">
[474] Fix | Delete
<button class="cg-carousel__btn js-carousel__prev-1"><svg width="20" height="30" viewBox="-5 0 23 23" xmlns="http://www.w3.org/2000/svg"><path d="M11.24.29.361 10.742l-.06.054a.97.97 0 0 0-.301.642v.124a.97.97 0 0 0 .3.642l.054.044L11.239 22.71a1.061 1.061 0 0 0 1.459 0 .964.964 0 0 0 0-1.402l-10.15-9.746 10.15-9.87a.964.964 0 0 0 0-1.402 1.061 1.061 0 0 0-1.459 0Z" fill="#fff"/></svg></button>
[475] Fix | Delete
[476] Fix | Delete
<button class="cg-carousel__btn js-carousel__next-1"><svg width="20" height="30" viewBox="-5 0 23 23" xmlns="http://www.w3.org/2000/svg"><path d="m1.76.29 10.879 10.452.06.054a.97.97 0 0 1 .301.642v.124a.97.97 0 0 1-.3.642l-.054.044L1.761 22.71a1.061 1.061 0 0 1-1.459 0 .964.964 0 0 1 0-1.402l10.15-9.746-10.15-9.87a.964.964 0 0 1 0-1.402 1.061 1.061 0 0 1 1.459 0Z" fill="#fff"/></svg></button>
[477] Fix | Delete
</div>`
[478] Fix | Delete
}
[479] Fix | Delete
else {
[480] Fix | Delete
if (instaPostData.media_type?.toLowerCase() === 'video') {
[481] Fix | Delete
carouselTemplate += `<video width="630" class="popup-media-image" controls src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}"></video>`;
[482] Fix | Delete
}
[483] Fix | Delete
else {
[484] Fix | Delete
carouselTemplate += `<img width="630" class="popup-media-image" src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}" />`;
[485] Fix | Delete
}
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
let srcUrl = `https://www.instagram.com/${instaPostData.username}/`;
[489] Fix | Delete
[490] Fix | Delete
if (hashtag) {
[491] Fix | Delete
instaPostData.username = '#' + hashtag;
[492] Fix | Delete
srcUrl = `https://www.instagram.com/explore/tags/${hashtag}/`;
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
[496] Fix | Delete
let likeComments = '';
[497] Fix | Delete
[498] Fix | Delete
if (eplocalize.is_pro_plugin_active && accountType === 'business') {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function