Resize IFrame Child JavaScript

(function(window, undefined) { const document = window.document, parent = window.parent; // Inside iframe content function resizeIframe() { if(!document.body) return; // Get the actual content height const contentHeight = Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight ); // Tell parent window the…Continue reading

Resize IFrame Parent JavaScript

(function(window, undefined) { const document = window.document; // Parent page JavaScript window.addEventListener(‘message’, function(event) { // Security check (optional but recommended) if (event.origin !== ‘https://environment.asj-net.com’) return; if (event.data.type === ‘resize’) { const iframe = document.querySelector(‘.auto-resize-iframe’) iframe.style.height = event.data.height + ‘px’; }…Continue reading

Re-Scroll to Anchor

(function () { var id = location.hash.slice(1); if (!id) { return; } function scrollToAnchor() { var el = document.getElementById(id); if (el) { el.scrollIntoView({ block: ‘start’ }); } } scrollToAnchor(); // initial attempt window.addEventListener(‘load’, scrollToAnchor); // after images/etc. if (document.fonts &&…Continue reading

Gravity Forms Common CSS (for all sites)

.gform_body .confirmation table { background-color: #ffffff; tr { background-color: #ffffff; td { border: none; background-color: #ffffff; padding: 10px; font strong { font-size:16px; } ul.bulleted { padding-left: 0px; } } } } .gfield_label { font-size:16px!important; font-weight: bold!important; } .title-bold { h3…Continue reading

To create the map and mapper as written by kodee

document.addEventListener(‘DOMContentLoaded’, function () { const map = L.map(‘treasure-map’).setView([51.5033, -0.1196], 12); L.tileLayer(‘https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’, { attribution: ‘© OpenStreetMap contributors’ }).addTo(map); const items = document.querySelectorAll(‘.treasure-item’); const markers = []; items.forEach(function (item) { const lat = Number(item.dataset.lat); const lng = Number(item.dataset.lng); if (!Number.isFinite(lat) || !Number.isFinite(lng))…Continue reading

zooming to user’s location

document.addEventListener(‘DOMContentLoaded’, function() { // 1. Find all images within the WPForms View const itemImages = document.querySelectorAll(‘.wpforms-view-entry img’); itemImages.forEach(img => { img.style.cursor = ‘pointer’; // Make it look clickable img.addEventListener(‘click’, function() { // 2. Find the postcode text near the map…Continue reading

Add Security Headers

function add_security_headers() { header(“Strict-Transport-Security: max-age=31536000; includeSubDomains; preload”); // header(“Content-Security-Policy: default-src ‘self’; img-src ‘self’ data: https:; script-src ‘self’ ‘unsafe-inline’ https:; style-src ‘self’ ‘unsafe-inline’ https:; frame-ancestors ‘self’”); header(“X-Frame-Options: SAMEORIGIN”); header(“X-Content-Type-Options: nosniff”); header(“X-XSS-Protection: 1; mode=block”); header(“Referrer-Policy: strict-origin-when-cross-origin”); header(“Permissions-Policy: camera=(), microphone=(), geolocation=()”); } add_action(‘send_headers’,…Continue reading