Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
8ctopotamus / gist:ab9113bc05e45405b551608277f7e399
Created June 5, 2023 00:54 — forked from shreyans94/gist:05b10194cf2f57cf054a5cf3da3fd931
Display ACF for woocommerce variations in backend
// Render fields at the bottom of variations - does not account for field group order or placement.
add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
global $abcdefgh_i; // Custom global variable to monitor index
$abcdefgh_i = $loop;
// Add filter to update field name
add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
// Loop through all field groups
$acf_field_groups = acf_get_field_groups();
foreach( $acf_field_groups as $acf_field_group ) {
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by craig@123marbella.com on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
@8ctopotamus
8ctopotamus / gist:b7474c6e027ae4c6cabb1c15f9fb03aa
Created November 13, 2022 16:04
Update a WP User's nicename/login through mysql
UPDATE wp_users SET user_nicename = "new_username", user_login = "new_username" WHERE user_login = "old_username";
SELECT * FROM wp_users WHERE user_login = "new_username";
@8ctopotamus
8ctopotamus / autofill-from query-params.js
Created June 22, 2021 16:05
Autofill fields based on query params
window.location.search
.replace('?', '')
.split('&')
.filter(str => !!str)
.forEach(str => {
const [k, v] = str.split('=')
const input = document.querySelector(`[name="${k}"`)
input && (input.value = v)
}, {})
@8ctopotamus
8ctopotamus / vscomposer-to-html-wpgraphql.php
Last active August 11, 2021 20:31
Render VSComposer shortcodes to HTML and add to WPGraphQL output.
// add to functions.php or a plugin.
// render js composer shortcodes to html in graphql response
add_action('graphql_register_types', function() {
function vsCodeShortcodesToHTML( $post ) {
if(class_exists('WPBMap') && method_exists('WPBMap', 'addAllMappedShortcodes')) {
WPBMap::addAllMappedShortcodes();
}
return do_shortcode(get_post($post->ID)->post_content);
}
@8ctopotamus
8ctopotamus / functions.php
Created November 3, 2020 00:35 — forked from mrkdevelopment/functions.php
remove divi cpt style action
/**
* Disable new divi crazy crap code for CPT
**/
function disable_cptdivi()
{
remove_action( 'wp_enqueue_scripts', 'et_divi_replace_stylesheet', 99999998 );
}
add_action('init', 'disable_cptdivi');
@8ctopotamus
8ctopotamus / form-tester.js
Last active October 11, 2020 19:02
Quickly fill out a form for testing
Array.from( document.querySelectorAll('input, textarea') ).forEach(function(el) {
if (el.type === 'text' || el.tagName === 'TEXTAREA') {
el.value = 'test'
} else if (el.type === 'number' || el.type === 'tel') {
el.value = 100
} else if (el.type === 'date') {
el.value = '2020-10-20'
} else if (el.type === 'checkbox') {
el.checked = true
}
@8ctopotamus
8ctopotamus / populate-infusionsoft-field.js
Created December 19, 2019 16:11
Populate an infusionsoft field based off of query param.
const inputToFill = document.getElementById('390')
const presentation = getQueryVariable('presentation')
function unSlugify(slug) {
var title = slug.split('-').join(' ');
var firstLetterCapital = title.charAt(0).toUpperCase();
var theRest = title.substring(1);
return firstLetterCapital + theRest;
}
@8ctopotamus
8ctopotamus / react-var_dump.js
Last active October 18, 2023 17:34
Display data in React, kinda like PHP's var_dump();
const dataDump = props => <pre>{JSON.stringify(props, null, 2)}</pre>
@8ctopotamus
8ctopotamus / Fetch.cs
Created August 27, 2019 17:40
Fetch data from REST API in C# example
using System.IO;
using System.Net;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;