Skip to content

Instantly share code, notes, and snippets.

View jinsley8's full-sized avatar

Jon Insley jinsley8

View GitHub Profile
@jinsley8
jinsley8 / useAxios.ts
Created November 29, 2022 22:16
A hook that uses axios to fetch data
import axios, { AxiosRequestConfig } from 'axios';
import { useEffect, useState } from 'react';
axios.defaults.baseURL = `${process.env.NEXT_PUBLIC_SITE_URL}/api/${process.env.NEXT_PUBLIC_API_VERSION}`;
export const useAxiosFetch = (params: AxiosRequestConfig<any>) => {
const [data, setData] = useState<any>(null);
const [error, setError] = useState<any>(null);
const [loading, setLoading] = useState<boolean>(true);
@jinsley8
jinsley8 / google-tag-manager.php
Created February 13, 2022 17:53
Enqueue Google Tag Manager script without tracking Admin
/**
* Enqueue Google Tag Manager script
*
*/
/* Add Google Tag Manager javascript code as close to
the opening <head> tag as possible
=====================================================*/
define("GTM_TAG","GTM-XXXXXX", false); // Replace with GTM tracking ID
@jinsley8
jinsley8 / google-analytics.php
Created February 13, 2022 17:51
Enqueue Google Analytics 4 script without tracking Admin
/**
* Enqueue Google Analytics 4 script
*
*/
/* Add Google Analytics 4 Site Tag as close to
the opening <head> tag as possible
=====================================================*/
define("GA4","G-XXXXXX", false); // Replace GA4 ID
@jinsley8
jinsley8 / Remote Image Slider
Created March 6, 2021 03:24 — forked from luvies/ Remote Image Slider
A JavaScript-accessible-only image slider that will slide to the next given image (after it has loaded), rather than a predetermined set. After sliding to this new image, the old one is removed, allowing you to slide any amount of images you want. You can also slide an image out or in by not providing an image location. Requires jQuery.
<!DOCTYPE html>
<!--
HTML Examples
-->
<html>
<head>
<link rel="stylesheet" href="https://rawgit.com/Gorea235/4844ce9e603d34c82b2d1253b1a71799/raw/remote-image-slider.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
@jinsley8
jinsley8 / product-loop.php
Last active February 3, 2018 22:29
product loop
/**
* Callback function of the shortcode.
*/
function ot_brand_products_cb($atts, $content){
/**
* Setting variable value none.
*/
$content = null;