Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
wplit / js.js
Created Apr 16, 2021
click to go to specific cell (add to button/link directly, advanced > javascript)
View js.js
jQuery(document).ready(function($) {
let carouselSelector = '.my-carousel'; /* Change to your carousel class */
let index = 3; /* Change to needed cell index */
$('#%%ELEMENT_ID%%').on('click', function(e) {
e.preventDefault()
$(carouselSelector).find($(carouselSelector).children().data('carousel')).flickity( 'select', index, false, true );
});
@wplit
wplit / code-snippet.php
Created Apr 7, 2021
apply shortcode from fluent forms as function
View code-snippet.php
/* Return the shortcode */
function fluent_form_submission_count($id) {
return do_shortcode('[fluentform_info id="'. $id .'" info="submission_count"]');
}
@wplit
wplit / code-block.js
Last active Mar 26, 2021
slide menu & icon opening on hover, closing on click
View code-block.js
/* Opens slidemenu if hovering the icon or inside the slide menu */
jQuery('#-slide-menu-20-28,#fancy_icon-18-28').hover(function () {
jQuery('#-slide-menu-20-28').stop().slideDown();
}, function(){
/* If you wanted to close when user moves cursor outside of the menu or icon */
//jQuery('#-slide-menu-20-28').stop().slideUp();
});
/* Close slidemenu when clicking on the page somewhere that isn't the menu or icon */
jQuery(document).on("click", function(e){
@wplit
wplit / slide-menu.js
Last active Mar 22, 2021
Make top-level menu items from slide menu be included in the offcanvas stagger effect ( add to slide menu > advanced > javascript)
View slide-menu.js
jQuery('#%%ELEMENT_ID%%').find('.oxy-slide-menu_list > .menu-item').attr( {
"data-aos":"fade-left" /* Change to the effect you want */
} );
@wplit
wplit / fluent-form.js
Last active Mar 22, 2021
Do something when OxyExtras Fluent Form is submitted (add to fluent form component > advanced > javascript)
View fluent-form.js
(function($){
$('#%%ELEMENT_ID%% form').on('fluentform_submission_success', function() {
/* Do something here like triggering a click on the trigger for the lightbox */
$( ".click-trigger" ).click();
});
}(jQuery));
@wplit
wplit / snippet.php
Created Mar 15, 2021
limit search results to only show products
View snippet.php
/* Filter search query to only display products */
add_filter('pre_get_posts','lit_search_products_only');
function lit_search_products_only($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('product'));
}
return $query;
@wplit
wplit / code-block.js
Last active Mar 11, 2021
Ensure readmore & lightbox functionality is added to new content when WPGridBuilder facets append new content.
View code-block.js
window.WP_Grid_Builder && WP_Grid_Builder.on( 'init', onInit );
function onInit( wpgb ) {
wpgb.facets.on( 'appended', onAppended );
}
function onAppended( content ) {
/* Do Lightbox */
if (typeof doExtrasLightbox == 'function') {
@wplit
wplit / code-block.php
Created Mar 10, 2021
output woocommerce gallery images. (inside product builder inside a code block)
View code-block.php
<?php
global $product;
$image_size = 'medium'; /* Image size */
$attachment_ids = $product->get_gallery_image_ids();
foreach( $attachment_ids as $attachment_id ) {
@wplit
wplit / code-block.js
Last active Mar 17, 2021
add status to carousel builder (add to code block)
View code-block.js
jQuery(document).ready(function($) {
let carouselSelector = '.my-carousel'; /* Change to your carousel class */
let statusSelector = '.oxy-carousel-builder_status'; /* Change to your text component class */
let $carousel = $(carouselSelector).find($(carouselSelector).children().data('carousel'));
var flkty = $carousel.data('flickity');
if (flkty) {
function updateStatus() {
@wplit
wplit / code-block.js
Last active Mar 8, 2021
Allow lightbox components to work with ajax loaded content if lightbox not inside the content
View code-block.js
jQuery('.oxy-dynamic-list').on( 'append.infiniteScroll', function( event, body, path, items, response ) {
doExtrasLightbox(jQuery('body'));
});