Skip to content

Instantly share code, notes, and snippets.

<?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 [email protected] 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;
@8ctopotamus
8ctopotamus / wp-generate-i18n.md
Last active August 11, 2019 20:45
Genrate a .pot file for i18n from your source code.
  1. Download https://github.com/wp-mirrors/wp-i18n-tools
  2. Extract contents to /wp-includes
  3. Run following in command line to generate .pot file (Fix paths as needed)

Plugin

php wp-includes/makepot.php wp-plugin wp-content/plugins/YOURPLUGIN/ wp-content/plugins/YOURPLUGIN/YOURPLUGINSLANGFOLDER/YOURPLUGIN.pot

Theme

php wp-includes/makepot.php wp-theme wp-content/themes/YOURTHEME/ wp-content/themes/YOURTHEME/YOURTHEMESLANGFOLDER/YOURTHEME.pot