Skip to content

Instantly share code, notes, and snippets.

View whyisjake's full-sized avatar
✈️

Jake Spurlock whyisjake

✈️
View GitHub Profile
@whyisjake
whyisjake / functions.php
Created January 17, 2013 18:46
This is an easy way to add a column that shows a link to sort the results of the edit.php screen to just the children of a post.
<?php
add_filter( 'manage_edit-magazine_columns', 'make_columns_filter', 10, 1 );
add_filter( 'manage_edit-projects_columns', 'make_columns_filter', 10, 1 );
add_filter( 'manage_edit-review_columns', 'make_columns_filter', 10, 1 );
function make_columns_filter( $columns ) {
$post_parent = array( 'post_parent' => 'Post Parent' );
$columns = array_slice( $columns, 0, 2, true ) + $post_parent + array_slice( $columns, 2, NULL, true );
return $columns;
@whyisjake
whyisjake / Sample Query
Created January 10, 2013 19:01
When you add an orderby with the meta_key set to the page number, if no value is set, the results are omitted, is there any way around that?
<?php
$args = array(
'post_type' => 'magazine',
'title' => 'Articles',
'post_parent' => $post->ID,
'order' => 'asc',
'meta_key' => 'PageNumber',
'orderby' => 'meta_value_num'
);
$args = array(
'category__in' => $cat_ID,
'posts_per_page' => 8,
'no_found_rows' => true,
);
$the_query = new WP_Query( $args );
//Maybe array_chunk isn't the right thing to do here...
$arrays = array_chunk( $the_query->posts, 4, true );
<script type="text/javascript">
$(document).ready(function(){
$('.container .row .span8').removeClass('span8').addClass('span12');
});
</script>
@whyisjake
whyisjake / index.html
Created December 20, 2012 22:45
A CodePen by Jake Spurlock.
<div class="container">
<div class="row">
<div class="span8">
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<input type="text" placeholder="Type something…">
<span class="help-block">Example block-level help text here.</span>
<label class="checkbox">
@whyisjake
whyisjake / Post Edit Screen Mockup.png
Created December 12, 2012 19:41 — forked from anonymous/how I am getting to the step data.
What we are trying to accomplis here is an easy way to manage all of the step data from Make: Projects.
Post Edit Screen Mockup.png
<?php
/**
* @package MakeZine
* Template Name: Arduino RSS
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); $more = 1; echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
@whyisjake
whyisjake / fizzbuzz.php
Created November 17, 2012 17:05
PHP FizzBuzz
<?php
$numbers = range(1,100);
foreach($numbers as $number) {
if( $number % 15 == 0 ) {
echo 'FizzBuzz<br />';
} elseif( $number % 5 == 0 ) {
echo 'Buzz<br />';
} elseif( $number % 3 == 0 ) {
echo 'Fizz<br />';
} else {
@whyisjake
whyisjake / projects.php
Created November 17, 2012 05:03
Make Projects WordPress API
<?php
function make_post_add_review($content) {
global $post;
if ('post' == get_post_type()) {
$guide = get_post_custom_values('MakeProjectsGuideNumber');
if (isset($guide[0])) {
$content .= js_make_project($guide);
}
<script type="text/javascript">
/* <![CDATA[ */
// Leader ad declaration
var slot1= googletag.defineSlot('/11548178/MakeProjects' +
'', [[728,90]],
'div-gpt-ad-leader').addService(googletag.pubads()).setTargeting('pos', 'atf');
// Corner ad declaration
var slot2= googletag.defineSlot('/11548178/MakeProjects' +
'', [[190,90]],
'div-gpt-ad-corner').addService(googletag.pubads()).setTargeting('pos', 'atf');