Skip to content

Instantly share code, notes, and snippets.

View zackeryfretty's full-sized avatar

Zackery Fretty zackeryfretty

View GitHub Profile
@zackeryfretty
zackeryfretty / Rename Passed Values in Zapier.js
Created February 15, 2024 04:06
For use with "Code" step, using JavaScript, useful for renaming values that come across from triggers.
/*
For use with "Code" step, using JavaScript,
useful for renaming values that come across from triggers.
inputData is the Object Zapier creates for the passed values.
*/
// Translation Table for Looking up
const translationTable = {
// "Source" : "Translation"
"fog-score{1}" : "Rarely",
@zackeryfretty
zackeryfretty / PowerPack: Custom Carousel Arrows
Created December 8, 2023 23:23
Allows you to customize the Left/Right arrows on the carousel in the 'Content Grid' module using Beaver Builder PowerPack.
<?php
// Enable Theme/Plugin Updates on FlyWheel (FIX)
add_action(
'wp_update_plugins',
function() {
if ( wp_doing_cron() && ! doing_action( 'wp_maybe_auto_update' ) ) {
do_action( 'wp_maybe_auto_update' );
}
},
20
@zackeryfretty
zackeryfretty / Add Post URL Field Connector for Beaver Themer
Created August 9, 2023 17:20
Adds a 'Post URL' Field Connector in Beaver Themer that pulls the full permalink of the current post.
if(defined('FL_THEME_BUILDER_VERSION')):
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'zf_get_post_url', array(
'label' => 'Post URL',
'group' => 'posts',
'type' => 'url',
'getter' => 'get_permalink',
) );
} );
endif;
<?php
add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
function is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
// Remove Filter
remove_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'is_product_eligible', 10, 4 );
// Get Cart
$cart = WC()->cart;
// Clickable Columns in Elementor via CSS class '.clickable-col'
const clickableCols = document.querySelectorAll('.clickable-col');
if(clickableCols.length > 0){
clickableCols.forEach(col => {
const link = col.querySelector('a');
col.addEventListener('click', () => {
window.location.href = link;
});
col.style.cursor = 'pointer';
});
@zackeryfretty
zackeryfretty / WC: Add Confirmation Tracking Scripts (Run Once).php
Last active June 25, 2023 20:46
Quick way to add a custom tracking script to the WooCommerce thank you / order confirmation page and prevent it from running multiple times in the event of a user page refresh.
<?php // Don't Include
// Run Scripts on Order Confirmation Endpoint in WooCommerce Once.
function zf_woocommerce_thankyou_scripts($order_id) {
// Check for meta key on order, only run if not found.
if( ! get_post_meta( $order_id , '_tracking_scripts_ran', true ) ) {
// Add meta key to order so scripts don't run a second time.
add_post_meta( $order_id, '_tracking_scripts_ran', 'yes', true ); ?>
<script type="text/javascript">
@zackeryfretty
zackeryfretty / BB: Replace Beaver Builder Menu Module Mobile Icon
Created June 17, 2023 19:00
Useful for replacing the default SVG with anything from Font Awesome or etc.
// Replace Beaver Builder Menu Module Mobile Menu Icon
function zf_replace_menu_icon($menu_icon) {
// Use anything from FontAwesome (or anything, really). Go nuts!
$menu_icon = '<i class="fas fa-bars fa-lg"></i>';
return $menu_icon;
}
add_filter( 'fl_builder_mobile_menu_icon', 'zf_replace_menu_icon', 10);
@zackeryfretty
zackeryfretty / WP: Change Individual Menu Item Markup
Created June 17, 2023 18:56
Useful for completely replacing the markup in the <li></li> on an individual element, useful for doing things like adding a logo in the middle of a menu.
// Replace Menu Item HTML Based on Attribute Title
function zf_replace_menu_item_html($item_output, $args) {
// Change 'main-logo' to match menu items Attribute Title
if($args->attr_title === 'main-logo') {
$item_output = '<div><!-- Your HTML Here --></div>';
}
return $item_output;
}
function zf_set_custom_width_on_posts_bb( $defaults, $form_type ) {
if ( get_post_type( get_the_ID() ) == 'post' ) {
if( $form_type == 'row' ) {
$defaults->max_content_width = '800';
}
}
return $defaults;
}