Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
@bhubbard
bhubbard / geodistance.php
Created October 13, 2017 23:11 — forked from ChrisFlannagan/geodistance.php
Calculate distance between to coordinates of latitude and longitude using the WP REST API and return posts ordered by distance from user's coordinates
<?php
/**
* Heavily borrowed from: http://xplus3.net/2010/08/08/filtering-on-a-non-standard-database-field-with-wordpress/
**/
class CoordinatesTable extends DB {
protected $db_option = "coordinates_db";
@bhubbard
bhubbard / yoast-idx-sitemap-filter.php
Created August 26, 2017 01:01 — forked from davebonds/yoast-idx-sitemap-filter.php
Add IDX sitemap to Yoast SEO sitemap
<?php
/**
* Adds IDX sitemap URLs to Yoast's sitemap_index.xml
* Get your individual sitemap URLs by viewing the source of your primary sitemap URL.
* To manually refresh your sitemaps, deactivate sitemaps and reactivate.
* From: https://kb.yoast.com/kb/add-external-sitemap-to-index/
*/
add_filter( 'wpseo_sitemap_index', 'add_idx_sitemap' );
function add_idx_sitemap() {
$idx_sitemap = '
@bhubbard
bhubbard / zendesk.js
Created July 27, 2017 01:42 — forked from moderatorwes/zendesk.js
Zendesk: Re-direct users to My Activities if End User
//re-direct end users to My Activities
if(HelpCenter.user.role=="end_user"){
location.href="https://yoursubdomain.zendesk.com/hc/en-us/requests/";}
@bhubbard
bhubbard / pdf_magic.js
Created July 27, 2017 00:48 — forked from mozz100/pdf_magic.js
Zendesk embedded PDF viewer via Google Docs
// add this javascript to your Zendesk Help Center pages
(function($) {
$(function() {
// for all attachment links whose URLs end with .pdf (case sensitive)...
var pdfs = $('.attachments a[href$=".pdf"]');
var eleBody = $('div.article-body');
if (pdfs.length > 0) {
@bhubbard
bhubbard / functions.php
Created April 6, 2017 04:54
Get number of active WordPress widgets in a widget area
<?php
/**
* Count number of widgets in a sidebar
* Used to add classes to widget areas so widgets can be displayed one, two, three or four per row
*/
function slbd_count_widgets( $sidebar_id ) {
// If loading from front page, consult $_wp_sidebars_widgets rather than options
// to see if wp_convert_widget_settings() has made manipulations in memory.
global $_wp_sidebars_widgets;
# This file follows the WordPress CSS standards as closely as possible. For any
# linters that aren't listed in this file, we're accepting the default settings.
# https://make.wordpress.org/core/handbook/best-practices/coding-standards/css/
# Linter documentation: http://git.io/vG7gu
# See also: http://sass-guidelin.es/
linters:
Comment:
@bhubbard
bhubbard / unit-testing-with-pressmatic.md
Created March 16, 2017 01:18 — forked from xeiter/unit-testing-with-pressmatic.md
[WordPress] Unit Testing with Pressmatic

Unit Testing with Pressmatic

  • Updated 20 August 2016

Installing Composer on Pressmatic

  1. SSH into the Pressmatic box
  2. $ apt-get update
  3. $ apt-get install curl php5-cli git subversion
  4. $ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
@bhubbard
bhubbard / zillowMiner.py
Created October 31, 2016 21:35 — forked from mansooralam/zillowMiner.py
Quick helper script for mining zillow data / commute times
"""
quick script put together to scrape zillow listing data
at the very least it functions so you don't need to go back and forth to calculate commute times
very messy... maybe i'll revisit this someday
"""
import requests
import re
import csv
@bhubbard
bhubbard / zillowEstimate.js
Created October 31, 2016 21:34 — forked from slickplaid/zillowEstimate.js
Get Zillow Estimate and Image from Zillow's API, Quick and Dirty
/* Quick and dirty, should be wrapped better but this is just a demo */
var app = app || {};
app.apikeys = app.apikeys || {};
app.urls = app.urls || {};
app.methods = app.methods || {};
app.apikeys.zillow = 'YOUR API KEY HERE';
app.urls.zillow = {
@bhubbard
bhubbard / main.php
Created October 26, 2016 04:18 — forked from itzikbenh/main.php
WordPress API login
<?php
//Register login route
//Test in postman with - www.yourdomain.com/wp-json/login-user/v1/user
function uab_register_endpoints()
{
register_rest_route('login-user/v1', '/user/', array(
'methods' => 'POST',
'callback' => 'uab_login_user'
));