Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/extendif.../src/Shared
File: shared.js
import domReady from '@wordpress/dom-ready';
[0] Fix | Delete
import '@shared/shared.css';
[1] Fix | Delete
import { EditPageToolTip } from '@shared/components/EditPageToolTip';
[2] Fix | Delete
import '@shared/lib/api-fetch';
[3] Fix | Delete
import { render } from '@shared/lib/dom';
[4] Fix | Delete
import { preFetchImages as preFetchUnsplashImages } from '@shared/lib/unsplash';
[5] Fix | Delete
[6] Fix | Delete
const showAIAgents = window.extSharedData.showAIAgents;
[7] Fix | Delete
[8] Fix | Delete
const isOnLaunch = () => {
[9] Fix | Delete
const query = new URLSearchParams(window.location.search);
[10] Fix | Delete
return query.get('page') === 'extendify-launch';
[11] Fix | Delete
};
[12] Fix | Delete
[13] Fix | Delete
domReady(() => {
[14] Fix | Delete
if (isOnLaunch()) return;
[15] Fix | Delete
[16] Fix | Delete
preFetchUnsplashImages();
[17] Fix | Delete
[18] Fix | Delete
const urlParams = new URLSearchParams(window.location.search);
[19] Fix | Delete
if (!urlParams.has('extendify-launch-success')) return;
[20] Fix | Delete
const currentUrl = new URL(window.location.href);
[21] Fix | Delete
// Remove the query param so it doesn't show again
[22] Fix | Delete
urlParams.delete('extendify-launch-success');
[23] Fix | Delete
const newUrl = `${currentUrl.origin}${currentUrl.pathname}`;
[24] Fix | Delete
window.history.replaceState({}, '', newUrl);
[25] Fix | Delete
// Trigger an event other features can listen to
[26] Fix | Delete
// Give time for others to add listeners
[27] Fix | Delete
requestAnimationFrame(() => {
[28] Fix | Delete
requestAnimationFrame(() => {
[29] Fix | Delete
window.dispatchEvent(new CustomEvent('extendify-launch-success'));
[30] Fix | Delete
// Open the Agent if not open
[31] Fix | Delete
window.dispatchEvent(new CustomEvent('extendify-agent:open'));
[32] Fix | Delete
});
[33] Fix | Delete
});
[34] Fix | Delete
if (showAIAgents) return;
[35] Fix | Delete
// This will show the toolbar for users not using AI Agent
[36] Fix | Delete
// but are redirected to home
[37] Fix | Delete
const homeUrl = new URL(window.extSharedData.homeUrl);
[38] Fix | Delete
const isHomePage =
[39] Fix | Delete
currentUrl.origin === homeUrl.origin &&
[40] Fix | Delete
currentUrl.pathname === homeUrl.pathname;
[41] Fix | Delete
if (!isHomePage) return;
[42] Fix | Delete
const div = Object.assign(document.createElement('div'), {
[43] Fix | Delete
id: 'extendify-edit-page-modal-tooltip',
[44] Fix | Delete
});
[45] Fix | Delete
document.body.appendChild(div);
[46] Fix | Delete
render(<EditPageToolTip />, div);
[47] Fix | Delete
});
[48] Fix | Delete
[49] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function