Skip to content

Instantly share code, notes, and snippets.

(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
<?php
function my_attachments( $attachments )
{
$args = array(
// title of the meta box (string)
'label' => 'My Attachments',
// all post types to utilize (string|array)
@fitzhaile
fitzhaile / is_blog.php
Created October 16, 2012 16:31 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@fitzhaile
fitzhaile / css-stats-ack.sh
Created October 2, 2012 17:56 — forked from pjkix/css-stats-ack.sh
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132
@fitzhaile
fitzhaile / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fitzhaile
fitzhaile / woocommerce_variable_fields.php
Last active August 29, 2015 14:06 — forked from corsonr/gist:9152652
WooCommerce Custom Fields for Variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'my_variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'my_variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'my_save_variable_fields', 10, 1 );
/**
<?php
// Delete all revisions from all posts in either a network or a single blog.
// Quick hack by @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/multisite_delete_revisions.php