Skip to content

Instantly share code, notes, and snippets.

View brandondove's full-sized avatar

Brandon Dove brandondove

View GitHub Profile
@brandondove
brandondove / gist:1306271
Created October 22, 2011 17:47
This method gets called on the admin_print_scripts hook. For some reason, the months array works on wp3.3 (trunk), but not on wp3.2.1.
<?php
function admin_print_scripts() {
if( get_post_type() == $this->type || get_query_var('post_type') == $this->type ) :
wp_enqueue_script( 'ads-admin' );
// BEGIN hack to highlight expired/expiring ads
$now = time();
$expired_ads = get_posts(
array(
@brandondove
brandondove / javascript
Created November 19, 2011 19:34
Example usage of WordPress autocomplete functionality
// AJAX USER SEARCH
$('#pdsm_teacher').suggest(
ajaxurl+'?action=pdsm_teacher_search',
{
delay: 500,
minchars: 2,
onSelect: function() {
var selected = $('ul.ac_results li.ac_over span.suggest-result-name').text();
this.value = selected;
}
@brandondove
brandondove / gist:1379270
Created November 19, 2011 19:39
reassign affiliate in AR
<?php
add_action( 'edit_user_profile', 'edit_user_profile' );
add_action( 'edit_user_profile_update', 'edit_user_profile_update' );
function edit_user_profile( $user ) {
?>
<h3><?php _e("Affiliate Assignment", "blank"); ?></h3>
<?php
$new_args = array(
'post_type' => 'shopp_product',
'orderby' => 'date',
'posts_per_page' => 15,
'tax_query' => array(
array(
'taxonomy' => 'shopp_category',
'field' => 'id',
@brandondove
brandondove / gist:3744635
Created September 18, 2012 17:52
This is Carpentry 125x125 ads CSS
.ad-125x125 {
float: left;
}
.ad-125x125.column-1 {
clear: both;
margin-right: 20px;
}
<?php
// Hook into the BuddyPress registration form
add_action( 'bp_after_signup_profile_fields', 'add_honeypot' );
/**
* Add a hidden text input that users won't see
* so it should always be empty. If it's filled out
* we know it's a spambot or some other hooligan
*/
@brandondove
brandondove / functions.php
Created September 20, 2012 19:06
home.php support for AppThemes Vantage theme. Place this code in your functions.php of your child theme.
add_action( 'template_include', 'pjbd_home_include' );
function pjbd_home_include( $template ) {
if( is_front_page() ) :
remove_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ), 99 );
$template = locate_template( 'home.php' );
endif;
return $template;
}
@brandondove
brandondove / gist:3969593
Created October 28, 2012 19:32
Sucuri Shirt Patch
<?php
if_my_site_is_infected() {
visit("sucuri.net");
} else {
die();
}
@brandondove
brandondove / modified-functions.php
Created November 14, 2012 19:14
This is a snippit from the top of the functions.php file for the Titanium theme from iThemes (lines 4-6).
<?php
register_sidebar(array('name'=>'Homepage Left Blue Box','before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
register_sidebar(array('name'=>'Homepage Right Blue Box','before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
register_sidebar(array('name'=>'Right Sidebar','before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
@brandondove
brandondove / mp-automatic-affiliates.php
Created June 29, 2013 19:31
Automatic AR Affiliates
<?php
/*
Plugin Name: Entrepreneurs Are Affiliates
Plugin URI: http://www.vincereed.com/
Description: This plugin enables and disables a user to be an affiliate based on whether or not they have purchased the Entrepreneur product. Affiliate status is double-checked every time a transaction is made.
Version: 1.0
Author: Pixel Jar
Author URI: http://www.pixeljar.net
*/