Skip to content

Instantly share code, notes, and snippets.

View codearachnid's full-sized avatar
🎯
Focusing

Timothy Wood codearachnid

🎯
Focusing
View GitHub Profile
@seemly
seemly / shortcode-extended.php
Last active May 3, 2024 12:21
Enable the use of ACF shortcodes within the native Query Loop gutenberg block.
<?php
/**
* Shortcode Extended
*
* @package ShortcodeExtended
* @author Chris Sparshott
* @copyright 2022 Chris Sparshott
* @license GPL-2.0-or-later
*
<?php
// The field accepts a value with this structure
$value = [
'address' => '123 Example St, Townsville XYZ 1234, Country',
'lat' => - 38.1486228,
'lng' => 144.360414,
'zoom' => 14,
'place_id' => 'Ei0xMjMgTW9vcmFib29sIFN0LCBHZWVsb25nIFZJQyAzMjIwLCBBdXN0cmFsaWEiMBIuChQKEgmX0JaIHBTUahFyH_LC9sYD8hB7KhQKEglDz-DYDxTUahECZY8QisCjzg',
'street_number' => 123,
@skyshab
skyshab / example.php
Last active August 2, 2021 22:39
Add organizer email to ticket emails
<?php
function modify_woo_ticket_headers( $headers, $id ) {
remove_filter( 'woocommerce_email_headers', 'modify_woo_ticket_headers' );
$organizer_email = tribe_get_organizer_email( $id, false );
// add organizer email if it's a valid email address
if ( is_email( $organizer_email ) ) {
$headers[] = sprintf( 'Cc: %s', $organizer_email );
}
@aaemnnosttv
aaemnnosttv / gravity-forms-select-optgroupify.php
Created October 5, 2018 09:58
GravityForms filter to allow for grouping select choices into labelled groups using special choice options.
<?php
/**
* Filter for GravityForms to group select field choices by a special "optgroup" choice.
*
* Simply add a new choice with a value of 'optgroup' to the dropdown to start a group of options.
* All following choices will be grouped under it using its label for the group.
* Any number of groups can be created, as each optgroup choice will start a new group.
* Supports field placeholder & ungrouped options, but must be before the first group.
*
* This snippet can be added to your theme's functions.php, or a custom plugin.
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@stsibel
stsibel / MySQL_zipcodes_within_radius.sql
Last active September 26, 2022 18:02
MySQL query to find zip-codes within given radius from any point (or zip-code)
/* Given table 'zipcodes' with columns:
zipcode, latitude, longitude.
Find zipcodes within radius from given zipcode.
EXAMPLE:
Coordinates for zip 91326 and radius 25 mi:
*/
SET @location_lat = 34.2766,
@location_lon = -118.544;
SELECT zipcode, ( 3959 * acos( cos( radians(@location_lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(@location_lon) ) + sin( radians(@location_lat) ) * sin( radians( latitude ) ) ) ) AS distance
@jonahcoyote
jonahcoyote / export.sql
Last active January 8, 2019 00:05
Sabai Directory Export SQL
/*
Intro:
Here are some export examples you can use to export Sabai directory data. I'm no MySQL expert and there's probably better ways to run these queries but this worked for my purposes. I hope this helps!
Note, this is going to export all columns and you'll need to manually go in and remove columns you don't need in Excel or Numbers or whatever spreadsheet program you have.
Usage:
This is meant to be run in phpMyAdmin. Look at your own table structure and modify as necessary for any custom fields, table prefix, and custom bundle. Custom fields are storedin their own tables and cross linked via entity_id which is the id of a listing.
*/
@NateWr
NateWr / imager-for-wp.php
Created March 12, 2014 01:07
Integrate Imager.js with WordPress
<?php
/**
* Integrate Imager.js with WordPress
*
* Imager.js is BBC's solution for serving responsive and retina images, without
* the double payload issues that affect other solutions. For more information:
*
* https://github.com/BBC-News/Imager.js/
*
* This collection of functions modifies the output of WordPress's
@spivurno
spivurno / gw-gravity-forms-unrequire-required-fields-usage.php
Last active June 13, 2022 20:04
Gravity Wiz // Gravity Forms Unrequire Required Fields for Speedy Testing
<?php
# Basic Usage
# requires that the user be logged in as an administrator and that a 'gwunrequire' parameter be added to the query string
# http://youurl.com/your-form-page/?gwunrequire=1
new GWUnrequire();
# Enable for All Users (Including Visitors)
# still requires the 'gwunrequire' parameter be added to the query string
new GWUnrequire( array(