Skip to content

Instantly share code, notes, and snippets.

View sc0ttkclark's full-sized avatar
🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@sc0ttkclark
sc0ttkclark / ahhhhh.php
Last active August 29, 2015 13:56 — forked from Shelob9/ahhhhh.php
<?php
function slug_tax_update_PRE( $pieces, $is_new_item, $id ) {
if ( 0 < $id ) {
$term = (int) $pieces[ 'fields' ][ 'tax' ][ 'value' ];
wp_set_object_terms( $id, $term, 'ant', false );
}
return $pieces;
@sc0ttkclark
sc0ttkclark / delete-orphan-gf-entry-data.sql
Created February 16, 2015 06:04
Delete all GF lead data if lead has been deleted
DELETE
lead_detail
FROM
wp_rg_lead_detail AS lead_detail
LEFT JOIN
wp_rg_lead AS lead ON lead.id = lead_detail.lead_id
WHERE
lead.id IS NULL;
DELETE
@sc0ttkclark
sc0ttkclark / podscast-2-demo.php
Created March 17, 2015 19:33
PodsCast 2 demo code
<?php
// Setup Speakers pod
$speaker = pods( 'speaker' );
// Find all Speakers
// with Lessons that are in the Series "That Series"
// or that have a Lesson "Awesome Lesson"
$params = array(
'where' => '
lessons.series.post_title = "That Series"
@sc0ttkclark
sc0ttkclark / gistify497541.buddypress-separate-bbpress-forums-site.php
Last active September 12, 2015 16:40
Code to enable having the main bbPress forums on a separate sub-site. Requires: WP Multisite, BuddyPress on main site and network-activated, bbPress on main site and sub-site
<?php
/**
* Remove and add a custom function for bbPress' BuddyPress activity filter
*/
function custom_bbp_notifications_fix() {
if ( !defined( 'BBPRESS_FORUMS_BLOG_ID' ) || !BBPRESS_FORUMS_BLOG_ID ) {
return;
}
@sc0ttkclark
sc0ttkclark / 0_reuse_code.js
Created September 29, 2015 19:58
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
@sc0ttkclark
sc0ttkclark / sort-by-term-name.php
Created October 23, 2015 16:30
Example PHP of how to enable sorting by term name. `orderby=term_name` and `orderby_tax={taxonomy_name}`
<?php
/**
* Filter EP args to add support for orderby term_name
*
* @param array $formatted_args
* @param array $args
*/
function ep_add_term_name_sort_support( $formatted_args, $args ) {
// Handle meta_value / meta_value_num sort

Use Case

We’re building a site for Golf Courses in a state. We need:

  1. Properties
  • taxonomies: Type (private/public), State, County
  1. Courses
    • taxonomies: bunkers (light, medium, heavy), features (sand trap, putting practice), rate tier ($, $$, $$$), Course Rating (*, **, ***)
  2. Holes
    • Holes have tees (black tee, white tee) each with different par/handicap/yards
@sc0ttkclark
sc0ttkclark / gist:5366044
Last active December 16, 2015 02:58
#pods-dev chat about Loop Fields
[10:52:04 AM on 04/11/13] <@sc0ttkclark> bing bang boom
[10:59:29 AM on 04/11/13] <@curtismchale> looks like 4 of us
[10:59:44 AM on 04/11/13] <@curtismchale> this is the ticket https://github.com/pods-framework/pods/issues/1174
[10:59:57 AM on 04/11/13] <@curtismchale> #109 is the most related for today's discussion
[11:00:06 AM on 04/11/13] <@curtismchale> https://github.com/pods-framework/pods/issues/109
[11:01:28 AM on 04/11/13] <@sc0ttkclark> lol
[11:01:29 AM on 04/11/13] <@sc0ttkclark> yep
[11:03:32 AM on 04/11/13] <@curtismchale> army: you going to join in?
[11:03:50 AM on 04/11/13] <@curtismchale> sc0ttkclark: is this logged anywhere so we can link it on the ticket?
[11:03:57 AM on 04/11/13] <@curtismchale> in case others want to see what was up
@sc0ttkclark
sc0ttkclark / my_merge_tags.php
Created September 3, 2013 14:41
my_merge_tags
<?php
function my_merge_tags ( $text ) {
if ( is_user_logged_in() ) {
global $user_ID, $user_login;
get_currentuserinfo();
$user = (array) get_user_meta( $user_ID );
$userdata = array();
@sc0ttkclark
sc0ttkclark / example.php
Created September 4, 2013 22:35
Example custom display
<?php
$ui[ 'fields' ][ 'manage' ][ 'my_custom_field' ] = array(
'label' => 'My Custom Field',
'custom_display' => 'my_custom_field_pods_value'
);
function my_custom_field_pods_value( $row, $obj, $value, $field, $attributes ) {
$value = $row[ 'a_number_field' ] + $row[ 'another_number_field' ];
return $value;