MySQLi Prepared Statement

$dbhost = "localhost";
$dbuser = "db_user";
$dbpass = "db_password";
$dbname = "db_name";
$mysqli = new mysqli( $dbhost, $dbuser, $dbpass, $dbname );

$q = "UPDATE table_name ";
$q .= "SET column_1 = ?, ";
$q .= "column_2 = ? ";
$q .= "WHERE column_3 = ? ";
$update = $mysqli->prepare( $q );
$update->bind_param( 'sii', $string_value, $integer_value, $integer_value );
$update->execute();

Minify Stylesheets Into One Request

<?php
/*
* This function will loop over some stylesheets and minify them into one request
* Place in <head>
*/
function load_head_styles() {
$stylesheets = array(
'bootstrap' => array(
'location' => '/css/bootstrap.css'
),
'theme' => array(
'location' => '/css/custom.css'
)
);

foreach ( $stylesheets as $stylesheet ) :
$css_to_minify[] = $stylesheet['location'];
endforeach;

?><link rel="stylesheet" type="text/css" href="/min/index.php?f=<?php echo implode( ',', $css_to_minify ); ?>"><?php

}
?>

Custom Post Types on "Right Now" Dashboard Widget

add_action( 'right_now_content_table_end' , 'right_now_content_table_end' );

function right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';

$post_types = get_post_types( $args , $output , $operator );

foreach( $post_types as $post_type ) {
$num_posts = wp_count_posts( $post_type->name );
$num = number_format_i18n( $num_posts->publish );
$text = _n( $post_type->labels->singular_name, $post_type->labels->name , intval( $num_posts->publish ) );
if ( current_user_can( 'edit_posts' ) ) {
$num = "<a href='edit.php?post_type=$post_type->name'>$num</a>";
$text = "<a href='edit.php?post_type=$post_type->name'>$text</a>";
}
echo '<tr><td class="first b b-' . $post_type->name . '">' . $num . '</td>';
echo '<td class="t ' . $post_type->name . '">' . $text . '</td></tr>';
}

}

Simple jQuery News Ticker

$(document).ready(function() {
var ticker = function()
{
setTimeout(function(){
$('#recent-posts li:first').animate( {marginTop: '-120px'}, 800, function()
{
$(this).detach().appendTo('ul#recent-posts').removeAttr('style');
});
ticker();
}, 4000);
};
ticker();
});

Jquery UI Calendar with From and To

<div>
<label for="sdate">Traveling Start Date</label>
<input type="text" name="from" id="from">
</div>

<div class="clear"></div>

<div>
<label for="edate">Traveling End Date</label>
<input type="text" name="to" id="to">
</div>

<script>
$(function() {
var dates = $( "#from, #to" ).datepicker({
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>
<div>

Comet Chat Friend of All

// friend_user_id is the id of the global friend
function create_global_comet_chat_friend($user_ID) {
global $wpdb;
$now = date('Y-m-d H:i:s');
$wpdb->insert($wpdb->prefix . "bp_friends", array('initiator_user_id' => $user_ID,'friend_user_id' => '21','is_confirmed' => '1','date_created' => $now));
}

add_action('user_register', 'create_global_comet_chat_friend');

Extract Query String from Form Submitted URL

$url = "http://www.youtube.com/watch?v=P22G8YHveEg&feature=feedrec_grec_index"
// get the query string of the url
$query_string = parse_url($url, PHP_URL_QUERY);
// parse out the query string into pieces
parse_str($query_string, $pieces);
// echo out the "v=" variable from the query string for storage in the DB and later use in a YouTube video plugin for WordPress
echo $pieces['v'];
// echos "P22G8YHveEg"

WordPress Check If Current Category Has Children

function category_has_children() {
global $wpdb;
$term = get_queried_object();
$category_children_check = $wpdb->get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term->term_id' ");
if ($category_children_check) {
return true;
} else {
return false;
}
}

<?php
if (!category_has_children()) {
//use whatever loop or template part here to show the posts at the end of the line
get_template_part('loop', 'index');
} else {
// show your category index page here
}
?>