Skip to content

Instantly share code, notes, and snippets.


Rheinard Korf rheinardkorf

View GitHub Profile
View acf-hooks-basic.php
* Hook before acf_get_value() queries the DB.
function( $meta, $object_id, $field ) {
// Initiate the ACF 'values' store.
rheinardkorf / acf-hooks.php
Last active Oct 1, 2021
Out of the box ACF is taxing on your site performance, but also CPU load if you have large sites (think 10k+ posts). There are ways to improve ACF by doing things like batch writes or pre-fetching values into the ACF Store. As I create some of these techniques I will add them to this Gist. This will work okay'ish without an object cache, but its…
View acf-hooks.php
* This file contains some hooks to improve ACF performance.
* @package rheinardkorf
function( $meta, $post_id, $field ) {
rheinardkorf / queries.mysql
Created Dec 7, 2020
Useful SQL queries for dealing with WordPress optimizations.
View queries.mysql
# Get a particular option entry.
SELECT * FROM wp_options WHERE option_name="<OPTION_NAME>" LIMIT 1000;
# Make sure an option to not autoloaded.
UPDATE wp_options SET autoload = 'no' WHERE option_name="<OPTION_NAME>";
# Get the size of total autoladed values.
SELECT SUM(LENGTH(option_value)) as autoload_size FROM wp_options WHERE autoload='yes';
# Get the top 10 most "expensive" autoloaded values.
rheinardkorf / cache-example.php
Last active Dec 7, 2020
Example using WP caching.
View cache-example.php
// This example assumes an object cache is available. If its not, transients WITHOUT EXPIRATION will be used.
$cache_key = 'unique_prefix_' . md5( $variables );
$results = wp_cache_get( $cache_key );
if ( false === $results ) {
$results = $wpdb->get_var( $wpdb->prepare("SQL STATEMENT HERE", $variables['here'], $variables['etc'] ));
wp_cache_set( $cache_key, $results );
rheinardkorf / .mermaidrc
Last active Sep 22, 2020
Alternate Remark-Mermaid Plugin
View .mermaidrc
"diagramMarginY" :10,
"diagramMarginX" :50,
"actorMargin" :50,
"width" :150,
"height" :65,
"boxMargin" :10,
"boxTextMargin" :5,
"noteMargin" :10,
rheinardkorf / .gitignore
Created Aug 13, 2020
A .gitignore for use on WP Engine. Slight tweaks to the official one:
View .gitignore
# wordpress specific
rheinardkorf / .gitignore
Last active Jul 27, 2020
Some GatsbyJS workspace stuff.
View .gitignore
# Logs
# Diagnostic reports (
rheinardkorf / mode-switch-plugin.js
Created Jun 3, 2020
Gutenberg manipulate Editor Mode state. (Experimental)
View mode-switch-plugin.js
(function (wp) {
var registerPlugin = wp.plugins.registerPlugin;
var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
// var image = wp.icons.image;
var el = wp.element.createElement;
var withDispatch =;
var MoreItem = function (props) {
return el(PluginMoreMenuItem,
rheinardkorf / gatsby-node.js
Last active Aug 27, 2019
Use parent's resolver using custom field extension. FTW!!
View gatsby-node.js
exports.createSchemaCustomization = ({ actions }) => {
const { createFieldExtension, createTypes } = actions;
name: `parent`,
description: `Proxy resolver from a parent's field.`,
args: {
from: `String!`

First attempt...

Inside gatsby-browser.js

import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './src/aws-exports'