Skip to content

Instantly share code, notes, and snippets.

View gregrickaby's full-sized avatar
:octocat:

Greg Rickaby gregrickaby

:octocat:
View GitHub Profile
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@gregrickaby
gregrickaby / functions.php
Created July 2, 2013 13:45
Get custom options from WordPress database
/**
* Create helper function to easily get options from database
*
* @since Child 1.0
*/
function child_get_option( $key, $setting = null ) {
$setting = $setting ? $setting : 'child_options'; // this must match your custom options in the database.
$options = get_option( $setting );
return is_array( $options[$key] ) ? stripslashes_deep( $options[$key] ) : stripslashes( wp_kses_decode_entities( $options[$key] ) );
}
@gregrickaby
gregrickaby / jsClass.jQuery.js
Created January 11, 2016 17:15 — forked from aubreypwd/jsClass.jQuery.js
How to create a Js application as a jQuery plugin
( function( $ ) {
// Create a jQuery Object.
$.fn.myObject = function() {
var target = this; // Store the target element in this variable (jQuery stuff).
// Our stuff.
this.object = {
/**
@gregrickaby
gregrickaby / wordpress-sample-content.txt
Last active August 10, 2016 20:35
Sample content for QA purposes. Just copy/paste into a post or page and hit "publish". Also, here is an Alfred Workflow: http://gregslink.co/1FFTova
<h1>This is an H1</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tu vero, inquam, ducas licet, si sequetur; Haec et tu ita posuisti, et verba vestra sunt. Atque his de rebus et splendida est eorum et illustris oratio. Eam stabilem appellas. Nam Pyrrho, Aristo, Erillus iam diu abiecti. Illa sunt similia: hebes acies est cuipiam oculorum, corpore alius senescit; Est enim effectrix multarum et magnarum voluptatum. Duo Reges: constructio interrete.<!--more-->
Fortasse id optimum, sed ubi illud: Plus semper voluptatis? Nihil enim hoc differt. Hoc enim constituto in philosophia constituta sunt omnia. Dat enim intervalla et relaxat. Aliena dixit in physicis nec ea ipsa, quae tibi probarentur; Tecum optime, deinde etiam cum mediocri amico. Ait enim se, si uratur, Quam hoc suave! dicturum. Respondent extrema primis, media utrisque, omnia omnibus.
<h2>This is an H2</h2>
Ita multo sanguine profuso in laetitia et in victoria est mortuus. Quae duo sunt, unum facit. Expectoque quid ad id, quod quaerebam, re
@gregrickaby
gregrickaby / get-related-posts.php
Last active August 24, 2016 15:25
Related posts by category with tag fallback
@gregrickaby
gregrickaby / functions.php
Created May 30, 2012 19:20
Custom Post-Info with Google Rich Snippet support (Genesis)
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
add_action( 'genesis_before_post_content', 'child_post_info' );
/**
* Custom Post-Info with Google Rich Snippet support
*
* @author Greg Rickaby
* @since 1.0.0
*/
function child_post_info() {
if ( is_page() )
@gregrickaby
gregrickaby / functions.php
Last active January 24, 2017 07:54
Customize the excerpt length, strip tags, append, and change the "Read More" text
<?php
// DO NOT INCLUDE OPENING PHP TAG
/**
* Customize the excerpt length and strip tags
*/
function custom_excerpt ( $text ) {
global $post;
@gregrickaby
gregrickaby / jquery-ajax-modal.js
Last active January 24, 2017 07:57
Simple jQuery Ajax Modal with fail-safe.
/**
* Loading Modal
*/
$(body).on({
// When ajaxStart is fired, add 'loading' to body class
ajaxStart: function() {
$(this).addClass('modal-loading');
@gregrickaby
gregrickaby / display-social-media-counts.php
Last active February 6, 2017 08:56
Display Likes, Tweets, Pageviews, and Comment Counts. Use transient cache to store data for 30 minutes.
<?php
/**
* Get tweet count from Twitter API (v1.1)
*/
function wds_post_tweet_count( $post_id ) {
// Check for transient
if ( ! ( $count = get_transient( 'wds_post_tweet_count' . $post_id ) ) ) {

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})