Skip to content

Instantly share code, notes, and snippets.

View tlovett1's full-sized avatar

Taylor Lovett tlovett1

View GitHub Profile
<script>
( function( $ ) {
$( '#pehub_post_quote_link' ).autocomplete( {
minLength: 3,
source: function( request, response ) {
var posts = [];
$.ajax( {
@tlovett1
tlovett1 / migrate-scoops
Last active December 25, 2015 04:39
A WP-CLI command to tag all posts without a term with a different term
<?php
/**
* Migrate posts to scoops
*
* @subcommand migrate-scoops
*/
public function migrate_scoops( $args, $assoc_args ) {
global $wpdb;
$scoops_term = get_term_by( 'slug', 'sccops-analysis', 'pehub_section' );
@tlovett1
tlovett1 / Gruntfile.js
Created January 10, 2014 15:47
Gruntfile.js
module.exports = function ( grunt ) {
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
concat: {
js: {
src: [
'js/config.js',
'js/utils.js',
'js/app.js',
'js/parent-models/*',
<?php
/**
* Class Vistage_Chair_API sets up routes and endpoints of CPT API
*/
class Vistage_Chair_API extends WP_JSON_CustomPostType {
protected $base = '/chair-profiles';
protected $type = 'vistage_chair';
<?php
class NYO_General_Settings {
private static $_instance;
private $option_defaults = array(
'trending_title' => array(
'sanitizer' => 'sanitize_text_field',
'default' => 'Trending:',
)
@tlovett1
tlovett1 / strip-taxonomy-base.php
Last active August 29, 2015 14:01
Strip taxonomy base from URL
<?php
function tl_filter_term_link( $termlink, $term, $taxonomy ) {
if ( 'taxonomy' != $taxonomy )
return $termlink;
$termlink = str_ireplace( 'taxonomy/', '', $termlink );
return $termlink;
}
@tlovett1
tlovett1 / gist:e9ea0a2a3e76004beab4
Created June 2, 2014 15:34
WP Mock wp_remote_request
<?php
class ESTestCore extends PHPUnit_Framework_TestCase {
public function setUp() {
\WP_Mock::setUp();
}
public function tearDown() {
\WP_Mock::tearDown();
}
@tlovett1
tlovett1 / adobe-socket-wp.js
Created June 17, 2014 16:23
Test an Adobe Socket object to a WP multisite install
var server = 'observer.vipstage.10uplabs.com';
var page = '/wp-admin/admin-ajax.php?action=wp-browser-search';
var reply = "";
conn = new Socket;
conn.timeout=30;
conn.encoding = 'UTF-8';
if( conn.open( server + ':' + WPBrowserSearchPort ) ) {
conn.write( 'GET ' + page + ' HTTP/1.0' + "\n\n" );
reply = conn.read(999999);
PMC_Deadline_Checklist = function () {
//cache the reference to our class
var self = this;
//Cache the checklist container
this.$checklist_container = $( '#pmc-deadline-post-checklist-meta-box' );
//Cache the HTML DOM Checklist Items we'll be updating
this.$vertical_taxonomy_todo_item = this.$checklist_container.find( 'li.vertical' );
this.$category_taxonomy_todo_item = this.$checklist_container.find( 'li.category' );
<?php
class EP_Cron {
public function __construct() {
add_action( 'ep_sync', array( $this, 'sync' ) );
add_action( 'init', array( $this, 'schedule_events' ) );
}
/**