Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar

Chris Castillo chris-castillo-dev

View GitHub Profile
View fluent-forms-tag-conversion-with-ms-clarity.js
$form.on('fluentform_submission_success', function() {
// You can run your own JS and will be run on successful form submission
var s = document.createElement('script');
var code = 'clarity("set", "conversionAction", "New Lead")';
try{
s.appendChild(document.createTextNode(code));
document.body.appendChild(s);
} catch(e){
s.text = code;
document.body.appendChild(s);
View load-bricks-splide-js-manually.php
if( !wp_script_is( 'bricks-splide' ) ){
wp_enqueue_script( 'bricks-splide', '/wp-content/themes/bricks/assets/js/libs/splide.min.js', null, '4.0.6', true );
}
View generate-gutenberg-color-palette.php
/**
* Populate Gutenberg Color Palette Colors
*/
function pro_populate_gutenberg_color_palette() {
// Disable Custom Colors
add_theme_support( 'disable-custom-colors' );
// Editor Color Palette
add_theme_support( 'editor-color-palette', array(
array(
View bricks-native-form-webhook-custom-action.php
/**
* Function to Send Bricks Form Data to Webhook
*/
function pro_bricks_form_to_webhook( $form ){
$data = $form->get_fields();
// The Bricks Form ID is the last part of the CSS ID
// So if a form has a CSS ID of bricks-element-fszxsr, then the form ID is fszxsr
$formId = $data['formId'];
View link-products-without-sku-to-orders.md
View hide-call-elements-outside-of-business-hours.js
<script>
var time = new Date();
var dayOfWeek = time.getDay();
// Set office opening time to 8:15am
var startTime = new Date().setHours(8,15);
// Set office closing time to 4:15pm
var endTime = new Date().setHours(16,15);
View propel_add_cwv_code.php
function propel_add_cwv_code(){
?>
<script>
window.addEventListener('load', function(){
document.getElementsByTagName( 'html' )[0].classList.add('loaded');
});
</script>
<style id="cwv-css">
html body{
View user-interaction-load.min.js
function detectUserInteraction(){document.getElementsByTagName("html")[0].classList.add("js-user-action"),"keydown mouseover touchmove touchstart wheel".split(" ").forEach(function(e){window.removeEventListener(e,detectUserInteraction,!1)})}window.mobileCheck=function(){let e=!1;var o;return o=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(o)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|
View user-interaction-load.js
window.mobileCheck = function() {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v
View lazy-load-bg.js
document.addEventListener("DOMContentLoaded", function() {
var lazyBackgrounds = [].slice.call(document.querySelectorAll(".lazy-bg"));
if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
let lazyBackgroundObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add("bg-visible");
lazyBackgroundObserver.unobserve(entry.target);
}