Skip to content

Instantly share code, notes, and snippets.

View theandystratton's full-sized avatar

Andy Stratton theandystratton

View GitHub Profile
<?php
/*
Place in theme's functions.php or /wp-content/mu-plugins folder
Assumes:
- PHP 7
- WP 5.2
- Gravity Forms
- Edit this file for the appropriate invite code => gform_id relationships (lines 32-37)
- Edit this file for the appropriate invite code user meta key (line 41)
*/
@theandystratton
theandystratton / wpdb-remove-like-placeholders.php
Created April 24, 2019 18:14
Remove $wpdb LIKE placeholders/tokens!
<?php
// Sample code for reference
global $wpdb;
$year = (int) ( $_GET['year'] ?? date_i18n( 'Y' ) );
$sql = "SELECT * FROM transactions WHERE DATE( datetime_created ) LIKE %s";
$sql = $wpdb->prepare( $sql, $year . '-01-%' );