Skip to content

Instantly share code, notes, and snippets.

@teolaz
teolaz / ACFToArray.php
Last active July 24, 2024 18:13
This class is an helpful method to add a caching layer to Advanced Custom Fields. This works adding a new row on database with the entire ACF data serialized for that saved post or option page, and then WITH A SINGLE QUERY done you can have all data back and ready to use.
<?php
/**
* Created by PhpStorm.
* User: Matteo
* Date: 04/07/2018
* Time: 12:52
*/
/**
* Class ACFToArray
@offroadkev
offroadkev / functions.php
Created July 20, 2018 22:05
Change Gravity Forms Spinner to CSS Spinner
// Changes Gravity Forms Ajax Spinner (next, back, submit) to a transparent image
// this allows you to target the css and create a pure css spinner like the one used below in the style.css file of this gist.
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // relative to you theme images folder
}
@wplit
wplit / snippet.php
Created September 10, 2018 23:17
Remove Google Fonts from Oxygen Builder
// Remove Google Fonts from Oxygen
remove_action('wp_head', 'add_web_font',0);
@npofopr
npofopr / DNS prefetching preconnect
Last active January 16, 2025 17:04
Common Prefetch Links
<!-- DNS preconnect -->
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="preconnect" href="//ajax.googleapis.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous">
<link rel="dns-prefetch" href="https://use.fontawesome.com">
<link rel="preconnect" href="https://use.fontawesome.com" crossorigin>
<link rel="preconnect" href="//cdnjs.cloudflare.com">
<link rel="preconnect" href="//www.googletagmanager.com">
<link rel="preconnect" href="//www.google-analytics.com">
@uamv
uamv / gf-map-class-to-post-meta.php
Last active January 22, 2024 10:54
Save Gravity Form field data to post meta by adding a class to the field.
<?php
/**
* Save Gravity Form field data to post meta by adding a class to any field.
* Meta is mapped so that it is readable by Advanced Custom Fields
* Format class as…
* post_meta-{meta_key} -- for simple fields & writing lists as array to single meta record
* post_meta-{meta_key}-.3 -- for multi-input fields
* post_meta-{repeater_key}-1.{meta_key} -- for list fields mapped to meta readable by ACF
*/
// Run this function after the Gravity Form has created a post
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active April 29, 2025 19:26
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@thomasfw
thomasfw / _theme.scss
Last active August 11, 2022 11:48
Wordpress Gutenberg - Auto register a theme's color palette by parsing the stylesheet (uses `editor-color-palette`)
// Gutenberg Color Palette
// These are merged Bootstrap 4 $theme-colors from global variables.
// The compiled rules are also read and cached in 'functions.php'
// so they don't need to be registered manually.
$gutenberg-colors: map-merge( (
'dark' : #1A1A1A,
'green' : #68b678,
'red' : #E2574D,
), $theme-colors );
@thetwopct
thetwopct / image-handling-wordpress.php
Last active March 27, 2023 13:04
WordPress image handling (ACF / Background Images / Inline / srcset /
//
<?php
if ( has_post_thumbnail() ) {
echo wp_get_attachment_image(get_post_thumbnail_id($post->ID), '', false, array('class' => 'featured-image'));
} else {
echo '<img src="' . get_bloginfo( 'stylesheet_directory' )
. '/library/images/thumbnail-default.jpg" alt="default thumb" class="featured-image"/>';
}
?>
const sql = require("../util/sql");
const Discord = require("discord.js")
const tools = require("../util/tools");
const challonge = require("challonge");
const Mong = require("../util/mong").Mong;
const {ObjectID} = require("mongodb");
const challongeClient = challonge.createClient({
apiKey:"***"
});
@christiaansnoei
christiaansnoei / acf-flexible-content.php
Last active January 20, 2022 10:51
Loop through each row of a flexible content field.
<?php
$flexible_content = '';
if( have_rows('partials', get_queried_object_id()) ):
while( have_rows('partials', get_queried_object_id()) ): the_row();
$row_layouts = [
'example-1',
'example-2',
'example-3',
];