PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / blocks / inc / block-share / frontend.js

frontend.js in WP Directory Kit 1.5.9, at blocks/inc/block-share/frontend.js

31 lines 847 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 document.addEventListener('DOMContentLoaded', function() {
2 // Add click event to each share link
3 document.querySelectorAll('.wdk-block-share').forEach(link => {
4 link.addEventListener('click', function(event) {
5 event.preventDefault();
6 wdkBlockShareUrl(link.getAttribute('href'));
7 });
8 });
9 });
10
11
12 // Share URL function
13 var wdkBlockShareUrl = (url = window.location.href) => {
14 // Check if the browser supports the Web Share API
15 if (!navigator.share) {
16 console.log("Web Share API not supported.");
17 return;
18 }
19
20 navigator.share({
21 url: url, // Share the current page URL
22 })
23 .then(() => {
24 console.log("Shared successfully!");
25 })
26 .catch((error) => {
27 console.error("Sharing failed:", error);
28 });
29 };
30
31