Skip to content

Instantly share code, notes, and snippets.

View gregrickaby's full-sized avatar
:octocat:

Greg Rickaby gregrickaby

:octocat:
View GitHub Profile
@gregrickaby
gregrickaby / even_odd_classes.php
Last active November 20, 2022 12:45
Even odd classes in WordPress loop
<?php
// WP_Query Arguments
$args = array(
'order' => 'DESC',
'posts_per_page' => 5
);
// The Loop
$query = new WP_Query( $args );
@gregrickaby
gregrickaby / functions.php
Last active September 26, 2022 04:27
Show me dev info in WordPress
add_action( 'wp_footer', 'wds_debug' );
/*
* Show me some dev info during development! DELETE ME BEFORE GOING LIVE!!!
*
*/
function wds_debug() {
global $template; ?><br />
<?php echo $template; ?><br />
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds<br />
Server load: <?php $load = sys_getloadavg(); echo $load[0]; ?>%<br />
@gregrickaby
gregrickaby / functions.php
Created July 17, 2014 15:39
Prevent Wordpress from inserting an extra 10px of width to image caption shortcodes.
<?php
// DO NOT INCLUDE OPENING PHP TAG
add_filter( 'img_caption_shortcode', 'custom_remove_additional_10px_from_captions', 10, 3 );
/**
* Prevent Wordpress from inserting an extra 10px of width to image caption shortcodes.
*/
function custom_remove_additional_10px_from_captions( $val, $attr, $content = null ) {
extract( shortcode_atts( array(
@gregrickaby
gregrickaby / wp-config.php
Last active September 26, 2022 04:15
WP DEBUG
<?php // do not include leading php tag
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', true);
@gregrickaby
gregrickaby / remove-emoji-support.php
Created May 25, 2015 14:34
Remove WordPress Emoji Support
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php
/**
* Remove emoji support.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@gregrickaby
gregrickaby / myObject.js
Created January 11, 2016 16:07
Creating a global Js Object
// Create an object in the global scope, pass in window, jQuery, and the global object into the anonymous function.
window.myObject = ( function( window, $, myObject ) {
// Create our object, properties, and functions.
myObject = {
window: $( window ), // Remove if you don't need it, makes your object smaller.
// Access variables using myObject.options
options {
@gregrickaby
gregrickaby / html5-schema.org-markup.html
Last active August 2, 2022 00:05
Proper SCHEMA.ORG markup
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noodp, noydir" />
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="canonical" href="http://mysite.com/" />
<link rel="stylesheet" href="http://mysite.com/style.css" type="text/css" />
@gregrickaby
gregrickaby / Custom_Walker_Nav_Menu.php
Created July 31, 2014 13:57
Add HTML Markup to WordPress Nav Menu Editor
<?php
/**
* Create HTML list of nav menu items.
*
* @since 3.0.0
* @uses Walker
*/
class Custom_Walker_Nav_Menu extends Walker_Nav_Menu {
/**
@gregrickaby
gregrickaby / wdsjQuery.js
Last active April 2, 2021 19:37
WDS Javascript Style
/**
* file: wdsjQuery.js
*
* Handle Foo things for the foo theme.
*/
window.wdsFoo = {};
( function( window, $, app ) {
// Private variable.
var fooVariable = 'foo';
@gregrickaby
gregrickaby / custom.css
Last active December 28, 2020 16:48
CSS markup to make Tiny Tiny RSS look a bit more like Google Reader. Paste this into the Custom CSS box inside "Preferences".
/* Reset
------------------------------------------------------------ */
body#ttrssMain,
body#ttrssPrefs,
body#ttrssLogin,
body {
color: #000;
font-family: "Arial", sans-serif;
font-size: 100%; /* Set to default browser size, 16px */
line-height: 1.5;