Skip to content

Instantly share code, notes, and snippets.

View ataylorme's full-sized avatar

Andrew Taylor ataylorme

View GitHub Profile
@ataylorme
ataylorme / books-cpt-metabox.php
Last active April 17, 2024 17:27
Books WordPress REST API Example
<?php
function register_books_cpt() {
$args = array(
'labels' => array(
'name' => _x( 'Books', 'post type general name' ),
'singular_name' => _x( 'Book', 'post type singular name' ),
),
'description' => '',
'hierarchical' => false,
@ataylorme
ataylorme / menu-walker-class
Created November 17, 2012 22:52
Menu Walker Class
class custom_menu_walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth, $args){
global $wp_query;
$indent = ( $depth ) ? str_repeat( "t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$ancestors = get_ancestors( $item->ID, 'page' );
@ataylorme
ataylorme / jQuery Validate Phone Number
Last active October 14, 2020 13:32
Adds phone number validation to jQuery Validate plugin in the format "(123) 456-7890". If any of the 3 sections contain all zeros the expression will return false
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
phone_number = phone_number.replace(/\s+/g, "");
return this.optional(element) || phone_number.length > 9 &&
phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please enter a valid phone number");
@ataylorme
ataylorme / .lando.yml
Created February 25, 2019 21:18
Lando file for running WordHat tests locally
name: ataylor-local-behat
services:
# Spin up a PHP CI service for Behat, PHPUnit, etc.
ci_php:
type: php:custom
overrides:
image: quay.io/pantheon-public/build-tools-ci:4.x
# Additional "lando" commands
From 78502e76a598b65d67ae6ea6216f1319debc59e9 Mon Sep 17 00:00:00 2001
From: ataylorme <andrew@ataylor.me>
Date: Wed, 12 Sep 2018 16:16:35 -0700
Subject: [PATCH 1/1] Use get_home_url instead of get_site_url in lh-hsts
plugin
---
web/wp-content/plugins/lh-hsts/lh-hsts.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Keybase proof

I hereby claim:

  • I am ataylorme on github.
  • I am ataylorme (https://keybase.io/ataylorme) on keybase.
  • I have a public key ASCKk31Y0ixruyL6tTEYLZytjyRP5h0QTauZubk1SBwfrQo

To claim this, I am signing this object:

@ataylorme
ataylorme / gist:55bb0ba93026f1c43af4487aaa61efae
Created June 28, 2018 17:39
Solr Power Custom Field Filter Example
<?php
function filter_solr_index_custom_fields( $facet_on_custom_fields ) {
$car_custom_fields = array(
'vehicle_cylinders',
'vehicle_drive_type',
'vehicle_fuel_type',
'vehicle_transmission',
'vehicle_year',
);
@ataylorme
ataylorme / WordPress gulpfile.js
Created September 4, 2014 15:52
WordPress gulpfile.js
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifyCss = require("gulp-minify-css"),
autoprefixer = require("gulp-autoprefixer"),
imagemin = require('gulp-imagemin'),
notify = require("gulp-notify"),
rename = require("gulp-rename"),
cmq = require('gulp-combine-media-queries'),
uglify = require('gulp-uglify'),
# Composer Vendor Directory #
#############################
vendor/
# Webroot #
###########
!web/
web/*
!web/index.php
!web/wp-cli.yml
{
"name": "WordPress-Composer-Example",
"description": "",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "package",