PluginProbe
Extendify / 3.2.3
Extendify v3.2.3
3.2.3 3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 All 129 releases
extendify / src / Notifications / notification-link.js

notification-link.js in Extendify 3.2.3, at src/Notifications/notification-link.js

18 lines 649 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // A partner-authored link can't know the customer's host at authoring time.
2 const withSiteHost = (link, host) => link?.replaceAll('{SITEURL}', host);
3
4 export const resolveNotificationLink = (notification, host = '') => {
5 const href = withSiteHost(notification?.link, host);
6 if (!href) return {};
7 try {
8 return { href, external: new URL(href).host !== host };
9 } catch {
10 // URL() throws on relative paths, which are never external.
11 return { href };
12 }
13 };
14
15 // `rel` travels with `target`, or the new tab keeps a handle back to wp-admin.
16 export const externalLinkProps = (external) =>
17 external ? { target: '_blank', rel: 'noreferrer' } : {};
18