Skip to content

Instantly share code, notes, and snippets.

View zgordon's full-sized avatar
🎓
Prepping a Course on Gatsby, GraphQL & WordPress

Zac Gordon zgordon

🎓
Prepping a Course on Gatsby, GraphQL & WordPress
View GitHub Profile
@zgordon
zgordon / wpquery-ajax-loop
Created March 2, 2014 15:57
WP_Query Loop for GET AJAX Request
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
$post_type = $_GET['post_type'];
$time = $_GET['time'];
$order = $_GET['order'];
$page_num = $_GET['page'];
@zgordon
zgordon / js-include
Created March 2, 2014 17:26
Include JavaScript in WordPress function.php File
<?php
function my_theme_scripts() {
wp_enqueue_script( 'theme_js', get_stylesheet_directory_uri() . '/js/theme.js', array('jquery'), false, true );
}
add_action("wp_enqueue_scripts", "my_theme_scripts");
?>
@zgordon
zgordon / object-event-handler.js
Created March 26, 2011 15:13
How to attach a single event to an object behavior
var form = $("form");
function validate() {
$("forms input, forms textarea").each(function () {
if($(this).empty alert("failWhale");
})
}
form.onsubmit = validate;
@zgordon
zgordon / javascript-media-methods.js
Created March 26, 2011 15:11
JS API Methods for HTML5 Audio and Video
player.play();
player.pause();
player.currentTime=0;
player.volume=0;

Focus remote/local

opt + command + arrow

@zgordon
zgordon / css3-selectors.css
Created March 27, 2011 03:30
Selectors for CSS3
:first-child
:nth-child(0)
:last-child
::before
::after
@zgordon
zgordon / print.js
Created April 7, 2011 11:48
Pure JavaScript model of how to build and add to screen a working print button
window.onload = function()
{
if(!document.getElementsByTagName) return false;
var print = document.createElement("a");
print.href = "#"; print.id = "printlink";
var print_icon = document.createElement("img");
print_icon.src = ("printer.png");
var print_link_node = document.createTextNode("print");
print.appendChild(print_icon);
@zgordon
zgordon / child-cat-count-ee
Created May 14, 2011 01:06
Child Cat Count - ExpressionEngine Plugin
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$plugin_info = array(
'pi_name' => 'Child Category Count',
'pi_version' =>'1.0',
'pi_author' =>'Zac Gordon',
'pi_author_url' => 'http://www.wideskyweb.com/expressionengine',
'pi_description' => 'Returns number of child categories.',
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@zgordon
zgordon / node-wpapi-w-async.js
Created June 27, 2017 08:09
Attempting to use async and await with Node WP API Client
// What I'm calling in my router
await Page.render( slug );
Gallery.render();
// The Page.render() code
export default class Page {
/**
* render - Display pages on the Page