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 / 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;
@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;

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 / breadcrumbs-spacer-before.css
Created April 6, 2011 03:41
place a > before or after list items in your breadcrumbs
nav.breadcrumbs ul li::before {
content: ">";
margin-right: 10px;
}
/* Remove the > from before the first breadcrumb */
nav.breadcrumbs ul li:first-child::before {
content: "";
margin-left: 0;
}
@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.',
@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 / wp-meta-description.php
Last active June 2, 2021 09:55
Add Meta Description to WordPress Theme
function custom_get_excerpt($post_id) {
$temp = $post;
$post = get_post( $post_id );
setup_postdata( $post );
$excerpt = esc_attr(strip_tags(get_the_excerpt()));
wp_reset_postdata();
$post = $temp;