Skip to content

Instantly share code, notes, and snippets.

<?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 / 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();
});
@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;
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 / 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%);
}
@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 / 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 / remove_menu_items.php
Created June 20, 2018 21:22
Remove unwanted menu items from main blog in WP multisite
function remove_menus() {
global $blog_id, $menu;
if ( $blog_id == '1' ) {
$restricted = array( 'Plans', 'Providers' );
end( $menu );
@machouinard
machouinard / setup-phpunit.sh
Created November 6, 2019 01:22 — forked from keesiemeijer/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
@machouinard
machouinard / class-mc-login-logo.php
Created December 1, 2019 07:58
Custom WordPress login logo
<?php
namespace Chouinard\Logo;
/**
* Class MCLoginLogo
* @package Chouinard\Logo
*/
class MCLoginLogo {