Skip to content

Instantly share code, notes, and snippets.

View wplit's full-sized avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
wplit / tabs.min.js
Created July 19, 2024 10:57
Tabs with focus removed when use hovers tabs
function xTabsToggleAccordionItem(e,t,a=!0){let r=0,l=a?t.duration:0;!0!==t.closeSibling&&e.closest(".x-tabs_content")&&e.closest(".x-tabs_content").querySelectorAll(".x-tabs_toggle[aria-expanded=true]").forEach((t,a)=>{let r=null!=t.nextElementSibling?t.nextElementSibling:t.closest(".x-tabs_content-item").querySelector(".x-tabs_panel");t!=e&&(t.setAttribute("aria-expanded","false"),r.xslideUp(l))});let s=null!=e.nextElementSibling?e.nextElementSibling:!!e.closest(".x-tabs_content-item")&&!!e.closest(".x-tabs_content-item").querySelector(".x-tabs_panel")&&e.closest(".x-tabs_content-item").querySelector(".x-tabs_panel");e.parentElement&&e.parentElement.parentElement&&(r=[...e.parentElement.parentElement.children].indexOf(e.parentElement)),s&&("true"!==e.getAttribute("aria-expanded")?(e.setAttribute("aria-expanded","true"),s.xslideDown(l),window.dispatchEvent(new Event("resize")),s.querySelector(".x-read-more_content")&&(s.querySelector(".x-read-more_content").style.maxHeight="",setTimeout(()=>{"function"==type
@wplit
wplit / code-snippet.php
Last active July 11, 2024 10:27
allow iframe tags in ACF field
<?php
/* allow iframe tags */
add_filter( 'wp_kses_allowed_html', 'acf_add_allowed_iframe_tag', 10, 2 );
function acf_add_allowed_iframe_tag( $tags, $context ) {
if ( $context === 'post' ) {
$tags['iframe'] = array(
@wplit
wplit / x-lottie.php
Created July 9, 2024 15:35
lottie php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class X_Lottie extends \Bricks\Element {
// Element properties
public $category = 'extras';
public $name = 'xlottie';
public $icon = 'ti-image';
@wplit
wplit / code-block.js
Created July 9, 2024 10:24
manually trigger resize after page load
document.addEventListener("DOMContentLoaded", () => {
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
}, 1000)
});
@wplit
wplit / dynamic-tag
Last active July 6, 2024 08:25
using dynamic tag to output custom field
{echo:get_field('field_name')}
@wplit
wplit / code-snippet.php
Last active July 4, 2024 10:04
check user status matches in specific membership level (RCP)
<?php
/* custom function for checking status of user in membership (add to code snippets or child theme)
* @return bool True if user has the status in that memberhip.
*/
function rcp_member_status( $membership_level, $status ) {
$customer = rcp_get_customer_by_user_id( get_current_user_id() );
if ($customer) {
@wplit
wplit / footer-scripts.html
Created July 2, 2024 10:19
disable gyroscope from tilt
@wplit
wplit / code-block.js
Created June 25, 2024 17:59
remove heading text from beginning of links in table of contents
jQuery(document).ready(($) => {
const headingText = "New York Tipps - ";
tocbot.options.headingLabelCallback = (string) => {
return string.replace(headingText, "");
}
tocbot.refresh()
@wplit
wplit / code.js
Last active June 25, 2024 17:40
prevent tab moved on a + d keys
jQuery(document).ready(($) => {
$('#%%ELEMENT_ID%% .oxy-dynamic-tabs_panel-group').on('keydown', (e) => {
if ( 65 === e.keyCode || 68 === e.keyCode ) {
e.stopPropagation()
}
})
@wplit
wplit / code.js
Last active June 20, 2024 00:55
stop presto player when lightboxes close
jQuery(document).ready(function($) {
$('.oxy-lightbox').on('extras_lightbox:close', () => {
$(this).find('presto-player').stop();
})
})