Skip to content

Instantly share code, notes, and snippets.

View naomicbush's full-sized avatar

Naomi C. Bush naomicbush

View GitHub Profile
<?php
/*
Handles URL Rewriting in WordPress 3.0 like this:
fastigheter-spanien/X -> property/X&lang=sv
fastigheter-usa/X -> property/X&lang=sv
properties-spain/X -> property/X&lang=en
properties-usa/X -> property/X&lang=en
@boonebgorges
boonebgorges / gist:1331676
Created November 1, 2011 19:39
Display BuddyPress group content in the context of the associated groupblog
<?php
/**
* Does the grunt work
*/
function bbg_test_groupblog_idea2() {
global $wpdb, $bp, $current_blog;
// Never do this on the root blog
if ( bp_is_root_blog() )
@mikeschinkel
mikeschinkel / Sunrise_for_WordPress.xml
Created December 1, 2011 23:50
Sunrise for WordPress Coding Standards for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="Sunrise for WordPress">
<option name="USE_SAME_INDENTS" value="true" />
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="false" />
@mikeschinkel
mikeschinkel / gist:1445728
Created December 8, 2011 01:48
WordPress URL $rewrite Array
Array
(
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
@mikeschinkel
mikeschinkel / wordpress-vs-sunrise-way.php
Created December 21, 2011 00:50
Extending WordPress the WordPress Way vs. the Sunrise Way
<?php
/**
* This is a hypothetical example showing how to add two columns to a 'person' post type using
* WordPress' way vs. the a potential future Sunrise Way:
*/
/**
* Here is how you might do it in the WordPress way.
*/
@trepmal
trepmal / maybe-create-missing-intermediate-images.php
Created December 29, 2011 00:22
WordPress: Create missing intermediate images
<?php
/*
* @param int $id Image attachment ID
* @param string $size_name Name of custom image size as added with add_image_size()
* return bool True if intermediate image exists or was created. False if failed to create.
*/
function maybe_create_missing_intermediate_images( $id, $size_name ) {
@mikeschinkel
mikeschinkel / must-have-mac-apps.txt
Created February 22, 2012 01:05
List of Mac OS X Apps I've Found indispensable coming from Windows
Here's a list of Mac OS X Apps I've found indispensable coming from Windows.
It's not the complete list of apps I used or cannot live without as it doesn't
include ones Windows users would already know about.
-Mike Schinkel
http://about.me/mikeschinkel
Last Updated: Feb 21, 2012
Must Have
@mikeschinkel
mikeschinkel / rootbased-taxonomy-urls.php
Created March 26, 2012 04:29
Root-based Taxonomy URLs Plugin for WordPress
<?php
/*
* Plugin Name: Root-based Taxonomy URLs for WordPress
* Description: Enables root-based Taxonomy URLs, i.e. Makes /taxonomy/my-taxonomy/ URLs route as /my-taxonomy/
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
* Plugin URI: https://gist.github.com/1421235
* Version: 0.1
* License: GPL 2+
* Notes: Must use register_root_based_taxonomy_url( $taxonomy[, $priority] ) in an 'init' hook to specify root_based taxonomy.
@nacin
nacin / gist:2323060
Created April 6, 2012 21:23
Nacin's SVN override
# SVN override to prevent commits that try to implicitly commit more than one file.
# Has weaned me off of svn ci -m very effectively. I now almost always use svn ci,
# which usually results in me writing longer and more helpful commit messages.
# Also, it prevents me from committing unrelated code, so there's that.
#
# Also checks for error_log, var_dump, and console.log, and rejects these commits.
function svn() {
if [ "$1" == "ci" ] && [ "$2" == "-m" ] && [ -z "$4" ] && [ "$(svn stat --ignore-externals | grep '^[^?X]' | wc -l | awk '{print $1}')" -gt 1 ]; then
svn stat --ignore-externals | grep '^[^?X]'
@kovshenin
kovshenin / options.php
Created April 23, 2012 12:12
Reusable Settings API fields
<?php
/**
* Text Field
*
* A simple text field callback to use with the Settings API. Don't forget to pass in
* the arguments array. Here's an example call to add_settings_field() :
*
* add_settings_field( 'my_option', __( 'My Option' ), 'foo_field_text', 'theme_options', 'general', array(
* 'name' => 'my_theme_options[my_option]',
* 'value' => $options['my_option'], // assuming $options is declared