Skip to content

Instantly share code, notes, and snippets.

@musicalbigfoot
musicalbigfoot / montana-zip-counties
Last active May 22, 2019 20:46
Array of Montana Zip Code => County (updated 05/2019)
$montana_zip_counties = [
"59001" => "Stillwater",
"59002" => "Yellowstone",
"59003" => "Rosebud",
"59004" => "Rosebud",
"59006" => "Yellowstone",
"59007" => "Carbon",
"59008" => "Carbon",
"59010" => "Treasure",
"59011" => "Sweet Grass",
@musicalbigfoot
musicalbigfoot / javascript-debounce
Created October 12, 2016 15:35
javascript debounce
function debounce(func, wait, immediate?) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
@musicalbigfoot
musicalbigfoot / functions.php
Created July 10, 2015 15:18
Woocommerce: Show variable product price when all prices are the same
// Display Price For Variable Product With Same Variations Prices
add_filter('woocommerce_available_variation', function ($value, $object = null, $variation = null) {
if ($value['price_html'] == '') {
$value['price_html'] = '<span class="price">' . $variation->get_price_html() . '</span>';
}
return $value;
}, 10, 3);
@musicalbigfoot
musicalbigfoot / gist:ce8d86175e05cdf5fb7e
Created June 21, 2015 16:12
Wordpress Woocommerce Product Archive
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_featured',
'meta_value' => 'no',
'posts_per_page' => -1,
'order' => 'asc',
);
$products = array();
$products_query = new WP_Query( $args );
@musicalbigfoot
musicalbigfoot / gist:6ce386ae68da98d26088
Created June 10, 2015 21:47
Wordpress ACF Pro Options Page
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Fiera Woocommerce Settings',
'menu_title' => 'Fiera Woo',
'menu_slug' => 'fiera-woocommerce-settings',
'capability' => 'edit_posts',
'position' => 62,
'icon_url' => 'dashicons-cart',
));
@musicalbigfoot
musicalbigfoot / gist:7ec04f6c3eb12c8a029b
Created May 27, 2015 20:32
clearfix shortcode - wordpress functions
function clearfix_shortcode( $atts, $content = null ) {
extract( shortcode_atts(
array(
'' => '',
), $atts )
);
$result = '<div class="clear"></div>';
return $result;
@musicalbigfoot
musicalbigfoot / gist:bf0e089eed7423672132
Created April 10, 2015 17:20
Javascript: Style console.log message
console.log('%c Console Style', 'color: #be226e; font-size: 24px;');
@musicalbigfoot
musicalbigfoot / gist:bbabae80cefc8d0ae9e8
Created April 9, 2015 04:06
ACF: Update repeater field sort order jquery/ajax
$('#my-library').sortable({
// containment: "parent",
items: "> li.set-item",
update: function(e, ui){
console.log('UPDATE');
var new_order = $(this).sortable('toArray');
updateSortOrder(new_order);
}
});
@musicalbigfoot
musicalbigfoot / gist:f52dc92f52a6211aa022
Created April 9, 2015 04:05
ACF: Update sort order of repeater fields - functions/php
add_action('wp_ajax_library_set_update_sort', 'library_set_update_sort');
add_action('wp_ajax_nopriv_library_set_update_sort', 'library_set_update_sort');
function library_set_update_sort() {
$return = array();
$order = array();
$new_order = $_POST['new_order'];
foreach ($new_order as $i => $row) {
$row = split('-', $row);
$my_library_id = $row[0];
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pattern.test(emailAddress);
}