This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
.sr-only { | |
position: absolute; | |
width: 1px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filters the query arguments for the 'featured_posts' ACF Post Object field. | |
* The filter limits the displayed posts to those associated with the currently edited/viewed term | |
* for the taxonomies: 'category', and 'post_tag'. | |
* | |
* @param array $args The WP_Query arguments. | |
* @param array $field The field settings. | |
* @param int $post_id The post ID (or term ID, depending on context). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Validates the 'sjd_unit_phone' field for the 'sjd_orders' custom post type. | |
* | |
* If the phone number format is incorrect, it prevents the post from being saved, | |
* sets the post status to 'draft', and redirects the user back to the post editor | |
* with a custom query parameter to indicate validation failure. | |
* | |
* @param int $post_id The ID of the post being saved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if the user is logged in to the main site. | |
* | |
* @return bool True if the user is logged in to the main site, false otherwise. | |
*/ | |
function sjd_is_user_logged_in_main_site() { | |
switch_to_blog( 1 ); // 1 usually represents the main site in a multisite setup. | |
$logged_in = is_user_logged_in(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function restrict_search_to_specific_post_type($query) { | |
// Check if query is a search, is on the frontend, and is on the 'product' post type archive | |
if ($query->is_search && !is_admin() && is_post_type_archive('product')) { | |
$query->set('post_type', 'product'); | |
} | |
return $query; | |
} | |
add_action('pre_get_posts', 'restrict_search_to_specific_post_type'); |
NewerOlder