Skip to content

Instantly share code, notes, and snippets.

@SteveJonesDev
SteveJonesDev / oxygen-video-move.-title-attribute-to-iframe.js
Last active May 29, 2026 15:55
WordPress Oxygen page builder: Move title attribute to iframe
(function () {
function fixOxygenVideoTitles() {
document.querySelectorAll( '.ct-video[title]' ).forEach( function ( wrapper ) {
const iframe = wrapper.querySelector( 'iframe' );
const title = wrapper.getAttribute( 'title' );
if ( iframe && title && ! iframe.getAttribute( 'title' ) ) {
iframe.setAttribute( 'title', title );
wrapper.removeAttribute( 'title' );
}
@SteveJonesDev
SteveJonesDev / oxygen-unslider-pagination-accessibility.js
Created May 22, 2026 00:25
Accessibility: Make Unslider pagination and arrows keyboard accessible
(function () {
function activateWithKeyboard(element, event) {
var key = event.key;
if (key === 'Enter' || key === ' ') {
event.preventDefault();
element.click();
}
}
@SteveJonesDev
SteveJonesDev / oxygen-breadcrumb-current.js
Created May 22, 2026 00:24
Accessibility: Add aria-current=“page” to Final Breadcrumb Item in Oxygen
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.oxel-breadcrumb').forEach(function(nav) {
nav.style.display = 'block';
const items = nav.querySelectorAll('ol li');
if (!items.length) return;
items[items.length - 1].setAttribute('aria-current', 'page');
});
});
@SteveJonesDev
SteveJonesDev / oxygen-flickity-slider-remove-tabindex.js
Created May 22, 2026 00:23
Accessibility: Remove tabindex 0 on Flickity sliders
document.addEventListener('DOMContentLoaded', function () {
function removeFlickityTabindex() {
document.querySelectorAll('.flickity-enabled[tabindex="0"]').forEach(function (slider) {
slider.removeAttribute('tabindex');
});
}
removeFlickityTabindex();
const observer = new MutationObserver(removeFlickityTabindex);
@SteveJonesDev
SteveJonesDev / oxygen-flickity-pause.js
Last active May 22, 2026 00:19
WordPress Oxygen page builder slider pause buttons
window.addEventListener('load', function () {
setTimeout(function () {
if (typeof Flickity === 'undefined') return;
function updateButton(button, isPaused) {
button.setAttribute('aria-pressed', isPaused ? 'true' : 'false');
button.setAttribute(
'aria-label',
isPaused ? 'Play carousel autoplay' : 'Pause carousel autoplay'
);
@SteveJonesDev
SteveJonesDev / accessible-popup-modal.php
Last active August 25, 2025 14:54
Accessible Popup Modal for WordPress
/**
* Adds an accessible popup to the footer.
*
* This function outputs the HTML, CSS, and JavaScript needed for an accessible popup.
* The popup can be opened with a button click, and it traps focus within itself when open.
* The popup can be closed with a button click or by pressing the Escape key.
*/
function add_accessible_popup_to_footer() {
?>
<!-- Accessible Popup HTML -->
@SteveJonesDev
SteveJonesDev / script.js
Created April 30, 2024 18:25
Elementor Slides Widget - Hide duplicate slides available to keyboard users in the Dom for better accessibility
document.addEventListener('DOMContentLoaded', function() {
const swiperWrapper = document.querySelector('.swiper-wrapper');
if (!swiperWrapper) {
console.error('Swiper wrapper not found!');
return;
}
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
@SteveJonesDev
SteveJonesDev / script.js
Last active June 26, 2024 15:05
Elementor Slides Widget - Accessible Pause Button
// Wait for the DOM content to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
// Create a MutationObserver to watch for changes in the DOM
const observer = new MutationObserver(function(mutations, obs) {
// Look for the swiper wrapper element
const swiperWrapper = document.querySelector('.elementor-main-swiper .swiper-wrapper');
// If the swiper wrapper is found, set up slider controls and stop observing
if (swiperWrapper) {
@SteveJonesDev
SteveJonesDev / script.js
Created April 25, 2024 20:18
Elementor Mini Cart Accessibility Enhancement
document.addEventListener('DOMContentLoaded', function() {
const toggleButtons = document.querySelectorAll('.elementor-menu-cart__toggle_button');
const closeButtons = document.querySelectorAll('.elementor-menu-cart__close-button');
const modalContainers = document.querySelectorAll('.elementor-menu-cart__container');
function setAccessibility(container, isOpen) {
const focusableElements = container.querySelectorAll('a, button, input, select, textarea, [tabindex]');
focusableElements.forEach(element => {
element.setAttribute('tabindex', isOpen ? '0' : '-1');
});
@SteveJonesDev
SteveJonesDev / scripts.js
Created April 25, 2024 20:00
Elementor Search Widget Accessibility Enhancements
document.addEventListener("DOMContentLoaded", function() {
// Get all search widgets
const widgets = document.querySelectorAll('.elementor-search-form');
widgets.forEach(function(widget) {
const searchToggle = widget.querySelector('.elementor-search-form__toggle');
const searchInput = widget.querySelector('.elementor-search-form__input');
const searchContainer = widget.querySelector('.elementor-search-form__container');
const closeButton = widget.querySelector('.dialog-lightbox-close-button');