Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
LinzardMac / 1-wp-config.php
Last active October 8, 2021 20:26
Stupid simple conditional config for local and production w/ constants.
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
@LinzardMac
LinzardMac / google-maps-api-poi-events.md
Last active August 28, 2017 20:10
GOOGLE MAPS JAVASCRIPT API PROBLEMS WITH POINTS-OF-INTEREST / CLICKABLE ICONS

GOOGLE MAPS JAVASCRIPT API PROBLEMS WITH POINTS-OF-INTEREST / CLICKABLE ICONS

See the example code working on JSFiddle.net and follow along using this document to discover the wonderful world of WHAT THE F&%^K!(https://jsfiddle.net/t3jt3szr/)


Goal: To allow a user to add a new marker to a google map and utilize the "drag and drop" 1 marker feature to reposition the marker after adding it to the map.

@LinzardMac
LinzardMac / 1-is_valid_id.php
Last active May 30, 2017 01:29
Standardizing the validation of BIGINT integers used in the ID column of wp_posts & adding filters
<?php
/** see attached meta.php for usage sample **/
function is_valid_id( $id ) {
// added for a fallback if filter_var is disabled for php build
if ( function_exists( 'filter_var' ) ) {
$default_opts = array(
'options' => array(
'default' => false, // value to return if the filter fails
@LinzardMac
LinzardMac / functions.php
Last active November 9, 2015 18:25
Get a specified number of images in a post's gallery by post ID
function get_first_images($post, $count){
$post = get_post($post);
if ( ! has_shortcode( $post->post_content, 'gallery' ) ){
return array();
}
$galleries = array();
// find and separate out what kind of shortcode we are looking at
if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) {
foreach ( $matches as $shortcode ) {
@LinzardMac
LinzardMac / grouped-input-fields
Created March 31, 2015 22:36
Reusable meta box for WordPress - Grouped input fields
Works when plugged in to custom reusable metaboxes by TammyHart
This code takes the values of THREE input fields and saves them as one meta option value. This works particularly well for time inputs where the user enters the hour, minute, and am/pm and you want to store a unix timestamp OR a 24 hour time stamp
// settings for grouped input fields
array(
'label'=> 'Start Time',
'desc' => '',
'id' => $prefix.'startselect',
'type' => 'timegroup',
'options' => array(
@HoundstoothSTL
HoundstoothSTL / Embed.js
Last active October 12, 2020 03:29
On-demand vimeo embedded videos with oEmbed API, no jQuery, just javascript. Videos are not loaded on page load for performance reasons, use placeholder images, then on click, fire off the javascript.
var Embed = {
config : {
elementId : 'embed',
trigger: document.querySelectorAll('[data-js="embedTrigger"]'),
videoId : 7100569,
autoplay : true,
vidWidth: 640,
vidHeight: 400
},