Skip to content

Instantly share code, notes, and snippets.

@wycks
wycks / gist:1268066
Created October 6, 2011 17:40
hReview meta SEO guide stuff
<div class="hreview">
<span class="item">
<span class="fn">Google Nexus One</span>
</span>
<span class="rating">3.5</span>
<span class="reviewer">Richard Baxter</span>
<abbr class="dtreviewed" title="20100110">January 10th 2010</abbr>
<span class="summary">"Great so far..."</span>
<span class="description">"The phone syncs easily with a Google account, in fact,
you should definitely have a Google account before you get this phone. If you use Google
@wycks
wycks / gist:2176359
Created March 23, 2012 23:31
PDF Cross Browser Embed Plugin Wordpress
<?php
/*
Plugin Name: PDF Cross Browser Embed
Plugin URI: http://#
Description: Embeds PDf into a post/page using default media uploader using a cross browser freindly iframe
Version: 1.0
Author: Wycks
License: GPL2
@wycks
wycks / gist:2315279
Created April 6, 2012 00:05
Relative URLs in WordPress (hide wordpress)
<?php
function roots_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
create_function(
'$matches',
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
@wycks
wycks / gist:2315295
Created April 6, 2012 00:08
Rewrite static theme assets and plugins directory (WordPress)
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
@wycks
wycks / gist:2377285
Created April 13, 2012 14:33 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?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(
@wycks
wycks / gist:2377383
Created April 13, 2012 14:46
Register Custom Post Type reference - WordPress
<?php
add_action( 'init', 'register_cpt_example' );
function register_cpt_example() {
//// Label parameters for the CPT admin
$labels = array(
'name' => _x( 'Examples', 'example' ),
'singular_name' => _x( 'Example', 'example' ),
@wycks
wycks / gist:2389259
Created April 15, 2012 01:39
Chrome Developer Inspect theme (build 18.02) - based on IR_Black Theme
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@wycks
wycks / gist:2624062
Created May 6, 2012 19:44
Output wordpress template in footer source code
<?php
// this is handy for debugging live site, out puts page template in footer source code.
add_action('wp_footer', 'show_template');
function show_template() {
global $template;
echo '<!-- the template is:' . $template . '-->';
}
@wycks
wycks / gist:2668630
Created May 12, 2012 20:00
Testing image size filter for post editor
<?php
// test images
add_image_size( 'ducks', 350, 350, true );
add_image_size( 'cows', 750, 150, true );
//this function does not work and acts very wacky
function add_image_check(){
global $_wp_additional_image_sizes;
@wycks
wycks / gist:2685422
Created May 13, 2012 05:46
Jquery UI drag and drop counter
$(function() {
$( "#drag-me" ).draggable();
$( "#drop" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
$('#counter').html(function(i, val) {
return val * 1 + 1