Dev site orange background

<?php
/*
Plugin Name: HypDevSiteBackground
Plugin URI: http://hyperspatial.com
Description: Prevent blunders by changing the background of your dev site
Version: 1.0
Author: Adam Nowak
Author URI: http://hyperspatial.com
License: GPL2
*/

function add_dev_styles(){?>
<style type="text/css">
html{background:#FCDC9D;}
</style>
<?php
}

function add_admin_dev_styles(){?>
<style type="text/css">
html, .wp-dialog{background-color:#FCDC9D!important;}
</style>
<?php
}

add_action('wp_head','add_dev_styles');
add_action('admin_head','add_admin_dev_styles');
?>

Signup Redirect

function bp_redirect($user) {

$redirect_url = 'http://www.mysite.com/yeah';

bp_core_redirect($redirect_url);

}

add_action('bp_core_signup_user', 'bp_redirect', 100, 1);

Alpha or Numeric

is_numeric($var) will check to see if it's numbers
preg_match('%^[A-Za-z]+$%', $var) will check to see if it's letters
preg_match('%^[A-Za-z0-9]+$%', $var) will check to see if it's alphanumeric

Hex Shifta

<div style="background:#<?php echo hex_shift('c1c2b4',10,'+'); ?>">Shifta</div>

<?php
function hex_shift($hex,$percent = 10,$shift_dir = '-'){
$RGB_values = array();
$new_hex = null;
if(strlen($hex) == 3) if(preg_match('/^([0-9a-f])([0-9a-f])([0-9a-f])/i',$hex)) $hex = preg_replace('/^([0-9a-f])([0-9a-f])([0-9a-f])/i','\1\1\2\2\3\3',$hex);
$RGB_values['R'] = hexdec($hex{0}.$hex{1});
$RGB_values['G'] = hexdec($hex{2}.$hex{3});
$RGB_values['B'] = hexdec($hex{4}.$hex{5});
foreach($RGB_values as $c => $v){
if($shift_dir == '+') $amount = round(((255 - $v) / 100) * $percent) + $v;
else $amount = $v - round(($v / 100) * $percent);
$new_hex .= $current_value = (strlen($decimal_to_hex = dechex($amount)) < 2) ? '0' . $decimal_to_hex : $decimal_to_hex;
}
return $new_hex;
}
?>

Logout Redirect

<?php
//Redirect subscribers to the referring page
function wco_redirect(){
if(current_user_can('editor')) return;
$logout_redirect_url = $_SERVER['HTTP_REFERER'];
if(!empty($_REQUEST['redirect_to'])) wp_safe_redirect($_REQUEST['redirect_to']);
else wp_redirect($logout_redirect_url);
exit();
}
add_filter('wp_logout','wco_redirect');
?>

Assign post numbers

<?php
//Add this above the loop in your template
if(is_paged()) $post_number = $wp_query->found_posts - ($wp_query->query_vars['paged'] -1) * $wp_query->query_vars['posts_per_page'];
else $post_number = $wp_query->found_posts;
?>

<?php
//Add this within the loop wherever you want to print the number
echo $post_number; $post_number--;
?>

Random hex css color

<span style=" <?php mhs_random_hex_color_css() ?>">HI</span>

function mhs_random_hex_color_css(){ echo 'color:#' . sprintf("%02X%02X%02X",mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)) . ';'; }