Skip to content

Instantly share code, notes, and snippets.

View thefrosty's full-sized avatar
🏖️
Santa Monica WordPress Developer

Austin Passy thefrosty

🏖️
Santa Monica WordPress Developer
View GitHub Profile
@thefrosty
thefrosty / gist:3835942
Created October 4, 2012 19:47
Returns Undefined index
$defaults = array(
'company' => 'client_company',
'address_1' => 'client_address_1',
'address_2' => 'client_address_2',
'city' => 'client_city',
'state' => 'client_state',
'postcode' => 'client_postcode',
'country' => 'client_country'
);
@thefrosty
thefrosty / avery74459
Created September 11, 2012 19:34
Set badge location.
<?php
// http://www.avery.com/avery/en_us/Products/Name-Badges/Name-Badges/Insertable-Name-Badges_74459.htm (3" X 4")
// Add a page, but only on a multiple of 6
if ( $counter == 1 || ( $counter % 7 == 0 ) ) {
$pdf->AddPage('P', 'Letter');
$counter = 1;
}
// Set the co-ordinates for all items in each of the badges
switch ( $counter ) {
@thefrosty
thefrosty / gist:3417988
Created August 21, 2012 18:09
Autoset Featured Image
function autoset_featured() {
global $post;
if ( empty( $post ) ) return;
$already_has_thumb = has_post_thumbnail( $post->ID );
if ( !$already_has_thumb ) {
$attached_image = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => '1' ) );
if ( $attached_image ) {
@thefrosty
thefrosty / array_rand
Created May 21, 2012 18:56
Random array
$ads = array('<a href="#">Sponsored link 1</a>', '<a href="#">Sponsored link 2</a>', '<a href="#">Sponsored link 3</a>');
echo $ads[array_rand($ads, 1)];
OR
$numb = rand( 1, 3 );
if ( $numb == 1 )
echo '<a href="#">Sponsored link 1</a>';
@thefrosty
thefrosty / gist:2604443
Created May 5, 2012 18:07
Custom query to grab posts from the same day..
global $post;
$args = array(
'post__not_in' => array( $post->ID ),
'posts_per_page'=> -1,
'day' => get_the_time( 'd', $post->ID ),
'month' => get_the_time( 'm', $post->ID ),
'year' => get_the_time( 'Y', $post->ID ),
);
$the_query = new WP_Query( $args );
@thefrosty
thefrosty / php array
Created February 23, 2012 22:01
Trying to get array settings
function get_editable_roles() {
global $wp_roles;
$all_roles = $wp_roles->roles;
$editable_roles = apply_filters( 'editable_roles', $all_roles );
$options = array();
foreach ( $editable_roles as $roles ) {
foreach( $roles as $role ) {
$options[] = array( $role => $role );
Why is this returning an empty array()?
$order-items->name = empty array()
$order->items =
[items] => Array
(
[0] => Array
(
[id] => 88
@thefrosty
thefrosty / WordCamp Vegas Plugability
Created December 14, 2011 01:03
Core functionality plugin.
<?php
/**
* Plugin Name: PluginName
* Plugin URI: http://austinpassy.com/wordpress-plugins/
* Description: Core functionality for __________
* Version: 1.0.0
* Author: Austin Passy
* Author URI: http://austinpassy.com/
*
* @copyright 2012
@thefrosty
thefrosty / gist:1304823
Created October 21, 2011 20:08
MySQL create error
$sql = "CREATE TABLE {$wpdb->prefix}venuesmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
venues_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY venues_id (venues_id),
KEY meta_key (meta_key)
) {$charset_collate};";
@thefrosty
thefrosty / do_shortcode AJAX
Created October 14, 2011 23:38
do_shortcode() in an AJAX call
function add_twitter_discount() {
global $post;
$post_id = $_POST['id'];
$item = get_post_meta( $post_id, 'item_number_discount', true );
$numb = str_replace( 'theme-', '', $item );
//if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'confirmed' ) {
$arr = array();