Skip to content

Instantly share code, notes, and snippets.

@machouinard
machouinard / smooth-scroll-fix.js
Created March 31, 2017 07:05
Fix smooth scroll in Chrome
jQuery( document ).ready( function ( $ ) {
'use strict';
// Smooth scroll anchors
$( 'a[href*="#"]:not([href="#"])' ).click( function () {
if ( location.pathname.replace( /^\//, '' ) === this.pathname.replace( /^\//, '' ) && location.hostname === this.hostname ) {
var target = $( this.hash );
@machouinard
machouinard / gist:fae9ec615d7e3dc8bd45d5dc0e708bef
Created March 11, 2017 20:27 — forked from bradp/gist:4999343
WordPress function to convert address to Lat/Long
<?php
function brrad_geocode($street_address,$city,$state){
$street_address = str_replace(" ", "+", $street_address); //google doesn't like spaces in urls, but who does?
$city = str_replace(" ", "+", $city);
$state = str_replace(" ", "+", $state);
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$street_address,+$city,+$state&sensor=false";
$google_api_response = wp_remote_get( $url );
@machouinard
machouinard / pe-customize-controls.css
Created February 14, 2017 07:33 — forked from OriginalEXE/pe-customize-controls.css
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
add_filter( 'gform_pre_render_9', 'uri_interested_property' );
add_filter( 'gform_pre_validation_9', 'uri_interested_property' );
add_filter( 'gform_pre_submission_9', 'uri_interested_property' );
add_filter( 'gform_admin_pre_render_9', 'uri_interested_property' );
/**
* Dynamically builds Gravity Fields dropdown for Property of Interest form field
*
* @param $form
*
* @return mixed
@machouinard
machouinard / acf-rules.php
Created October 12, 2016 01:53
Custom ACF location rule for The Events Calendar Event category
<?php
//* Add custom location rule type to column one for selecting an Event category
add_filter( 'acf/location/rule_types', 'mc_location_rule_types' );
function mc_location_rule_types( $choices ) {
$choices['Events']['event_type'] = 'Event Type';
return $choices;
@machouinard
machouinard / test.js
Created August 11, 2016 23:56 — forked from mgibbs189/test.js
FacetWP - intercept Genesis pagination
(function($) {
$(document).on('click', '.pagination a', function(e) {
e.preventDefault();
var matches = $(this).attr('href').match(/\/page\/(\d+)/);
if (null != matches) {
FWP.paged = parseInt(matches[1]);
}
FWP.soft_refresh = true;
FWP.refresh();
});
<?php
function my_facetwp_sort_options( $options, $params ) {
$options['rating'] = array(
'label' => 'Rating',
'query_args' => array(
'orderby' => 'meta_value_num', // sort by numerical custom field
'meta_key' => 'rating', // required when sorting by custom fields
'order' => 'DESC', // descending order
)
@machouinard
machouinard / functions.php
Created May 19, 2016 18:21
Add ACF settings page under existing custom menu item.
/**
* Add ACF settings page under Cooked CPT Menu
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Custom Recipe Settings',
'parent' => 'edit.php?post_type=cp_recipe',
'capability' => 'manage_options'
));
}

Last updated: 2015-08-11

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

<?php
/**
* Includes a few useful predicates in the bootstrapped `infiniteScroll` JS object
* that is served along with the rest of the document upon initial page request.
*/
add_filter( 'infinite_scroll_js_settings', 'mcsf_extra_js_settings' );
function mcsf_extra_js_settings( $js_settings ) {
$js_settings['query_args']['extra'] = array(
'is_home' => is_home(),