Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

P. E. A. Lutz misfist

  • NYC
View GitHub Profile
@misfist
misfist / getDataAutocomplete.js
Last active August 29, 2015 14:17
Post and Get
$(function() {
function log( message ) {
$( "<ul>" ).html(message).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
$( "#page" ).autocomplete({
source: function( request, response ) {
$.ajax({
@misfist
misfist / Checkout Button.markdown
Last active August 29, 2015 14:23
Checkout Button

Checkout Button

@misfist
misfist / jquery-boilerplate.js
Last active August 29, 2015 14:25 — forked from tommcfarlin/jquery-boilerplate.js
WP jQuery Function
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@misfist
misfist / .gitignore-node
Created August 1, 2015 00:19
Node.js .gitignore
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
@misfist
misfist / wp-page-slug
Created August 7, 2015 20:59
Add page slug to body tag
/************* ADD SLUG TO BODY CLASS *****************/
// Add specific CSS class by filter
add_filter('body_class','glocal_class_names');
function glocal_class_names($classes) {
// add 'class-name' to the $classes array
global $post;
$post_slug_class = $post->post_name;
$classes[] = $post_slug_class . ' page-' . $post_slug_class;
@misfist
misfist / gulpfile.js
Last active September 22, 2015 16:22
Gulpfile for WP
var gulp = require('gulp'),
plumber = require( 'gulp-plumber' ),
watch = require( 'gulp-watch' ),
livereload = require( 'gulp-livereload' ),
minifycss = require( 'gulp-minify-css' ),
jshint = require( 'gulp-jshint' ),
stylish = require( 'jshint-stylish' ),
uglify = require( 'gulp-uglify' ),
rename = require( 'gulp-rename' ),
notify = require( 'gulp-notify' ),
@misfist
misfist / forEachCreateButton.js
Created September 10, 2015 15:20
Create a button for each element in an array
function createButtons(element, index) {
var button = document.createElement("button");
button.id = element;
button.innerHTML = element;
controlpanel.appendChild(button);
}
["Play", "Pause", "Mute"].forEach(createButtons);
@misfist
misfist / functions.php
Created September 22, 2015 16:17 — forked from yoren/functions.php
Add Featured Image Thumbnail URL to wp-json/wp/v2/posts Endpoint
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id );
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$data->data = $_data;
@misfist
misfist / include_cpt_in_rest_api
Created September 22, 2015 16:21
Add custom post type to Rest API
register_post_type('service',
array(
'labels' => array(
'name' => __('Services'),
'singular_name' => __('service')
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true, //Adds the custom post type to the rest api
)
@misfist
misfist / .gitignore
Created October 27, 2015 02:44 — forked from salcode/.gitignore
WordPress .gitignore - this is my preferred gitignore file when working with WordPress. It ignores almost all files by default.
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20150227
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.