Skip to content

Instantly share code, notes, and snippets.

View scribu's full-sized avatar

Cristi Burcă scribu

View GitHub Profile
@scribu
scribu / gist:661032
Created November 3, 2010 12:39
Mingle - Users - Online (example)
<?php
/*
Plugin Name: Mingle - Users - Online (example)
Description: Requires WP-UserOnline to be installed
*/
function mingle_linked_names( $name, $user ) {
if ( !$user->user_id ) {
return $name;
}
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
server_name example.com;
root /var/www;
@scribu
scribu / gist:775598
Created January 12, 2011 02:39
Debug WP_Query request
<?php
function debug_query() {
add_filter('the_posts', '_debug_query', 10, 2);
}
function _debug_query($posts, $wp_query) {
remove_filter( current_filter(), __FUNCTION__, 10, 2 );
debug( $wp_query->request );
@scribu
scribu / debug_filters.php
Created January 26, 2011 10:45
debug_filters()
<?php
/**
* @param string $tag The hook name
*/
function debug_filters( $tag = false ) {
global $wp_filter;
if ( $tag ) {
$hook[ $tag ] = $wp_filter[ $tag ];
@scribu
scribu / gist:856587
Created March 5, 2011 18:34
'product' post type + 'color' taxonomy
<?php
// Register the post type and taxonomy
function init_product_cpt() {
register_post_type( 'product', array(
'public' => true,
'label' => __( 'Products', 'my-plugin' )
) );
register_taxonomy( 'color', 'product', array(
@scribu
scribu / compare-wp-query-sql.php
Created March 28, 2011 23:39
Compare WP_Query SQL
<?php
/*
Plugin Name: Compare WP_Query SQL
Version: 1.0
Description: Compare SQL generated by WP_Query between WordPress versions.
Author: scribu
Author URI: http://scribu.net/
Copyright (C) 2011 Cristi Burcă (scribu@gmail.com)
if(!jQuery('<input PLACEHOLDER="1" />')[0].placeholder){ //Uppercase attr for IE
jQuery(':input[placeholder]').each(function(){
var $this = $(this);
if(!$this.val()){
$this.val($this.attr('placeholder'));
$this.addClass('input-placeholder');
}
}).live('focus', function(e){
var $this = $(this);
if($this.hasClass('input-placeholder')){
@scribu
scribu / wp-hooks-filters-flow.php
Created March 31, 2011 00:38
WordPress Hooks & Filters Flow
<?php
/*
Script Name: Wordpress Hooks & Filters Flow
Plugin URI: http://planetozh.com/blog/my-projects/wordpress-hooks-filter-flow/
Description: Lists hooks and their associated filters/actions for your blog. Meant to provide debugging help.
Version: 1.0
Author: Ozh
Author URI: http://planetOzh.com/
*/
@scribu
scribu / unit-query-flags.php
Created April 5, 2011 22:01
WP Unit Test: query flags
<?php
/*
Plugin Name: Unit Test: Query Flags
Description: Drop into mu-plugins folder and go to the front page
Author: scribu
Version: 1.0
*/
class Unit_Query_Flags {
@scribu
scribu / gist:906872
Created April 7, 2011 01:21
'price' sortable column example
<?php
// Register the column
function price_column_register( $columns ) {
$columns['price'] = __( 'Price', 'my-plugin' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'price_column_register' );