Skip to content

Instantly share code, notes, and snippets.

View curtismchale's full-sized avatar

Curtis McHale curtismchale

View GitHub Profile
config/app_config.yml
config/database.yml
config/*.sphinx.conf
config/s3_credentials.yml
*~
*.cache
*.log
*.pid
tmp/**/*
.DS_Store
@curtismchale
curtismchale / show-post-relations-relations-post-type
Created August 25, 2011 23:24
Shows the related content on a WordPress site using Relations post type
function tan_show_related_content( $postid, $post_type ) {
global $wp_query, $post;
// Related IDs for this view ?
$ids = rpt_get_object_relation( $postid, $post_type );
if( $ids == false || empty($ids) )
return false;
$items_query = new WP_Query( array(
'post__in' => $ids,
@curtismchale
curtismchale / populate-dropdown.php
Created August 31, 2011 05:06
Populates GF dropdown
/*
* Load any taxonomy terms
*/
function load_cpt_choices($post_type, $type, $first_choice = '', $term) {
$choices = array();
if ($type === 'select') {
$posts = get_posts('post_type='.$post_type.'&numberposts=-1&school_type='.$term);
}
@curtismchale
curtismchale / search-filtering.php
Created September 5, 2011 22:03
Takes the results of a search query and runs a bunch of filters on it
<?php
function tan_athlete_search_page(){
if( isset($_GET['sport']) ) {
$sport = $_GET['sport'];
$sportquery = array( 'key' => 'sfn_tan_choose_sport', 'compare' => 'like', 'value' => $sport );
} else {
$sportquery = '';
}
@curtismchale
curtismchale / fitlered-searchform.php
Created September 5, 2011 22:04
gives the user more options to filter the site by (like meta values)
<form method="get" id="searchform" action="<?php echo home_url(); ?>/">
<label class="hidden" for="s"><?php _e('', 'comienzo'); ?></label>
<input type="search" class="text" value="search site" name="s" id="s" />
<select name="sport">
<option value="" />Choose sport</option>
<?php
$metakey = 'sfn_tan_choose_sport';
$sports = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
if ($sports) {
@curtismchale
curtismchale / ipn-response
Created October 12, 2011 16:44
paypal IPN output
Array
(
[headers] => Array
(
[date] => Wed, 12 Oct 2011 16:43:03 GMT
[server] => Apache
[x-frame-options] => SAMEORIGIN
[set-cookie] => Array
(
[0] => cwrClyrK4LoCV1fydGbAxiNL6iG=nCjyLd7d9MfRHl7YkCVHge47b1p2aZUcZJqm1l1pWkIOrNBCDtI3mJdoGwduc0EGILEnqCTT5zWFZ8QEPHgj_6hLrbjGH8B22_UCH3YkQvhladuusBIOPX-o_dCG-6gfEXsdpW%7cTMrchYr4J_kFS4bGx1rn1P3FESW--5D9CO1P9O6AUlgyt_42EAN2ZVKosoS5LWfgGI1NXG%7ckyTIO3wmjAAEyG2e7Uds0yBvJDS3ALVbWf1lUfNbhkQX4MUu8thJXciIguLaC1ALUK5IyW%7c1318437784; domain=.paypal.com; path=/; Secure; HttpOnly
@curtismchale
curtismchale / paypal-ipn-publish.php
Created October 18, 2011 18:12
supposed to catch the PayPal IPN response and publish posts
add_action( 'gform_paypal_post_ipn', 'tan_deal_with_posts', 10, 8 );
function tan_deal_with_posts( $ipn_post, $entry, $config, $cancel ){
global $current_user;
$time_period = $entry['1.1'];
$userid = $entry['created_by'];
if( empty( $userid ) ) $userid = $current_user->ID;
@curtismchale
curtismchale / redirect-user-role.php
Created November 2, 2011 22:32
redirect on user role
// Redirect admins to the dashboard and other users elsewhere
add_filter( 'login_redirect', 'sfn_tan_login_redirect', 10, 3 );
function sfn_tan_login_redirect( $redirect_to, $request, $user ) {
// Is there a user?
if ( is_array( $user->roles ) ) {
// Is it an administrator?
if ( in_array( 'athlete', $user->roles ) )
return home_url( '/dashboard/' );
else
@curtismchale
curtismchale / tinymce-custom-classes.php
Created November 30, 2011 03:23
Adds buttons/wrappers to tinymce for WordPress
<?php
// adds our custom style buttons
/**
* Filter TinyMCE Buttons
*
* Here we are filtering the TinyMCE buttons and adding a button
* to it. In this case, we are looking to add a style select
* box (button) which is referenced as "styleselect". In this
@curtismchale
curtismchale / comienzo-js.php
Created December 20, 2011 05:16
Current JS file for my WordPress Development Theme
<?php
/**
* Adds scripts to the front end of the site
*
* Most scripts are only needed on the front end of the site
* and the function below makes sure jQuery is ready then adds
* the scripts we need for the site
*
* @uses wp_enqueue_script