Skip to content

Instantly share code, notes, and snippets.

View saltnpixels's full-sized avatar

Eric saltnpixels

View GitHub Profile
@saltnpixels
saltnpixels / membership_meta.php
Last active November 3, 2022 19:55
adding membership meta to rcp from ACF
<?php
/*--------------------------------------------------------------
# Saving Features to Membership Levels from an acf repeater field for RCP Pro
--------------------------------------------------------------*/
function some_feature_list( $level ) {
/**
* @var RCP_Levels $rcp_levels_db
*/
global $rcp_levels_db;
@saltnpixels
saltnpixels / save_upload_field_to_custom_field.php
Last active January 18, 2024 20:32
gravity form upload file to media library and use attachment ID in custom field
add_action( 'gform_after_create_post', 'gf_add_to_media_library', 10, 3 );
/**
* Save file upload fields under custom post field to the library
*
* @param $post_id The post identifier
* @param $entry The entry
* @param $form The form
*/
@saltnpixels
saltnpixels / useResizeObserver.tsx
Created April 2, 2024 15:33
React Resize Observer
import { useState, useLayoutEffect } from 'react';
import throttle from 'lodash.throttle';
function useResizeObserver(ref: React.MutableRefObject<any>) {
const [dimensions, setDimensions] = useState({
width: 0,
height: 0,
dimensionsLoaded: false,
});
@saltnpixels
saltnpixels / useStickyObserver.tsx
Created April 9, 2024 13:01
Sticky Intersect Observer
const useStickyScroll = (
{
elementRef,
containerRef
}: {elementRef: any; containerRef?: any; onScroll?: (y: number) => void},
dependencies: any[] = []
) => {
const [isSticky, setIsSticky] = useState(false);
// Use useRef for the callback to avoid triggering re-renders
const onCallbackRef = useRef<(y: number) => void>();
@saltnpixels
saltnpixels / swiper.tsx
Last active May 7, 2024 19:40
Swiper with react customizable
import { useRef, useEffect, useState } from 'react';
import Swiper from 'swiper';
import { SwiperOptions } from 'swiper/types';
import { Pagination, Navigation } from 'swiper/modules';
import { Box, BoxProps, MotionBox } from '@components';
import { Chevronleft, Chevronright } from '@/icons';
import { Variants } from 'framer-motion';
// now importing all thee manually with emotion
// import 'swiper/css';