Skip to content

Instantly share code, notes, and snippets.

View imCorfitz's full-sized avatar
🧩
Putting things together

Corfitz imCorfitz

🧩
Putting things together
View GitHub Profile
@imCorfitz
imCorfitz / .htaccess
Last active August 25, 2023 06:55
Allow for nested subdirectories in WordPress Multisite
# BEGIN WordPress Multisite
# Using subfolder network type: https://wordpress.org/documentation/article/htaccess/#multisite
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
@imCorfitz
imCorfitz / isFakeEmail.ts
Created March 19, 2023 12:44
Validate submitted email address using Fakefilter
import { isFakeEmailOnline, isFakeEmail as isFakeEmailLocal } from 'fakefilter';
export default async function isFakeEmail(email: string) {
const onlineResponse = await isFakeEmailOnline(email);
if (onlineResponse === null) {
return !!isFakeEmailLocal(email);
}
return !!onlineResponse.isFakeDomain;
}
@imCorfitz
imCorfitz / index.js
Created July 7, 2022 13:08
MailChimp combined click report
// Simply add API key and MC region - and set what condition to look for as url - and run `node index.js` in terminal.
const client = require("mailchimp-marketing");
client.setConfig({
apiKey: "MC_API_KEY",
server: "MC_REGION",
});
let total_clicks = {};
@imCorfitz
imCorfitz / functions.php
Last active May 26, 2022 18:03
Extend WP Rest API with `parent_category` param that includes posts from subcategories
<?php
// Add somewhere in functions.php for your child theme
// Add parent_category filter to REST API
if (!function_exists('wprabpc_wp_rest_api_by_parent_category')) {
function wprabpc_wp_rest_api_by_parent_category($args, $request)
{
if (isset($request['parent_category'])) {
$parent_category = sanitize_text_field($request['parent_category']);
$args['tax_query'] = [
@imCorfitz
imCorfitz / component-card.css
Created April 25, 2022 18:21
Adding CSS for colour swatches on Shopify collection pages using metafields
.color-options {
display:flex;
margin-left:-2px;
flex-wrap:wrap;
}
.color-options__item {
width:14px;
height:14px;
flex-shrink:0;
@imCorfitz
imCorfitz / product-card.liquid
Last active April 25, 2022 18:18
Adding colour swatches to Shopify collection pages using metafields.
{% comment %} Show color options {% endcomment %}
{%- if product_card_product.metafields.product_info.color.type == "list.color" -%}
<div class="color-options">
{%- for color in product_card_product.metafields.product_info.color.value -%}
<div class="color-options__item" style="background-color:{{color}};">&nbsp;</div>
{%- endfor -%}
</div>
{%- endif -%}
@imCorfitz
imCorfitz / .bashrc
Last active November 24, 2021 13:07 — forked from callumlocke/.zshrc
BASH and ZSH function to auto-switch to correct Node version
####
# Simple bash alternative to execute nvm use whenever a .nvmrc file is present in your directory.
####
enter_directory() {
if [[ $PWD == $PREV_PWD ]]; then
return
fi
PREV_PWD=$PWD
[[ -f ".nvmrc" ]] && nvm use
@imCorfitz
imCorfitz / .functions
Last active November 2, 2021 14:59
Create a custom create-next-project function to facilitate creating next.js apps using https://github.com/jpedroschmitz/typescript-nextjs-starter
# $HOME/.functions
function create-next-project() {
NAME=${1:-too-lazy-to-come-up-with-a-project-name}
npx create-next-app $NAME -e https://github.com/jpedroschmitz/typescript-nextjs-starter
}
# In order to have these functions available in your terminal at all times
# make sure to add following command to your .bashrc or .zshrc file:
# source $HOME/.functions
@imCorfitz
imCorfitz / Auth.js
Created June 14, 2021 11:27
Strapi Refresh Token
// extensions/users-permissions/controllers/Auth.js
"use strict";
/**
* Auth.js controller
*
* @description: A set of functions called "actions" for managing `Auth`.
*/
/* eslint-disable no-useless-escape */
@imCorfitz
imCorfitz / _app.tsx
Created December 5, 2020 15:14
Ant Design – Switching between Dark and Light mode
import '@/styles/themes.scss';
import '@/styles/global.scss';
function App({ Component, pageProps }): JSX.Element {
return <Component {...pageProps} />
}
export default App;