Skip to content

Instantly share code, notes, and snippets.

Avatar

Curtis McHale curtismchale

View GitHub Profile
View starting gitignore file
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 Aug 25, 2011
Shows the related content on a WordPress site using Relations post type
View show-post-relations-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,
View populate-dropdown.php
/*
* 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 Sep 5, 2011
Takes the results of a search query and runs a bunch of filters on it
View search-filtering.php
<?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 Sep 5, 2011
gives the user more options to filter the site by (like meta values)
View fitlered-searchform.php
<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) {
View ipn-response
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 Oct 18, 2011
supposed to catch the PayPal IPN response and publish posts
View paypal-ipn-publish.php
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;
View redirect-user-role.php
// 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 Nov 30, 2011
Adds buttons/wrappers to tinymce for WordPress
View tinymce-custom-classes.php
<?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 Dec 20, 2011
Current JS file for my WordPress Development Theme
View comienzo-js.php
<?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