Skip to content

Instantly share code, notes, and snippets.

@ryelle
ryelle / kd-chosen-cmb-taxonomy.php
Created March 9, 2012 17:29
Chosen.js for CMB Taxonomy field
<?php
/**
* Plugin Name: KD Example!
* Version: v0.1
* Author: Kelly Dwan
* Author URI: http://redradar.net/
* Description: Using Chosen + Custom Meta Boxes
*/
class KD_Example_Class {
@ryelle
ryelle / cmb_example_init.php
Created March 10, 2012 17:18
Example Custom Meta Boxes use
<?php
// Initialize the metabox class
function be_initialize_cmb_meta_boxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once( 'libs/cmb-library/init.php' );
}
} add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 );
@ryelle
ryelle / php-fastcgi
Created May 30, 2012 17:41
Content of my php-fastcgi script, used to start PHP-FastCGI on startup. Referenced in http://me.redradar.net/2011/09/21/switching-from-apache-to-nginx/
#!/bin/bash
BIND=/tmp/php.socket
USER=www-data
PHP_FCGI_CHILDREN=5
PHP_FCGI_MAX_REQUESTS=50
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
@ryelle
ryelle / style.css
Created June 5, 2012 17:42
Cross-Browser Image Rotation
.photo {
position: absolute;
right: 30px;
top: 50px;
}
.photo img {
padding: 10px;
background-color: white;
.box-shadow(2px 2px 4px rgba(0,0,0,.3));
.rotate(3deg);
@ryelle
ryelle / vs_meetup_bp_fields.php
Created July 1, 2012 22:32
Meetup Login & BuddyPress integration
<?php
function vs_meetup_bp_fields($user, $meetup) {
global $wpdb;
$wpdb->insert(
$wpdb->prefix.'bp_xprofile_data',
array(
'field_id' => 2, // meetup ID
'user_id' => $user->id,
'value' => $meetup->id
),
@ryelle
ryelle / drupal-to-wordpress.sql
Created October 2, 2012 21:16
Drupal to WordPress Migration
# DRUPAL-TO-WORDPRESS CONVERSION SCRIPT
# Changelog
# 10.02.2012 - Updated by Kelly Dwan !! THIS VERSION HAS NOT BEEN TESTED !!
# 07.29.2010 - Updated by Scott Anderson / Room 34 Creative Services http://blog.room34.com/archives/4530
# 02.06.2009 - Updated by Mike Smullin http://www.mikesmullin.com/development/migrate-convert-import-drupal-5-to-wordpress-27/
# 05.15.2007 - Updated by D’Arcy Norman http://www.darcynorman.net/2007/05/15/how-to-migrate-from-drupal-5-to-wordpress-2/
# 05.19.2006 - Created by Dave Dash http://spindrop.us/2006/05/19/migrating-from-drupal-47-to-wordpress/
@ryelle
ryelle / datepicker-wp.php
Created November 27, 2012 19:21
Datepicker in Metabox
<?php
function display_meta_box( $post, $args ) {
// Get the date (if this is a post) we're editing
$archive_date = get_post_meta( $post->ID, '_guns-archive-date', true );
if ( ! $archive_date )
$archive_date = date( 'F d, Y' );
else
$archive_date = date( 'F d, Y', $archive_date );
@ryelle
ryelle / press-publish-date.php
Created November 27, 2012 19:48
Press "Published Date" Metabox
<?php
/**
* Add Press Custom Post Type Metaboxes
*/
add_action( 'add_meta_boxes', 'add_press_metaboxes' );
// Add the Press Meta Boxes
function add_press_metaboxes() {
add_meta_box('press_publish_date', 'Published Date', 'press_publish_date', 'press', 'normal', 'high');
<?php
/**
* Use WP_Query, not query_posts.
* get_posts is an OK alternative, but is basically a
* wrapper for WP_Query; and using WP_Query directly lets us
* use `$my_query->the_post();` which sets up the global $post
* object -- so that we can use the `the_*` functions.
* http://codex.wordpress.org/Class_Reference/WP_Query#Usage
*/
$my_query = new WP_Query(array(
@ryelle
ryelle / mp6-color-schemes.php
Last active December 22, 2015 20:59
This is an example plugin that creates 2 color schemes for use with MP6, using the new `mp6_add_admin_colors` function.
<?php
/**
* Plugin Name: MP6 Color Scheme
*/
function kd_mp6_add_colors() {
// Check that MP6 exists and that our new function exists
if ( ! defined( 'MP6' ) || ! function_exists( 'mp6_add_admin_colors' ) )
return;
mp6_add_admin_colors( 'sunset', array(